By default, QEMU will allow devices to be plugged into a bus up to the bus class's device count limit. If the user creates a device on the command line or via the monitor and doesn't explicitly specify the bus to plug it in, QEMU will plug it into the first non-full bus that it finds.
This is fine in most cases, but some machines have multiple buses of a given type, some of which are dedicated to on-board devices and some of which have an externally exposed connector for user-pluggable devices. In particular, the various MPS2 and MPS3 boards have multiple I2C buses. Some of these are used purely for on-board devices like the touchscreen controller or the DDR4 EEPROM, and some are routed to the "shield" expansion connector. Currently if the user creates an I2C device (eg with "-device tmp105") it gets plugged into whatever the search happens to find first, which for some of these boards is one of the internal-devices-only buses. The first patch in this series adds a new function qbus_mark_full() which marks an individual qbus as full, and makes the "find an available bus" search code honour that. The intention is that the board code can handle internal-devices-only buses like * create the bus controller * create all the internal devices, and plug them into that bus * call qbus_mark_full() on the bus Patches 2-4 use this to mark the internal-only i2c buses on the various mps2/mps3 machines as 'full'. (As it happens, we don't model any of the internal i2c devices on these boards yet, so the 'full' buses won't have any devices on them.) This is a minor behaviour change for existing command-lines for these boards, since an i2c device will now get plugged in in a different place; but none of these boards are versioned and very few people will be manually creating i2c devices anyway. thanks -- PMM Peter Maydell (4): qdev: Support marking individual buses as 'full' hw/arm/mps2-tz.c: Add extra data parameter to MakeDevFn hw/arm/mps2-tz.c: Mark internal-only I2C buses as 'full' hw/arm/mps2.c: Mark internal-only I2C buses as 'full' include/hw/qdev-core.h | 24 +++++++++++ hw/arm/mps2-tz.c | 92 +++++++++++++++++++++++++++++------------- hw/arm/mps2.c | 12 +++++- softmmu/qdev-monitor.c | 7 +++- 4 files changed, 106 insertions(+), 29 deletions(-) -- 2.20.1
