render / rpms / libvirt

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