Skip to contentSkip to conversation

Usb 20181029 patches

GIT PULL Applied Gerd Hoffmann 2 participants 5 messages Oct 29, 2018 – Oct 30, 2018

lore
Share & tools
lore
#0 lore raw

The following changes since commit b312532fd03413d0e6ae6767ec793a3e30f487b8:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-10-19 19:01:07 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/usb-20181029-pull-request

for you to fetch changes up to 7dea29e4af17fc1d27478de9f8ea38144deac54a:

hw: ccid-card-emulated: cleanup resource when realize in error path (2018-10-29 10:46:07 +0100)

----------------------------------------------------------------
usb: fixes for ohci and smart card emulation.

----------------------------------------------------------------

Li Qiang (3):
usb: ohci: make num_ports to an unsinged integer
hw: ccid-card-emulated: introduce clean_event_notifier
hw: ccid-card-emulated: cleanup resource when realize in error path

 hw/usb/ccid-card-emulated.c | 27 +++++++++++++++++++++------
 hw/usb/hcd-ohci.c           |  6 +++---
 2 files changed, 24 insertions(+), 9 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

[Qemu-devel] [PULL 1/3] usb: ohci: make num_ports to an unsinged integer

From: Li Qiang <[email protected]>

This can avoid setting OCHIState.num_ports to a negative num.

Message-id: [email protected]

---
 hw/usb/hcd-ohci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/usb/hcd-ohci.c +3 -3
index 66656a1133..c34cf5b73a 100644
@@ -57,7 +57,7 @@ typedef struct {
     qemu_irq irq;
     MemoryRegion mem;
     AddressSpace *as;
-    int num_ports;
+    uint32_t num_ports;
     const char *name;
 
     QEMUTimer *eof_timer;
@@ -1850,7 +1850,7 @@ static USBBusOps ohci_bus_ops = {
 };
 
 static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
-                          int num_ports, dma_addr_t localmem_base,
+                          uint32_t num_ports, dma_addr_t localmem_base,
                           char *masterbus, uint32_t firstport,
                           AddressSpace *as, Error **errp)
 {
@@ -1860,7 +1860,7 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
     ohci->as = as;
 
     if (num_ports > OHCI_MAX_PORTS) {
-        error_setg(errp, "OHCI num-ports=%d is too big (limit is %d ports)",
+        error_setg(errp, "OHCI num-ports=%u is too big (limit is %u ports)",
                    num_ports, OHCI_MAX_PORTS);
         return;
     }
Signature · 1 line
2.9.3
#2 lore raw

[Qemu-devel] [PULL 2/3] hw: ccid-card-emulated: introduce clean_event_notifier

In reply to Gerd Hoffmann

From: Li Qiang <[email protected]>

Call it in device unrealize function.

Message-id: [email protected]

---
 hw/usb/ccid-card-emulated.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/usb/ccid-card-emulated.c +7 -0
index 5c8b3c9907..b356edb0f3 100644
@@ -409,6 +409,12 @@ static int init_event_notifier(EmulatedState *card, Error **errp)
     return 0;
 }
 
+static void clean_event_notifier(EmulatedState *card)
+{
+    event_notifier_set_handler(&card->notifier, NULL);
+    event_notifier_cleanup(&card->notifier);
+}
+
 #define CERTIFICATES_DEFAULT_DB "/etc/pki/nssdb"
 #define CERTIFICATES_ARGS_TEMPLATE\
     "db=\"%s\" use_hw=no soft=(,Virtual Reader,CAC,,%s,%s,%s)"
@@ -556,6 +562,7 @@ static void emulated_unrealize(CCIDCardState *base, Error **errp)
     qemu_cond_signal(&card->handle_apdu_cond);
     qemu_thread_join(&card->apdu_thread_id);
 
+    clean_event_notifier(card);
     /* threads exited, can destroy all condvars/mutexes */
     qemu_cond_destroy(&card->handle_apdu_cond);
     qemu_mutex_destroy(&card->handle_apdu_mutex);
Signature · 1 line
2.9.3
#3 lore raw

[Qemu-devel] [PULL 3/3] hw: ccid-card-emulated: cleanup resource when realize in error path

In reply to Gerd Hoffmann

From: Li Qiang <[email protected]>

Message-id: [email protected]

---
 hw/usb/ccid-card-emulated.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
hw/usb/ccid-card-emulated.c +14 -6
index b356edb0f3..25976ed84f 100644
@@ -499,7 +499,7 @@ static void emulated_realize(CCIDCardState *base, Error **errp)
     card->reader = NULL;
     card->quit_apdu_thread = 0;
     if (init_event_notifier(card, errp) < 0) {
-        return;
+        goto out1;
     }
 
     card->backend = 0;
@@ -513,7 +513,7 @@ static void emulated_realize(CCIDCardState *base, Error **errp)
         for (ptable = backend_enum_table; ptable->name != NULL; ++ptable) {
             error_append_hint(errp, "%s\n", ptable->name);
         }
-        return;
+        goto out2;
     }
 
     /* TODO: a passthru backened that works on local machine. third card type?*/
@@ -523,31 +523,39 @@ static void emulated_realize(CCIDCardState *base, Error **errp)
         } else {
             error_setg(errp, "%s: you must provide all three certs for"
                        " certificates backend", TYPE_EMULATED_CCID);
-            return;
+            goto out2;
         }
     } else {
         if (card->backend != BACKEND_NSS_EMULATED) {
             error_setg(errp, "%s: bad backend specified. The options are:%s"
                        " (default), %s.", TYPE_EMULATED_CCID,
                        BACKEND_NSS_EMULATED_NAME, BACKEND_CERTIFICATES_NAME);
-            return;
+            goto out2;
         }
         if (card->cert1 != NULL || card->cert2 != NULL || card->cert3 != NULL) {
             error_setg(errp, "%s: unexpected cert parameters to nss emulated "
                        "backend", TYPE_EMULATED_CCID);
-            return;
+            goto out2;
         }
         /* default to mirroring the local hardware readers */
         ret = wrap_vcard_emul_init(NULL);
     }
     if (ret != VCARD_EMUL_OK) {
         error_setg(errp, "%s: failed to initialize vcard", TYPE_EMULATED_CCID);
-        return;
+        goto out2;
     }
     qemu_thread_create(&card->event_thread_id, "ccid/event", event_thread,
                        card, QEMU_THREAD_JOINABLE);
     qemu_thread_create(&card->apdu_thread_id, "ccid/apdu", handle_apdu_thread,
                        card, QEMU_THREAD_JOINABLE);
+
+out2:
+    clean_event_notifier(card);
+out1:
+    qemu_cond_destroy(&card->handle_apdu_cond);
+    qemu_mutex_destroy(&card->handle_apdu_mutex);
+    qemu_mutex_destroy(&card->vreader_mutex);
+    qemu_mutex_destroy(&card->event_list_mutex);
 }
 
 static void emulated_unrealize(CCIDCardState *base, Error **errp)
Signature · 1 line
2.9.3
#4 lore raw
In reply to Gerd Hoffmann
Quoted 17 lines · Gerd Hoffmann

The following changes since commit b312532fd03413d0e6ae6767ec793a3e30f487b8:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-10-19 19:01:07 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/usb-20181029-pull-request

for you to fetch changes up to 7dea29e4af17fc1d27478de9f8ea38144deac54a:

hw: ccid-card-emulated: cleanup resource when realize in error path (2018-10-29 10:46:07 +0100)

----------------------------------------------------------------
usb: fixes for ohci and smart card emulation.

----------------------------------------------------------------

Quoted 8 lines

Li Qiang (3):
usb: ohci: make num_ports to an unsinged integer
hw: ccid-card-emulated: introduce clean_event_notifier
hw: ccid-card-emulated: cleanup resource when realize in error path

 hw/usb/ccid-card-emulated.c | 27 +++++++++++++++++++++------
 hw/usb/hcd-ohci.c           |  6 +++---
 2 files changed, 24 insertions(+), 9 deletions(-)

Applied, thanks.

-- PMM