[PATCH 4/9] Add newDomain parameter to qemuDomainAssignAddresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To differentiate a new domain from an existing one.
---
 src/qemu/qemu_command.c  |  5 ++++-
 src/qemu/qemu_command.h  |  3 ++-
 src/qemu/qemu_driver.c   | 22 +++++++++++-----------
 src/qemu/qemu_process.c  |  6 +++---
 tests/qemuhotplugtest.c  |  2 +-
 tests/qemuxml2argvtest.c |  2 +-
 tests/qemuxmlnstest.c    |  2 +-
 7 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4e77279..4b520d7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1773,10 +1773,13 @@ qemuDomainPCIBusFullyReserved(virDomainPCIAddressBusPtr bus)
 
 int qemuDomainAssignAddresses(virDomainDefPtr def,
                               virQEMUCapsPtr qemuCaps,
-                              virDomainObjPtr obj)
+                              virDomainObjPtr obj,
+                              bool newDomain ATTRIBUTE_UNUSED)
 {
     int rc;
 
+    VIR_DEBUG("def=%p obj=%p newDomain=%d", def, obj, newDomain);
+
     rc = qemuDomainAssignVirtioSerialAddresses(def, obj);
     if (rc)
         return rc;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index e356f5b..da9ea14 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -266,7 +266,8 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
 
 int qemuDomainAssignAddresses(virDomainDefPtr def,
                               virQEMUCapsPtr qemuCaps,
-                              virDomainObjPtr obj)
+                              virDomainObjPtr obj,
+                              bool newDomain)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
                                       virQEMUCapsPtr qemuCaps);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2e44500..02faf3e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1737,7 +1737,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
     if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
         goto cleanup;
 
-    if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+    if (qemuDomainAssignAddresses(def, qemuCaps, NULL, true) < 0)
         goto cleanup;
 
     if (!(vm = virDomainObjListAdd(driver->domains, def,
@@ -7246,7 +7246,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
     if (qemuAssignDeviceAliases(def, qemuCaps) < 0)
         goto cleanup;
 
-    if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+    if (qemuDomainAssignAddresses(def, qemuCaps, NULL, true) < 0)
         goto cleanup;
 
     /* do fake auto-alloc of graphics ports, if such config is used */
@@ -7486,7 +7486,7 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
     if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
         goto cleanup;
 
-    if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+    if (qemuDomainAssignAddresses(def, qemuCaps, NULL, true) < 0)
         goto cleanup;
 
     if (!(vm = virDomainObjListAdd(driver->domains, def,
@@ -8036,7 +8036,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
         if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)
             if (virDomainDefAddImplicitControllers(vmdef) < 0)
                 return -1;
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -8045,7 +8045,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
         if (virDomainNetInsert(vmdef, net))
             return -1;
         dev->data.net = NULL;
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -8061,7 +8061,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
         dev->data.hostdev = NULL;
         if (virDomainDefAddImplicitControllers(vmdef) < 0)
             return -1;
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -8093,7 +8093,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
             return -1;
         dev->data.controller = NULL;
 
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -8103,7 +8103,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
         dev->data.chr = NULL;
         if (virDomainDefAddImplicitControllers(vmdef) < 0)
             return -1;
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -8132,7 +8132,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
             return -1;
         dev->data.rng = NULL;
 
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -8371,7 +8371,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
         vmdef->nets[pos] = net;
         dev->data.net = NULL;
 
-        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
+        if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL, false) < 0)
             return -1;
         break;
 
@@ -15859,7 +15859,7 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
     if (qemuAssignDeviceAliases(def, qemuCaps) < 0)
         goto cleanup;
 
-    if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+    if (qemuDomainAssignAddresses(def, qemuCaps, NULL, false) < 0)
         goto cleanup;
 
     if (!(vm = virDomainObjListAdd(driver->domains, def,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 505778e..5349021 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3840,7 +3840,7 @@ qemuProcessReconnect(void *opaque)
     }
 
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
-        if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, obj)) < 0)
+        if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, obj, false)) < 0)
             goto error;
 
     /* if domain requests security driver we haven't loaded, report error, but
@@ -4711,7 +4711,7 @@ int qemuProcessStart(virConnectPtr conn,
      */
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
         VIR_DEBUG("Assigning domain PCI addresses");
-        if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+        if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm, false)) < 0)
             goto cleanup;
     }
 
@@ -5561,7 +5561,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
      */
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
         VIR_DEBUG("Assigning domain PCI addresses");
-        if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+        if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm, false)) < 0)
             goto error;
     }
 
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 368a5e7..ea37a6c 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -85,7 +85,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
     if (event)
         virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
 
-    if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm) < 0)
+    if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm, true) < 0)
         goto cleanup;
 
     if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c2482e6..8815087 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -307,7 +307,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
     virQEMUCapsFilterByMachineType(extraFlags, vmdef->os.machine);
 
     if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
-        if (qemuDomainAssignAddresses(vmdef, extraFlags, NULL)) {
+        if (qemuDomainAssignAddresses(vmdef, extraFlags, NULL, true)) {
             if (flags & FLAG_EXPECT_ERROR)
                 goto ok;
             goto out;
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 8eaab8a..ed11eb8 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -89,7 +89,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
                        QEMU_CAPS_LAST);
 
     if (virQEMUCapsGet(extraFlags, QEMU_CAPS_DEVICE))
-        qemuDomainAssignAddresses(vmdef, extraFlags, NULL);
+        qemuDomainAssignAddresses(vmdef, extraFlags, NULL, true);
 
     log = virtTestLogContentAndReset();
     VIR_FREE(log);
-- 
2.4.6

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]