diff mbox

[06/12] qemu: Handle CanonicalizeMachine in post parse

Message ID 9a7ec47841804bd157c480ff75a24bcc0cf02fea.1452224621.git.crobinso@redhat.com
State Accepted
Commit a8b628e7a858dc80108c6ce4c13beef6278fcc36
Headers show

Commit Message

Cole Robinson Jan. 8, 2016, 3:50 a.m. UTC
Rather than open coding calls. I can't see any reason not to
---
 src/qemu/qemu_domain.c | 23 +++++++++++++++++++++++
 src/qemu/qemu_driver.c | 29 -----------------------------
 2 files changed, 23 insertions(+), 29 deletions(-)

-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 26a29b1..48a2160 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1199,6 +1199,26 @@  qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
 
 
 static int
+qemuCanonicalizeMachine(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
+{
+    const char *canon;
+
+    if (!(canon = virQEMUCapsGetCanonicalMachine(qemuCaps, def->os.machine)))
+        return 0;
+
+    if (STRNEQ(canon, def->os.machine)) {
+        char *tmp;
+        if (VIR_STRDUP(tmp, canon) < 0)
+            return -1;
+        VIR_FREE(def->os.machine);
+        def->os.machine = tmp;
+    }
+
+    return 0;
+}
+
+
+static int
 qemuDomainDefPostParse(virDomainDefPtr def,
                        virCapsPtr caps,
                        void *opaque)
@@ -1223,6 +1243,9 @@  qemuDomainDefPostParse(virDomainDefPtr def,
     if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0)
         goto cleanup;
 
+    if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
+        goto cleanup;
+
     ret = 0;
  cleanup:
     virObjectUnref(qemuCaps);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 51c6950..50ce514 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1684,26 +1684,6 @@  static int qemuConnectNumOfDomains(virConnectPtr conn)
 }
 
 
-static int
-qemuCanonicalizeMachine(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
-{
-    const char *canon;
-
-    if (!(canon = virQEMUCapsGetCanonicalMachine(qemuCaps, def->os.machine)))
-        return 0;
-
-    if (STRNEQ(canon, def->os.machine)) {
-        char *tmp;
-        if (VIR_STRDUP(tmp, canon) < 0)
-            return -1;
-        VIR_FREE(def->os.machine);
-        def->os.machine = tmp;
-    }
-
-    return 0;
-}
-
-
 static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
                                         const char *xml,
                                         unsigned int flags)
@@ -1749,9 +1729,6 @@  static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
     if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator)))
         goto cleanup;
 
-    if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
-        goto cleanup;
-
     if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
         goto cleanup;
 
@@ -7531,9 +7508,6 @@  static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
     if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator)))
         goto cleanup;
 
-    if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
-        goto cleanup;
-
     if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
         goto cleanup;
 
@@ -15888,9 +15862,6 @@  static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
     if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator)))
         goto cleanup;
 
-    if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
-        goto cleanup;
-
     if (qemuAssignDeviceAliases(def, qemuCaps) < 0)
         goto cleanup;