render / rpms / libvirt

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