[PATCH v3 39/49] qdev-monitor: make print_dev() callback take MonitorHMP
Marc-André Lureau <[email protected]>
| Newsgroups | org.xenproject.lists.xen-devel,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
The callback is specific to HMP context, avoid unsafe MONITOR_HMP() cast. Signed-off-by: Marc-André Lureau <[email protected]> --- hw/char/virtio-serial-bus.c | 6 +++--- hw/core/sysbus.c | 5 ++--- hw/misc/auxbus.c | 7 +++---- hw/pci/pci-hmp-cmds.c | 3 +-- hw/pci/pci-internal.h | 2 +- hw/usb/bus.c | 5 ++--- hw/xen/xen-bus.c | 3 +-- include/hw/core/qdev.h | 3 ++- system/qdev-monitor.c | 7 +++---- 9 files changed, 18 insertions(+), 23 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 33fdc0846ac3..4dcc4516e45e 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -814,7 +814,7 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f, return 0; } -static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); +static void virtser_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent); static const Property virtser_props[] = { DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BAD_ID), @@ -834,11 +834,11 @@ static const TypeInfo virtser_bus_info = { .class_init = virtser_bus_class_init, }; -static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) +static void virtser_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent) { VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(qdev); - monitor_hmp_printf(MONITOR_HMP(mon), "%*sport %d, guest %s, host %s, throttle %s\n", + monitor_hmp_printf(hmp, "%*sport %d, guest %s, host %s, throttle %s\n", indent, "", port->id, port->guest_connected ? "on" : "off", port->host_connected ? "on" : "off", diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 82130ba04698..31c4fdf79d48 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -24,7 +24,7 @@ #include "monitor/hmp.h" #include "system/address-spaces.h" -static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent); +static void sysbus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent); static char *sysbus_get_fw_dev_path(DeviceState *dev); typedef struct SysBusFind { @@ -249,10 +249,9 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp) return qdev_realize_and_unref(DEVICE(dev), sysbus_get_default(), errp); } -static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent) +static void sysbus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { SysBusDevice *s = SYS_BUS_DEVICE(dev); - MonitorHMP *hmp = MONITOR_HMP(mon); hwaddr size; int i; diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index ffa76f83016b..0bb89c5a60ab 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -47,7 +47,7 @@ } while (0) -static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent); +static void aux_slave_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent); static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge); /* aux-bus implementation (internal not public) */ @@ -288,7 +288,7 @@ static const TypeInfo aux_to_i2c_type_info = { }; /* aux-slave implementation */ -static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent) +static void aux_slave_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev)); AUXSlave *s; @@ -300,8 +300,7 @@ static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent) s = AUX_SLAVE(dev); - monitor_hmp_printf(MONITOR_HMP(mon), - "%*smemory " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n", + monitor_hmp_printf(hmp, "%*smemory " HWADDR_FMT_plx "/" HWADDR_FMT_plx "\n", indent, "", object_property_get_uint(OBJECT(s->mmio), "addr", NULL), memory_region_size(s->mmio)); diff --git a/hw/pci/pci-hmp-cmds.c b/hw/pci/pci-hmp-cmds.c index 500f821246a9..bcccfaf07f4d 100644 --- a/hw/pci/pci-hmp-cmds.c +++ b/hw/pci/pci-hmp-cmds.c @@ -135,9 +135,8 @@ void hmp_info_pci(MonitorHMP *hmp, const QDict *qdict) qapi_free_PciInfoList(info_list); } -void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) +void pcibus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { - MonitorHMP *hmp = MONITOR_HMP(mon); PCIDevice *d = (PCIDevice *)dev; int class = pci_get_word(d->config + PCI_CLASS_DEVICE); const pci_class_desc *desc = get_class_desc(class); diff --git a/hw/pci/pci-internal.h b/hw/pci/pci-internal.h index a7d6d8a7324e..b7231fab5dc9 100644 --- a/hw/pci/pci-internal.h +++ b/hw/pci/pci-internal.h @@ -16,7 +16,7 @@ extern PCIHostStateList pci_host_bridges; const pci_class_desc *get_class_desc(int class); PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num); -void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); +void pcibus_dev_print(MonitorHMP *mon, DeviceState *dev, int indent); int pcie_aer_parse_error_string(const char *error_name, uint32_t *status, bool *correctable); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index fe3dbfa2227c..8bd25a9d872a 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -13,7 +13,7 @@ #include "trace.h" #include "qemu/cutils.h" -static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); +static void usb_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent); static char *usb_get_dev_path(DeviceState *dev); static char *usb_get_fw_dev_path(DeviceState *qdev); @@ -544,9 +544,8 @@ static const char *usb_speed(unsigned int speed) return txt[speed]; } -static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent) +static void usb_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent) { - MonitorHMP *hmp = MONITOR_HMP(mon); USBDevice *dev = USB_DEVICE(qdev); USBBus *bus = usb_bus_from_device(dev); diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 4075b5b001ae..b81a067e7753 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -101,9 +101,8 @@ abort: qemu_xen_xs_transaction_end(xenbus->xsh, tid, true); } -static void xen_bus_print_dev(Monitor *mon, DeviceState *dev, int indent) +static void xen_bus_print_dev(MonitorHMP *hmp, DeviceState *dev, int indent) { - MonitorHMP *hmp = MONITOR_HMP(mon); XenDevice *xendev = XEN_DEVICE(dev); monitor_hmp_printf(hmp, "%*sname = '%s' frontend_id = %u\n", diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index 37f7d3355193..1391dc060caf 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -10,6 +10,7 @@ #include "qom/object.h" #include "hw/core/hotplug.h" #include "hw/core/resettable.h" +#include "monitor/hmp.h" /** * DOC: The QEMU Device API @@ -323,7 +324,7 @@ struct BusClass { ObjectClass parent_class; /* FIXME first arg should be BusState */ - void (*print_dev)(Monitor *mon, DeviceState *dev, int indent); + void (*print_dev)(MonitorHMP *mon, DeviceState *dev, int indent); /* * Return a newly allocated string containing the path of the * device on this bus. diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 3860ada2a237..13ac9f8f3be1 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -790,18 +790,17 @@ static void qdev_print_props(MonitorHMP *hmp, DeviceState *dev, DeviceClass *dc, } } -static void bus_print_dev(BusState *bus, Monitor *mon, DeviceState *dev, int indent) +static void bus_print_dev(BusState *bus, MonitorHMP *hmp, DeviceState *dev, int indent) { BusClass *bc = BUS_GET_CLASS(bus); if (bc->print_dev) { - bc->print_dev(mon, dev, indent); + bc->print_dev(hmp, dev, indent); } } static void qdev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { - Monitor *mon = MONITOR(hmp); ObjectClass *class; NamedGPIOList *ngl; NamedClockList *ncl; @@ -828,7 +827,7 @@ static void qdev_print(MonitorHMP *hmp, DeviceState *dev, int indent) qdev_print_props(hmp, dev, DEVICE_CLASS(class), indent); class = object_class_get_parent(class); } while (class != object_class_by_name(TYPE_DEVICE)); - bus_print_dev(dev->parent_bus, mon, dev, indent); + bus_print_dev(dev->parent_bus, hmp, dev, indent); } static void qbus_print(MonitorHMP *hmp, BusState *bus, int indent, bool details) -- 2.55.0.543.g5ebe2ebe4ea8