[libvirt] [PATCH] qemu: use default machine type if missing it in qemu command line
Eric Blake
eblake at redhat.com
Thu Nov 1 14:59:48 UTC 2012
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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121101/9468a74d/attachment-0001.sig>
More information about the libvir-list
mailing list