summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Borntraeger <borntraeger@de.ibm.com>2013-02-22 14:37:10 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2013-03-04 09:54:16 +0100
commit69b302b2044a9a0f6d157d25b39a91ff7124c61f (patch)
treebe66ecfb923c2641b4b2819d0cc881da56d490b0
parent02d583c7232d65920634f7553700eb348f84e472 (diff)
downloadhqemu-69b302b2044a9a0f6d157d25b39a91ff7124c61f.zip
hqemu-69b302b2044a9a0f6d157d25b39a91ff7124c61f.tar.gz
virtio-blk: fix unplug + virsh reboot
virtio-blk registers a vmstate change handler. Unfortunately this handler is not unregistered on unplug, leading to some random crashes if the system is restarted, e.g. via virsh reboot. Lets unregister the vmstate change handler if the device is removed. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--hw/virtio-blk.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 34913ee..f5e6ee9 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -36,6 +36,7 @@ typedef struct VirtIOBlock
VirtIOBlkConf *blk;
unsigned short sector_mask;
DeviceState *qdev;
+ VMChangeStateEntry *change;
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
VirtIOBlockDataPlane *dataplane;
#endif
@@ -681,7 +682,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk)
}
#endif
- qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
+ s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
s->qdev = dev;
register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
virtio_blk_save, virtio_blk_load, s);
@@ -702,6 +703,7 @@ void virtio_blk_exit(VirtIODevice *vdev)
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
#endif
+ qemu_del_vm_change_state_handler(s->change);
unregister_savevm(s->qdev, "virtio-blk", s);
blockdev_mark_auto_del(s->bs);
virtio_cleanup(vdev);
OpenPOWER on IntegriCloud