Re: [PATCH RFC 18/51] qemu: blockjob: Add functions for block job state control

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

 



On Wed, Dec 12, 2018 at 06:08:34PM +0100, Peter Krempa wrote:
Rather than direclty modifying fields in the qemuBlockJobDataPtr

directly

structure add a bunch of fields which allow to do the transitions.

This will help later when adding more complexity to the job handing.

handling


APIs introduced in this patch are:

qemuBlockJobDiskNew - prepare for starting a new blockjob on a disk
qemuBlockJobDiskGetJob - get the block job data structure for a disk

For individual job state manipulation the following APIs are added:
qemuBlockJobStarted - Sets the job as started with qemu. Until that
                     the job can be cancelled without asking qemu.

qemuBlockJobStartupFinalize - finalize job startup. If the job was
                             started in qemu already, just releases
                             reference to the job object. Otherwise
                             clears everything as if the job was never
                             started.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
src/qemu/qemu_blockjob.c  | 81 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_blockjob.h  | 19 +++++++++
src/qemu/qemu_driver.c    | 31 ++++++++++++---
src/qemu/qemu_migration.c |  7 +++-
src/qemu/qemu_process.c   | 17 ++++----
5 files changed, 141 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 637307806b..9e5171744e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4716,7 +4716,7 @@ processBlockJobEvent(virQEMUDriverPtr driver,
                     int status)
{
    virDomainDiskDefPtr disk;
-    qemuBlockJobDataPtr job;
+    qemuBlockJobDataPtr job = NULL;

    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
        return;
@@ -4731,7 +4731,11 @@ processBlockJobEvent(virQEMUDriverPtr driver,
        goto endjob;
    }

-    job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
+    if (!(job = qemuBlockJobDiskGetJob(disk))) {

Can qemuBlockJobDiskGetJob really return NULL here?

+        if (!(job = qemuBlockJobDiskNew(disk)))
+            goto endjob;
+        qemuBlockJobStarted(job);
+    }

    job->type = type;
    job->newstate = status;
@@ -937,9 +937,9 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
    if (!(disk = qemuProcessFindDomainDiskByAliasOrQOM(vm, diskAlias, NULL)))
        goto cleanup;

-    job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
+    job = qemuBlockJobDiskGetJob(disk);

-    if (job->synchronous) {
+    if (job && job->synchronous) {

Same question

        /* We have a SYNC API waiting for this event, dispatch it back */
        job->type = type;
        job->newstate = status;

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

--
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