From: KONRAD Frederic <fred.kon...@greensocs.com> As said on IRC, I send only VirtioBus as old implementation of VirtioPCI is not longer making sense after the changes on VirtioBus.
As anthony said, the better way to do this refactoring is : * Introducing a virtio-bus which extends bus-state. * Implementing a virtio-pci-bus which extends virtio-bus. * Implementing virtio-device which extends device-states. This patch introduce virtio-bus, which is abstract and extends bus-state. The VirtioBusClass still has init and exit methods, which must be called by the VirtIODevice, and have all the VirtioBindings methods. The futur virtio-x-bus, will have to implement this methods to be a virtio-bus. The second patch is a modification of qdev-monitor.c, it forces the function qbus_find_recursive(..) to return a non full bus, and return an error if the desired bus ( with "bus=" option ) is full. It add a max_dev field to the bus_state structure. If max_dev=0 it has no limitation, if not the maximum amount of device connected to the bus is max_dev. Changes v2 -> v3: * Added VirtioBusClass. * Renamed VirtioBus -> VirtioBusState. * Renamed qbus -> parent_obj. * Plug the device only in a non-full bus. Changes v1 -> v2: * All the little fix you suggest ( License, Debug printf, naming convention, ...) * Added get_virtio_device_id(), and remove the pci_id* from the VirtioBus structure. * Added virtio_bus_reset(). * Added cast macros VIRTIO_BUS. * Added virtio_bus_plug_device. * Replaced the old-style "bus->qbus" by BUS() macro. Fred KONRAD Frederic (2): virtio-bus : Introduce virtio-bus qbus : add a maximum device. hw/qdev-core.h | 1 + hw/qdev-monitor.c | 12 +++++ hw/virtio-bus.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-bus.h | 74 +++++++++++++++++++++++++++++++++ 4 files changed, 205 insertions(+), 0 deletions(-) create mode 100644 hw/virtio-bus.c create mode 100644 hw/virtio-bus.h