On Mon, Jan 07, 2019 at 14:35:08 +0100, Ján Tomko wrote:
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(a)redhat.com>
> ---
> 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?
Not at this point in the series. In patch 29 though the block job data
struct is allocated only when there's a job.
I don't remember whether this originates from the forethought that such
a change will happen or I've reorganized it, but I'd prefer to keep the
checks here.