[libvirt] [PATCH 05/11] libxl: use job functions in libxlDomainDestroyFlags

Michal Privoznik mprivozn at redhat.com
Tue Feb 11 14:36:43 UTC 2014


On 07.02.2014 04:53, Jim Fehlig wrote:
> Modify operation that needs to wait in the queue of modify jobs.
>
> Signed-off-by: Jim Fehlig <jfehlig at suse.com>
> ---
>   src/libxl/libxl_driver.c | 21 +++++++++++++++------
>   1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
> index caabb44..bb574bc 100644
> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
> @@ -1549,6 +1549,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
>       libxlDriverPrivatePtr driver = dom->conn->privateData;
>       virDomainObjPtr vm;
>       int ret = -1;
> +    bool remove_dom = false;
>       virObjectEventPtr event = NULL;
>
>       virCheckFlags(0, -1);
> @@ -1559,10 +1560,13 @@ libxlDomainDestroyFlags(virDomainPtr dom,
>       if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
>           goto cleanup;
>
> +    if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_DESTROY) < 0)
> +        goto cleanup;
> +
>       if (!virDomainObjIsActive(vm)) {
>           virReportError(VIR_ERR_OPERATION_INVALID,
>                          "%s", _("Domain is not running"));
> -        goto cleanup;
> +        goto endjob;
>       }
>
>       event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
> @@ -1571,17 +1575,22 @@ libxlDomainDestroyFlags(virDomainPtr dom,
>       if (libxlVmReap(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED) != 0) {
>           virReportError(VIR_ERR_INTERNAL_ERROR,
>                          _("Failed to destroy domain '%d'"), dom->id);
> -        goto cleanup;
> +        goto endjob;
>       }
>
> -    if (!vm->persistent) {
> -        virDomainObjListRemove(driver->domains, vm);
> -        vm = NULL;
> -    }
> +    if (!vm->persistent)
> +        remove_dom = true;
>
>       ret = 0;
>
> +endjob:
> +    libxlDomainObjEndJob(driver, vm);
> +
>   cleanup:
> +    if (remove_dom) {
> +        virDomainObjListRemove(driver->domains, vm);
> +        vm = NULL;
> +    }
>       if (vm)
>           virObjectUnlock(vm);
>       if (event)
>

Okay, this helps a bit. Since currently you are not allowing any async 
jobs, the destroy API can't jump in the middle of other job-full APIs. 
But it still can jump into the job-less APIs (*) that unlocks VM 
somewhere in the middle.

Again, conditional ACK.

Michal

a job-full API = API using BeginJob + EndJob()
a job-less API = API using bare virObjectLock(vm)




More information about the libvir-list mailing list