]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsGetCanonicalMachine
authorPeter Krempa <pkrempa@redhat.com>
Wed, 16 Aug 2017 13:37:18 +0000 (15:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 18 Aug 2017 13:07:44 +0000 (15:07 +0200)
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

index e61d2f7b0d296ac1366653ce1b49a8cb28ee5bcf..f05e7650a20b89bd2ff831a90c85e79e1be7ea8a 100644 (file)
@@ -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)