mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-30 16:35:24 +00:00
qemu: add support for -device pvpanic
Map the new <panic> device in XML to the '-device pvpanic' command line of qemu. Clients can then couple the <panic> device and the <on_crash> directive to control behavior when the guest reports a panic to qemu. Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
4313feade4
commit
4d18758df8
@ -245,6 +245,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
||||
"kvm-pit-lost-tick-policy",
|
||||
|
||||
"boot-strict", /* 160 */
|
||||
"pvpanic", /* 161 */
|
||||
);
|
||||
|
||||
struct _virQEMUCaps {
|
||||
@ -1396,6 +1397,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
|
||||
{ "usb-storage", QEMU_CAPS_DEVICE_USB_STORAGE },
|
||||
{ "virtio-mmio", QEMU_CAPS_DEVICE_VIRTIO_MMIO },
|
||||
{ "ich9-intel-hda", QEMU_CAPS_DEVICE_ICH9_INTEL_HDA },
|
||||
{ "pvpanic", QEMU_CAPS_DEVICE_PANIC },
|
||||
};
|
||||
|
||||
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
|
||||
|
@ -199,6 +199,7 @@ enum virQEMUCapsFlags {
|
||||
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
|
||||
QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */
|
||||
QEMU_CAPS_BOOT_STRICT = 160, /* -boot strict */
|
||||
QEMU_CAPS_DEVICE_PANIC = 161, /* -device pvpanic */
|
||||
|
||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||
};
|
||||
|
@ -9621,6 +9621,22 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (def->panic) {
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) {
|
||||
if (def->panic->info.addr.isa.iobase > 0) {
|
||||
virCommandAddArg(cmd, "-device");
|
||||
virCommandAddArgFormat(cmd, "pvpanic,ioport=%d",
|
||||
def->panic->info.addr.isa.iobase);
|
||||
} else {
|
||||
virCommandAddArgList(cmd, "-device", "pvpanic", NULL);
|
||||
}
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("your QEMU is too old to support pvpanic"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (mlock) {
|
||||
unsigned long long memKB;
|
||||
|
||||
|
@ -132,4 +132,5 @@
|
||||
<flag name='ich9-intel-hda'/>
|
||||
<flag name='kvm-pit-lost-tick-policy'/>
|
||||
<flag name='boot-strict'/>
|
||||
<flag name='pvpanic'/>
|
||||
</qemuCaps>
|
||||
|
@ -136,4 +136,5 @@
|
||||
<flag name='ich9-intel-hda'/>
|
||||
<flag name='kvm-pit-lost-tick-policy'/>
|
||||
<flag name='boot-strict'/>
|
||||
<flag name='pvpanic'/>
|
||||
</qemuCaps>
|
||||
|
@ -135,4 +135,5 @@
|
||||
<flag name='ich9-intel-hda'/>
|
||||
<flag name='kvm-pit-lost-tick-policy'/>
|
||||
<flag name='boot-strict'/>
|
||||
<flag name='pvpanic'/>
|
||||
</qemuCaps>
|
||||
|
6
tests/qemuxml2argvdata/qemuxml2argv-panic.args
Normal file
6
tests/qemuxml2argvdata/qemuxml2argv-panic.args
Normal file
@ -0,0 +1,6 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
|
||||
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
|
||||
-hda /dev/HostVG/QEMUGuest1 \
|
||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
|
||||
-device pvpanic,ioport=1285
|
31
tests/qemuxml2argvdata/qemuxml2argv-panic.xml
Normal file
31
tests/qemuxml2argvdata/qemuxml2argv-panic.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219136</memory>
|
||||
<currentMemory unit='KiB'>219136</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='fdc' index='0'/>
|
||||
<controller type='ide' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<memballoon model='virtio'/>
|
||||
<panic>
|
||||
<address type='isa' iobase='0x505'/>
|
||||
</panic>
|
||||
</devices>
|
||||
</domain>
|
@ -1306,6 +1306,9 @@ mymain(void)
|
||||
DO_TEST("kvm-pit-device", QEMU_CAPS_NO_KVM_PIT,
|
||||
QEMU_CAPS_KVM_PIT_TICK_POLICY);
|
||||
|
||||
DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
|
||||
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
|
||||
virObjectUnref(driver.config);
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlopt);
|
||||
|
@ -323,6 +323,8 @@ mymain(void)
|
||||
DO_TEST("pcihole64-none");
|
||||
DO_TEST("pcihole64-q35");
|
||||
|
||||
DO_TEST("panic");
|
||||
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlopt);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user