From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 2/9] virtio-blk: fix unplug + virsh reboot
Date: Mon, 4 Mar 2013 10:15:24 +0100 [thread overview]
Message-ID: <1362388531-32305-3-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1362388531-32305-1-git-send-email-stefanha@redhat.com>
From: Christian Borntraeger <borntraeger@de.ibm.com>
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>
---
hw/virtio-blk.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
--
1.8.1.4
next prev parent reply other threads:[~2013-03-04 9:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 9:15 [Qemu-devel] [PULL 0/9] Block patches Stefan Hajnoczi
2013-03-04 9:15 ` [Qemu-devel] [PATCH 1/9] ide/macio: Fix macio DMA initialisation Stefan Hajnoczi
2013-03-04 9:15 ` Stefan Hajnoczi [this message]
2013-03-04 9:15 ` [Qemu-devel] [PATCH 3/9] dataplane: remove EventPoll in favor of AioContext Stefan Hajnoczi
2013-03-08 8:37 ` Christian Borntraeger
2013-03-08 9:22 ` Paolo Bonzini
2013-03-08 12:44 ` Cornelia Huck
2013-03-08 13:51 ` Paolo Bonzini
2013-03-04 9:15 ` [Qemu-devel] [PATCH 4/9] slirp/tcp_subr.c: fix coding style in tcp_connect Stefan Hajnoczi
2013-03-04 9:15 ` [Qemu-devel] [PATCH 5/9] move socket_set_nodelay to osdep.c Stefan Hajnoczi
2013-03-04 9:15 ` [Qemu-devel] [PATCH 6/9] sheepdog: accept URIs Stefan Hajnoczi
2013-03-04 9:15 ` [Qemu-devel] [PATCH 7/9] sheepdog: use inet_connect to simplify connect code Stefan Hajnoczi
2013-03-04 9:15 ` [Qemu-devel] [PATCH 8/9] sheepdog: add support for connecting to unix domain socket Stefan Hajnoczi
2013-03-04 9:15 ` [Qemu-devel] [PATCH 9/9] block: for HMP commit() operations on 'all', skip non-COW drives Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1362388531-32305-3-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).