On 18/6/24 16:15, Philippe Mathieu-Daudé wrote:
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é <berra...@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <phi...@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/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;
  }

Also missing:

   #ifdef CONFIG_USB_LIBUSB

+HumanReadableText *qmp_x_query_usbhost(Error **errp)
+{
+    error_setg(errp, "Support for USB devices not built-in");
+    return NULL;
+}

   #endif

But still failing the build-without-defaults job:

▶ 59/61 /x86_64/qmp/x-query-usbhost - ERROR:../tests/qtest/qmp-cmd-test.c:88:test_query: assertion failed: (error) FAIL

So dropping patches 2 & 3 for now.

Reply via email to