[PATCH RFC 32/51] qemu: blockjob: Add job name into the data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently the job name corresponds to the disk the job belongs to. For
jobs which will not correspond to disks we'll need to track the name
separately.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_blockjob.c  | 20 ++++++++++++++++----
 src/qemu/qemu_blockjob.h  |  7 +++++--
 src/qemu/qemu_driver.c    |  8 ++++----
 src/qemu/qemu_migration.c |  2 +-
 src/qemu/qemu_process.c   |  2 +-
 5 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index c98d393f4b..27e854e2b2 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -36,6 +36,7 @@
 #include "virtime.h"
 #include "locking/domain_lock.h"
 #include "viralloc.h"
+#include "virstring.h"

 #define VIR_FROM_THIS VIR_FROM_QEMU

@@ -50,6 +51,7 @@ qemuBlockJobDataDispose(void *obj)
 {
     qemuBlockJobDataPtr job = obj;

+    VIR_FREE(job->name);
     VIR_FREE(job->errmsg);
 }

@@ -67,9 +69,11 @@ qemuBlockJobDataOnceInit(void)
 VIR_ONCE_GLOBAL_INIT(qemuBlockJobData)

 static qemuBlockJobDataPtr
-qemuBlockJobDataNew(qemuBlockjobType type)
+qemuBlockJobDataNew(qemuBlockjobType type,
+                    const char *name)
 {
     qemuBlockJobDataPtr job = NULL;
+    qemuBlockJobDataPtr ret = NULL;

     if (qemuBlockJobDataInitialize() < 0)
         return NULL;
@@ -77,11 +81,18 @@ qemuBlockJobDataNew(qemuBlockjobType type)
     if (!(job = virObjectNew(qemuBlockJobDataClass)))
         return NULL;

+    if (VIR_STRDUP(job->name, name) < 0)
+        goto cleanup;
+
     job->state = QEMU_BLOCKJOB_STATE_NEW;
     job->newstate = -1;
     job->type = type;

-    return job;
+    VIR_STEAL_PTR(ret, job);
+
+ cleanup:
+    virObjectUnref(job);
+    return ret;
 }


@@ -95,11 +106,12 @@ qemuBlockJobDataNew(qemuBlockjobType type)
  */
 qemuBlockJobDataPtr
 qemuBlockJobDiskNew(virDomainDiskDefPtr disk,
-                    qemuBlockjobType type)
+                    qemuBlockjobType type,
+                    const char *jobname)
 {
     qemuBlockJobDataPtr job = NULL;

-    if (!(job = qemuBlockJobDataNew(type)))
+    if (!(job = qemuBlockJobDataNew(type, jobname)))
         return NULL;

     job->disk = disk;
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index 0ec9fd17b7..f67b0f39be 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -63,6 +63,8 @@ typedef qemuBlockJobData *qemuBlockJobDataPtr;
 struct _qemuBlockJobData {
     virObject parent;

+    char *name;
+
     virDomainDiskDefPtr disk; /* may be NULL, if blockjob does not corrspond to any disk */

     int type; /* qemuBlockjobType */
@@ -76,8 +78,9 @@ struct _qemuBlockJobData {

 qemuBlockJobDataPtr
 qemuBlockJobDiskNew(virDomainDiskDefPtr disk,
-                    qemuBlockjobType type)
-    ATTRIBUTE_NONNULL(1);
+                    qemuBlockjobType type,
+                    const char *jobname)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);

 qemuBlockJobDataPtr
 qemuBlockJobDiskGetJob(virDomainDiskDefPtr disk)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ff113ae57b..5675d2dc87 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4732,7 +4732,7 @@ processBlockJobEvent(virQEMUDriverPtr driver,
     }

     if (!(job = qemuBlockJobDiskGetJob(disk))) {
-        if (!(job = qemuBlockJobDiskNew(disk, type)))
+        if (!(job = qemuBlockJobDiskNew(disk, type, diskAlias)))
             goto endjob;
         qemuBlockJobStarted(job);
     }
@@ -17268,7 +17268,7 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver,
         speed <<= 20;
     }

-    if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_PULL)))
+    if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_PULL, device)))
         goto endjob;

     qemuDomainObjEnterMonitor(driver, vm);
@@ -17803,7 +17803,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
         goto endjob;
     }

-    if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY)))
+    if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY, device)))
         goto endjob;

     /* Actually start the mirroring */
@@ -18217,7 +18217,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
         jobtype = QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT;
     }

-    if (!(job = qemuBlockJobDiskNew(disk, jobtype)))
+    if (!(job = qemuBlockJobDiskNew(disk, jobtype, device)))
         goto endjob;

     qemuDomainObjEnterMonitor(driver, vm);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 4a6f631689..4ce3141465 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -914,7 +914,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driver,
     if (!(diskAlias = qemuAliasDiskDriveFromDisk(disk)))
         goto cleanup;

-    if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY)))
+    if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY, diskAlias)))
         goto cleanup;

     qemuBlockJobSyncBegin(job);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1171da62a8..3f1dd662e9 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7776,7 +7776,7 @@ qemuProcessRefreshLegacyBlockjob(void *payload,
         disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
         jobtype = disk->mirrorJob;

-    if (!(job = qemuBlockJobDiskNew(disk, jobtype)))
+    if (!(job = qemuBlockJobDiskNew(disk, jobtype, jobname)))
         return -1;

     qemuBlockJobStarted(job);
-- 
2.19.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux