qemu: block: store the delete flag in libvirtd's status XML

Since blockcommit is asynchronous, libvirtd can be restarted while the
operation runs.  To ensure the information necessary to finish up the job
is not lost, serialisation to and deserialisation from the status XML is
added.

To unittest this, the new element was only added to the active commit test,
the non-active commit test doesn't have the new element so as to test its
absence.

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Pavel Mores
2019-12-10 17:25:40 +01:00
committed by Peter Krempa
parent 9e5c98e84f
commit 73532dadd2
2 changed files with 5 additions and 0 deletions

View File

@@ -2586,6 +2586,8 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload,
virBufferAsprintf(&childBuf, "<top node='%s'/>\n", job->data.commit.top->nodeformat); virBufferAsprintf(&childBuf, "<top node='%s'/>\n", job->data.commit.top->nodeformat);
if (job->data.commit.topparent) if (job->data.commit.topparent)
virBufferAsprintf(&childBuf, "<topparent node='%s'/>\n", job->data.commit.topparent->nodeformat); virBufferAsprintf(&childBuf, "<topparent node='%s'/>\n", job->data.commit.topparent->nodeformat);
if (job->data.commit.deleteCommittedImages)
virBufferAddLit(&childBuf, "<deleteCommittedImages/>\n");
break; break;
case QEMU_BLOCKJOB_TYPE_CREATE: case QEMU_BLOCKJOB_TYPE_CREATE:
@@ -3185,6 +3187,8 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
"string(./base/@node)", "string(./base/@node)",
&job->data.commit.base, &job->data.commit.base,
ctxt); ctxt);
if (virXPathNode("./deleteCommittedImages", ctxt))
job->data.commit.deleteCommittedImages = true;
if (!job->data.commit.top || if (!job->data.commit.top ||
!job->data.commit.base) !job->data.commit.base)
goto broken; goto broken;

View File

@@ -242,6 +242,7 @@
<disk dst='vde'/> <disk dst='vde'/>
<base node='libvirt-19-format'/> <base node='libvirt-19-format'/>
<top node='libvirt-17-format'/> <top node='libvirt-17-format'/>
<deleteCommittedImages/>
</blockjob> </blockjob>
<blockjob name='create-libvirt-1337-storage' type='create' state='running'> <blockjob name='create-libvirt-1337-storage' type='create' state='running'>
<create mode='storage'/> <create mode='storage'/>