qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit
@ 2012-01-13  9:59 Amit Shah
  2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 1/2] qdev: Add a 'free' method to disassociate chardev from qdev device Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Amit Shah @ 2012-01-13  9:59 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah, Gerd Hoffmann, Markus Armbruster

When the device is going away (e.g., hot-unplug), an associated
chardev should be freed and made available for use for other devices.

An earlier hack did this for virtio serial ports, do it in a generic
way and remove the virtio-serial specific hack.

v2:
 - actually remove virtconsole_exitfn()

Amit Shah (2):
  qdev: Add a 'free' method to disassociate chardev from qdev device
  virtio-console: no need to remove char handlers explicitly

 hw/qdev-properties.c |   11 +++++++++++
 hw/virtio-console.c  |   17 -----------------
 2 files changed, 11 insertions(+), 17 deletions(-)

-- 
1.7.7.5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] qdev: Add a 'free' method to disassociate chardev from qdev device
  2012-01-13  9:59 [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit Amit Shah
@ 2012-01-13  9:59 ` Amit Shah
  2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 2/2] virtio-console: no need to remove char handlers explicitly Amit Shah
  2012-01-13 16:54 ` [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Amit Shah @ 2012-01-13  9:59 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah, Gerd Hoffmann, Markus Armbruster

When a device is removed, remove the association with a chardev, if any,
so that the chardev can be re-used later for other devices.

Reported-by: Qunfang Zhang <qzhang@redhat.com>
Fix-suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/qdev-properties.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 663c2a0..02f0dae 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -680,6 +680,16 @@ static int parse_chr(DeviceState *dev, Property *prop, const char *str)
     return 0;
 }
 
+static void free_chr(DeviceState *dev, Property *prop)
+{
+    CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+
+    if (*ptr) {
+        qemu_chr_add_handlers(*ptr, NULL, NULL, NULL, NULL);
+    }
+}
+
+
 static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len)
 {
     CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
@@ -699,6 +709,7 @@ PropertyInfo qdev_prop_chr = {
     .print = print_chr,
     .get   = get_generic,
     .set   = set_generic,
+    .free  = free_chr,
 };
 
 /* --- netdev device --- */
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] virtio-console: no need to remove char handlers explicitly
  2012-01-13  9:59 [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit Amit Shah
  2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 1/2] qdev: Add a 'free' method to disassociate chardev from qdev device Amit Shah
@ 2012-01-13  9:59 ` Amit Shah
  2012-01-13 16:54 ` [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Amit Shah @ 2012-01-13  9:59 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah, Gerd Hoffmann, Markus Armbruster

qdev is now equipped (thanks to the last commit) to disassociate
chardevs from the qdev devices on the devices going away.  So doing it
in the virtio-console driver is not necessary.

Since that was the only thing being done in the qdev exit method, drop
it entirely.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-console.c |   17 -----------------
 1 files changed, 0 insertions(+), 17 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 73d866a..0b28a30 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -125,27 +125,11 @@ static int virtconsole_initfn(VirtIOSerialPort *port)
     return 0;
 }
 
-static int virtconsole_exitfn(VirtIOSerialPort *port)
-{
-    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
-
-    if (vcon->chr) {
-	/*
-	 * Instead of closing the chardev, free it so it can be used
-	 * for other purposes.
-	 */
-	qemu_chr_add_handlers(vcon->chr, NULL, NULL, NULL, NULL);
-    }
-
-    return 0;
-}
-
 static VirtIOSerialPortInfo virtconsole_info = {
     .qdev.name     = "virtconsole",
     .qdev.size     = sizeof(VirtConsole),
     .is_console    = true,
     .init          = virtconsole_initfn,
-    .exit          = virtconsole_exitfn,
     .have_data     = flush_buf,
     .guest_open    = guest_open,
     .guest_close   = guest_close,
@@ -165,7 +149,6 @@ static VirtIOSerialPortInfo virtserialport_info = {
     .qdev.name     = "virtserialport",
     .qdev.size     = sizeof(VirtConsole),
     .init          = virtconsole_initfn,
-    .exit          = virtconsole_exitfn,
     .have_data     = flush_buf,
     .guest_open    = guest_open,
     .guest_close   = guest_close,
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit
  2012-01-13  9:59 [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit Amit Shah
  2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 1/2] qdev: Add a 'free' method to disassociate chardev from qdev device Amit Shah
  2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 2/2] virtio-console: no need to remove char handlers explicitly Amit Shah
@ 2012-01-13 16:54 ` Anthony Liguori
  2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2012-01-13 16:54 UTC (permalink / raw)
  To: Amit Shah; +Cc: Markus Armbruster, qemu list, Gerd Hoffmann

On 01/13/2012 03:59 AM, Amit Shah wrote:
> When the device is going away (e.g., hot-unplug), an associated
> chardev should be freed and made available for use for other devices.
>
> An earlier hack did this for virtio serial ports, do it in a generic
> way and remove the virtio-serial specific hack.

Applied.  Thanks.

Regards,

Anthony Liguori

>
> v2:
>   - actually remove virtconsole_exitfn()
>
> Amit Shah (2):
>    qdev: Add a 'free' method to disassociate chardev from qdev device
>    virtio-console: no need to remove char handlers explicitly
>
>   hw/qdev-properties.c |   11 +++++++++++
>   hw/virtio-console.c  |   17 -----------------
>   2 files changed, 11 insertions(+), 17 deletions(-)
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-13 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13  9:59 [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit Amit Shah
2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 1/2] qdev: Add a 'free' method to disassociate chardev from qdev device Amit Shah
2012-01-13  9:59 ` [Qemu-devel] [PATCH v2 2/2] virtio-console: no need to remove char handlers explicitly Amit Shah
2012-01-13 16:54 ` [Qemu-devel] [PATCH v2 0/2] qdev: disassociate chardev from device on device exit 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).