qga: Introduce NVMe disk bus type
PATCH v2 1/1 qga: Introduce NVMe disk bus type
Assigning a NVMe disk by VFIO or emulating a NVMe controller by QEMU, a NVMe disk get exposed in guest side. Support NVMe disk bus type and implement posix version.
Test PCI passthrough case:
~#virsh qemu-agent-command buster '{"execute":"guest-get-disks"}' | jq
...
{
"name": "/dev/nvme0n1",
"dependencies": [],
"partition": false,
"address": {
"serial": "SAMSUNG MZQL23T8HCLS-00A07_S64HNE0N500076",
"bus-type": "nvme",
"bus": 0,
"unit": 0,
"pci-controller": {
"bus": 0,
"slot": 22,
"domain": 0,
"function": 0
},
"dev": "/dev/nvme0n1",
"target": 0
}...
--- qga/commands-posix.c | 5 ++++- qga/qapi-schema.json | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)
qga/commands-posix.c +4 -1
@@ -889,7 +889,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,if (driver && (g_str_equal (driver,"ata_piix" ) ||g_str_equal (driver,"sym53c8xx" ) ||g_str_equal (driver,"virtio-pci" ) || -g_str_equal (driver,"ahci" ))) { +g_str_equal (driver,"ahci" ) || +g_str_equal (driver,"nvme" ))) {break ; }
@@ -984,6 +985,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,g_debug ("no host for '%s' (driver '%s')" , syspath, driver); goto cleanup; } + }else if (strcmp (driver,"nvme" ) ==0 ) { + disk->bus_type =GUEST_DISK_BUS_TYPE_NVME ; }else {g_debug ("unknown driver '%s' (sysfs path '%s')" , driver, syspath); goto cleanup;
qga/qapi-schema.json +2 -1
@@ -827,13 +827,14 @@ # @mmc: Win multimedia card (MMC) bus type # @virtual: Win virtual bus type # @file-backed-virtual: Win file-backed bus type +# @nvme: NVMe disks (since 6.3) # # Since: 2.2; 'Unknown' and all entries below since 2.4 ## { 'enum': 'GuestDiskBusType', 'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata', 'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi', - 'sas', 'mmc', 'virtual', 'file-backed-virtual' ] } + 'sas', 'mmc', 'virtual', 'file-backed-virtual', 'nvme' ] } ##
Signature · 1 line
2.20.1
Quoted 25 lines · zhenwei pi
Assigning a NVMe disk by VFIO or emulating a NVMe controller by QEMU, a NVMe disk get exposed in guest side. Support NVMe disk bus type and implement posix version.
Test PCI passthrough case:
~#virsh qemu-agent-command buster '{"execute":"guest-get-disks"}' | jq
...{ "name": "/dev/nvme0n1", "dependencies": [], "partition": false, "address": { "serial": "SAMSUNG MZQL23T8HCLS-00A07_S64HNE0N500076", "bus-type": "nvme", "bus": 0, "unit": 0, "pci-controller": { "bus": 0, "slot": 22, "domain": 0, "function": 0 }, "dev": "/dev/nvme0n1", "target": 0 }
Quoted 4 lines
...
Signed-off-by zhenwei pi <[email protected]>
Quoted 54 lines
--- qga/commands-posix.c | 5 ++++- qga/qapi-schema.json | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)qga/commands-posix.c +4
-1@@ -889,7 +889,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath, if (driver && (g_str_equal(driver, "ata_piix") ||g_str_equal (driver,"sym53c8xx" ) ||g_str_equal (driver,"virtio-pci" ) || - g_str_equal(driver, "ahci"))) { +g_str_equal (driver,"ahci" ) || + g_str_equal(driver, "nvme"))) {break ; }@@ -984,6 +985,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,g_debug ("no host for '%s' (driver '%s')" , syspath, driver); goto cleanup; } + }else if (strcmp (driver,"nvme" ) ==0 ) { + disk->bus_type =GUEST_DISK_BUS_TYPE_NVME ; }else {g_debug ("unknown driver '%s' (sysfs path '%s')" , driver, syspath);goto cleanup;qga/qapi-schema.json +2
-2@@ -827,13 +827,14 @@ # @mmc: Win multimedia card (MMC) bus type # @virtual: Win virtual bus type # @file-backed-virtual: Win file-backed bus type +# @nvme: NVMe disks (since 6.3) # # Since: 2.2; 'Unknown' and all entries below since 2.4 ## { 'enum': 'GuestDiskBusType', 'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata', 'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi', - 'sas', 'mmc', 'virtual', 'file-backed-virtual' ] } + 'sas', 'mmc', 'virtual', 'file-backed-virtual', 'nvme' ] } ## --2.20.1
Signature · 1 line
Marc-André Lureau
Quoted 38 lines · zhenwei pi
Assigning a NVMe disk by VFIO or emulating a NVMe controller by QEMU, a NVMe disk get exposed in guest side. Support NVMe disk bus type and implement posix version.
Test PCI passthrough case:
~#virsh qemu-agent-command buster '{"execute":"guest-get-disks"}' | jq
...{ "name": "/dev/nvme0n1", "dependencies": [], "partition": false, "address": { "serial": "SAMSUNG MZQL23T8HCLS-00A07_S64HNE0N500076", "bus-type": "nvme", "bus": 0, "unit": 0, "pci-controller": { "bus": 0, "slot": 22, "domain": 0, "function": 0 }, "dev": "/dev/nvme0n1", "target": 0 }...
Signed-off-by zhenwei pi <[email protected]>--- qga/commands-posix.c | 5 ++++- qga/qapi-schema.json | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)qga/qapi-schema.json +0
-0
qga/qapi-schema.json line 830
Quoted 4 lines
qga/qapi-schema.json +1
-0@@ -827,13 +827,14 @@ # @mmc: Win multimedia card (MMC) bus type # @virtual: Win virtual bus type # @file-backed-virtual: Win file-backed bus type +# @nvme: NVMe disks (since 6.3)
Next release will be 7.0, not 6.3.
With that fixed: