[PATCH v3 43/49] hw: guard BusClass::print_dev with CONFIG_HMP
Marc-André Lureau <[email protected]>
| Newsgroups | gmane.comp.emulators.qemu,gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <[email protected]> |
The print_dev callback is only used by HMP 'info qtree'. Guard the field in BusClass, all implementations, and the caller with CONFIG_HMP. Signed-off-by: Marc-André Lureau <[email protected]> --- hw/char/virtio-serial-bus.c | 6 ++++++ hw/core/sysbus.c | 6 ++++++ hw/misc/auxbus.c | 16 +++++++++++----- hw/pci/pci-hmp-cmds.c | 2 ++ hw/pci/pci.c | 2 ++ hw/usb/bus.c | 6 ++++++ hw/xen/xen-bus.c | 4 ++++ include/hw/core/qdev.h | 2 ++ 8 files changed, 39 insertions(+), 5 deletions(-) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 4dcc4516e45e..83a033ce8555 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -814,7 +814,9 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f, return 0; } +#ifdef CONFIG_HMP static void virtser_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent); +#endif static const Property virtser_props[] = { DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BAD_ID), @@ -823,8 +825,10 @@ static const Property virtser_props[] = { static void virtser_bus_class_init(ObjectClass *klass, const void *data) { +#ifdef CONFIG_HMP BusClass *k = BUS_CLASS(klass); k->print_dev = virtser_bus_dev_print; +#endif } static const TypeInfo virtser_bus_info = { @@ -834,6 +838,7 @@ static const TypeInfo virtser_bus_info = { .class_init = virtser_bus_class_init, }; +#ifdef CONFIG_HMP static void virtser_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent) { VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(qdev); @@ -844,6 +849,7 @@ static void virtser_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent port->host_connected ? "on" : "off", port->throttled ? "on" : "off"); } +#endif /* This function is only used if a port id is not provided by the user */ static uint32_t find_free_port_id(VirtIOSerial *vser) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 31c4fdf79d48..fe8f867a8d9c 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -24,7 +24,9 @@ #include "monitor/hmp.h" #include "system/address-spaces.h" +#ifdef CONFIG_HMP static void sysbus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent); +#endif static char *sysbus_get_fw_dev_path(DeviceState *dev); typedef struct SysBusFind { @@ -76,7 +78,9 @@ static void system_bus_class_init(ObjectClass *klass, const void *data) { BusClass *k = BUS_CLASS(klass); +#ifdef CONFIG_HMP k->print_dev = sysbus_dev_print; +#endif k->get_fw_dev_path = sysbus_get_fw_dev_path; } @@ -249,6 +253,7 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp) return qdev_realize_and_unref(DEVICE(dev), sysbus_get_default(), errp); } +#ifdef CONFIG_HMP static void sysbus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { SysBusDevice *s = SYS_BUS_DEVICE(dev); @@ -261,6 +266,7 @@ static void sysbus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) indent, "", s->mmio[i].addr, size); } } +#endif static char *sysbus_get_fw_dev_path(DeviceState *dev) { diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index 0bb89c5a60ab..3f17784d9b8a 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -47,18 +47,22 @@ } while (0) +#ifdef CONFIG_HMP static void aux_slave_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent); +#endif static inline I2CBus *aux_bridge_get_i2c_bus(AUXTOI2CState *bridge); /* aux-bus implementation (internal not public) */ static void aux_bus_class_init(ObjectClass *klass, const void *data) { +#ifdef CONFIG_HMP BusClass *k = BUS_CLASS(klass); /* AUXSlave has an MMIO so we need to change the way we print information * in monitor. */ k->print_dev = aux_slave_dev_print; +#endif } AUXBus *aux_bus_init(DeviceState *parent, const char *name) @@ -91,11 +95,6 @@ void aux_map_slave(AUXSlave *aux_dev, hwaddr addr) memory_region_add_subregion(bus->aux_io, addr, aux_dev->mmio); } -static bool aux_bus_is_bridge(AUXBus *bus, DeviceState *dev) -{ - return (dev == DEVICE(bus->bridge)); -} - I2CBus *aux_get_i2c_bus(AUXBus *bus) { return aux_bridge_get_i2c_bus(bus->bridge); @@ -288,6 +287,12 @@ static const TypeInfo aux_to_i2c_type_info = { }; /* aux-slave implementation */ +#ifdef CONFIG_HMP +static bool aux_bus_is_bridge(AUXBus *bus, DeviceState *dev) +{ + return (dev == DEVICE(bus->bridge)); +} + static void aux_slave_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { AUXBus *bus = AUX_BUS(qdev_get_parent_bus(dev)); @@ -305,6 +310,7 @@ static void aux_slave_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) object_property_get_uint(OBJECT(s->mmio), "addr", NULL), memory_region_size(s->mmio)); } +#endif void aux_init_mmio(AUXSlave *aux_slave, MemoryRegion *mmio) { diff --git a/hw/pci/pci-hmp-cmds.c b/hw/pci/pci-hmp-cmds.c index bcccfaf07f4d..879011da1384 100644 --- a/hw/pci/pci-hmp-cmds.c +++ b/hw/pci/pci-hmp-cmds.c @@ -135,6 +135,7 @@ void hmp_info_pci(MonitorHMP *hmp, const QDict *qdict) qapi_free_PciInfoList(info_list); } +#ifdef CONFIG_HMP void pcibus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) { PCIDevice *d = (PCIDevice *)dev; @@ -170,6 +171,7 @@ void pcibus_dev_print(MonitorHMP *hmp, DeviceState *dev, int indent) r->addr, r->addr + r->size - 1); } } +#endif void hmp_pcie_aer_inject_error(MonitorHMP *hmp, const QDict *qdict) { diff --git a/hw/pci/pci.c b/hw/pci/pci.c index d3191609e283..9e5db9529379 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -290,7 +290,9 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data) ResettableClass *rc = RESETTABLE_CLASS(klass); FWCfgDataGeneratorClass *fwgc = FW_CFG_DATA_GENERATOR_CLASS(klass); +#ifdef CONFIG_HMP k->print_dev = pcibus_dev_print; +#endif k->get_dev_path = pcibus_get_dev_path; k->get_fw_dev_path = pcibus_get_fw_dev_path; k->realize = pci_bus_realize; diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 8bd25a9d872a..5cc5ffec33a1 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -13,7 +13,9 @@ #include "trace.h" #include "qemu/cutils.h" +#ifdef CONFIG_HMP static void usb_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent); +#endif static char *usb_get_dev_path(DeviceState *dev); static char *usb_get_fw_dev_path(DeviceState *qdev); @@ -32,7 +34,9 @@ static void usb_bus_class_init(ObjectClass *klass, const void *data) BusClass *k = BUS_CLASS(klass); HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass); +#ifdef CONFIG_HMP k->print_dev = usb_bus_dev_print; +#endif k->get_dev_path = usb_get_dev_path; k->get_fw_dev_path = usb_get_fw_dev_path; hc->unplug = qdev_simple_device_unplug_cb; @@ -544,6 +548,7 @@ static const char *usb_speed(unsigned int speed) return txt[speed]; } +#ifdef CONFIG_HMP static void usb_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent) { USBDevice *dev = USB_DEVICE(qdev); @@ -555,6 +560,7 @@ static void usb_bus_dev_print(MonitorHMP *hmp, DeviceState *qdev, int indent) usb_speed(dev->speed), dev->product_desc, dev->attached ? ", attached" : ""); } +#endif static char *usb_get_dev_path(DeviceState *qdev) { diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index b81a067e7753..1762816bf469 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -101,6 +101,7 @@ abort: qemu_xen_xs_transaction_end(xenbus->xsh, tid, true); } +#ifdef CONFIG_HMP static void xen_bus_print_dev(MonitorHMP *hmp, DeviceState *dev, int indent) { XenDevice *xendev = XEN_DEVICE(dev); @@ -108,6 +109,7 @@ static void xen_bus_print_dev(MonitorHMP *hmp, DeviceState *dev, int indent) monitor_hmp_printf(hmp, "%*sname = '%s' frontend_id = %u\n", indent, "", xendev->name, xendev->frontend_id); } +#endif static char *xen_bus_get_dev_path(DeviceState *dev) { @@ -386,7 +388,9 @@ static void xen_bus_class_init(ObjectClass *class, const void *data) BusClass *bus_class = BUS_CLASS(class); HotplugHandlerClass *hotplug_class = HOTPLUG_HANDLER_CLASS(class); +#ifdef CONFIG_HMP bus_class->print_dev = xen_bus_print_dev; +#endif bus_class->get_dev_path = xen_bus_get_dev_path; bus_class->realize = xen_bus_realize; bus_class->unrealize = xen_bus_unrealize; diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index 1391dc060caf..f054a214fc6a 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -323,8 +323,10 @@ DECLARE_OBJ_CHECKERS(BusState, BusClass, struct BusClass { ObjectClass parent_class; +#ifdef CONFIG_HMP /* FIXME first arg should be BusState */ void (*print_dev)(MonitorHMP *mon, DeviceState *dev, int indent); +#endif /* * Return a newly allocated string containing the path of the * device on this bus. -- 2.55.0.543.g5ebe2ebe4ea8