On Sat, Jul 23, 2016 at 03:47:06AM +0200, Tomasz Flendrich wrote:
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;
One common thing to do in libvirt's codebase is (although of course
there are too many ways to approach this):
Initialize this to NULL,
+ 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;
set it to NULL here as well,
+ cleanup:
+ if (!ret)
+ virDomainVirtioSerialAddrSetFree(addrs);
and call this unconditionally.
ACK with that changed.