qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/3] Usb 20181029 patches
@ 2018-10-29 20:02 Gerd Hoffmann
  2018-10-29 20:02 ` [Qemu-devel] [PULL 1/3] usb: ohci: make num_ports to an unsinged integer Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: 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.

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

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(-)

-- 
2.9.3

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

* [Qemu-devel] [PULL 1/3] usb: ohci: make num_ports to an unsinged integer
  2018-10-29 20:02 [Qemu-devel] [PULL 0/3] Usb 20181029 patches Gerd Hoffmann
@ 2018-10-29 20:02 ` Gerd Hoffmann
  2018-10-29 20:02 ` [Qemu-devel] [PULL 2/3] hw: ccid-card-emulated: introduce clean_event_notifier Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Li Qiang

From: Li Qiang <liq3ea@gmail.com>

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

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Message-id: 1540263618-18344-1-git-send-email-liq3ea@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-ohci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 66656a1133..c34cf5b73a 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -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;
     }
-- 
2.9.3

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

* [Qemu-devel] [PULL 2/3] hw: ccid-card-emulated: introduce clean_event_notifier
  2018-10-29 20:02 [Qemu-devel] [PULL 0/3] Usb 20181029 patches Gerd Hoffmann
  2018-10-29 20:02 ` [Qemu-devel] [PULL 1/3] usb: ohci: make num_ports to an unsinged integer Gerd Hoffmann
@ 2018-10-29 20:02 ` Gerd Hoffmann
  2018-10-29 20:02 ` [Qemu-devel] [PULL 3/3] hw: ccid-card-emulated: cleanup resource when realize in error path Gerd Hoffmann
  2018-10-30 14:09 ` [Qemu-devel] [PULL 0/3] Usb 20181029 patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Li Qiang

From: Li Qiang <liq3ea@gmail.com>

Call it in device unrealize function.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Message-id: 1539946236-18028-2-git-send-email-liq3ea@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/ccid-card-emulated.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index 5c8b3c9907..b356edb0f3 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -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);
-- 
2.9.3

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

* [Qemu-devel] [PULL 3/3] hw: ccid-card-emulated: cleanup resource when realize in error path
  2018-10-29 20:02 [Qemu-devel] [PULL 0/3] Usb 20181029 patches Gerd Hoffmann
  2018-10-29 20:02 ` [Qemu-devel] [PULL 1/3] usb: ohci: make num_ports to an unsinged integer Gerd Hoffmann
  2018-10-29 20:02 ` [Qemu-devel] [PULL 2/3] hw: ccid-card-emulated: introduce clean_event_notifier Gerd Hoffmann
@ 2018-10-29 20:02 ` Gerd Hoffmann
  2018-10-30 14:09 ` [Qemu-devel] [PULL 0/3] Usb 20181029 patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2018-10-29 20:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Li Qiang

From: Li Qiang <liq3ea@gmail.com>

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Message-id: 1539946236-18028-3-git-send-email-liq3ea@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/ccid-card-emulated.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index b356edb0f3..25976ed84f 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -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)
-- 
2.9.3

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

* Re: [Qemu-devel] [PULL 0/3] Usb 20181029 patches
  2018-10-29 20:02 [Qemu-devel] [PULL 0/3] Usb 20181029 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2018-10-29 20:02 ` [Qemu-devel] [PULL 3/3] hw: ccid-card-emulated: cleanup resource when realize in error path Gerd Hoffmann
@ 2018-10-30 14:09 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2018-10-30 14:09 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 29 October 2018 at 20:02, Gerd Hoffmann <kraxel@redhat.com> wrote:
> 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(-)

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2018-10-30 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-29 20:02 [Qemu-devel] [PULL 0/3] Usb 20181029 patches Gerd Hoffmann
2018-10-29 20:02 ` [Qemu-devel] [PULL 1/3] usb: ohci: make num_ports to an unsinged integer Gerd Hoffmann
2018-10-29 20:02 ` [Qemu-devel] [PULL 2/3] hw: ccid-card-emulated: introduce clean_event_notifier Gerd Hoffmann
2018-10-29 20:02 ` [Qemu-devel] [PULL 3/3] hw: ccid-card-emulated: cleanup resource when realize in error path Gerd Hoffmann
2018-10-30 14:09 ` [Qemu-devel] [PULL 0/3] Usb 20181029 patches Peter Maydell

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).