From: Peter Krempa Date: Thu, 29 Nov 2018 11:50:09 +0000 (+0100) Subject: qemu: domain: Add global table of blockjobs X-Git-Tag: v5.6.0-rc1~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acff58291541874038afabed30fcce386583a502;p=thirdparty%2Flibvirt.git qemu: domain: Add global table of blockjobs 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 Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 56a82df050..af0f856b78 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1975,6 +1975,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; @@ -2044,6 +2047,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv) qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); + + virHashRemoveAll(priv->blockjobs); } @@ -2075,6 +2080,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 5a4188ab65..6bf8af661d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -389,6 +389,9 @@ struct _qemuDomainObjPrivate { /* true if global -mem-prealloc appears on cmd line */ bool memPrealloc; + + /* running block jobs */ + virHashTablePtr blockjobs; }; #define QEMU_DOMAIN_PRIVATE(vm) \