[libvirt] [PATCH RFC 33/51] qemu: domain: Add global table of blockjobs

Peter Krempa pkrempa at redhat.com
Wed Dec 12 17:08:49 UTC 2018


Block jobs currently belong to disks only so we can look up the block
job data for them in the corresponding disks. This won't be the case
when using blockdev as certain jobs don't even correspond to a disk and
most of them can run on a part of the backing chain.

Add a global table of blockjobs which can be used to look up the data
for the blockjobs when the job events need to be processed.

The table is a hash table organized by job name and has a reference to
the job. New and running jobs will later be added to this table.
Reference counting will allow to reap job state for synchronous callers.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_domain.c | 7 +++++++
 src/qemu/qemu_domain.h | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9961ba67d8..7a9a94efcf 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1906,6 +1906,9 @@ qemuDomainObjPrivateAlloc(void *opaque)
     if (!(priv->devs = virChrdevAlloc()))
         goto error;

+    if (!(priv->blockjobs = virHashCreate(5, virObjectFreeHashData)))
+        goto error;
+
     priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
     priv->driver = opaque;

@@ -1973,6 +1976,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv)

     qemuDomainObjResetJob(priv);
     qemuDomainObjResetAsyncJob(priv);
+
+    virHashRemoveAll(priv->blockjobs);
 }


@@ -2004,6 +2009,8 @@ qemuDomainObjPrivateFree(void *data)
     qemuDomainSecretInfoFree(&priv->migSecinfo);
     qemuDomainMasterKeyFree(priv);

+    virHashFree(priv->blockjobs);
+
     VIR_FREE(priv);
 }

diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index a03950e77b..a243bdc80e 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -373,6 +373,9 @@ struct _qemuDomainObjPrivate {

     /* true if libvirt remembers the original owner for files */
     bool rememberOwner;
+
+    /* running block jobs */
+    virHashTablePtr blockjobs;
 };

 # define QEMU_DOMAIN_PRIVATE(vm) \
-- 
2.19.2




More information about the libvir-list mailing list