qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Daniel P . Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH v2 2/3] hw/usb: Introduce x-query-usbhost QMP command
Date: Tue, 18 Jun 2024 16:15:15 +0200	[thread overview]
Message-ID: <7c8cf4f0-c717-47dd-8390-41c7fd7d0a0b@linaro.org> (raw)
In-Reply-To: <20240611102305.60735-3-philmd@linaro.org>

On 11/6/24 12:23, Philippe Mathieu-Daudé wrote:
> This is a counterpart to the HMP "info usbhost" command. It is being
> added with an "x-" prefix because this QMP command is intended as an
> adhoc debugging tool and will thus not be modelled in QAPI as fully
> structured data, nor will it have long term guaranteed stability.
> The existing HMP command is rewritten to call the QMP command.
> 
> Since host-libusb.c can be built as part of the 'hw-usb' module,
> we introduce the libusb_register_hmp_info_hrt() helper to allow late
> registration when the module is loaded.
> 
> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   qapi/machine.json           | 18 ++++++++++++++++
>   hw/usb/host-libusb.h        | 16 ++++++++++++++
>   include/hw/usb.h            |  3 ---
>   hw/usb/bus-stub.c           |  7 +++++-
>   hw/usb/host-libusb-common.c | 31 ++++++++++++++++++++++++++
>   hw/usb/host-libusb.c        | 43 +++++++++++++++++++++++++------------
>   tests/qtest/qmp-cmd-test.c  |  3 +++
>   hmp-commands-info.hx        |  2 ++
>   hw/usb/meson.build          |  1 +
>   9 files changed, 106 insertions(+), 18 deletions(-)
>   create mode 100644 hw/usb/host-libusb.h
>   create mode 100644 hw/usb/host-libusb-common.c


> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index d46d96779a..c0b34af518 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -465,9 +465,6 @@ void usb_device_reset(USBDevice *dev);
>   void usb_wakeup(USBEndpoint *ep, unsigned int stream);
>   void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
>   
> -/* usb-linux.c */
> -void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
> -
>   /* usb ports of the VM */
>   
>   #define VM_USB_HUB_SIZE 8
> diff --git a/hw/usb/bus-stub.c b/hw/usb/bus-stub.c
> index fcabe8429e..948429bb33 100644
> --- a/hw/usb/bus-stub.c
> +++ b/hw/usb/bus-stub.c
> @@ -11,7 +11,6 @@
>   #include "qapi/error.h"
>   #include "qapi/qapi-commands-machine.h"
>   #include "sysemu/sysemu.h"
> -#include "monitor/monitor.h"
>   #include "hw/usb.h"
>   
>   USBDevice *usbdevice_create(const char *driver)
> @@ -26,3 +25,9 @@ HumanReadableText *qmp_x_query_usb(Error **errp)
>       error_setg(errp, "Support for USB devices not built-in");
>       return NULL;
>   }
> +
> +HumanReadableText *qmp_x_query_usbhost(Error **errp)
> +{
> +    error_setg(errp, "Support for USB devices not built-in");
> +    return NULL;
> +}
> diff --git a/hw/usb/host-libusb-common.c b/hw/usb/host-libusb-common.c
> new file mode 100644
> index 0000000000..406a2b25be
> --- /dev/null
> +++ b/hw/usb/host-libusb-common.c
> @@ -0,0 +1,31 @@
> +/*
> + * QEMU USB host redirector helpers
> + *
> + * SPDX-FileContributor: Philippe Mathieu-Daudé <philmd@linaro.org>
> + * SPDX-FileCopyrightText: 2024 Linaro Ltd.
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/module.h"
> +#include "qapi/error.h"
> +#include "qapi/qapi-commands-machine.h"
> +#include "monitor/monitor.h"
> +#include "host-libusb.h"
> +
> +static HumanReadableText *(*qmp_x_query_usbhost_handler)(Error **errp);
> +
> +void libusb_register_hmp_info_hrt(HumanReadableText *(*handler)(Error **errp))
> +{
> +    qmp_x_query_usbhost_handler = handler;
> +    monitor_register_hmp_info_hrt("usbhost", handler);
> +}
> +
> +HumanReadableText *qmp_x_query_usbhost(Error **errp)
> +{
> +    if (module_load("hw-usb-", "host", errp) <= 0) {
> +        return NULL;
> +    }
> +    assert(qmp_x_query_usbhost_handler);
> +    return qmp_x_query_usbhost_handler(errp);
> +}



> diff --git a/hw/usb/meson.build b/hw/usb/meson.build
> index d7de1003e3..af92b504fd 100644
> --- a/hw/usb/meson.build
> +++ b/hw/usb/meson.build
> @@ -7,6 +7,7 @@ system_ss.add(when: 'CONFIG_USB', if_true: files(
>     'core.c',
>     'desc.c',
>     'desc-msos.c',
> +  'host-libusb-common.c',
>     'libhw.c',
>     'pcap.c',
>   ), if_false: files('bus-stub.c'))

Since this files depends on libusb, squashing:

-- >8 --
diff --git a/hw/usb/meson.build b/hw/usb/meson.build
index af92b504fd..89b197fbd8 100644
--- a/hw/usb/meson.build
+++ b/hw/usb/meson.build
@@ -9,3 +9,2 @@ system_ss.add(when: 'CONFIG_USB', if_true: files(
    'desc-msos.c',
-  'host-libusb-common.c',
    'libhw.c',
@@ -86,2 +85,3 @@ endif
  if libusb.found()
+  system_ss.add(when: 'CONFIG_USB', if_true: files('host-libusb-common.c'))
    usbhost_ss = ss.source_set()
---


  parent reply	other threads:[~2024-06-18 14:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11 10:23 [PATCH v2 0/3] hw/usb: Introduce x-query-usbhost QMP command Philippe Mathieu-Daudé
2024-06-11 10:23 ` [PATCH v2 1/3] hw/usb: Remove unused 'host.h' header Philippe Mathieu-Daudé
2024-06-11 12:25   ` Daniel P. Berrangé
2024-06-11 10:23 ` [PATCH v2 2/3] hw/usb: Introduce x-query-usbhost QMP command Philippe Mathieu-Daudé
2024-06-11 12:28   ` Daniel P. Berrangé
2024-06-18 14:15   ` Philippe Mathieu-Daudé [this message]
2024-06-18 15:33     ` Philippe Mathieu-Daudé
2024-06-11 10:23 ` [PATCH v2 3/3] monitor: Remove monitor_register_hmp() Philippe Mathieu-Daudé
2024-06-11 12:30   ` Daniel P. Berrangé
2024-06-18 10:57 ` [PATCH v2 0/3] hw/usb: Introduce x-query-usbhost QMP command Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c8cf4f0-c717-47dd-8390-41c7fd7d0a0b@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dave@treblig.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).