]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add qemuDomainCCWAddrSetCreateFromDomain
authorTomasz Flendrich <t.flendrich@gmail.com>
Sat, 23 Jul 2016 01:47:09 +0000 (03:47 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 26 Jul 2016 11:04:46 +0000 (13:04 +0200)
The address sets (pci, ccw, virtio serial) are currently cached
in qemu private data, but all the information required to recreate
these sets is in the domain definition. Therefore I am removing
the redundant data and adding a way to recalculate these sets.

Add a function that calculates the ccw address set
from the domain definition.

src/qemu/qemu_domain_address.c
src/qemu/qemu_domain_address.h

index 0df112ba36ed26e1c7ece7b08296d7447bd302d0..b23790ff5b814cd4ec4a0a683e2e25308f4a743c 100644 (file)
@@ -320,6 +320,28 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
     }
 }
 
+virDomainCCWAddressSetPtr
+qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def)
+{
+    virDomainCCWAddressSetPtr addrs = NULL;
+
+    if (!(addrs = virDomainCCWAddressSetCreate()))
+        goto error;
+
+    if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate,
+                                   addrs) < 0)
+        goto error;
+
+    if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate,
+                                   addrs) < 0)
+        goto error;
+
+    return addrs;
+
+ error:
+    virDomainCCWAddressSetFree(addrs);
+    return NULL;
+}
 
 /*
  * Three steps populating CCW devnos
@@ -341,16 +363,9 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
         qemuDomainPrimeVirtioDeviceAddresses(
             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
 
-        if (!(addrs = virDomainCCWAddressSetCreate()))
-            goto cleanup;
-
-        if (virDomainDeviceInfoIterate(def, virDomainCCWAddressValidate,
-                                       addrs) < 0)
+        if (!(addrs = qemuDomainCCWAddrSetCreateFromDomain(def)))
             goto cleanup;
 
-        if (virDomainDeviceInfoIterate(def, virDomainCCWAddressAllocate,
-                                       addrs) < 0)
-            goto cleanup;
     } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
         /* deal with legacy virtio-s390 */
         qemuDomainPrimeVirtioDeviceAddresses(
index ee326d756bfd3e5c2c2fb6034cc6d823caa37fe2..11d6e92a4174b430fb86fe9f6bb1c1086ef75931 100644 (file)
@@ -41,6 +41,10 @@ void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
                                     virDomainDeviceInfoPtr info,
                                     const char *devstr);
 
+virDomainCCWAddressSetPtr
+qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def)
+    ATTRIBUTE_NONNULL(1);
+
 # define __QEMU_DOMAIN_ADDRESS_H__
 
 #endif /* __QEMU_DOMAIN_ADDRESS_H__ */