diff mbox

hw/arm/virt: Reject gic-version=host for non-KVM

Message ID b1b3b0dd143b7995a7f4062966b80a2cf3e3c71e.1464273085.git.crobinso@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cole Robinson May 26, 2016, 2:31 p.m. UTC
If you try to gic-version=host with TCG on a KVM aarch64 host,
qemu segfaults, since host requires KVM APIs.

Explicitly reject gic-version=host if KVM is not enabled

https://bugzilla.redhat.com/show_bug.cgi?id=1339977
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 hw/arm/virt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Richard W.M. Jones May 26, 2016, 2:46 p.m. UTC | #1
On Thu, May 26, 2016 at 10:31:25AM -0400, Cole Robinson wrote:
> If you try to gic-version=host with TCG on a KVM aarch64 host,
> qemu segfaults, since host requires KVM APIs.
> 
> Explicitly reject gic-version=host if KVM is not enabled
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1339977
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  hw/arm/virt.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index e77ed88..1e82597 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1122,10 +1122,14 @@ static void machvirt_init(MachineState *machine)
>       * KVM is not available yet
>       */
>      if (!gic_version) {
> +        if (!kvm_enabled()) {
> +            error_report("gic-version=host requires KVM");
> +            exit(1);
> +        }

The problem with this is if I'm using TCG fallback mode, how
can I specify the right gic-version?  ie:

  -M virt,gic-version=host,accel=kvm:tcg

Only qemu knows if KVM is going to be enabled.

The same problem happens with '-cpu host' BTW.  I really want a "make
it work" option, as I've said on several previous occasions on this
list eg:
https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg04173.html

Rich.
Peter Maydell May 26, 2016, 2:53 p.m. UTC | #2
On 26 May 2016 at 15:46, Richard W.M. Jones <rjones@redhat.com> wrote:
> The problem with this is if I'm using TCG fallback mode, how
> can I specify the right gic-version?  ie:
>
>   -M virt,gic-version=host,accel=kvm:tcg
>
> Only qemu knows if KVM is going to be enabled.
>
> The same problem happens with '-cpu host' BTW.  I really want a "make
> it work" option, as I've said on several previous occasions on this
> list eg:
> https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg04173.html

I agree that we really need to do better here (thinking about
the problem is on my todo list but generally other more pressing
issues intervene). I'd welcome suggestions for semantics which
(a) do what you want (b) are reasonably in line with what we do
on other host architectures (c) don't break existing command lines.
(I think those are the main requirements.)

In the meantime I think this patch is correct for what we
are currently trying to implement.

thanks
-- PMM
Richard W.M. Jones May 26, 2016, 3:14 p.m. UTC | #3
On Thu, May 26, 2016 at 03:53:54PM +0100, Peter Maydell wrote:
> On 26 May 2016 at 15:46, Richard W.M. Jones <rjones@redhat.com> wrote:
> > The problem with this is if I'm using TCG fallback mode, how
> > can I specify the right gic-version?  ie:
> >
> >   -M virt,gic-version=host,accel=kvm:tcg
> >
> > Only qemu knows if KVM is going to be enabled.
> >
> > The same problem happens with '-cpu host' BTW.  I really want a "make
> > it work" option, as I've said on several previous occasions on this
> > list eg:
> > https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg04173.html
> 
> I agree that we really need to do better here (thinking about
> the problem is on my todo list but generally other more pressing
> issues intervene). I'd welcome suggestions for semantics which
> (a) do what you want (b) are reasonably in line with what we do
> on other host architectures (c) don't break existing command lines.
> (I think those are the main requirements.)
> 
> In the meantime I think this patch is correct for what we
> are currently trying to implement.

Agreed this patch is an improvement on segfaulting which is
what qemu does at the moment :-(

Rich.
Peter Maydell June 3, 2016, 6:34 p.m. UTC | #4
On 26 May 2016 at 15:31, Cole Robinson <crobinso@redhat.com> wrote:
> If you try to gic-version=host with TCG on a KVM aarch64 host,
> qemu segfaults, since host requires KVM APIs.
>
> Explicitly reject gic-version=host if KVM is not enabled
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1339977
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  hw/arm/virt.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>



Applied to target-arm.next, thanks.

-- PMM
Peter Maydell June 17, 2016, 2:49 p.m. UTC | #5
On 26 May 2016 at 15:53, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 26 May 2016 at 15:46, Richard W.M. Jones <rjones@redhat.com> wrote:
>> The problem with this is if I'm using TCG fallback mode, how
>> can I specify the right gic-version?  ie:
>>
>>   -M virt,gic-version=host,accel=kvm:tcg
>>
>> Only qemu knows if KVM is going to be enabled.
>>
>> The same problem happens with '-cpu host' BTW.  I really want a "make
>> it work" option, as I've said on several previous occasions on this
>> list eg:
>> https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg04173.html
>
> I agree that we really need to do better here (thinking about
> the problem is on my todo list but generally other more pressing
> issues intervene). I'd welcome suggestions for semantics which
> (a) do what you want (b) are reasonably in line with what we do
> on other host architectures (c) don't break existing command lines.
> (I think those are the main requirements.)

...so does anybody have any concrete suggestions? We could fix
this for 2.7 but we're starting to run low on time for that.

thanks
-- PMM
Richard W.M. Jones June 17, 2016, 4:10 p.m. UTC | #6
On Fri, Jun 17, 2016 at 03:49:38PM +0100, Peter Maydell wrote:
> On 26 May 2016 at 15:53, Peter Maydell <peter.maydell@linaro.org> wrote:
> > On 26 May 2016 at 15:46, Richard W.M. Jones <rjones@redhat.com> wrote:
> >> The problem with this is if I'm using TCG fallback mode, how
> >> can I specify the right gic-version?  ie:
> >>
> >>   -M virt,gic-version=host,accel=kvm:tcg
> >>
> >> Only qemu knows if KVM is going to be enabled.
> >>
> >> The same problem happens with '-cpu host' BTW.  I really want a "make
> >> it work" option, as I've said on several previous occasions on this
> >> list eg:
> >> https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg04173.html
> >
> > I agree that we really need to do better here (thinking about
> > the problem is on my todo list but generally other more pressing
> > issues intervene). I'd welcome suggestions for semantics which
> > (a) do what you want (b) are reasonably in line with what we do
> > on other host architectures (c) don't break existing command lines.
> > (I think those are the main requirements.)
> 
> ...so does anybody have any concrete suggestions? We could fix
> this for 2.7 but we're starting to run low on time for that.

I have changed libguestfs so it tries to guess if KVM will be used or
not.  We have to do this for the -cpu option too, but the guess is not
too reliable.  Only QEMU has the actual knowledge we need.

https://github.com/libguestfs/libguestfs/commit/7023f20830a681ef36f8f99415fe41791555a3db

Can we not have a "give me a GIC which will work" option, eg.

  -M virt,gic-version=besteffort,accel=kvm:tcg

I don't care if it's not the fastest or most featureful.

Rich.
Peter Maydell June 17, 2016, 4:31 p.m. UTC | #7
On 17 June 2016 at 17:10, Richard W.M. Jones <rjones@redhat.com> wrote:
> On Fri, Jun 17, 2016 at 03:49:38PM +0100, Peter Maydell wrote:
>> > I agree that we really need to do better here (thinking about
>> > the problem is on my todo list but generally other more pressing
>> > issues intervene). I'd welcome suggestions for semantics which
>> > (a) do what you want (b) are reasonably in line with what we do
>> > on other host architectures (c) don't break existing command lines.
>> > (I think those are the main requirements.)
>>
>> ...so does anybody have any concrete suggestions? We could fix
>> this for 2.7 but we're starting to run low on time for that.
>
> I have changed libguestfs so it tries to guess if KVM will be used or
> not.  We have to do this for the -cpu option too, but the guess is not
> too reliable.  Only QEMU has the actual knowledge we need.
>
> https://github.com/libguestfs/libguestfs/commit/7023f20830a681ef36f8f99415fe41791555a3db
>
> Can we not have a "give me a GIC which will work" option, eg.
>
>   -M virt,gic-version=besteffort,accel=kvm:tcg
>
> I don't care if it's not the fastest or most featureful.

Do we also not care if the result is not consistent
between versions of QEMU? (eg if you go from 2.6 to
2.7 does it have to stay doing the same thing it
always did?)

thanks
-- PMM
Richard W.M. Jones June 17, 2016, 4:33 p.m. UTC | #8
On Fri, Jun 17, 2016 at 05:31:20PM +0100, Peter Maydell wrote:
> On 17 June 2016 at 17:10, Richard W.M. Jones <rjones@redhat.com> wrote:
> > On Fri, Jun 17, 2016 at 03:49:38PM +0100, Peter Maydell wrote:
> >> > I agree that we really need to do better here (thinking about
> >> > the problem is on my todo list but generally other more pressing
> >> > issues intervene). I'd welcome suggestions for semantics which
> >> > (a) do what you want (b) are reasonably in line with what we do
> >> > on other host architectures (c) don't break existing command lines.
> >> > (I think those are the main requirements.)
> >>
> >> ...so does anybody have any concrete suggestions? We could fix
> >> this for 2.7 but we're starting to run low on time for that.
> >
> > I have changed libguestfs so it tries to guess if KVM will be used or
> > not.  We have to do this for the -cpu option too, but the guess is not
> > too reliable.  Only QEMU has the actual knowledge we need.
> >
> > https://github.com/libguestfs/libguestfs/commit/7023f20830a681ef36f8f99415fe41791555a3db
> >
> > Can we not have a "give me a GIC which will work" option, eg.
> >
> >   -M virt,gic-version=besteffort,accel=kvm:tcg
> >
> > I don't care if it's not the fastest or most featureful.
> 
> Do we also not care if the result is not consistent
> between versions of QEMU? (eg if you go from 2.6 to
> 2.7 does it have to stay doing the same thing it
> always did?)

For libguestfs, no, since we don't do any migration or saving the
state of the VM.

Rich.
diff mbox

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index e77ed88..1e82597 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1122,10 +1122,14 @@  static void machvirt_init(MachineState *machine)
      * KVM is not available yet
      */
     if (!gic_version) {
+        if (!kvm_enabled()) {
+            error_report("gic-version=host requires KVM");
+            exit(1);
+        }
+
         gic_version = kvm_arm_vgic_probe();
         if (!gic_version) {
             error_report("Unable to determine GIC version supported by host");
-            error_printf("KVM acceleration is probably not supported\n");
             exit(1);
         }
     }