[libvirt] [PATCH 3/3] qemu: Deal with stucked qemu on daemon startup

Jiri Denemark jdenemar at redhat.com
Tue Aug 16 21:07:30 UTC 2011


On Tue, Aug 16, 2011 at 18:39:12 +0200, Michal Privoznik wrote:
> If libvirt daemon gets restarted and there is (at least) one
> unresponsive qemu, the startup procedure hangs up. This patch creates
> one thread per vm in which we try to reconnect to monitor. Therefore,
> blocking in one thread will not affect other APIs.
> ---
>  src/qemu/qemu_driver.c  |   23 +++---------
>  src/qemu/qemu_process.c |   87 ++++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 85 insertions(+), 25 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 421a98e..4574b6c 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -143,26 +143,15 @@ qemuAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaq
>  
>      virDomainObjLock(vm);
>      virResetLastError();
> -    if (qemuDomainObjBeginJobWithDriver(data->driver, vm,
> -                                        QEMU_JOB_MODIFY) < 0) {
> +    if (vm->autostart &&
> +        !virDomainObjIsActive(vm) &&
> +        qemuDomainObjStart(data->conn, data->driver, vm,
> +                           false, false,
> +                           data->driver->autoStartBypassCache) < 0) {
>          err = virGetLastError();
> -        VIR_ERROR(_("Failed to start job on VM '%s': %s"),
> +        VIR_ERROR(_("Failed to autostart VM '%s': %s"),
>                    vm->def->name,
>                    err ? err->message : _("unknown error"));
> -    } else {
> -        if (vm->autostart &&
> -            !virDomainObjIsActive(vm) &&
> -            qemuDomainObjStart(data->conn, data->driver, vm,
> -                               false, false,
> -                               data->driver->autoStartBypassCache) < 0) {
> -            err = virGetLastError();
> -            VIR_ERROR(_("Failed to autostart VM '%s': %s"),
> -                      vm->def->name,
> -                      err ? err->message : _("unknown error"));
> -        }
> -
> -        if (qemuDomainObjEndJob(data->driver, vm) == 0)
> -            vm = NULL;
>      }

I think this is wrong. qemuDomainObjStart expect the job to be set so that it
can enter qemu monitor. The patch should just move the
if (vm->autostrt && !virDomainObjIsActive(vm)) check before BeginJob so that a
job is started only if we're going to do something with the domain.

Jirka




More information about the libvir-list mailing list