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

Re: [libvirt] [PATCH] qemu: use default machine type if missing it in qemu command line



On 11/01/2012 04:36 AM, Guannan Ren wrote:
> BZ:https://bugzilla.redhat.com/show_bug.cgi?id=871273
> when using virsh qemu-attach to attach an existing qemu process,
> if it misses the -M option in qemu command line, libvirtd crashed
> because the NULL value of def->os.machine in later use.
> 
> Example:
> /usr/libexec/qemu-kvm -name foo \
>                       -cdrom /var/lib/libvirt/images/boot.img \
>                       -monitor unix:/tmp/demo,server,nowait \
> 
> error: End of file while reading data: Input/output error
> error: Failed to reconnect to the hypervisor
> 
> This patch tries to set default machine type if the value of
> def->os.machine is still NULL after qemu command line parsing.
> ---
>  src/qemu/qemu_command.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index fe99f5d..0b6d2f8 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -8768,6 +8768,17 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
>          }
>      }
>  
> +    if (!def->os.machine) {
> +        const char *defaultMachine =
> +                        virCapabilitiesDefaultGuestMachine(caps,
> +                                                           def->os.type,
> +                                                           def->os.arch,
> +                                                           virDomainVirtTypeToString(def->virtType));
> +        if (defaultMachine != NULL)
> +            if (!(def->os.machine = strdup(defaultMachine)))
> +                goto no_memory;

This code still leaves the possibility of def->os.machine being NULL
(such as if defaultMachine is NULL).  Shouldn't you error out in that case?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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