Re: [PATCH v2 2/4] qemu: avoid launching non-x86 guests with 'pvspinlock' setting

2020-03-25 Thread Andrea Bolognani
On Tue, 2020-03-24 at 14:33 -0300, Daniel Henrique Barboza wrote:
> The 'pvspinlock' feature is x86 only. The "" declaration
> will always have a value 'on' or 'off', and both will break QEMU when
> launching non-x86 guests. This is the error message for
> "" when running a ppc64 guest:
> 
> qemu-kvm: Expected key=value format, found +kvm_pv_unhalt
> 
> A similar error message is thrown for "".
> 
> This patch prevents non-x86 guests from launching with any
> pvspinlock setting with a more informative error message:
> 
> error: unsupported configuration: The 'pvspinlock' feature is not
> supported for architecture 'ppc64' or machine type 'pseries'
> 
> Suggested-by: Andrea Bolognani 
> Signed-off-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_domain.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)

Reviewed-by: Andrea Bolognani 

-- 
Andrea Bolognani / Red Hat / Virtualization



[PATCH v2 2/4] qemu: avoid launching non-x86 guests with 'pvspinlock' setting

2020-03-24 Thread Daniel Henrique Barboza
The 'pvspinlock' feature is x86 only. The "" declaration
will always have a value 'on' or 'off', and both will break QEMU when
launching non-x86 guests. This is the error message for
"" when running a ppc64 guest:

qemu-kvm: Expected key=value format, found +kvm_pv_unhalt

A similar error message is thrown for "".

This patch prevents non-x86 guests from launching with any
pvspinlock setting with a more informative error message:

error: unsupported configuration: The 'pvspinlock' feature is not
supported for architecture 'ppc64' or machine type 'pseries'

Suggested-by: Andrea Bolognani 
Signed-off-by: Daniel Henrique Barboza 
---
 src/qemu/qemu_domain.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 73a65128c6..c56b3a893b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5271,13 +5271,25 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
 }
 break;
 
+case VIR_DOMAIN_FEATURE_PVSPINLOCK:
+if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
+!ARCH_IS_X86(def->os.arch)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("The '%s' feature is not supported for "
+ "architecture '%s' or machine type '%s'"),
+ featureName,
+ virArchToString(def->os.arch),
+ def->os.machine);
+ return -1;
+}
+break;
+
 case VIR_DOMAIN_FEATURE_ACPI:
 case VIR_DOMAIN_FEATURE_PAE:
 case VIR_DOMAIN_FEATURE_HAP:
 case VIR_DOMAIN_FEATURE_VIRIDIAN:
 case VIR_DOMAIN_FEATURE_PRIVNET:
 case VIR_DOMAIN_FEATURE_HYPERV:
-case VIR_DOMAIN_FEATURE_PVSPINLOCK:
 case VIR_DOMAIN_FEATURE_CAPABILITIES:
 case VIR_DOMAIN_FEATURE_PMU:
 case VIR_DOMAIN_FEATURE_MSRS:
-- 
2.25.1