qemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct

The config is used both with the preparation and execution functions, so
we can store it in the context to simplify other helpers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-28 14:12:39 +02:00
parent 983bad4771
commit 18f976abe2

View File

@ -896,6 +896,8 @@ struct _qemuSnapshotDiskContext {
virJSONValue *actions;
virQEMUDriverConfig *cfg;
/* needed for automatic cleanup of 'dd' */
virDomainObj *vm;
qemuDomainAsyncJob asyncJob;
@ -909,11 +911,14 @@ qemuSnapshotDiskContextNew(size_t ndisks,
virDomainObj *vm,
qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
virQEMUDriver *driver = priv->driver;
qemuSnapshotDiskContext *ret = g_new0(qemuSnapshotDiskContext, 1);
ret->dd = g_new0(qemuSnapshotDiskData, ndisks);
ret->actions = virJSONValueNewArray();
ret->vm = vm;
ret->cfg = virQEMUDriverGetConfig(driver);
ret->asyncJob = asyncJob;
return ret;
@ -930,6 +935,8 @@ qemuSnapshotDiskContextCleanup(qemuSnapshotDiskContext *snapctxt)
qemuSnapshotDiskCleanup(snapctxt->dd, snapctxt->ndd, snapctxt->vm, snapctxt->asyncJob);
virObjectUnref(snapctxt->cfg);
g_free(snapctxt);
}