[libvirt] [PATCH 0/4] virt-host-validate: add s390 support

This patch series adds support to the s390 platform for the virt-host-validate tool which detects virtualization capabilities of the host. It has been tested on x86 that no regression is introduced. Bjoern Walk (4): tools: virt-host-validate: fix missing translation marker tools: virt-host-validate: fix CPU flag detection tools: virt-host-validate: improve error handling tools: virt-host-validate: HW virt support on s390 tools/virt-host-validate-common.c | 12 +++++++----- tools/virt-host-validate-common.h | 1 + tools/virt-host-validate-qemu.c | 31 ++++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 12 deletions(-) -- 2.6.6

Fix a minor typo. Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- tools/virt-host-validate-qemu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c index b96b020..eb08e7e 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -31,7 +31,7 @@ int virHostValidateQEMU(void) virBitmapPtr flags; int ret = 0; - virHostMsgCheck("QEMU", "%s", ("for hardware virtualization")); + virHostMsgCheck("QEMU", "%s", _("for hardware virtualization")); flags = virHostValidateGetCPUFlags(); -- 2.6.6

Let's fix CPU flag detection on s390, where the flags line begins with a lower-case 'features'. Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- tools/virt-host-validate-common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index c476c95..3c19249 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -212,10 +212,11 @@ virBitmapPtr virHostValidateGetCPUFlags(void) if (!fgets(line, sizeof(line), fp)) break; - /* The line we're interested in is marked either as "flags" or - * as "Features" depending on the architecture, so check both - * prefixes */ - if (!STRPREFIX(line, "flags") && !STRPREFIX(line, "Features")) + /* The line we're interested in is marked differently depending + * on the architecture, so check possible prefixes */ + if (!STRPREFIX(line, "flags") && + !STRPREFIX(line, "Features") && + !STRPREFIX(line, "features")) continue; /* fgets() includes the trailing newline in the output buffer, -- 2.6.6

When virHostValidateCPUFlag returns NULL, that's more an unexpected error than the sign of missing CPU flags. Let's react to this appropriately. Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- tools/virt-host-validate-qemu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c index eb08e7e..47f2f98 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -33,10 +33,10 @@ int virHostValidateQEMU(void) virHostMsgCheck("QEMU", "%s", _("for hardware virtualization")); - flags = virHostValidateGetCPUFlags(); + if (!(flags = virHostValidateGetCPUFlags())) + return -1; - if (flags && - (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) || + if ((virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) || virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))) { virHostMsgPass(); if (virHostValidateDeviceExists("QEMU", "/dev/kvm", -- 2.6.6

Extend the detection of hardware virtualization to the s390 platform. Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- tools/virt-host-validate-common.c | 3 ++- tools/virt-host-validate-common.h | 1 + tools/virt-host-validate-qemu.c | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c index 3c19249..4bfc52a 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -40,7 +40,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag, VIR_HOST_VALIDATE_CPU_FLAG_LAST, "vmx", - "svm"); + "svm", + "sie"); static bool quiet; diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-common.h index 26e006b..c14e922 100644 --- a/tools/virt-host-validate-common.h +++ b/tools/virt-host-validate-common.h @@ -37,6 +37,7 @@ typedef enum { typedef enum { VIR_HOST_VALIDATE_CPU_FLAG_VMX = 0, VIR_HOST_VALIDATE_CPU_FLAG_SVM, + VIR_HOST_VALIDATE_CPU_FLAG_SIE, VIR_HOST_VALIDATE_CPU_FLAG_LAST, } virHostValidateCPUFlag; diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c index 47f2f98..56ec3c7 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -24,20 +24,37 @@ #include "virt-host-validate-qemu.h" #include "virt-host-validate-common.h" +#include "virarch.h" #include "virbitmap.h" int virHostValidateQEMU(void) { virBitmapPtr flags; int ret = 0; + bool hasHwVirt = false; virHostMsgCheck("QEMU", "%s", _("for hardware virtualization")); if (!(flags = virHostValidateGetCPUFlags())) return -1; - if ((virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) || - virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))) { + switch (virArchFromHost()) { + case VIR_ARCH_I686: + case VIR_ARCH_X86_64: + if (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) || + virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX)) + hasHwVirt = true; + break; + case VIR_ARCH_S390: + case VIR_ARCH_S390X: + if (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SIE)) + hasHwVirt = true; + break; + default: + hasHwVirt = false; + } + + if (hasHwVirt) { virHostMsgPass(); if (virHostValidateDeviceExists("QEMU", "/dev/kvm", VIR_HOST_VALIDATE_FAIL, -- 2.6.6

On 03.05.2016 08:10, Bjoern Walk wrote:
This patch series adds support to the s390 platform for the virt-host-validate tool which detects virtualization capabilities of the host.
It has been tested on x86 that no regression is introduced.
Bjoern Walk (4): tools: virt-host-validate: fix missing translation marker tools: virt-host-validate: fix CPU flag detection tools: virt-host-validate: improve error handling tools: virt-host-validate: HW virt support on s390
tools/virt-host-validate-common.c | 12 +++++++----- tools/virt-host-validate-common.h | 1 + tools/virt-host-validate-qemu.c | 31 ++++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 12 deletions(-)
ACKed and pushed. Michal
participants (2)
-
Bjoern Walk
-
Michal Privoznik