[libvirt] [PATCH 11/15] qemu: domain: Add private data for NBD migration storage source definition
Peter Krempa
pkrempa at redhat.com
Wed May 23 08:30:59 UTC 2018
On Tue, May 22, 2018 at 20:26:56 -0400, John Ferlan wrote:
>
>
> On 05/18/2018 07:29 AM, Peter Krempa wrote:
> > Allow saving various aspects necessary to do NBD migration via blockdev
> > by storing a 'virStorageSource' in the disk private data meant to store
> > the NBD target of migration. Along with this add code to parse and
> > format it into the status XML.
> >
> > Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> > ---
> > src/qemu/qemu_domain.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++---
> > src/qemu/qemu_domain.h | 1 +
> > 2 files changed, 156 insertions(+), 7 deletions(-)
> >
> > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> > index 94a9c5d1bc..632c025bef 100644
> > --- a/src/qemu/qemu_domain.c
> > +++ b/src/qemu/qemu_domain.c
>
> [...]
>
>
> >
> > @@ -2092,6 +2155,7 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
> > virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
> > virBuffer childBuf = VIR_BUFFER_INITIALIZER;
> > qemuDomainJob job = priv->job.active;
> > + int ret = -1;
> >
> > if (!qemuDomainTrackJob(job))
> > job = QEMU_JOB_NONE;
> > @@ -2115,13 +2179,23 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
> > if (priv->job.asyncJob != QEMU_ASYNC_JOB_NONE)
> > virBufferAsprintf(&attrBuf, " flags='0x%lx'", priv->job.apiFlags);
> >
> > - if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
> > - qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm);
> > + if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
> > + qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm) < 0)
> > + goto cleanup;
> >
> > if (priv->job.migParams)
> > qemuMigrationParamsFormat(&childBuf, priv->job.migParams);
> >
> > - return virXMLFormatElement(buf, "job", &attrBuf, &childBuf);
> > + if (virXMLFormatElement(buf, "job", &attrBuf, &childBuf) < 0)
> > + goto cleanup;
> > +
> > + ret = 0;
> > +
> > + cleanup:
> > + virBufferFreeAndReset(&attrBuf);
> > + virBufferFreeAndReset(&childBuf);
>
> So I assume the lack of FreeAndReset was existing prior to this patch
> since d8be0f4bc?
Yes. I assumed that virXMLFormatElement clears them on error, but it
apparently does not, so adding them here actually fixes a possible bug.
This chagne would be necessary even with the above assumption being
valid as this patch adds a possible error code path.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180523/e4ce5edb/attachment-0001.sig>
More information about the libvir-list
mailing list