Patchwork virtio-serial: Unplug port if guest reports failure in adding it

login
register
mail settings
Submitter Amit Shah
Date Aug. 31, 2010, 8:22 a.m.
Message ID <56229764a86564887032c74806e7d5f80d267741.1283242936.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/63209/
State New
Headers show

Comments

Amit Shah - Aug. 31, 2010, 8:22 a.m.
If a guest reports failure in adding a port, we shouldn't keep it lying
around.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-serial-bus.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Amit Shah - Sept. 1, 2010, 10 a.m.
On (Tue) Aug 31 2010 [13:52:22], Amit Shah wrote:
> If a guest reports failure in adding a port, we shouldn't keep it lying
> around.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  hw/virtio-serial-bus.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 74ba5ec..86c2364 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -303,6 +303,7 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
>          if (!cpkt.value) {
>              error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
>                           port->id, vser->bus->qbus.name);
> +            qdev_unplug(&port->dev);
>              break;
>          }
>          /*

OK, ignore this patch.

My original thinking was that if the device got added successfully in
qemu and failed to be added by the guest (can happen for a variety of
reasons), we should keep the device lying around and tell the user about
it. If the user doesn't want the device any more, it can be unplugged.

I briefly thought that shouldn't be the case: if a guest can't use a
device, it's no good to let it lie around in qemu.

Just had a brief chat with Dan and he supported the original idea, so
we'll let the device exist in qemu and let libvirt / the user yank it
away if that's needed.

(Of course, users of the device itself should check if the guest
addition was successful by using virtio_serial_guest_ready(port))

		Amit

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 74ba5ec..86c2364 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -303,6 +303,7 @@  static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len)
         if (!cpkt.value) {
             error_report("virtio-serial-bus: Guest failure in adding port %u for device %s\n",
                          port->id, vser->bus->qbus.name);
+            qdev_unplug(&port->dev);
             break;
         }
         /*