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

[libvirt] [PATCH RFC 23/51] qemu: blockjob: Convert qemuBlockJobSyncBeginDisk to work with the job



Modify qemuBlockJobSyncBeginDisk to operate on qemuBlockt sJobDataPtr and
rename it accordingly.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_blockjob.c  | 11 +++++++----
 src/qemu/qemu_blockjob.h  |  2 +-
 src/qemu/qemu_driver.c    | 10 +++++++++-
 src/qemu/qemu_migration.c | 11 +++++++----
 4 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index c6b70c5388..0b2c667dae 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -359,7 +359,7 @@ qemuBlockJobUpdateDisk(virDomainObjPtr vm,


 /**
- * qemuBlockJobSyncBeginDisk:
+ * qemuBlockJobSyncBegin:
  * @disk: domain disk
  *
  * Begin a new synchronous block job for @disk. The synchronous
@@ -372,11 +372,14 @@ qemuBlockJobUpdateDisk(virDomainObjPtr vm,
  * is called.
  */
 void
-qemuBlockJobSyncBeginDisk(virDomainDiskDefPtr disk)
+qemuBlockJobSyncBegin(qemuBlockJobDataPtr job)
 {
-    qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
+    const char *diskdst = NULL;

-    VIR_DEBUG("disk=%s", disk->dst);
+    if (job->disk)
+        diskdst = job->disk->dst;
+
+    VIR_DEBUG("disk=%s", NULLSTR(diskdst));
     job->synchronous = true;
     job->newstate = -1;
 }
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index 6f6d0aa691..0c2ce46986 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -80,7 +80,7 @@ int qemuBlockJobUpdateDisk(virDomainObjPtr vm,
                            virDomainDiskDefPtr disk,
                            char **error);

-void qemuBlockJobSyncBeginDisk(virDomainDiskDefPtr disk);
+void qemuBlockJobSyncBegin(qemuBlockJobDataPtr job);
 void qemuBlockJobSyncEndDisk(virDomainObjPtr vm,
                              int asyncJob,
                              virDomainDiskDefPtr disk);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5eace06099..5fd92ca0c1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17316,6 +17316,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
     bool save = false;
     bool pivot = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT);
     bool async = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC);
+    qemuBlockJobDataPtr job = NULL;
     virDomainObjPtr vm;
     int ret = -1;

@@ -17343,6 +17344,12 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
     if (!(device = qemuAliasDiskDriveFromDisk(disk)))
         goto endjob;

+    if (!(job = qemuBlockJobDiskGetJob(disk))) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("disk %s does not have an active block job"), disk->dst);
+        goto endjob;
+    }
+
     if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_NONE &&
         disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) {
         virReportError(VIR_ERR_OPERATION_INVALID,
@@ -17352,7 +17359,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
     }

     if (!async)
-        qemuBlockJobSyncBeginDisk(disk);
+        qemuBlockJobSyncBegin(job);

     if (pivot) {
         if ((ret = qemuDomainBlockPivot(driver, vm, device, disk)) < 0)
@@ -17407,6 +17414,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
     qemuDomainObjEndJob(driver, vm);

  cleanup:
+    virObjectUnref(job);
     virObjectUnref(cfg);
     VIR_FREE(device);
     virDomainObjEndAPI(&vm);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 837ed39efe..b9119c5b89 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -911,7 +911,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driver,
     if (!(job = qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY)))
         goto cleanup;

-    qemuBlockJobSyncBeginDisk(disk);
+    qemuBlockJobSyncBegin(job);

     if (flags & VIR_MIGRATE_TLS) {
         rc = qemuMigrationSrcNBDStorageCopyBlockdev(driver, vm,
@@ -5393,16 +5393,19 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
     for (i = 0; i < vm->def->ndisks; i++) {
         virDomainDiskDefPtr disk = vm->def->disks[i];
         qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+        qemuBlockJobDataPtr job;

-        if (!diskPriv->blockjob->started)
+        if (!(job = qemuBlockJobDiskGetJob(disk)) ||
+            !job->started)
             diskPriv->migrating = false;

         if (diskPriv->migrating) {
-            qemuBlockJobSyncBeginDisk(disk);
+            qemuBlockJobSyncBegin(job);
             storage = true;
         }
-    }

+        virObjectUnref(job);
+    }

     if (storage &&
         qemuMigrationSrcNBDCopyCancel(driver, vm, false,
-- 
2.19.2


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