libvirt/src/qemu
Alex Jia 96518d4316 qemu: Prevent crash of libvirtd without guest agent configuration
If users haven't configured guest agent then qemuAgentCommand() will
dereference a NULL 'mon' pointer, which causes crash of libvirtd when
using agent based cpu (un)plug.

With the patch, when the qemu-ga service isn't running in the guest,
a expected error "error: Guest agent is not responding: Guest agent
not available for now" will be raised, and the error "error: argument
unsupported: QEMU guest agent is not configured" is raised when the
guest hasn't configured guest agent.

GDB backtrace:

 (gdb) bt
 #0  virNetServerFatalSignal (sig=11, siginfo=<value optimized out>, context=<value optimized out>) at rpc/virnetserver.c:326
 #1  <signal handler called>
 #2  qemuAgentCommand (mon=0x0, cmd=0x7f39300017b0, reply=0x7f394b090910, seconds=-2) at qemu/qemu_agent.c:975
 #3  0x00007f39429507f6 in qemuAgentGetVCPUs (mon=0x0, info=0x7f394b0909b8) at qemu/qemu_agent.c:1475
 #4  0x00007f39429d9857 in qemuDomainGetVcpusFlags (dom=<value optimized out>, flags=9) at qemu/qemu_driver.c:4849
 #5  0x00007f3957dffd8d in virDomainGetVcpusFlags (domain=0x7f39300009c0, flags=8) at libvirt.c:9843

How to reproduce?

 # To start a guest without guest agent configuration
 # then run the following cmdline

 # virsh vcpucount foobar --guest
 error: End of file while reading data: Input/output error
 error: One or more references were leaked after disconnect from the hypervisor
 error: Failed to reconnect to the hypervisor

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=984821

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2013-07-16 14:14:07 +02:00
..
libvirtd_qemu.aug qemu: Add VNC WebSocket support 2013-05-15 09:48:05 +02:00
MIGRATION.txt qemu: Implement migration job phases 2011-07-27 08:45:09 -06:00
qemu_agent.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_agent.h qemu_agent: Introduce helpers for agent based CPU hot(un)plug 2013-06-07 15:58:24 +02:00
qemu_bridge_filter.c virutil: Move string related functions to virstring.c 2013-05-02 16:56:55 +02:00
qemu_bridge_filter.h Replace 'struct qemud_driver *' with virQEMUDriverPtr 2012-11-28 18:17:25 +00:00
qemu_capabilities.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_capabilities.h qemu: Implement CPUs check against machine type's cpu-max 2013-07-01 14:30:42 +02:00
qemu_cgroup.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_cgroup.h qemu: put usb cgroup setup in common function 2013-04-29 21:52:28 -04:00
qemu_command.c qemu: Implement chardev hotplug on live level 2013-07-16 11:47:39 +02:00
qemu_command.h qemu: Introduce qemuBuildChrDeviceStr 2013-07-12 11:00:28 +02:00
qemu_conf.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_conf.h maint: don't use config.h in .h files 2013-06-05 05:53:25 -06:00
qemu_domain.c qemu: Slightly increase memory limit 2013-07-11 11:17:47 +02:00
qemu_domain.h qemu: Move memory limit computation to a reusable function 2013-07-08 12:35:27 +02:00
qemu_driver.c qemu: Prevent crash of libvirtd without guest agent configuration 2013-07-16 14:14:07 +02:00
qemu_driver.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
qemu_hostdev.c pci: make virPCIDeviceReset more autonomous 2013-07-15 10:43:03 -04:00
qemu_hostdev.h qemu: Introduce activeScsiHostdevs list for scsi host devices 2013-05-13 21:26:06 +08:00
qemu_hotplug.c qemu: Implement chardev hotplug on live level 2013-07-16 11:47:39 +02:00
qemu_hotplug.h qemu: Implement chardev hotplug on live level 2013-07-16 11:47:39 +02:00
qemu_migration.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_migration.h qemu: Implement support for VIR_MIGRATE_PARAM_GRAPHICS_URI 2013-06-25 16:41:58 +02:00
qemu_monitor_json.c Add qemuMonitorJSONSetObjectProperty() method for QMP qom-set command 2013-07-15 12:26:16 -04:00
qemu_monitor_json.h Add qemuMonitorJSONSetObjectProperty() method for QMP qom-set command 2013-07-15 12:26:16 -04:00
qemu_monitor_text.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_monitor_text.h qemu: Use bool instead of int in qemuMonitorSetCPU APIs 2013-06-07 15:57:03 +02:00
qemu_monitor.c qemu_monitor: Introduce qemuMonitorDetachCharDev 2013-07-12 11:00:04 +02:00
qemu_monitor.h qemu_monitor: Introduce qemuMonitorDetachCharDev 2013-07-12 11:00:04 +02:00
qemu_process.c Convert 'int i' to 'size_t i' in src/qemu files 2013-07-10 17:55:15 +01:00
qemu_process.h qemu: expose qemuProcessShutdownOrReboot() 2013-07-02 12:02:27 -06:00
qemu.conf qemu: Add VNC WebSocket support 2013-05-15 09:48:05 +02:00
test_libvirtd_qemu.aug.in qemu: Add VNC WebSocket support 2013-05-15 09:48:05 +02:00
THREADS.txt Remove qemuDriverLock from almost everywhere 2013-02-13 11:10:30 +00:00