[libvirt] [PATCH 4/4] qemu: assign addresses before aliases

Ján Tomko jtomko at redhat.com
Wed Apr 13 07:51:41 UTC 2016


The address assigning code might add new pci bridges.
We need them to have an alias when building the command line.

In real word usage, this is not a problem because all the code
paths already call qemuDomainAssignAddresses. However moving
this call lets us remove one extra call from qemuxml2argvtest.
---
 src/qemu/qemu_process.c  | 26 +++++++++++++-------------
 tests/qemuxml2argvtest.c |  6 ------
 2 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2171665..986f406 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4999,6 +4999,19 @@ qemuProcessPrepareDomain(virConnectPtr conn,
         }
     }
 
+    /*
+     * Normally PCI addresses are assigned in the virDomainCreate
+     * or virDomainDefine methods. We might still need to assign
+     * some here to cope with the question of upgrades. Regardless
+     * we also need to populate the PCI address set cache for later
+     * use in hotplug
+     */
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+        VIR_DEBUG("Assigning domain PCI addresses");
+        if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+            goto cleanup;
+    }
+
     if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
         goto cleanup;
 
@@ -5022,19 +5035,6 @@ qemuProcessPrepareDomain(virConnectPtr conn,
     priv->monStart = 0;
     priv->gotShutdown = false;
 
-    /*
-     * Normally PCI addresses are assigned in the virDomainCreate
-     * or virDomainDefine methods. We might still need to assign
-     * some here to cope with the question of upgrades. Regardless
-     * we also need to populate the PCI address set cache for later
-     * use in hotplug
-     */
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
-        VIR_DEBUG("Assigning domain PCI addresses");
-        if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
-            goto cleanup;
-    }
-
     ret = 0;
  cleanup:
     VIR_FREE(nodeset);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 2a57176..be74178 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -311,12 +311,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     virQEMUCapsFilterByMachineType(extraFlags, vm->def->os.machine);
 
-    if (qemuDomainAssignAddresses(vm->def, extraFlags, NULL)) {
-        if (flags & FLAG_EXPECT_FAILURE)
-            goto ok;
-        goto out;
-    }
-
     log = virtTestLogContentAndReset();
     VIR_FREE(log);
     virResetLastError();
-- 
2.7.3




More information about the libvir-list mailing list