a41c76
From 5278c00147b0ac777d5ddd73062d0c6146da4908 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <5278c00147b0ac777d5ddd73062d0c6146da4908@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 4 Feb 2020 15:08:21 +0100
a41c76
Subject: [PATCH] qemu: blockjob: Store 'jobflags' with block job data
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Add a variable which will store the contents of the 'flags' variable as
a41c76
passed in by the individual block jobs. Since the flags may influence
a41c76
behaviour of the jobs it's important to preserve them to the
a41c76
finalization steps.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 9ba804a1d16b12dac2ec2edbd0f384c21d4bc5c8)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1207659
a41c76
Message-Id: <81db2d5e281716bf385d6d9c634136e36e8bd391.1580824112.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_blockjob.h                             | 3 +++
a41c76
 src/qemu/qemu_domain.c                               | 7 +++++++
a41c76
 tests/qemustatusxml2xmldata/backup-pull-in.xml       | 2 +-
a41c76
 tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml | 8 ++++----
a41c76
 4 files changed, 15 insertions(+), 5 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
a41c76
index 7d584a2980..53c495fa8a 100644
a41c76
--- a/src/qemu/qemu_blockjob.h
a41c76
+++ b/src/qemu/qemu_blockjob.h
a41c76
@@ -129,6 +129,9 @@ struct _qemuBlockJobData {
a41c76
     virStorageSourcePtr chain; /* Reference to the chain the job operates on. */
a41c76
     virStorageSourcePtr mirrorChain; /* reference to 'mirror' part of the job */
a41c76
 
a41c76
+    unsigned int jobflags; /* per job flags */
a41c76
+    bool jobflagsmissing; /* job flags were not stored */
a41c76
+
a41c76
     union {
a41c76
         qemuBlockJobPullData pull;
a41c76
         qemuBlockJobCommitData commit;
a41c76
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a41c76
index 94efcdf9b1..846d1ecb29 100644
a41c76
--- a/src/qemu/qemu_domain.c
a41c76
+++ b/src/qemu/qemu_domain.c
a41c76
@@ -2582,6 +2582,8 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload,
a41c76
     virBufferEscapeString(&attrBuf, " newstate='%s'", newstate);
a41c76
     if (job->brokentype != QEMU_BLOCKJOB_TYPE_NONE)
a41c76
         virBufferEscapeString(&attrBuf, " brokentype='%s'", qemuBlockjobTypeToString(job->brokentype));
a41c76
+    if (!job->jobflagsmissing)
a41c76
+        virBufferAsprintf(&attrBuf, " jobflags='0x%x'", job->jobflags);
a41c76
     virBufferEscapeString(&childBuf, "<errmsg>%s</errmsg>", job->errmsg);
a41c76
 
a41c76
     if (job->disk) {
a41c76
@@ -3294,6 +3296,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm,
a41c76
     int newstate = -1;
a41c76
     bool invalidData = false;
a41c76
     xmlNodePtr tmp;
a41c76
+    unsigned long jobflags = 0;
a41c76
 
a41c76
     ctxt->node = node;
a41c76
 
a41c76
@@ -3333,6 +3336,9 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm,
a41c76
         STRNEQ(mirror, "yes"))
a41c76
         invalidData = true;
a41c76
 
a41c76
+    if (virXPathULongHex("string(./@jobflags)", ctxt, &jobflags) != 0)
a41c76
+        job->jobflagsmissing = true;
a41c76
+
a41c76
     if (!disk && !invalidData) {
a41c76
         if ((tmp = virXPathNode("./chains/disk", ctxt)) &&
a41c76
             !(job->chain = qemuDomainObjPrivateXMLParseBlockjobChain(tmp, ctxt, xmlopt)))
a41c76
@@ -3352,6 +3358,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm,
a41c76
 
a41c76
     job->state = state;
a41c76
     job->newstate = newstate;
a41c76
+    job->jobflags = jobflags;
a41c76
     job->errmsg = virXPathString("string(./errmsg)", ctxt);
a41c76
     job->invalidData = invalidData;
a41c76
     job->disk = disk;
a41c76
diff --git a/tests/qemustatusxml2xmldata/backup-pull-in.xml b/tests/qemustatusxml2xmldata/backup-pull-in.xml
a41c76
index 3c69c41840..1db978a3ac 100644
a41c76
--- a/tests/qemustatusxml2xmldata/backup-pull-in.xml
a41c76
+++ b/tests/qemustatusxml2xmldata/backup-pull-in.xml
a41c76
@@ -235,7 +235,7 @@
a41c76
   <allowReboot value='yes'/>
a41c76
   <nodename index='0'/>
a41c76
   <blockjobs active='yes'>
a41c76
-    <blockjob name='backup-vda-libvirt-3-format' type='backup' state='running'>
a41c76
+    <blockjob name='backup-vda-libvirt-3-format' type='backup' state='running' jobflags='0x0'>
a41c76
       <disk dst='vda'/>
a41c76
       <bitmap name='bitmapname'/>
a41c76
       <store type='file' format='qcow2'>
a41c76
diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
a41c76
index b5d62fd4ab..ca6d110179 100644
a41c76
--- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
a41c76
+++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml
a41c76
@@ -261,19 +261,19 @@
a41c76
         </source>
a41c76
       </src>
a41c76
     </blockjob>
a41c76
-    <blockjob name='copy-vdd-libvirt-4321-format' type='copy' state='ready' shallownew='yes'>
a41c76
+    <blockjob name='copy-vdd-libvirt-4321-format' type='copy' state='ready' jobflags='0x0' shallownew='yes'>
a41c76
       <disk dst='vdd'/>
a41c76
     </blockjob>
a41c76
-    <blockjob name='commit-vdc-libvirt-9-format' type='commit' state='running'>
a41c76
+    <blockjob name='commit-vdc-libvirt-9-format' type='commit' state='running' jobflags='0x0'>
a41c76
       <disk dst='vdc'/>
a41c76
       <base node='libvirt-11-format'/>
a41c76
       <top node='libvirt-9-format'/>
a41c76
       <topparent node='libvirt-2-format'/>
a41c76
     </blockjob>
a41c76
-    <blockjob name='drive-virtio-disk0' type='copy' state='ready'>
a41c76
+    <blockjob name='drive-virtio-disk0' type='copy' state='ready' jobflags='0x0'>
a41c76
       <disk dst='vda' mirror='yes'/>
a41c76
     </blockjob>
a41c76
-    <blockjob name='create-libvirt-1338-format' type='create' state='running'>
a41c76
+    <blockjob name='create-libvirt-1338-format' type='create' state='running' jobflags='0xabcd'>
a41c76
       <chains>
a41c76
         <disk type='file' format='qcow2'>
a41c76
           <source file='/create/src1.qcow2' index='1339'>
a41c76
-- 
a41c76
2.25.0
a41c76