mbox series

[0/7] hw/kvm: Exit gracefully when KVM is not supported

Message ID 20210219114428.1936109-1-philmd@redhat.com (mailing list archive)
Headers show
Series hw/kvm: Exit gracefully when KVM is not supported | expand

Message

Philippe Mathieu-Daudé Feb. 19, 2021, 11:44 a.m. UTC
Hi,

This series aims to improve user experience by providing
a better error message when the user tries to enable KVM
on machines not supporting it.

Regards,

Phil.

Philippe Mathieu-Daudé (7):
  accel/kvm: Check MachineClass kvm_type() return value
  hw/boards: Introduce 'kvm_supported' field to MachineClass
  hw/arm: Set kvm_supported for KVM-compatible machines
  hw/mips: Set kvm_supported for KVM-compatible machines
  hw/ppc: Set kvm_supported for KVM-compatible machines
  hw/s390x: Set kvm_supported to s390-ccw-virtio machines
  accel/kvm: Exit gracefully when KVM is not supported

 include/hw/boards.h        |  6 +++++-
 accel/kvm/kvm-all.c        | 12 ++++++++++++
 hw/arm/sbsa-ref.c          |  1 +
 hw/arm/virt.c              |  1 +
 hw/arm/xlnx-versal-virt.c  |  1 +
 hw/mips/loongson3_virt.c   |  1 +
 hw/mips/malta.c            |  1 +
 hw/ppc/e500plat.c          |  1 +
 hw/ppc/mac_newworld.c      |  1 +
 hw/ppc/mac_oldworld.c      |  1 +
 hw/ppc/mpc8544ds.c         |  1 +
 hw/ppc/ppc440_bamboo.c     |  1 +
 hw/ppc/prep.c              |  1 +
 hw/ppc/sam460ex.c          |  1 +
 hw/ppc/spapr.c             |  1 +
 hw/s390x/s390-virtio-ccw.c |  1 +
 16 files changed, 31 insertions(+), 1 deletion(-)

Comments

Peter Maydell Feb. 19, 2021, 11:55 a.m. UTC | #1
On Fri, 19 Feb 2021 at 11:44, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> This series aims to improve user experience by providing
> a better error message when the user tries to enable KVM
> on machines not supporting it.

Thanks for having a look at this; fixing the ugly assertion
failure if you try to enable KVM for the raspi boards has
been vaguely on my todo list but never made it up to the top...

> Philippe Mathieu-Daudé (7):
>   accel/kvm: Check MachineClass kvm_type() return value
>   hw/boards: Introduce 'kvm_supported' field to MachineClass
>   hw/arm: Set kvm_supported for KVM-compatible machines
>   hw/mips: Set kvm_supported for KVM-compatible machines
>   hw/ppc: Set kvm_supported for KVM-compatible machines
>   hw/s390x: Set kvm_supported to s390-ccw-virtio machines
>   accel/kvm: Exit gracefully when KVM is not supported

Don't we also need to set kvm_supported for the relevant
machine types in hw/i386 ?

thanks
-- PMM
Daniel P. Berrangé Feb. 19, 2021, noon UTC | #2
On Fri, Feb 19, 2021 at 12:44:21PM +0100, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series aims to improve user experience by providing
> a better error message when the user tries to enable KVM
> on machines not supporting it.

Improved error message is good, but it is better if the mgmt apps knows
not to try this in the first place.

IOW, I think we want "query-machines" to filter out machines
which are not available with the currently configured accelerator.

libvirt will probe separately with both TCG and KVM enabled, so if
query-machines can give the right answer in these cases, libvirt
will probably "just work" and not offer to even start such a VM.


Regards,
Daniel
Philippe Mathieu-Daudé Feb. 19, 2021, 12:09 p.m. UTC | #3
On 2/19/21 12:55 PM, Peter Maydell wrote:
> On Fri, 19 Feb 2021 at 11:44, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>> This series aims to improve user experience by providing
>> a better error message when the user tries to enable KVM
>> on machines not supporting it.
> 
> Thanks for having a look at this; fixing the ugly assertion
> failure if you try to enable KVM for the raspi boards has
> been vaguely on my todo list but never made it up to the top...

The other one annoying was the xlnx-zcu102 when creating
the Cortex-R cores.

>> Philippe Mathieu-Daudé (7):
>>   accel/kvm: Check MachineClass kvm_type() return value
>>   hw/boards: Introduce 'kvm_supported' field to MachineClass
>>   hw/arm: Set kvm_supported for KVM-compatible machines
>>   hw/mips: Set kvm_supported for KVM-compatible machines
>>   hw/ppc: Set kvm_supported for KVM-compatible machines
>>   hw/s390x: Set kvm_supported to s390-ccw-virtio machines
>>   accel/kvm: Exit gracefully when KVM is not supported
> 
> Don't we also need to set kvm_supported for the relevant
> machine types in hw/i386 ?

Lol, clearly a parapraxis =)

I'll send it as 8/7 until I get more review comments for a
v2 (in particular on the PPC patch):

-- >8 --
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 6329f90ef90..da895aa051d 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1218,6 +1218,7 @@ static void x86_machine_class_init(ObjectClass
*oc, void *data)
     mc->cpu_index_to_instance_props = x86_cpu_index_to_props;
     mc->get_default_cpu_node_id = x86_get_default_cpu_node_id;
     mc->possible_cpu_arch_ids = x86_possible_cpu_arch_ids;
+    mc->kvm_supported = true;
     x86mc->compat_apic_id_mode = false;
     x86mc->save_tsc_khz = true;
     nc->nmi_monitor_handler = x86_nmi;
---

Regards,

Phil.
Philippe Mathieu-Daudé Feb. 19, 2021, 12:15 p.m. UTC | #4
On 2/19/21 1:00 PM, Daniel P. Berrangé wrote:
> On Fri, Feb 19, 2021 at 12:44:21PM +0100, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> This series aims to improve user experience by providing
>> a better error message when the user tries to enable KVM
>> on machines not supporting it.
> 
> Improved error message is good, but it is better if the mgmt apps knows
> not to try this in the first place.

I am not sure this is the same problem. This series addresses
users from the command line (without mgmt app).

> IOW, I think we want "query-machines" to filter out machines
> which are not available with the currently configured accelerator.
> 
> libvirt will probe separately with both TCG and KVM enabled, so if
> query-machines can give the right answer in these cases, libvirt
> will probably "just work" and not offer to even start such a VM.

Yes, agreed. There are other discussions about 'query-machines'
and an eventual 'query-accels'. This series doesn't aim to fix
the mgmt app problems.
Daniel P. Berrangé Feb. 19, 2021, 12:18 p.m. UTC | #5
On Fri, Feb 19, 2021 at 01:15:25PM +0100, Philippe Mathieu-Daudé wrote:
> On 2/19/21 1:00 PM, Daniel P. Berrangé wrote:
> > On Fri, Feb 19, 2021 at 12:44:21PM +0100, Philippe Mathieu-Daudé wrote:
> >> Hi,
> >>
> >> This series aims to improve user experience by providing
> >> a better error message when the user tries to enable KVM
> >> on machines not supporting it.
> > 
> > Improved error message is good, but it is better if the mgmt apps knows
> > not to try this in the first place.
> 
> I am not sure this is the same problem. This series addresses
> users from the command line (without mgmt app).

Users of mgmt apps can launch the same problematic raspbi + KVM config
as people who  don't use a mgmt app.

> > IOW, I think we want "query-machines" to filter out machines
> > which are not available with the currently configured accelerator.
> > 
> > libvirt will probe separately with both TCG and KVM enabled, so if
> > query-machines can give the right answer in these cases, libvirt
> > will probably "just work" and not offer to even start such a VM.
> 
> Yes, agreed. There are other discussions about 'query-machines'
> and an eventual 'query-accels'. This series doesn't aim to fix
> the mgmt app problems.

I think this should be fixing query-machines right now. It shouldn't
be much harder than a single if (...) test in the code.

Regards,
Daniel
Claudio Fontana Feb. 19, 2021, 12:34 p.m. UTC | #6
On 2/19/21 12:44 PM, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series aims to improve user experience by providing
> a better error message when the user tries to enable KVM
> on machines not supporting it.
> 
> Regards,
> 
> Phil.

Hi Philippe, not sure if it fits in this series,

but also the experience of a user running on a machine with cortex-a72,
choosing that very same cpu with -cpu and then getting:

qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument

is not super-friendly. Maybe some suggestion to use -cpu host with KVM could be good?

Thanks,

Claudio

> 
> Philippe Mathieu-Daudé (7):
>   accel/kvm: Check MachineClass kvm_type() return value
>   hw/boards: Introduce 'kvm_supported' field to MachineClass
>   hw/arm: Set kvm_supported for KVM-compatible machines
>   hw/mips: Set kvm_supported for KVM-compatible machines
>   hw/ppc: Set kvm_supported for KVM-compatible machines
>   hw/s390x: Set kvm_supported to s390-ccw-virtio machines
>   accel/kvm: Exit gracefully when KVM is not supported
> 
>  include/hw/boards.h        |  6 +++++-
>  accel/kvm/kvm-all.c        | 12 ++++++++++++
>  hw/arm/sbsa-ref.c          |  1 +
>  hw/arm/virt.c              |  1 +
>  hw/arm/xlnx-versal-virt.c  |  1 +
>  hw/mips/loongson3_virt.c   |  1 +
>  hw/mips/malta.c            |  1 +
>  hw/ppc/e500plat.c          |  1 +
>  hw/ppc/mac_newworld.c      |  1 +
>  hw/ppc/mac_oldworld.c      |  1 +
>  hw/ppc/mpc8544ds.c         |  1 +
>  hw/ppc/ppc440_bamboo.c     |  1 +
>  hw/ppc/prep.c              |  1 +
>  hw/ppc/sam460ex.c          |  1 +
>  hw/ppc/spapr.c             |  1 +
>  hw/s390x/s390-virtio-ccw.c |  1 +
>  16 files changed, 31 insertions(+), 1 deletion(-)
>
Philippe Mathieu-Daudé Feb. 19, 2021, 1:10 p.m. UTC | #7
On 2/19/21 1:18 PM, Daniel P. Berrangé wrote:
> On Fri, Feb 19, 2021 at 01:15:25PM +0100, Philippe Mathieu-Daudé wrote:
>> On 2/19/21 1:00 PM, Daniel P. Berrangé wrote:
>>> On Fri, Feb 19, 2021 at 12:44:21PM +0100, Philippe Mathieu-Daudé wrote:
>>>> Hi,
>>>>
>>>> This series aims to improve user experience by providing
>>>> a better error message when the user tries to enable KVM
>>>> on machines not supporting it.
>>>
>>> Improved error message is good, but it is better if the mgmt apps knows
>>> not to try this in the first place.
>>
>> I am not sure this is the same problem. This series addresses
>> users from the command line (without mgmt app).
> 
> Users of mgmt apps can launch the same problematic raspbi + KVM config
> as people who  don't use a mgmt app.
> 
>>> IOW, I think we want "query-machines" to filter out machines
>>> which are not available with the currently configured accelerator.
>>>
>>> libvirt will probe separately with both TCG and KVM enabled, so if
>>> query-machines can give the right answer in these cases, libvirt
>>> will probably "just work" and not offer to even start such a VM.
>>
>> Yes, agreed. There are other discussions about 'query-machines'
>> and an eventual 'query-accels'. This series doesn't aim to fix
>> the mgmt app problems.
> 
> I think this should be fixing query-machines right now. It shouldn't
> be much harder than a single if (...) test in the code.

OK I misunderstood you at first, now I got it. Will include that in v2.
Philippe Mathieu-Daudé Feb. 19, 2021, 5:36 p.m. UTC | #8
On 2/19/21 1:34 PM, Claudio Fontana wrote:
> On 2/19/21 12:44 PM, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> This series aims to improve user experience by providing
>> a better error message when the user tries to enable KVM
>> on machines not supporting it.
>>
>> Regards,
>>
>> Phil.
> 
> Hi Philippe, not sure if it fits in this series,
> 
> but also the experience of a user running on a machine with cortex-a72,
> choosing that very same cpu with -cpu and then getting:
> 
> qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
> 
> is not super-friendly. Maybe some suggestion to use -cpu host with KVM could be good?

I agree this should be improved, but it is out of the scope of this
series :)