[libvirt] [PATCH 08/12] qemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsGetCanonicalMachine

Peter Krempa pkrempa at redhat.com
Wed Aug 16 14:57:57 UTC 2017


If qemuCaps are not present, just return the original machine type name.

This will help in situations when qemuCaps is not available in the post
parse callback.
---
 src/qemu/qemu_capabilities.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e61d2f7b0..f05e7650a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2739,15 +2739,21 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
 }


-
-
+/**
+ * virQEMUCapsGetCanonicalMachine:
+ * @qemuCaps: qemu capabilities object
+ * @name: machine name
+ *
+ * Resolves aliased machine names to the actual machine name. If qemuCaps isn't
+ * present @name is returned.
+ */
 const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
                                            const char *name)
 {
     size_t i;

-    if (!name)
-        return NULL;
+    if (!name || !qemuCaps)
+        return name;

     for (i = 0; i < qemuCaps->nmachineTypes; i++) {
         if (!qemuCaps->machineTypes[i].alias)
-- 
2.14.0




More information about the libvir-list mailing list