[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/10] fix: unrealize virtio device if we fail to hot
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 01/10] fix: unrealize virtio device if we fail to hotplug it |
Date: |
Wed, 15 Nov 2017 20:17:47 +0200 |
From: linzhecheng <address@hidden>
If we fail to hotplug virtio-blk device and then suspend
or shutdown VM, qemu is likely to crash.
Re-production steps:
1. Run VM named vm001
2. Create a virtio-blk.xml which contains wrong configurations:
<disk device="lun" rawio="yes" type="block">
<driver cache="none" io="native" name="qemu" type="raw" />
<source dev="/dev/mapper/11-dm" />
<target bus="virtio" dev="vdx" />
</disk>
3. Run command : virsh attach-device vm001 virtio-blk.xml
error: Failed to attach device from blk-scsi.xml
error: internal error: unable to execute QEMU command 'device_add': Please set
scsi=off for virtio-blk devices in order to use virtio 1.0
it means hotplug virtio-blk device failed.
4. Suspend or shutdown VM will leads to qemu crash
Problem happens in virtio_vmstate_change which is called by
vm_state_notify:
vdev’s parent_bus is NULL, so qdev_get_parent_bus(DEVICE(vdev)) will crash.
virtio_vmstate_change is added to the list vm_change_state_head at
virtio_blk_device_realize(virtio_init),
but after hotplug virtio-blk failed, virtio_vmstate_change will not be removed
from vm_change_state_head.
Adding unrealize function of virtio-blk device can solve this problem.
Signed-off-by: linzhecheng <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5884ce3..ea532dc 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2491,6 +2491,7 @@ static void virtio_device_realize(DeviceState *dev, Error
**errp)
virtio_bus_device_plugged(vdev, &err);
if (err != NULL) {
error_propagate(errp, err);
+ vdc->unrealize(dev, NULL);
return;
}
--
MST
- [Qemu-devel] [PULL 00/10] pc, pci, virtio: fixes for rc1, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 01/10] fix: unrealize virtio device if we fail to hotplug it,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 02/10] pci: Initialize pci_dev->name before use, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 03/10] tests: report errors when iasl exits with non-zero status, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 04/10] test: fix detection of errors from iasl, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 05/10] hw/pci-host: Fix x86 Host Bridges 64bit PCI hole, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 06/10] hw/pcie-pci-bridge: restrict to X86 and ARM, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 07/10] tests/acpi-test-data: update _CRS in DSDT, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 08/10] NUMA: Enable adding NUMA node implicitly, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 09/10] vmcoreinfo: put it in the 'misc' device category, Michael S. Tsirkin, 2017/11/15
- [Qemu-devel] [PULL 10/10] build-sys: restrict vmcoreinfo to fw_cfg+dma capable targets, Michael S. Tsirkin, 2017/11/15