From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paul Brook <paul@codesourcery.com>, Avi Kivity <avi@redhat.com>,
qemu-devel@nongnu.org, Carsten Otte <cotte@de.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
kraxel@redhat.com, markmc@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] qemu/virtio: fix reset with device removal
Date: Tue, 15 Sep 2009 17:33:52 +0300 [thread overview]
Message-ID: <20090915143352.GC24708@redhat.com> (raw)
In-Reply-To: <cover.1253025151.git.mst@redhat.com>
virtio pci registers its own reset handler, but fails to unregister it,
which will lead to crashes after device removal. Solve this problem by
switching to qdev reset handler, which is automatically unregistered.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio-pci.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f7a51ff..951d1dc 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -155,9 +155,8 @@ static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
return 0;
}
-static void virtio_pci_reset(void *opaque)
+static void virtio_pci_reset(VirtIOPCIProxy *proxy)
{
- VirtIOPCIProxy *proxy = opaque;
virtio_reset(proxy->vdev);
msix_reset(&proxy->pci_dev);
}
@@ -429,8 +428,6 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
pci_register_bar(&proxy->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,
virtio_map);
- qemu_register_reset(virtio_pci_reset, proxy);
-
virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
}
@@ -514,6 +511,11 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev)
return 0;
}
+static void virtio_reset_pci(DeviceState *d)
+{
+ virtio_pci_reset(container_of(d, VirtIOPCIProxy, pci_dev.qdev));
+}
+
static PCIDeviceInfo virtio_info[] = {
{
.qdev.name = "virtio-blk-pci",
@@ -525,6 +527,7 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
DEFINE_PROP_END_OF_LIST(),
},
+ .qdev.reset = virtio_reset_pci,
},{
.qdev.name = "virtio-net-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
@@ -534,6 +537,7 @@ static PCIDeviceInfo virtio_info[] = {
NIC_NVECTORS_UNSPECIFIED),
DEFINE_PROP_END_OF_LIST(),
},
+ .qdev.reset = virtio_reset_pci,
},{
.qdev.name = "virtio-console-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
@@ -542,10 +546,12 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
DEFINE_PROP_END_OF_LIST(),
},
+ .qdev.reset = virtio_reset_pci,
},{
.qdev.name = "virtio-balloon-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_balloon_init_pci,
+ .qdev.reset = virtio_reset_pci,
},{
/* end of list */
}
--
1.6.2.5
next prev parent reply other threads:[~2009-09-15 14:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1253025151.git.mst@redhat.com>
2009-09-15 14:33 ` [Qemu-devel] [PATCH 1/2] qemu/qdev: type safety in reset handler Michael S. Tsirkin
2009-09-15 14:55 ` [Qemu-devel] " Gerd Hoffmann
2009-09-15 20:20 ` [Qemu-devel] " Blue Swirl
2009-09-15 20:42 ` Michael S. Tsirkin
2009-09-15 21:16 ` [Qemu-devel] " Paolo Bonzini
2009-09-15 21:37 ` Michael S. Tsirkin
2009-09-16 10:13 ` Gerd Hoffmann
2009-09-16 10:14 ` Michael S. Tsirkin
[not found] ` <m3vdjjutwa.fsf@neno.mitica>
2009-09-16 9:34 ` Michael S. Tsirkin
2009-09-16 10:05 ` Gerd Hoffmann
2009-09-16 10:06 ` Michael S. Tsirkin
2009-09-16 10:22 ` Gerd Hoffmann
2009-09-16 10:30 ` Michael S. Tsirkin
2009-09-16 10:47 ` Michael S. Tsirkin
2009-09-16 12:08 ` Michael S. Tsirkin
2009-09-15 14:33 ` Michael S. Tsirkin [this message]
2009-09-15 15:30 ` [Qemu-devel] Re: [PATCH 2/2] qemu/virtio: fix reset with device removal Gerd Hoffmann
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=20090915143352.GC24708@redhat.com \
--to=mst@redhat.com \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=kraxel@redhat.com \
--cc=markmc@redhat.com \
--cc=paul@codesourcery.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).