All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas.
@ 2016-06-22 11:48 Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 1/5] usb-storage: qcow2 encryption support is finally gone, zap dead code Gerd Hoffmann
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Here is the usb patch queue, with hotplug support for
usb-bot and usb-uas.  Also some dead code removal.

please pull,
  Gerd

The following changes since commit 6f1d2d1c5ad20d464705b17318cb7ca495f8078a:

  Merge remote-tracking branch 'remotes/stsquad/tags/pull-travis-20160621-1' into staging (2016-06-21 15:19:58 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-usb-20160622-2

for you to fetch changes up to 0d4cf3e72aadc40aa866fef7ceb82dfbfdc9ac47:

  usb-uas: hotplug support (2016-06-22 12:53:26 +0200)

----------------------------------------------------------------
usb: add hotplug support for usb-bot and usb-uas.

----------------------------------------------------------------
Gerd Hoffmann (5):
      usb-storage: qcow2 encryption support is finally gone, zap dead code
      usb: make USBDevice->attached bool
      usb: Add QOM property "attached".
      usb-bot: hotplug support
      usb-uas: hotplug support

 hw/usb/bus.c         | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
 hw/usb/dev-storage.c | 42 ++++++------------------------------------
 hw/usb/dev-uas.c     |  5 +++++
 include/hw/usb.h     |  3 ++-
 4 files changed, 60 insertions(+), 41 deletions(-)

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

* [Qemu-devel] [PULL 1/5] usb-storage: qcow2 encryption support is finally gone, zap dead code
  2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
@ 2016-06-22 11:48 ` Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 2/5] usb: make USBDevice->attached bool Gerd Hoffmann
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1465984019-28963-2-git-send-email-kraxel@redhat.com
---
 hw/usb/dev-storage.c | 34 ----------------------------------
 1 file changed, 34 deletions(-)

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 9fd00df..bbd6f4f 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -556,21 +556,6 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
     }
 }
 
-static void usb_msd_password_cb(void *opaque, int err)
-{
-    MSDState *s = opaque;
-    Error *local_err = NULL;
-
-    if (!err) {
-        usb_device_attach(&s->dev, &local_err);
-    }
-
-    if (local_err) {
-        error_report_err(local_err);
-        qdev_unplug(&s->dev.qdev, NULL);
-    }
-}
-
 static void *usb_msd_load_request(QEMUFile *f, SCSIRequest *req)
 {
     MSDState *s = DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent);
@@ -616,25 +601,6 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
         return;
     }
 
-    if (blk_bs(blk)) {
-        bdrv_add_key(blk_bs(blk), NULL, &err);
-        if (err) {
-            if (monitor_cur_is_qmp()) {
-                error_propagate(errp, err);
-                return;
-            }
-            error_free(err);
-            err = NULL;
-            if (cur_mon) {
-                monitor_read_bdrv_key_start(cur_mon, blk_bs(blk),
-                                            usb_msd_password_cb, s);
-                s->dev.auto_attach = 0;
-            } else {
-                autostart = 0;
-            }
-        }
-    }
-
     blkconf_serial(&s->conf, &dev->serial);
     blkconf_blocksizes(&s->conf);
 
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 2/5] usb: make USBDevice->attached bool
  2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 1/5] usb-storage: qcow2 encryption support is finally gone, zap dead code Gerd Hoffmann
@ 2016-06-22 11:48 ` Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 3/5] usb: Add QOM property "attached" Gerd Hoffmann
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1465984019-28963-3-git-send-email-kraxel@redhat.com
---
 hw/usb/bus.c     | 8 ++++----
 include/hw/usb.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 16c3461..afd70ea 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -55,9 +55,9 @@ static int usb_device_post_load(void *opaque, int version_id)
     USBDevice *dev = opaque;
 
     if (dev->state == USB_STATE_NOTATTACHED) {
-        dev->attached = 0;
+        dev->attached = false;
     } else {
-        dev->attached = 1;
+        dev->attached = true;
     }
     if (dev->setup_index < 0 ||
         dev->setup_len < 0 ||
@@ -533,7 +533,7 @@ void usb_device_attach(USBDevice *dev, Error **errp)
         return;
     }
 
-    dev->attached++;
+    dev->attached = true;
     usb_attach(port);
 }
 
@@ -547,7 +547,7 @@ int usb_device_detach(USBDevice *dev)
     trace_usb_port_detach(bus->busnr, port->path);
 
     usb_detach(port);
-    dev->attached--;
+    dev->attached = false;
     return 0;
 }
 
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 163fe04..8f39470 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -235,7 +235,7 @@ struct USBDevice {
     uint8_t addr;
     char product_desc[32];
     int auto_attach;
-    int attached;
+    bool attached;
 
     int32_t state;
     uint8_t setup_buf[8];
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 3/5] usb: Add QOM property "attached".
  2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 1/5] usb-storage: qcow2 encryption support is finally gone, zap dead code Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 2/5] usb: make USBDevice->attached bool Gerd Hoffmann
@ 2016-06-22 11:48 ` Gerd Hoffmann
  2016-06-22 11:48 ` [Qemu-devel] [PULL 4/5] usb-bot: hotplug support Gerd Hoffmann
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

USB devices in attached state are visible to the guest.  This patch adds
a QOM property for this.  Write access is opt-in per device.  Some
devices manage attached state automatically (usb-host, usb-serial,
usb-redir), so we can't enable write access universally but have to do
it on a case by case base.  So far, no device opts in.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1465984019-28963-4-git-send-email-kraxel@redhat.com

[ minor codestyle fix ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/bus.c     | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/usb.h |  1 +
 2 files changed, 44 insertions(+)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index afd70ea..c28ccb8 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -736,6 +736,48 @@ USBDevice *usbdevice_create(const char *cmdline)
     return dev;
 }
 
+static bool usb_get_attached(Object *obj, Error **errp)
+{
+    USBDevice *dev = USB_DEVICE(obj);
+
+    return dev->attached;
+}
+
+static void usb_set_attached(Object *obj, bool value, Error **errp)
+{
+    USBDevice *dev = USB_DEVICE(obj);
+    Error *err = NULL;
+
+    if (dev->attached == value) {
+        return;
+    }
+
+    if (value) {
+        usb_device_attach(dev, &err);
+        if (err) {
+            error_propagate(errp, err);
+        }
+    } else {
+        usb_device_detach(dev);
+    }
+}
+
+static void usb_device_instance_init(Object *obj)
+{
+    USBDevice *dev = USB_DEVICE(obj);
+    USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev);
+
+    if (klass->attached_settable) {
+        object_property_add_bool(obj, "attached",
+                                 usb_get_attached, usb_set_attached,
+                                 NULL);
+    } else {
+        object_property_add_bool(obj, "attached",
+                                 usb_get_attached, NULL,
+                                 NULL);
+    }
+}
+
 static void usb_device_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *k = DEVICE_CLASS(klass);
@@ -749,6 +791,7 @@ static const TypeInfo usb_device_type_info = {
     .name = TYPE_USB_DEVICE,
     .parent = TYPE_DEVICE,
     .instance_size = sizeof(USBDevice),
+    .instance_init = usb_device_instance_init,
     .abstract = true,
     .class_size = sizeof(USBDeviceClass),
     .class_init = usb_device_class_init,
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 8f39470..847c9de 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -347,6 +347,7 @@ typedef struct USBDeviceClass {
 
     const char *product_desc;
     const USBDesc *usb_desc;
+    bool attached_settable;
 } USBDeviceClass;
 
 typedef struct USBPortOps {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 4/5] usb-bot: hotplug support
  2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2016-06-22 11:48 ` [Qemu-devel] [PULL 3/5] usb: Add QOM property "attached" Gerd Hoffmann
@ 2016-06-22 11:48 ` Gerd Hoffmann
  2016-06-22 14:20   ` Paolo Bonzini
  2016-06-22 11:48 ` [Qemu-devel] [PULL 5/5] usb-uas: " Gerd Hoffmann
  2016-06-23 10:53 ` [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Peter Maydell
  5 siblings, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

This patch marks usb-bot as hot-pluggable device, makes attached
property settable and turns off auto-attach in case the device
was hotplugged.

Hot-plugging a usb-bot device with one or more scsi devices can be
done this way now:

  (1) device-add usb-bot,id=foo
  (2) device-add scsi-{hd,cd},bus=foo.0,lun=0
  (2b) optionally add more devices (luns 0 ... 15).
  (3) qom-set foo.attached = true

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1465984019-28963-5-git-send-email-kraxel@redhat.com
---
 hw/usb/dev-storage.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index bbd6f4f..4d605b8 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -634,9 +634,14 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
 static void usb_msd_realize_bot(USBDevice *dev, Error **errp)
 {
     MSDState *s = USB_STORAGE_DEV(dev);
+    DeviceState *d = DEVICE(dev);
 
     usb_desc_create_serial(dev);
     usb_desc_init(dev);
+    if (d->hotplugged) {
+        s->dev.auto_attach = 0;
+    }
+
     scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
                  &usb_msd_scsi_info_bot, NULL);
     usb_msd_handle_reset(dev);
@@ -806,10 +811,9 @@ static void usb_msd_instance_init(Object *obj)
 static void usb_msd_class_initfn_bot(ObjectClass *klass, void *data)
 {
     USBDeviceClass *uc = USB_DEVICE_CLASS(klass);
-    DeviceClass *dc = DEVICE_CLASS(klass);
 
     uc->realize = usb_msd_realize_bot;
-    dc->hotpluggable = false;
+    uc->attached_settable = true;
 }
 
 static const TypeInfo msd_info = {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL 5/5] usb-uas: hotplug support
  2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2016-06-22 11:48 ` [Qemu-devel] [PULL 4/5] usb-bot: hotplug support Gerd Hoffmann
@ 2016-06-22 11:48 ` Gerd Hoffmann
  2016-06-23 10:53 ` [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Peter Maydell
  5 siblings, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Make attached property settable and turns off auto-attach in case the
device was hotplugged.  Hotplugging works simliar to usb-bot now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1465984019-28963-6-git-send-email-kraxel@redhat.com
---
 hw/usb/dev-uas.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index 0678b1b..3a8ff18 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -900,9 +900,13 @@ static void usb_uas_handle_destroy(USBDevice *dev)
 static void usb_uas_realize(USBDevice *dev, Error **errp)
 {
     UASDevice *uas = USB_UAS(dev);
+    DeviceState *d = DEVICE(dev);
 
     usb_desc_create_serial(dev);
     usb_desc_init(dev);
+    if (d->hotplugged) {
+        uas->dev.auto_attach = 0;
+    }
 
     QTAILQ_INIT(&uas->results);
     QTAILQ_INIT(&uas->requests);
@@ -940,6 +944,7 @@ static void usb_uas_class_initfn(ObjectClass *klass, void *data)
     uc->handle_control = usb_uas_handle_control;
     uc->handle_data    = usb_uas_handle_data;
     uc->handle_destroy = usb_uas_handle_destroy;
+    uc->attached_settable = true;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     dc->fw_name = "storage";
     dc->vmsd = &vmstate_usb_uas;
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL 4/5] usb-bot: hotplug support
  2016-06-22 11:48 ` [Qemu-devel] [PULL 4/5] usb-bot: hotplug support Gerd Hoffmann
@ 2016-06-22 14:20   ` Paolo Bonzini
  2016-06-23  7:31     ` Gerd Hoffmann
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2016-06-22 14:20 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel



On 22/06/2016 13:48, Gerd Hoffmann wrote:
> Hot-plugging a usb-bot device with one or more scsi devices can be
> done this way now:
> 
>   (1) device-add usb-bot,id=foo
>   (2) device-add scsi-{hd,cd},bus=foo.0,lun=0
>   (2b) optionally add more devices (luns 0 ... 15).
>   (3) qom-set foo.attached = true

Can you document it in docs/usb-storage.txt?

Thanks,

Paolo

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

* Re: [Qemu-devel] [PULL 4/5] usb-bot: hotplug support
  2016-06-22 14:20   ` Paolo Bonzini
@ 2016-06-23  7:31     ` Gerd Hoffmann
  0 siblings, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2016-06-23  7:31 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

On Mi, 2016-06-22 at 16:20 +0200, Paolo Bonzini wrote:
> 
> On 22/06/2016 13:48, Gerd Hoffmann wrote:
> > Hot-plugging a usb-bot device with one or more scsi devices can be
> > done this way now:
> > 
> >   (1) device-add usb-bot,id=foo
> >   (2) device-add scsi-{hd,cd},bus=foo.0,lun=0
> >   (2b) optionally add more devices (luns 0 ... 15).
> >   (3) qom-set foo.attached = true
> 
> Can you document it in docs/usb-storage.txt?

Good idea, will do as followup.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas.
  2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2016-06-22 11:48 ` [Qemu-devel] [PULL 5/5] usb-uas: " Gerd Hoffmann
@ 2016-06-23 10:53 ` Peter Maydell
  5 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2016-06-23 10:53 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 22 June 2016 at 12:48, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Here is the usb patch queue, with hotplug support for
> usb-bot and usb-uas.  Also some dead code removal.
>
> please pull,
>   Gerd
>
> The following changes since commit 6f1d2d1c5ad20d464705b17318cb7ca495f8078a:
>
>   Merge remote-tracking branch 'remotes/stsquad/tags/pull-travis-20160621-1' into staging (2016-06-21 15:19:58 +0100)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-usb-20160622-2
>
> for you to fetch changes up to 0d4cf3e72aadc40aa866fef7ceb82dfbfdc9ac47:
>
>   usb-uas: hotplug support (2016-06-22 12:53:26 +0200)
>
> ----------------------------------------------------------------
> usb: add hotplug support for usb-bot and usb-uas.
>

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2016-06-23 10:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 11:48 [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Gerd Hoffmann
2016-06-22 11:48 ` [Qemu-devel] [PULL 1/5] usb-storage: qcow2 encryption support is finally gone, zap dead code Gerd Hoffmann
2016-06-22 11:48 ` [Qemu-devel] [PULL 2/5] usb: make USBDevice->attached bool Gerd Hoffmann
2016-06-22 11:48 ` [Qemu-devel] [PULL 3/5] usb: Add QOM property "attached" Gerd Hoffmann
2016-06-22 11:48 ` [Qemu-devel] [PULL 4/5] usb-bot: hotplug support Gerd Hoffmann
2016-06-22 14:20   ` Paolo Bonzini
2016-06-23  7:31     ` Gerd Hoffmann
2016-06-22 11:48 ` [Qemu-devel] [PULL 5/5] usb-uas: " Gerd Hoffmann
2016-06-23 10:53 ` [Qemu-devel] [PULL 0/5] usb: add hotplug support for usb-bot and usb-uas Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.