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 virtio serial address set
from the domain definition.
Credit goes to Cole Robinson.
---
src/conf/domain_addr.c | 31 +++++++++++++++++++++++++++++++
src/conf/domain_addr.h | 3 +++
src/libvirt_private.syms | 1 +
src/qemu/qemu_domain_address.c | 9 +--------
4 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index c3469ee..e09b409 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -975,6 +975,37 @@ virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr
addrs)
}
}
+
+/* virDomainVirtioSerialAddrSetCreateFromDomain
++ *
++ * @def: Domain def to introspect
++ *
++ * Inspect the domain definition and return an address set containing
++ * every virtio serial address we find
++ */
+virDomainVirtioSerialAddrSetPtr
+virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def)
+{
+ virDomainVirtioSerialAddrSetPtr addrs;
+ virDomainVirtioSerialAddrSetPtr ret = NULL;
+
+ if (!(addrs = virDomainVirtioSerialAddrSetCreate()))
+ goto cleanup;
+
+ if (virDomainVirtioSerialAddrSetAddControllers(addrs, def) < 0)
+ goto cleanup;
+
+ if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve,
+ addrs) < 0)
+ goto cleanup;
+
+ ret = addrs;
+ cleanup:
+ if (!ret)
+ virDomainVirtioSerialAddrSetFree(addrs);
+ return ret;
+}
+
static int
virDomainVirtioSerialAddrSetAutoaddController(virDomainDefPtr def,
virDomainVirtioSerialAddrSetPtr addrs,
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index ce94981..4584e0a 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -208,6 +208,9 @@
virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void
virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs);
+virDomainVirtioSerialAddrSetPtr
+virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def)
+ ATTRIBUTE_NONNULL(1);
bool
virDomainVirtioSerialAddrIsComplete(virDomainDeviceInfoPtr info);
int
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9396c4e..6b54812 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -126,6 +126,7 @@ virDomainVirtioSerialAddrRelease;
virDomainVirtioSerialAddrReserve;
virDomainVirtioSerialAddrSetAddControllers;
virDomainVirtioSerialAddrSetCreate;
+virDomainVirtioSerialAddrSetCreateFromDomain;
virDomainVirtioSerialAddrSetFree;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 787b357..2bd095f 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -114,14 +114,7 @@ qemuDomainAssignVirtioSerialAddresses(virDomainDefPtr def,
virDomainVirtioSerialAddrSetPtr addrs = NULL;
qemuDomainObjPrivatePtr priv = NULL;
- if (!(addrs = virDomainVirtioSerialAddrSetCreate()))
- goto cleanup;
-
- if (virDomainVirtioSerialAddrSetAddControllers(addrs, def) < 0)
- goto cleanup;
-
- if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve,
- addrs) < 0)
+ if (!(addrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
goto cleanup;
VIR_DEBUG("Finished reserving existing ports");
--
2.7.4 (Apple Git-66)