qmp: query-device-slots command
RFC v3 1/1 qmp: query-device-slots command
Changes v2 -> v3:
* Implemented a "slot set" structure, where multiple slots can be reported by using integer ranges or lists for possible values for each property. Added a ValueSet struct, that can represent a set of values using either a simple list of values, or integer ranges. (Its JSON representation is very verbose, though. See comments below).
* Removed the *Properties structs, and replaced them with a simple list of SlotOption structs.
* DeviceSlotInfo is not an union anymore, removed the 'type' field only because there are no slot-type-specific fields in the current implementation, but we may add it back if necessary
* The implementation is very quick and dirty, the main purpose of this RFC is to evaluate the schema and returned data.
Changes v1 -> v2:
* Don't show sysbus unless has_dynamic_sysbus is set for the machine type
* Removed max-devices and devices properties
* Introduced "non-slot" slot type, to explicitly indicate we are returning info on a bus that doesn't implement slot enumeration yet.
* Return bus name instead of full QOM path on "bus" field
* PCI: Replaced "addr" property (string parsed by property setter) with "device-number" uint32 property
* PCI: return only one slot for PCIe ports
This adds a new command to QMP: query-device-slots. It will allow management software to query possible slots where devices can be plugged.
This implementation of the command will return:
* Multiple PCI slots per bus, in the case of PCI buses;
* One slot per bus for the other buses (that don't implement slot enumeration yet);
* One slot for each entry from query-hotpluggable-cpus.
Representation of slot sets in JSON
-----------------------------------
Slot sets are represented by a list of option names and sets of possible values for each of those options. See the SlotOption struct below for details.
The representation of those sets is very verbose in this version (see below). e.g. the following set of 5 PCI functions:
bus: pcie.0
device-number: 31
function: 1,4-7Is represented in the JSON data as:
"props": [
{
"values": {
"data": {
"ranges": [
{ "max": 1, "min": 1 },
{ "max": 7, "min": 4 }
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [ { "max": 31, "min": 31 } ]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [ "pcie.0" ],
"type": "list"
},
"option": "bus"
}
]We could have used something more compact like:
function: 1,4-7
device-number: 31
bus: pcie.0 "props": {
"function": [ 1, { 'min': 4, 'max': 7 } ],
"device-number": 31,
"bus": "pcie.0"
}But this would probably cost us the ability of describing and validating the exact representation using the QAPI schema. I don't know which way we should go.
QAPI schema
-----------
The following structures were added to the QAPI schema:
{ 'struct': 'IntegerSet',
'data': { 'ranges': [ 'IntegerRange' ] } }
{ 'struct': 'IntegerRange',
'data': { 'min': 'int', 'max': 'int' } }
{ 'union': 'ValueSet',
'data': { 'list': [ 'any' ], 'int-set': 'IntegerSet' } }
{ 'struct': 'SlotOption',
'data': { 'option': 'str', 'values': 'ValueSet' } }
{ 'struct': 'DeviceSlotInfo',
'data': { 'accepted-device-types': [ 'str' ],
'available': 'bool', 'hotpluggable': 'bool',
'*count': 'int', 'incomplete': 'bool',
'props': [ 'SlotOption' ] } }{ 'command': 'query-device-slots',
'returns': [ 'DeviceSlotInfo' ] }
Git tree
--------
This patch needs the previous query-machines series I am working on. The full tree can be found on the git tree at:
git://github.com/ehabkost/qemu-hacks.git work/query-machines-bus-info
Example output
--------------
The following output was returned by QEMU when running it as:
$ qemu-system-x86_64 -machine q35 \ -readconfig docs/q35-chipset.cfg \ -smp 4,maxcpus=8,sockets=2,cores=2,threads=2
As the JSON output is now quite verbose, I am including the output of a script that translates the JSON data to a more human-friendly format:
Slot set for: i2c-slave
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: i2c
Slot set for: ide-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ide.4
Slot set for: ide-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ide.5
Slot set for: ide-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ide.0
Slot set for: ide-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ide.1
Slot set for: ide-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ide.2
Slot set for: ide-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ide.3
Slot set for: sys-bus-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: main-system-bus
Slot set for: isa-device
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: isa.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 0
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 7
available: yes
hotpluggable: no
valid device_add arguments:
function: 1-7
device-number: 0
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 1
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 7
available: yes
hotpluggable: no
valid device_add arguments:
function: 1-7
device-number: 1
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 2
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 7
available: yes
hotpluggable: no
valid device_add arguments:
function: 1-7
device-number: 2
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 26
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 1
device-number: 26
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 2
device-number: 26
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 7
device-number: 26
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 4
available: yes
hotpluggable: no
valid device_add arguments:
function: 3-6
device-number: 26
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 27
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 7
available: yes
hotpluggable: no
valid device_add arguments:
function: 1-7
device-number: 27
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 28
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 1
device-number: 28
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 2
device-number: 28
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 3
device-number: 28
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 4
available: yes
hotpluggable: no
valid device_add arguments:
function: 4-7
device-number: 28
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 29
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 1
device-number: 29
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 2
device-number: 29
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 7
device-number: 29
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 4
available: yes
hotpluggable: no
valid device_add arguments:
function: 3-6
device-number: 29
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 30
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 7
available: yes
hotpluggable: no
valid device_add arguments:
function: 1-7
device-number: 30
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 0
device-number: 31
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 2
device-number: 31
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 1
available: no
hotpluggable: no
valid device_add arguments:
function: 3
device-number: 31
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 5
available: yes
hotpluggable: no
valid device_add arguments:
function: 1,4-7
device-number: 31
bus: pcie.0
Slot set for: legacy-pci-device, pci-express-device
Slot count: 184
available: yes
hotpluggable: no
valid device_add arguments:
function: 0-7
device-number: 3-25
bus: pcie.0
Slot set for: pci-express-device
Slot count: 8
available: yes
hotpluggable: yes
valid device_add arguments:
function: 0-7
device-number: 0
bus: ich9-pcie-port-1
Slot set for: pci-express-device
Slot count: 8
available: yes
hotpluggable: yes
valid device_add arguments:
function: 0-7
device-number: 0
bus: ich9-pcie-port-2
Slot set for: pci-express-device
Slot count: 8
available: yes
hotpluggable: yes
valid device_add arguments:
function: 0-7
device-number: 0
bus: ich9-pcie-port-3
Slot set for: pci-express-device
Slot count: 8
available: yes
hotpluggable: yes
valid device_add arguments:
function: 0-7
device-number: 0
bus: ich9-pcie-port-4
Slot set for: legacy-pci-device
Slot count: 256
available: yes
hotpluggable: no
valid device_add arguments:
function: 0-7
device-number: 0-31
bus: ich9-pci-bridge Slot set for: usb-device
Incomplete set
available: yes
hotpluggable: yes
valid device_add arguments:
bus: ich9-ehci-1.0
Slot set for: usb-device
Incomplete set
available: yes
hotpluggable: yes
valid device_add arguments:
bus: ich9-ehci-2.0
Slot set for: hda-codec
Incomplete set
available: no
hotpluggable: no
valid device_add arguments:
bus: ich9-hda-audio.0
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: yes
hotpluggable: yes
valid device_add arguments:
socket-id: 1
thread-id: 1
core-id: 1
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: yes
hotpluggable: yes
valid device_add arguments:
socket-id: 1
thread-id: 0
core-id: 1
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: yes
hotpluggable: yes
valid device_add arguments:
socket-id: 1
thread-id: 1
core-id: 0
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: yes
hotpluggable: yes
valid device_add arguments:
socket-id: 1
thread-id: 0
core-id: 0
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: no
hotpluggable: yes
valid device_add arguments:
socket-id: 0
thread-id: 1
core-id: 1
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: no
hotpluggable: yes
valid device_add arguments:
socket-id: 0
thread-id: 0
core-id: 1
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: no
hotpluggable: yes
valid device_add arguments:
socket-id: 0
thread-id: 1
core-id: 0
Slot set for: qemu64-x86_64-cpu
Slot count: 1
available: no
hotpluggable: yes
valid device_add arguments:
socket-id: 0
thread-id: 0
core-id: 0
Raw JSON data for the above:
{
"return": [
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"i2c"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"i2c-slave"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ide.4"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"ide-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ide.5"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"ide-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ide.0"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"ide-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ide.1"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"ide-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ide.2"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"ide-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ide.3"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"ide-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"main-system-bus"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"sys-bus-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"isa.0"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"isa-device"
]
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 7,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 1,
"min": 1
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 7,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 1,
"min": 1
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 2,
"min": 2
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 7,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 2,
"min": 2
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 26,
"min": 26
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 1,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 26,
"min": 26
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 2,
"min": 2
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 26,
"min": 26
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 7
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 26,
"min": 26
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 4,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 6,
"min": 3
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 26,
"min": 26
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 27,
"min": 27
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 7,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 27,
"min": 27
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 28,
"min": 28
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 1,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 28,
"min": 28
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 2,
"min": 2
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 28,
"min": 28
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 3,
"min": 3
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 28,
"min": 28
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 4,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 4
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 28,
"min": 28
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 29,
"min": 29
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 1,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 29,
"min": 29
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 2,
"min": 2
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 29,
"min": 29
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 7
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 29,
"min": 29
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 4,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 6,
"min": 3
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 29,
"min": 29
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 30,
"min": 30
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 7,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 1
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 30,
"min": 30
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 31,
"min": 31
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 2,
"min": 2
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 31,
"min": 31
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 3,
"min": 3
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 31,
"min": 31
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 5,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 1,
"min": 1
},
{
"max": 7,
"min": 4
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 31,
"min": 31
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 184,
"accepted-device-types": [
"legacy-pci-device",
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 25,
"min": 3
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"pcie.0"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"count": 8,
"accepted-device-types": [
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"ich9-pcie-port-1"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 8,
"accepted-device-types": [
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"ich9-pcie-port-2"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 8,
"accepted-device-types": [
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"ich9-pcie-port-3"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 8,
"accepted-device-types": [
"pci-express-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 0,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"ich9-pcie-port-4"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 256,
"accepted-device-types": [
"legacy-pci-device"
],
"props": [
{
"values": {
"data": {
"ranges": [
{
"max": 7,
"min": 0
}
]
},
"type": "int-set"
},
"option": "function"
},
{
"values": {
"data": {
"ranges": [
{
"max": 31,
"min": 0
}
]
},
"type": "int-set"
},
"option": "device-number"
},
{
"values": {
"data": [
"ich9-pci-bridge"
],
"type": "list"
},
"option": "bus"
}
],
"hotpluggable": false,
"incomplete": false
},
{
"available": true,
"hotpluggable": true,
"props": [
{
"values": {
"data": [
"ich9-ehci-1.0"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"usb-device"
]
},
{
"available": true,
"hotpluggable": true,
"props": [
{
"values": {
"data": [
"ich9-ehci-2.0"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"usb-device"
]
},
{
"available": false,
"hotpluggable": false,
"props": [
{
"values": {
"data": [
"ich9-hda-audio.0"
],
"type": "list"
},
"option": "bus"
}
],
"incomplete": true,
"accepted-device-types": [
"hda-codec"
]
},
{
"available": true,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": true,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
1
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
},
{
"available": false,
"count": 1,
"accepted-device-types": [
"qemu64-x86_64-cpu"
],
"props": [
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "socket-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "thread-id"
},
{
"values": {
"data": [
0
],
"type": "list"
},
"option": "core-id"
}
],
"hotpluggable": true,
"incomplete": false
}
]
}---
--- qapi-schema.json | 109 ++++++++++ scripts/qmp/query-slots.py | 50 +++++ include/hw/qdev-core.h | 6 + include/qapi/qobject-output-visitor.h | 9 + hw/core/bus.c | 45 +++++ hw/pci/pci.c | 363 +++++++++++++++++++++++++++++++--- qapi/qobject-output-visitor.c | 14 ++ qdev-monitor.c | 128 +++++++++++- tests/qmp-machine-info.py | 72 +++++-- 9 files changed, 746 insertions(+), 50 deletions(-) create mode 100755 scripts/qmp/query-slots.py
qapi-schema.json +109 -0
@@ -3165,6 +3165,115 @@ ## { 'command': 'closefd', 'data': {'fdname': 'str'} } + +## +# @IntegerSet: +# +# A set of integers. +## +{ 'struct': 'IntegerSet', + 'data': { 'ranges': [ 'IntegerRange' ] } } + +## +# @IntegerRange: +# +# A contiguous range of integers. +# +# @min: The first value in the range +# @max: The last value in the range +## +{ 'struct': 'IntegerRange', + 'data': { 'min': 'int', 'max': 'int' } } + +## +# @ValueSet: +# +# A set of values. +# +# @list: A set of elements in a list. +# +# @int-set: A set represented by an IntegerSet. +## +{ 'union': 'ValueSet', + 'data': { 'list': [ 'any' ], 'int-set': 'IntegerSet' } } + +## +# @SlotOption: +# +# A option to be used when plugging a device to a slot. +# +# @option: Option name. +# +# @values: Set of valid option values. +## +{ 'struct': 'SlotOption', + 'data': { 'option': 'str', 'values': 'ValueSet' } } + +## +# @DeviceSlotInfo: +# +# Information on a set of slots where devices can be plugged. +# +# @type: type of device slot. +# +# @accepted-device-types: List of device types accepted by the slots. +# Any device plugged to the slot should implement +# one of the accepted device types. +# +# @available: If false, the slot is not available for plugging any device. +# This value can change at runtime if condition changes +# (e.g. if the slot becomes full, or if the machine +# was already initialized and the slot doesn't support +# hotplug). +# +# @hotpluggable: If true, the slot accepts hotplugged devices. +# +# @count: #optional Number of slots represented by this slot set. +# Will always be present if @incomplete=false. +# +# @incomplete: Slot information is incomplete. Slot count is not +# available, and additional arguments are missing +# on @props. +# +# @props: Information on the arguments that should be given to +# @device_add if plugging a device to this slot. +# +# How to interpret @props +# ----------------------- +# +# Each key/value pair in @props represent an option that should +# be set when using @device_add to plug a new device. +# +# Each value in @props represent a single value that should be +# provided to @device_add, or a set of possible values for the option. +# +# Incomplete Slot Sets +# -------------------- +# +# Slot sets with @incomplete=true represent a bus that doesn't +# support slot enumeration yet. Slots of this type should be replaced +# by more detailed slot sets in future QEMU versions. +# +# Slots of this type may or may not support multiple devices. +# +# Slots in incomplete slot sets might require extra arguments to +# be set to specify the device address. +## +{ 'struct': 'DeviceSlotInfo', + 'data': { 'accepted-device-types': [ 'str' ], + 'available': 'bool', 'hotpluggable': 'bool', + '*count': 'int', 'incomplete': 'bool', + 'props': [ 'SlotOption' ] } } + +## +# @query-device-slots: +# +# Return the list of possible slots for plugging devices using +# @device_add. +## +{ 'command': 'query-device-slots', + 'returns': [ 'DeviceSlotInfo' ] } + ## # @MachineBusInfo #
scripts/qmp/query-slots.py new file +50 -0
50 lines not on this page · raw message
include/hw/qdev-core.h +6 -0
@@ -214,6 +214,10 @@ struct BusClass {* but on some cases bus instances may override it. */ const char *device_type; + +/*TODO: write doc */ + DeviceSlotInfoList *(*enumerate_slots)(BusState *bus, Error **errp); + }; typedef struct BusChild {
@@ -412,4 +416,6 @@ static inline bool qbus_is_hotpluggable(BusState *bus)void device_listener_register (DeviceListener *listener);void device_listener_unregister (DeviceListener *listener); +bool qbus_is_full (BusState *bus); +#endif
include/qapi/qobject-output-visitor.h +9 -0
@@ -16,6 +16,7 @@#include "qapi/visitor.h" #include "qapi/qmp/qobject.h" +#include "qapi/error.h" typedef struct QObjectOutputVisitor QObjectOutputVisitor ;
@@ -27,4 +28,12 @@ typedef struct QObjectOutputVisitor QObjectOutputVisitor;*/ Visitor *qobject_output_visitor_new (QObject **result); +QObject *qapi_to_qobject (const void *src, +void (*visit_fn)(Visitor *,const char *, +void **,Error **)); + +#define QAPI_TO_QOBJ (type, src) \ + (qapi_to_qobject((src), (void (*)(Visitor *, const char *, void**, \ + Error **))visit_type_ ## type)) +#endif
hw/core/bus.c +45 -0
64 lines not on this page · raw message
hw/pci/pci.c +336 -27
405 lines not on this page · raw message
qapi/qobject-output-visitor.c +14 -0
@@ -252,3 +252,17 @@ Visitor *qobject_output_visitor_new(QObject **result)return &v->visitor; } + +QObject *qapi_to_qobject (const void *src, +void (*visit_fn)(Visitor *,const char *, +void **,Error **)) +{ +QObject *qobj =NULL ; +void *obj = (void *) src; +Visitor *v =qobject_output_visitor_new (&qobj); + +visit_fn (v,"unused" , &obj, &error_abort); +visit_complete (v, &qobj); +visit_free (v); +return qobj; +}
qdev-monitor.c +122 -6
146 lines not on this page · raw message
tests/qmp-machine-info.py +55 -17
103 lines not on this page · raw message
Signature · 1 line
2.7.4