[PATCH 04/35] qemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct

Peter Krempa posted 35 patches 4 years, 8 months ago
[PATCH 04/35] qemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct
Posted by Peter Krempa 4 years, 8 months ago
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>
---
 src/qemu/qemu_snapshot.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index b93b9b9fb0..def2733958 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -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);
 }

-- 
2.31.1

Re: [PATCH 04/35] qemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct
Posted by Ján Tomko 4 years, 8 months ago
On a Friday in 2021, Peter Krempa wrote:
>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>
>---
> src/qemu/qemu_snapshot.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano