[libvirt] [PATCH 3/4] tools: virt-host-validate: improve error handling

Bjoern Walk bwalk at linux.vnet.ibm.com
Tue May 3 06:10:53 UTC 2016


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 at 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




More information about the libvir-list mailing list