[libvirt] [PATCH v2 01/10] add virDomainVirtioSerialAddrSetCreateFromDomain
Martin Kletzander
mkletzan at redhat.com
Mon Jul 25 14:27:12 UTC 2016
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160725/94bd2ab4/attachment-0001.sig>
More information about the libvir-list
mailing list