* [Qemu-devel] [PATCH] virtio-serial: Cleanup on device hot-unplug
@ 2010-08-19 1:21 Amit Shah
2010-08-20 12:00 ` Amit Shah
2010-08-22 21:30 ` Anthony Liguori
0 siblings, 2 replies; 3+ messages in thread
From: Amit Shah @ 2010-08-19 1:21 UTC (permalink / raw)
To: qemu list; +Cc: Amit Shah, Juan Quintela
Free malloc'ed memory, unregister from savevm and clean up virtio-common
bits on device hot-unplug.
This was found performing a migration after device hot-unplug.
Reported-by: <lihuang@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
hw/virtio-pci.c | 10 +++++++++-
hw/virtio-serial-bus.c | 17 +++++++++++++++++
hw/virtio.h | 1 +
3 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 17c3d15..82a6d78 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -599,6 +599,14 @@ static int virtio_serial_init_pci(PCIDevice *pci_dev)
return 0;
}
+static int virtio_serial_exit_pci(PCIDevice *pci_dev)
+{
+ VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+
+ virtio_serial_exit(proxy->vdev);
+ return virtio_exit_pci(pci_dev);
+}
+
static int virtio_net_init_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
@@ -689,7 +697,7 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.alias = "virtio-serial",
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_serial_init_pci,
- .exit = virtio_exit_pci,
+ .exit = virtio_serial_exit_pci,
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
DEV_NVECTORS_UNSPECIFIED),
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 0586b89..74ba5ec 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -41,6 +41,8 @@ struct VirtIOSerial {
VirtIOSerialBus *bus;
+ DeviceState *qdev;
+
QTAILQ_HEAD(, VirtIOSerialPort) ports;
/* bitmap for identifying active ports */
@@ -792,6 +794,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
vser->vdev.get_config = get_config;
vser->vdev.set_config = set_config;
+ vser->qdev = dev;
+
/*
* Register for the savevm section with the virtio-console name
* to preserve backward compat
@@ -801,3 +805,16 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
return vdev;
}
+
+void virtio_serial_exit(VirtIODevice *vdev)
+{
+ VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+
+ unregister_savevm(vser->qdev, "virtio-console", vser);
+
+ qemu_free(vser->ivqs);
+ qemu_free(vser->ovqs);
+ qemu_free(vser->ports_map);
+
+ virtio_cleanup(vdev);
+}
diff --git a/hw/virtio.h b/hw/virtio.h
index 30e472a..5836ab6 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -195,6 +195,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf);
void virtio_net_exit(VirtIODevice *vdev);
void virtio_blk_exit(VirtIODevice *vdev);
+void virtio_serial_exit(VirtIODevice *vdev);
#define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \
DEFINE_PROP_BIT("indirect_desc", _state, _field, \
--
1.7.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-serial: Cleanup on device hot-unplug
2010-08-19 1:21 [Qemu-devel] [PATCH] virtio-serial: Cleanup on device hot-unplug Amit Shah
@ 2010-08-20 12:00 ` Amit Shah
2010-08-22 21:30 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Amit Shah @ 2010-08-20 12:00 UTC (permalink / raw)
To: qemu list; +Cc: Juan Quintela
On (Thu) Aug 19 2010 [06:51:04], Amit Shah wrote:
> Free malloc'ed memory, unregister from savevm and clean up virtio-common
> bits on device hot-unplug.
>
> This was found performing a migration after device hot-unplug.
>
> Reported-by: <lihuang@redhat.com>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
> hw/virtio-pci.c | 10 +++++++++-
> hw/virtio-serial-bus.c | 17 +++++++++++++++++
> hw/virtio.h | 1 +
> 3 files changed, 27 insertions(+), 1 deletions(-)
Please pick this for 0.13 as well.
Thanks,
Amit
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-serial: Cleanup on device hot-unplug
2010-08-19 1:21 [Qemu-devel] [PATCH] virtio-serial: Cleanup on device hot-unplug Amit Shah
2010-08-20 12:00 ` Amit Shah
@ 2010-08-22 21:30 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2010-08-22 21:30 UTC (permalink / raw)
To: Amit Shah; +Cc: qemu list, Juan Quintela
On 08/18/2010 08:21 PM, Amit Shah wrote:
> Free malloc'ed memory, unregister from savevm and clean up virtio-common
> bits on device hot-unplug.
>
> This was found performing a migration after device hot-unplug.
>
> Reported-by:<lihuang@redhat.com>
> Signed-off-by: Amit Shah<amit.shah@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> hw/virtio-pci.c | 10 +++++++++-
> hw/virtio-serial-bus.c | 17 +++++++++++++++++
> hw/virtio.h | 1 +
> 3 files changed, 27 insertions(+), 1 deletions(-)
>
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 17c3d15..82a6d78 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -599,6 +599,14 @@ static int virtio_serial_init_pci(PCIDevice *pci_dev)
> return 0;
> }
>
> +static int virtio_serial_exit_pci(PCIDevice *pci_dev)
> +{
> + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
> +
> + virtio_serial_exit(proxy->vdev);
> + return virtio_exit_pci(pci_dev);
> +}
> +
> static int virtio_net_init_pci(PCIDevice *pci_dev)
> {
> VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
> @@ -689,7 +697,7 @@ static PCIDeviceInfo virtio_info[] = {
> .qdev.alias = "virtio-serial",
> .qdev.size = sizeof(VirtIOPCIProxy),
> .init = virtio_serial_init_pci,
> - .exit = virtio_exit_pci,
> + .exit = virtio_serial_exit_pci,
> .qdev.props = (Property[]) {
> DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
> DEV_NVECTORS_UNSPECIFIED),
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 0586b89..74ba5ec 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -41,6 +41,8 @@ struct VirtIOSerial {
>
> VirtIOSerialBus *bus;
>
> + DeviceState *qdev;
> +
> QTAILQ_HEAD(, VirtIOSerialPort) ports;
>
> /* bitmap for identifying active ports */
> @@ -792,6 +794,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
> vser->vdev.get_config = get_config;
> vser->vdev.set_config = set_config;
>
> + vser->qdev = dev;
> +
> /*
> * Register for the savevm section with the virtio-console name
> * to preserve backward compat
> @@ -801,3 +805,16 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
>
> return vdev;
> }
> +
> +void virtio_serial_exit(VirtIODevice *vdev)
> +{
> + VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
> +
> + unregister_savevm(vser->qdev, "virtio-console", vser);
> +
> + qemu_free(vser->ivqs);
> + qemu_free(vser->ovqs);
> + qemu_free(vser->ports_map);
> +
> + virtio_cleanup(vdev);
> +}
> diff --git a/hw/virtio.h b/hw/virtio.h
> index 30e472a..5836ab6 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -195,6 +195,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf);
>
> void virtio_net_exit(VirtIODevice *vdev);
> void virtio_blk_exit(VirtIODevice *vdev);
> +void virtio_serial_exit(VirtIODevice *vdev);
>
> #define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \
> DEFINE_PROP_BIT("indirect_desc", _state, _field, \
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-22 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-19 1:21 [Qemu-devel] [PATCH] virtio-serial: Cleanup on device hot-unplug Amit Shah
2010-08-20 12:00 ` Amit Shah
2010-08-22 21:30 ` Anthony Liguori
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).