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

Re: [libvirt] [PATCH 4/4] Autostart domains using virDomainObjStart



On 05/20/2010 08:54 AM, Jiri Denemark wrote:
> ---
>  src/qemu/qemu_driver.c |   34 ++++++++++++++++++----------------
>  1 files changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 8f5cae1..d40e29a 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -626,29 +626,31 @@ qemuAutostartDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq
>  {
>      virDomainObjPtr vm = payload;
>      struct qemuAutostartData *data = opaque;
> +    virErrorPtr err;
>  
>      virDomainObjLock(vm);
> -    if (vm->autostart &&
> -        !virDomainObjIsActive(vm)) {
> -        int ret;
> -
> -        virResetLastError();
> -        ret = qemudStartVMDaemon(data->conn, data->driver, vm, NULL, -1);
> -        if (ret < 0) {
> -            virErrorPtr err = virGetLastError();
> +    virResetLastError();
> +    if (qemuDomainObjBeginJobWithDriver(data->driver, vm) < 0) {
> +        err = virGetLastError();
> +        VIR_ERROR(_("Failed to start job on VM '%s': %s"),
> +                  vm->def->name,
> +                  err ? err->message : "");
> +    } else {
> +        if (vm->autostart &&
> +            !virDomainObjIsActive(vm) &&
> +            qemudDomainObjStart(data->conn, data->driver, vm) < 0) {
> +            err = virGetLastError();
>              VIR_ERROR(_("Failed to autostart VM '%s': %s"),
>                        vm->def->name,
>                        err ? err->message : "");
> -        } else {
> -            virDomainEventPtr event =
> -                virDomainEventNewFromObj(vm,
> -                                         VIR_DOMAIN_EVENT_STARTED,
> -                                         VIR_DOMAIN_EVENT_STARTED_BOOTED);
> -            if (event)
> -                qemuDomainEventQueue(data->driver, event);
>          }
> +
> +        if (qemuDomainObjEndJob(vm) == 0)
> +            vm = NULL;
>      }
> -    virDomainObjUnlock(vm);
> +
> +    if (vm)
> +        virDomainObjUnlock(vm);
>  }
>  
>  static void

ACK

- Cole


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