diff mbox

[05/12] qemu: domain: split out post parse default device handling

Message ID 6e205192009450e607a9602c0d5baef9844ad0fd.1452224621.git.crobinso@redhat.com
State New
Headers show

Commit Message

Cole Robinson Jan. 8, 2016, 3:49 a.m. UTC
Should be a no-op
---
 src/qemu/qemu_domain.c | 53 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 20 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 bb8d47f..26a29b1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1025,14 +1025,10 @@  virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = {
     .href = qemuDomainDefNamespaceHref,
 };
 
-
 static int
-qemuDomainDefPostParse(virDomainDefPtr def,
-                       virCapsPtr caps,
-                       void *opaque)
+qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
+                               virQEMUCapsPtr qemuCaps)
 {
-    virQEMUDriverPtr driver = opaque;
-    virQEMUCapsPtr qemuCaps = NULL;
     bool addDefaultUSB = true;
     bool addImplicitSATA = false;
     bool addPCIRoot = false;
@@ -1043,20 +1039,6 @@  qemuDomainDefPostParse(virDomainDefPtr def,
     bool addPanicDevice = false;
     int ret = -1;
 
-    if (def->os.bootloader || def->os.bootloaderArgs) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("bootloader is not supported by QEMU"));
-        return ret;
-    }
-
-    /* check for emulator and create a default one if needed */
-    if (!def->emulator &&
-        !(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
-        return ret;
-
-
-    qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
-
     /* Add implicit PCI root controller if the machine has one */
     switch (def->os.arch) {
     case VIR_ARCH_I686:
@@ -1212,6 +1194,37 @@  qemuDomainDefPostParse(virDomainDefPtr def,
 
     ret = 0;
  cleanup:
+    return ret;
+}
+
+
+static int
+qemuDomainDefPostParse(virDomainDefPtr def,
+                       virCapsPtr caps,
+                       void *opaque)
+{
+    virQEMUDriverPtr driver = opaque;
+    virQEMUCapsPtr qemuCaps = NULL;
+    int ret = -1;
+
+    if (def->os.bootloader || def->os.bootloaderArgs) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("bootloader is not supported by QEMU"));
+        return ret;
+    }
+
+    /* check for emulator and create a default one if needed */
+    if (!def->emulator &&
+        !(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
+        return ret;
+
+    qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
+
+    if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0)
+        goto cleanup;
+
+    ret = 0;
+ cleanup:
     virObjectUnref(qemuCaps);
     return ret;
 }