[libvirt] [PATCH v3 00/17] qemu: virtio-{non-}transitional support

v2 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00877.html v1 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00593.html Previous incomplete RFC here: https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html qemu patches, queued for qemu 4.0.0: https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html Previous libvirt discussion around this: https://www.redhat.com/archives/libvir-list/2018-August/msg01073.html Changes since v2: * Some prep patches merged * filesystem model dropped the -9p naming, now uses virtio-{non-}transitional like other devices * Now uses a single capability QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL which is set whenever any of the -transitional or -non-transitional devices are present. * Add a formatdomain section 'Virtio transitional devices' and reference it from each relevant device section * if virtio-transitional specified, and qemu is too old but has the disable_X options, convert it to explicit disable-legacy=off,disable-modern=off * Misc small changes pointed out in review Thanks, Cole Cole Robinson (17): qemu: command: Add qemuCaps to BuildVirtioStr qemu: capabilities: Add virtio/vhost {non-}transitional conf: Add <disk model='virtio-{non-}transitional'/> qemu: Support disk model=virtio-{non-}transitional qemu: Support interface model=virtio-{non-}transitional conf: Add <hostdev model='virtio-{non-}transitional'/> qemu: Support hostdev model=virtio-{non-}transitional qemu: Support rng model=virtio-{non-}transitional conf: Add <filesystem model='virtio-{non-}transitional'/> qemu: Support filesystem model=virtio-{non-}transitional qemu: Support memballoon model=virtio-{non-}transitional qemu: Support vsock model=virtio-{non-}transitional conf: Add <input model='virtio-{non-}transitional'/> qemu: Support input model=virtio-{non-}transitional qemu: Support virtio-serial controller model=virtio-{non-}transitional qemu: Support scsi controller model=virtio-{non-}transitional qemu: domcaps: Report disk <enum name="model"> docs/formatdomain.html.in | 97 ++++++++- docs/schemas/domaincommon.rng | 61 +++++- src/conf/domain_capabilities.c | 1 + src/conf/domain_capabilities.h | 1 + src/conf/domain_conf.c | 184 ++++++++++++++++-- src/conf/domain_conf.h | 63 ++++++ src/libvirt_private.syms | 4 + src/libxl/libxl_conf.c | 2 + src/qemu/qemu_capabilities.c | 31 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 150 ++++++++++++-- src/qemu/qemu_domain.c | 17 +- src/qemu/qemu_domain_address.c | 110 +++++++++-- src/vbox/vbox_common.c | 2 + src/vmx/vmx.c | 5 +- .../bhyve_basic.x86_64.xml | 1 + .../bhyve_fbuf.x86_64.xml | 1 + .../bhyve_uefi.x86_64.xml | 1 + tests/domaincapsschemadata/full.xml | 6 + .../domaincapsschemadata/libxl-xenfv-usb.xml | 1 + .../domaincapsschemadata/libxl-xenpv-usb.xml | 1 + .../qemu_1.7.0.x86_64.xml | 3 + .../qemu_2.12.0-virt.aarch64.xml | 5 + .../qemu_2.12.0.ppc64.xml | 5 + .../qemu_2.12.0.s390x.xml | 5 + .../qemu_2.12.0.x86_64.xml | 5 + .../qemu_2.6.0-virt.aarch64.xml | 5 + .../qemu_2.6.0.aarch64.xml | 5 + .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 5 + .../qemu_2.6.0.x86_64.xml | 5 + .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 5 + .../qemu_2.8.0-tcg.x86_64.xml | 5 + .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 5 + .../qemu_2.8.0.x86_64.xml | 5 + .../qemu_2.9.0-q35.x86_64.xml | 5 + .../qemu_2.9.0-tcg.x86_64.xml | 5 + .../qemu_2.9.0.x86_64.xml | 5 + .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 5 + .../qemu_4.0.0.x86_64.xml | 153 +++++++++++++++ tests/domaincapstest.c | 4 + .../caps_4.0.0.riscv32.xml | 1 + .../caps_4.0.0.riscv64.xml | 1 + .../caps_4.0.0.x86_64.xml | 1 + .../virtio-non-transitional.x86_64-3.1.0.args | 65 +++++++ ...virtio-non-transitional.x86_64-latest.args | 62 ++++++ .../virtio-non-transitional.xml | 39 ++++ .../virtio-transitional.x86_64-3.1.0.args | 56 ++++++ .../virtio-transitional.x86_64-latest.args | 52 +++++ .../qemuxml2argvdata/virtio-transitional.xml | 39 ++++ tests/qemuxml2argvtest.c | 6 + .../virtio-non-transitional.xml | 121 ++++++++++++ .../virtio-transitional.xml | 80 ++++++++ tests/qemuxml2xmltest.c | 17 ++ 53 files changed, 1470 insertions(+), 50 deletions(-) create mode 100644 tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.xml create mode 100644 tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args create mode 100644 tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-transitional.xml create mode 100644 tests/qemuxml2xmloutdata/virtio-non-transitional.xml create mode 100644 tests/qemuxml2xmloutdata/virtio-transitional.xml -- 2.20.1

It will be used in future patches Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 572d3bc20f..a26f6291ac 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -409,6 +409,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, * qemuBuildVirtioDevStr * @buf: virBufferPtr to append the built string * @baseName: qemu virtio device basename string. Ex: virtio-rng for <rng> + * @qemuCaps: virQEMUCapPtr * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG * @devdata: *DefPtr of the device definition * @@ -422,6 +423,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, static int qemuBuildVirtioDevStr(virBufferPtr buf, const char *baseName, + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, virDomainDeviceType devtype, void *devdata) { @@ -2078,7 +2080,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, break; case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (qemuBuildVirtioDevStr(&opt, "virtio-blk", + if (qemuBuildVirtioDevStr(&opt, "virtio-blk", qemuCaps, VIR_DOMAIN_DEVICE_DISK, disk) < 0) { goto error; } @@ -2673,7 +2675,7 @@ qemuBuildFSDevStr(const virDomainDef *def, goto error; } - if (qemuBuildVirtioDevStr(&opt, "virtio-9p", + if (qemuBuildVirtioDevStr(&opt, "virtio-9p", qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) < 0) { goto error; } @@ -2880,7 +2882,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch ((virDomainControllerModelSCSI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - if (qemuBuildVirtioDevStr(&buf, "virtio-scsi", + if (qemuBuildVirtioDevStr(&buf, "virtio-scsi", qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { goto error; } @@ -2923,7 +2925,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, break; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - if (qemuBuildVirtioDevStr(&buf, "virtio-serial", + if (qemuBuildVirtioDevStr(&buf, "virtio-serial", qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { goto error; } @@ -3745,7 +3747,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, char macaddr[VIR_MAC_STRING_BUFLEN]; if (virDomainNetIsVirtioModel(net)) { - if (qemuBuildVirtioDevStr(&buf, "virtio-net", + if (qemuBuildVirtioDevStr(&buf, "virtio-net", qemuCaps, VIR_DOMAIN_DEVICE_NET, net) < 0) { goto error; } @@ -4141,7 +4143,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd, if (!virDomainDefHasMemballoon(def)) return 0; - if (qemuBuildVirtioDevStr(&buf, "virtio-balloon", + if (qemuBuildVirtioDevStr(&buf, "virtio-balloon", qemuCaps, VIR_DOMAIN_DEVICE_MEMBALLOON, def->memballoon) < 0) { goto error; @@ -4241,25 +4243,25 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, switch ((virDomainInputType)dev->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: - if (qemuBuildVirtioDevStr(&buf, "virtio-mouse", + if (qemuBuildVirtioDevStr(&buf, "virtio-mouse", qemuCaps, VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { goto error; } break; case VIR_DOMAIN_INPUT_TYPE_TABLET: - if (qemuBuildVirtioDevStr(&buf, "virtio-tablet", + if (qemuBuildVirtioDevStr(&buf, "virtio-tablet", qemuCaps, VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { goto error; } break; case VIR_DOMAIN_INPUT_TYPE_KBD: - if (qemuBuildVirtioDevStr(&buf, "virtio-keyboard", + if (qemuBuildVirtioDevStr(&buf, "virtio-keyboard", qemuCaps, VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { goto error; } break; case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: - if (qemuBuildVirtioDevStr(&buf, "virtio-input-host", + if (qemuBuildVirtioDevStr(&buf, "virtio-input-host", qemuCaps, VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { goto error; } @@ -4580,7 +4582,7 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, } if (STREQ(model, "virtio-gpu")) { - if (qemuBuildVirtioDevStr(&buf, "virtio-gpu", + if (qemuBuildVirtioDevStr(&buf, "virtio-gpu", qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { goto error; } @@ -5028,7 +5030,7 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, goto cleanup; } - if (qemuBuildVirtioDevStr(&buf, "vhost-scsi", + if (qemuBuildVirtioDevStr(&buf, "vhost-scsi", qemuCaps, VIR_DOMAIN_DEVICE_HOSTDEV, dev) < 0) { goto cleanup; } @@ -5978,7 +5980,7 @@ qemuBuildRNGDevStr(const virDomainDef *def, dev->source.file)) goto error; - if (qemuBuildVirtioDevStr(&buf, "virtio-rng", + if (qemuBuildVirtioDevStr(&buf, "virtio-rng", qemuCaps, VIR_DOMAIN_DEVICE_RNG, dev) < 0) { goto error; } @@ -10449,7 +10451,7 @@ qemuBuildVsockDevStr(virDomainDefPtr def, char *ret = NULL; - if (qemuBuildVirtioDevStr(&buf, "vhost-vsock", + if (qemuBuildVirtioDevStr(&buf, "vhost-vsock", qemuCaps, VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) { goto cleanup; } -- 2.20.1

Add a single QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL that will be set if any of the following qemu devices are found: virtio-blk-pci-transitional virtio-blk-pci-non-transitional virtio-net-pci-transitional virtio-net-pci-non-transitional vhost-scsi-pci-transitional vhost-scsi-pci-non-transitional virtio-rng-pci-transitional virtio-rng-pci-non-transitional virtio-9p-pci-transitional virtio-9p-pci-non-transitional virtio-balloon-pci-transitional virtio-balloon-pci-non-transitional vhost-vsock-pci-transitional vhost-vsock-pci-non-transitional virtio-input-host-pci-transitional virtio-input-host-pci-non-transitional virtio-scsi-pci-transitional virtio-scsi-pci-non-transitional virtio-serial-pci-transitional virtio-serial-pci-non-transitional Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_capabilities.c | 21 +++++++++++++++++++ src/qemu/qemu_capabilities.h | 1 + .../caps_4.0.0.riscv32.xml | 1 + .../caps_4.0.0.riscv64.xml | 1 + .../caps_4.0.0.x86_64.xml | 1 + 5 files changed, 25 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f035e68251..8e42c1c51c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -525,6 +525,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "memory-backend-file.pmem", "nvdimm.unarmed", "scsi-disk.device_id", + "virtio-pci-non-transitional", ); @@ -1102,6 +1103,26 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "vfio-ap", QEMU_CAPS_DEVICE_VFIO_AP }, { "zpci", QEMU_CAPS_DEVICE_ZPCI }, { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD }, + { "virtio-blk-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-blk-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-net-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-net-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "vhost-scsi-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "vhost-scsi-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-rng-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-rng-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-9p-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-9p-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-balloon-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-balloon-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "vhost-vsock-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "vhost-vsock-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-input-host-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-input-host-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-scsi-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-scsi-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-serial-pci-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, + { "virtio-serial-pci-non-transitional", QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL }, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index ba84052bca..c5e985d6b5 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -505,6 +505,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM, /* -object memory-backend-file,pmem= */ QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */ QEMU_CAPS_SCSI_DISK_DEVICE_ID, /* 'device_id' property of scsi disk */ + QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL, /* virtio *-pci-{non-}transitional devices */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml index 3d958db461..20b91663bc 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -161,6 +161,7 @@ <flag name='egl-headless.rendernode'/> <flag name='memory-backend-file.align'/> <flag name='memory-backend-file.pmem'/> + <flag name='virtio-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml index 40083843f2..7f37a3709c 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -161,6 +161,7 @@ <flag name='egl-headless.rendernode'/> <flag name='memory-backend-file.align'/> <flag name='memory-backend-file.pmem'/> + <flag name='virtio-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 109b1ff753..08f604385f 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -206,6 +206,7 @@ <flag name='memory-backend-file.pmem'/> <flag name='nvdimm.unarmed'/> <flag name='scsi-disk.device_id'/> + <flag name='virtio-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100758</microcodeVersion> -- 2.20.1

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote: [...]
+++ b/src/qemu/qemu_capabilities.h @@ -505,6 +505,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM, /* -object memory-backend-file,pmem= */ QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */ QEMU_CAPS_SCSI_DISK_DEVICE_ID, /* 'device_id' property of scsi disk */ + QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL, /* virtio *-pci-{non-}transitional devices */
I realize I'm the one who suggested this name in the first place :/ but the "NON" part is... Not very useful when you think about it. So we could just as well call this QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL instead and save a few bytes. Whether you feel like renaming it or not, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

<disk> devices lack the model= attribute which is used by most other device types. bus= mostly acts as one, but it serves other purposes too like determing what target= prefix to use, and for matching against controller type= values. Extending bus= to handle additional virtio transitional devices will complicate apps lives, and it isn't a clean mapping anyways. So let's bite the bullet and add a new <disk model=X/> attribute, and wire up common handling for virtio and virtio-{non-}transitional Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 45 +++++++++++++++++++ docs/schemas/domaincommon.rng | 9 ++++ src/conf/domain_conf.c | 40 +++++++++++++++++ src/conf/domain_conf.h | 11 +++++ src/libvirt_private.syms | 2 + .../virtio-non-transitional.x86_64-3.1.0.args | 34 ++++++++++++++ ...virtio-non-transitional.x86_64-latest.args | 34 ++++++++++++++ .../virtio-non-transitional.xml | 17 +++++++ .../virtio-transitional.x86_64-3.1.0.args | 34 ++++++++++++++ .../virtio-transitional.x86_64-latest.args | 34 ++++++++++++++ .../qemuxml2argvdata/virtio-transitional.xml | 17 +++++++ tests/qemuxml2argvtest.c | 6 +++ .../virtio-non-transitional.xml | 42 +++++++++++++++++ .../virtio-transitional.xml | 42 +++++++++++++++++ tests/qemuxml2xmltest.c | 11 +++++ 15 files changed, 378 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-non-transitional.xml create mode 100644 tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args create mode 100644 tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-transitional.xml create mode 100644 tests/qemuxml2xmloutdata/virtio-non-transitional.xml create mode 100644 tests/qemuxml2xmloutdata/virtio-transitional.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 2ae5006849..85bc6a9d0b 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2922,6 +2922,17 @@ <span class="since">Since 0.1.4</span> </p> </dd> + <dt><code>model</code></dt> + <dd> + Indicates the emulated device model of the disk. Typically + this is indicated solely by the <code>bus</code> property but + for <code>bus</code> "virtio" the model can be specified further + with "virtio-transitional", "virtio-non-transitional", or + "virtio", see + <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. + <span class="since">Since 5.1.0</span> + </dd> <dt><code>rawio</code></dt> <dd> Indicates whether the disk needs rawio capability. Valid @@ -4074,6 +4085,40 @@ <span class="since">Since 3.5.0</span> </p> + <h4><a id="elementsVirtioTransitional">Virtio transitional devices</a></h4> + + <p> + <span class="since">Since 5.1.0</span>, some of QEMU's virtio devices, + when used with PCI/PCIe machine types, accept the following + <code>model</code> values: + </p> + + <dl> + <dt><code>virtio-transitional</code></dt> + <dd>This instructs libvirt to always place the device in a conventional + PCI slot. The device can work with a virtio 0.9 or virtio 1.0 + guest driver. + </dd> + <dt><code>virtio-non-transitional</code></dt> + <dd> + The device can only work with a virtio 1.0 guest driver. + </dd> + <dt><code>virtio</code></dt> + <dd> If the device is plugged into a PCIe slot, it acts as a + virtio-non-transitional device. If plugged into a conventional PCI slot, + it will function as a virtio-transitional device. This logic only + applies to devices that support the transitional models; for other + devices, <code>virtio</code> behavior will be different. + </dd> + </dl> + + <p> + For more details see the + <a href="https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html">qemu patch posting</a> and the + <a href="http://docs.oasis-open.org/virtio/virtio/v1.0/virtio-v1.0.html">virtio-1.0 spec</a>. + </p> + + <h4><a id="elementsControllers">Controllers</a></h4> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ba80440c72..8811cf7e45 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1509,6 +1509,15 @@ </interleave> </group> </choice> + <optional> + <attribute name="model"> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> + </attribute> + </optional> <optional> <ref name="snapshot"/> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6772c327ed..3768143b2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -985,6 +985,13 @@ VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, "unmap", ); +VIR_ENUM_IMPL(virDomainDiskModel, VIR_DOMAIN_DISK_MODEL_LAST, + "default", + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); + VIR_ENUM_IMPL(virDomainDiskMirrorState, VIR_DOMAIN_DISK_MIRROR_STATE_LAST, "none", "yes", @@ -5633,6 +5640,17 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk) return -1; } + if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO && + (disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO || + disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || + disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk model '%s' not supported for bus '%s'"), + virDomainDiskModelTypeToString(disk->model), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + return 0; } @@ -9719,6 +9737,14 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } VIR_FREE(tmp); + if ((tmp = virXMLPropString(node, "model")) && + (def->model = virDomainDiskModelTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk model '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + snapshot = virXMLPropString(node, "snapshot"); rawio = virXMLPropString(node, "rawio"); @@ -21960,6 +21986,14 @@ virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src, return false; } + if (src->model != dst->model) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target disk model %s does not match source %s"), + virDomainDiskModelTypeToString(dst->model), + virDomainDiskModelTypeToString(src->model)); + return false; + } + if (src->virtio && dst->virtio && !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; @@ -24517,6 +24551,12 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<disk type='%s' device='%s'", type, device); + + if (def->model) { + virBufferAsprintf(buf, " model='%s'", + virDomainDiskModelTypeToString(def->model)); + } + if (def->rawio) { virBufferAsprintf(buf, " rawio='%s'", virTristateBoolTypeToString(def->rawio)); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2bc3f879f7..ecf8b06c2e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -567,6 +567,15 @@ typedef enum { VIR_DOMAIN_DISK_DETECT_ZEROES_LAST } virDomainDiskDetectZeroes; +typedef enum { + VIR_DOMAIN_DISK_MODEL_DEFAULT = 0, + VIR_DOMAIN_DISK_MODEL_VIRTIO, + VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL, + + VIR_DOMAIN_DISK_MODEL_LAST +} virDomainDiskModel; + typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo; struct _virDomainBlockIoTuneInfo { unsigned long long total_bytes_sec; @@ -674,6 +683,7 @@ struct _virDomainDiskDef { int detect_zeroes; /* enum virDomainDiskDetectZeroes */ char *domain_name; /* backend domain name */ unsigned int queues; + int model; /* enum virDomainDiskModel */ virDomainVirtioOptionsPtr virtio; }; @@ -3416,6 +3426,7 @@ VIR_ENUM_DECL(virDomainDeviceSGIO); VIR_ENUM_DECL(virDomainDiskTray); VIR_ENUM_DECL(virDomainDiskDiscard); VIR_ENUM_DECL(virDomainDiskDetectZeroes); +VIR_ENUM_DECL(virDomainDiskModel); VIR_ENUM_DECL(virDomainDiskMirrorState); VIR_ENUM_DECL(virDomainController); VIR_ENUM_DECL(virDomainControllerModelPCI); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 67579742fd..aeedb1834c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -344,6 +344,8 @@ virDomainDiskIoTypeFromString; virDomainDiskIoTypeToString; virDomainDiskMirrorStateTypeFromString; virDomainDiskMirrorStateTypeToString; +virDomainDiskModelTypeFromString; +virDomainDiskModelTypeToString; virDomainDiskPathByName; virDomainDiskRemove; virDomainDiskRemoveByName; diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args new file mode 100644 index 0000000000..9e11e900da --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc-q35-3.1,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ +addr=0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ +-device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ +id=virtio-disk0,bootindex=1 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args new file mode 100644 index 0000000000..070b4b8334 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine q35,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ +addr=0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ +-device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ +id=virtio-disk0,bootindex=1 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml new file mode 100644 index 0000000000..115ae48737 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -0,0 +1,17 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + </os> + <devices> + <disk type='block' device='disk' model='virtio-non-transitional'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='usb' index='0' model='none'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args new file mode 100644 index 0000000000..9e11e900da --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc-q35-3.1,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ +addr=0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ +-device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ +id=virtio-disk0,bootindex=1 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args new file mode 100644 index 0000000000..070b4b8334 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine q35,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ +addr=0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ +-device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ +id=virtio-disk0,bootindex=1 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml new file mode 100644 index 0000000000..8febfc8423 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -0,0 +1,17 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + </os> + <devices> + <disk type='block' device='disk' model='virtio-transitional'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='usb' index='0' model='none'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index dd4f73a5fb..de9eb6abdb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2996,6 +2996,12 @@ mymain(void) DO_TEST("riscv64-virt-pci", QEMU_CAPS_OBJECT_GPEX); + /* Older version checks disable-legacy usage */ + DO_TEST_CAPS_VER("virtio-transitional", "3.1.0"); + DO_TEST_CAPS_VER("virtio-non-transitional", "3.1.0"); + DO_TEST_CAPS_LATEST("virtio-transitional"); + DO_TEST_CAPS_LATEST("virtio-non-transitional"); + /* Simple headless guests for various architectures */ DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64"); DO_TEST_CAPS_ARCH_LATEST("ppc64-pseries-headless", "ppc64"); diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml new file mode 100644 index 0000000000..7e4aa16b32 --- /dev/null +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -0,0 +1,42 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <disk type='block' device='disk' model='virtio-non-transitional'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </disk> + <controller type='usb' index='0' model='none'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='1' port='0x8'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml new file mode 100644 index 0000000000..1d28af9abb --- /dev/null +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -0,0 +1,42 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <disk type='block' device='disk' model='virtio-transitional'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </disk> + <controller type='usb' index='0' model='none'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='1' port='0x8'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b38cbd6994..15f0ccffb1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1254,6 +1254,17 @@ mymain(void) DO_TEST("riscv64-virt-pci", QEMU_CAPS_OBJECT_GPEX); + DO_TEST("virtio-transitional", + QEMU_CAPS_DEVICE_VIDEO_PRIMARY, + QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + DO_TEST("virtio-non-transitional", + QEMU_CAPS_DEVICE_VIDEO_PRIMARY, + QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.20.1

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote: [...]
+++ b/docs/formatdomain.html.in @@ -2922,6 +2922,17 @@ <span class="since">Since 0.1.4</span> </p> </dd> + <dt><code>model</code></dt> + <dd> + Indicates the emulated device model of the disk. Typically + this is indicated solely by the <code>bus</code> property but + for <code>bus</code> "virtio" the model can be specified further + with "virtio-transitional", "virtio-non-transitional", or + "virtio", see
s/, see/. See/ [...]
+ <dt><code>virtio-transitional</code></dt> + <dd>This instructs libvirt to always place the device in a conventional + PCI slot. The device can work with a virtio 0.9 or virtio 1.0 + guest driver. + </dd>
I'd reword this a bit to highlight the fact that protocol compatibility is the main point of these devices, and slot assignment stems from it. Something like This device can work both with virtio 0.9 and virtio 1.0 guest drivers, so it's the best choice when compatibility with older guest operating systems is desired. libvirt will plug the device into a conventional PCI slot.
+ <dt><code>virtio-non-transitional</code></dt> + <dd> + The device can only work with a virtio 1.0 guest driver.
In the same vein as the above, This device can only work with virtio 1.0 guest drivers, and it's the recommended option unless compatibility with older guest operating systems is necessary. libvirt will plug the device into either a PCI Express slot or a conventional PCI slot based on the machine type, resulting in a more optimized PCI topology.
+ </dd> + <dt><code>virtio</code></dt> + <dd> If the device is plugged into a PCIe slot, it acts as a + virtio-non-transitional device. If plugged into a conventional PCI slot, + it will function as a virtio-transitional device. This logic only + applies to devices that support the transitional models; for other + devices, <code>virtio</code> behavior will be different.
And here too, This device will work like a <code>virtio-non-transitional</code> device when plugged into a PCI Express slot, and like a <code>virtio-transitional</code> device otherwise; libvirt will pick one or the other based on the machine type. This is the best choice when compatibility with libvirt versions older than 5.1.0 is necessary, but it's otherwise not recommended to use it. The idea behind these suggestions is that we should help the user understand the various trade-offs and pick the value that better suits their needs. [...]
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -0,0 +1,17 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + </os> + <devices> + <disk type='block' device='disk' model='virtio-non-transitional'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='usb' index='0' model='none'/>
s/index='0' // [...]
+++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -0,0 +1,17 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + </os> + <devices> + <disk type='block' device='disk' model='virtio-transitional'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='usb' index='0' model='none'/>
Here too. Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add new <disk> model values for virtio transitional devices. When combined with bus='virtio': * "virtio-transitional" maps to qemu "virtio-blk-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-blk-pci-non-transitional" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 75 ++++++++++++++++++- src/qemu/qemu_domain_address.c | 14 +++- .../virtio-non-transitional.x86_64-3.1.0.args | 4 +- ...virtio-non-transitional.x86_64-latest.args | 4 +- .../virtio-transitional.x86_64-3.1.0.args | 7 +- .../virtio-transitional.x86_64-latest.args | 7 +- .../virtio-transitional.xml | 10 ++- 7 files changed, 106 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a26f6291ac..9dda5619fd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -423,13 +423,14 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, static int qemuBuildVirtioDevStr(virBufferPtr buf, const char *baseName, - virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, + virQEMUCapsPtr qemuCaps, virDomainDeviceType devtype, void *devdata) { const char *implName = NULL; virDomainDeviceDef device = { .type = devtype }; virDomainDeviceInfoPtr info; + bool has_tmodel, has_ntmodel; virDomainDeviceSetData(&device, devdata); info = virDomainDeviceGetInfo(&device); @@ -471,6 +472,78 @@ qemuBuildVirtioDevStr(virBufferPtr buf, virBufferAsprintf(buf, "%s-%s", baseName, implName); + switch (devtype) { + case VIR_DOMAIN_DEVICE_DISK: + has_tmodel = device.data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + + case VIR_DOMAIN_DEVICE_NET: + case VIR_DOMAIN_DEVICE_LEASE: + case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_INPUT: + case VIR_DOMAIN_DEVICE_SOUND: + case VIR_DOMAIN_DEVICE_VIDEO: + case VIR_DOMAIN_DEVICE_HOSTDEV: + case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_CONTROLLER: + case VIR_DOMAIN_DEVICE_GRAPHICS: + case VIR_DOMAIN_DEVICE_HUB: + case VIR_DOMAIN_DEVICE_REDIRDEV: + case VIR_DOMAIN_DEVICE_NONE: + case VIR_DOMAIN_DEVICE_SMARTCARD: + case VIR_DOMAIN_DEVICE_CHR: + case VIR_DOMAIN_DEVICE_MEMBALLOON: + case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_SHMEM: + case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_RNG: + case VIR_DOMAIN_DEVICE_MEMORY: + case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_VSOCK: + case VIR_DOMAIN_DEVICE_LAST: + default: + return 0; + } + + if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + (has_tmodel || has_ntmodel)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio (non-)transitional models are not " + "supported for address type=%s"), + virDomainDeviceAddressTypeToString(info->type)); + return -1; + } + + if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL)) { + virBufferAddLit(buf, "-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=off,disable-modern=off"); + } + /* No error if -transitional is not supported: our address + * allocation will force the device into plain PCI bus, which + * is functionally identical to standard 'virtio-XXX' behavior + */ + } else if (has_ntmodel) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + /* Even if the QEMU binary doesn't support the non-transitional + * device, we can still make it work by manually disabling legacy + * VirtIO and enabling modern VirtIO */ + virBufferAddLit(buf, ",disable-legacy=on,disable-modern=off"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + } + return 0; } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 32fdd59566..40b8efa0b5 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -720,7 +720,19 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_DISK: switch ((virDomainDiskBus) dev->data.disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: - return virtioFlags; /* only virtio disks use PCI */ + /* only virtio disks use PCI */ + switch ((virDomainDiskModel) dev->data.disk->model) { + case VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; + case VIR_DOMAIN_DISK_MODEL_VIRTIO: + case VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_DISK_MODEL_DEFAULT: + return virtioFlags; + case VIR_DOMAIN_DISK_MODEL_LAST: + break; + } + return 0; case VIR_DOMAIN_DISK_BUS_IDE: case VIR_DOMAIN_DISK_BUS_FDC: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 9e11e900da..70446f16f2 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -27,8 +27,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ -id=virtio-disk0,bootindex=1 \ +-device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.1,\ +addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 070b4b8334..37078765bc 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -27,8 +27,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ -id=virtio-disk0,bootindex=1 \ +-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.1,addr=0x0,\ +drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index 9e11e900da..e254014471 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -25,10 +25,11 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ -id=virtio-disk0,bootindex=1 \ +-device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ +bus=pci.2,addr=0x1,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 070b4b8334..e78223eac8 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -25,10 +25,11 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,scsi=off,bus=pci.1,addr=0x0,drive=drive-virtio-disk0,\ -id=virtio-disk0,bootindex=1 \ +-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x1,\ +drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 1d28af9abb..c19e133bb3 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -18,7 +18,7 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> </disk> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> @@ -30,9 +30,13 @@ <target chassis='1' port='0x8'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> </controller> - <controller type='pci' index='2' model='pcie-root-port'> + <controller type='pci' index='2' model='pcie-to-pci-bridge'> + <model name='pcie-pci-bridge'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </controller> + <controller type='pci' index='3' model='pcie-root-port'> <model name='pcie-root-port'/> - <target chassis='2' port='0x9'/> + <target chassis='3' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <input type='mouse' bus='ps2'/> -- 2.20.1

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote:
Add new <disk> model values for virtio transitional devices. When combined with bus='virtio':
* "virtio-transitional" maps to qemu "virtio-blk-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-blk-pci-non-transitional"
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 75 ++++++++++++++++++- src/qemu/qemu_domain_address.c | 14 +++- .../virtio-non-transitional.x86_64-3.1.0.args | 4 +- ...virtio-non-transitional.x86_64-latest.args | 4 +- .../virtio-transitional.x86_64-3.1.0.args | 7 +- .../virtio-transitional.x86_64-latest.args | 7 +- .../virtio-transitional.xml | 10 ++- 7 files changed, 106 insertions(+), 15 deletions(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add new <interface> model handling for virtio transitional devices. Ex: <interface> <model type='virtio-transitional'/> </interface> * "virtio-transitional" maps to qemu "virtio-net-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 6 +++++- src/conf/domain_conf.c | 4 +++- src/qemu/qemu_command.c | 6 ++++++ src/qemu/qemu_domain_address.c | 9 +++++++-- .../virtio-non-transitional.x86_64-3.1.0.args | 6 +++++- .../virtio-non-transitional.x86_64-latest.args | 6 +++++- tests/qemuxml2argvdata/virtio-non-transitional.xml | 4 ++++ .../virtio-transitional.x86_64-3.1.0.args | 5 ++++- .../virtio-transitional.x86_64-latest.args | 5 ++++- tests/qemuxml2argvdata/virtio-transitional.xml | 4 ++++ tests/qemuxml2xmloutdata/virtio-non-transitional.xml | 12 +++++++++++- tests/qemuxml2xmloutdata/virtio-transitional.xml | 7 ++++++- 12 files changed, 64 insertions(+), 10 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 85bc6a9d0b..c8012f0a22 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5749,7 +5749,11 @@ qemu-kvm -net nic,model=? /dev/null <p> Typical values for QEMU and KVM include: - ne2k_isa i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio + ne2k_isa i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio. + <span class="since">Since 5.1.0</span>, <code>virtio-transitional</code> + and <code>virtio-non-transitional</code> values are supported. + See <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. </p> <h5><a id="elementsDriverBackendOptions">Setting NIC driver-specific options</a></h5> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3768143b2c..e29f143f3d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29943,7 +29943,9 @@ virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface) bool virDomainNetIsVirtioModel(const virDomainNetDef *net) { - return STREQ_NULLABLE(net->model, "virtio"); + return (STREQ_NULLABLE(net->model, "virtio") || + STREQ_NULLABLE(net->model, "virtio-transitional") || + STREQ_NULLABLE(net->model, "virtio-non-transitional")); } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9dda5619fd..552f4c0807 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -479,6 +479,12 @@ qemuBuildVirtioDevStr(virBufferPtr buf, break; case VIR_DOMAIN_DEVICE_NET: + has_tmodel = STREQ_NULLABLE(device.data.net->model, + "virtio-transitional"); + has_ntmodel = STREQ_NULLABLE(device.data.net->model, + "virtio-non-transitional"); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 40b8efa0b5..5920439a96 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -692,8 +692,13 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, return 0; } - if (STREQ_NULLABLE(net->model, "virtio")) - return virtioFlags; + if (STREQ_NULLABLE(net->model, "virtio") || + STREQ_NULLABLE(net->model, "virtio-non-transitional")) + return virtioFlags; + + /* Transitional devices only work in conventional PCI slots */ + if (STREQ_NULLABLE(net->model, "virtio-transitional")) + return pciFlags; if (STREQ_NULLABLE(net->model, "e1000e")) return pcieFlags; diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 70446f16f2..827b4070d4 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -26,9 +26,13 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.1,\ +-device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.2,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-netdev user,id=hostnet0 \ +-device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ +id=net0,mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 37078765bc..9a0eb9a1f3 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -26,9 +26,13 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-non-transitional,scsi=off,bus=pci.1,addr=0x0,\ +-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.2,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-netdev user,id=hostnet0 \ +-device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ +mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 115ae48737..72d92ba720 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -11,6 +11,10 @@ <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> </disk> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio-non-transitional'/> + </interface> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index e254014471..ed0d3b7f7a 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -29,7 +29,10 @@ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ -bus=pci.2,addr=0x1,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +bus=pci.2,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-netdev user,id=hostnet0 \ +-device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ +id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index e78223eac8..46e139d492 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -28,8 +28,11 @@ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x1,\ +-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x2,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-netdev user,id=hostnet0 \ +-device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ +mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index 8febfc8423..a35a2e9cb4 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -11,6 +11,10 @@ <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> </disk> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio-transitional'/> + </interface> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 7e4aa16b32..f0dc7c0833 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -18,7 +18,7 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> </disk> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> @@ -35,6 +35,16 @@ <target chassis='2' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> + <controller type='pci' index='3' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='3' port='0xa'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio-non-transitional'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <memballoon model='none'/> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index c19e133bb3..f9729391a5 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -18,7 +18,7 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/> </disk> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> @@ -39,6 +39,11 @@ <target chassis='3' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio-transitional'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> + </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <memballoon model='none'/> -- 2.20.1

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote:
Add new <interface> model handling for virtio transitional devices. Ex:
<interface> <model type='virtio-transitional'/> </interface>
* "virtio-transitional" maps to qemu "virtio-net-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-net-pci-non-transitional"
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 6 +++++- src/conf/domain_conf.c | 4 +++- src/qemu/qemu_command.c | 6 ++++++ src/qemu/qemu_domain_address.c | 9 +++++++-- .../virtio-non-transitional.x86_64-3.1.0.args | 6 +++++- .../virtio-non-transitional.x86_64-latest.args | 6 +++++- tests/qemuxml2argvdata/virtio-non-transitional.xml | 4 ++++ .../virtio-transitional.x86_64-3.1.0.args | 5 ++++- .../virtio-transitional.x86_64-latest.args | 5 ++++- tests/qemuxml2argvdata/virtio-transitional.xml | 4 ++++ tests/qemuxml2xmloutdata/virtio-non-transitional.xml | 12 +++++++++++- tests/qemuxml2xmloutdata/virtio-transitional.xml | 7 ++++++- 12 files changed, 64 insertions(+), 10 deletions(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

qemu vhost-scsi devices map to XML roughly like: <hostdev mode='subsystem' type='scsi_host'> <source protocol='vhost' wwpn=X/> </hostdev> To support vhost-scsi-pci-{non-}traditional in qemu, we need to to extend the SCSI Host hostdev XML to handle model= value. This matches the XML model= format used for mediated devices. This is just the domain_conf bits and some XML test cases. Use of virtio-X naming here does not match the hostdev protocol=vhost nor does it match the qemu vhost-X device naming, however it's more consistent with all other model= names in this area, and also matches the inconsistency of <vsock> devices which use model=virtio but map to vhost-vsock on the qemu commandline Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 7 +++- docs/schemas/domaincommon.rng | 9 +++++ src/conf/domain_conf.c | 38 ++++++++++++++++--- src/conf/domain_conf.h | 12 ++++++ src/libvirt_private.syms | 2 + .../virtio-non-transitional.x86_64-3.1.0.args | 3 ++ ...virtio-non-transitional.x86_64-latest.args | 3 ++ .../virtio-non-transitional.xml | 3 ++ .../virtio-transitional.x86_64-3.1.0.args | 3 ++ .../virtio-transitional.x86_64-latest.args | 3 ++ .../qemuxml2argvdata/virtio-transitional.xml | 3 ++ .../virtio-non-transitional.xml | 9 +++++ .../virtio-transitional.xml | 9 +++++ 13 files changed, 98 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c8012f0a22..b7cea098bd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4715,7 +4715,12 @@ <dd><span class="since">since 2.5.0</span>For SCSI devices, user is responsible to make sure the device is not used by host. This <code>type</code> passes all LUNs presented by a single HBA to - the guest. + the guest. <span class="since">Since 5.1.0,</span> the + <code>model</code> attribute can be specified further + with "virtio-transitional", "virtio-non-transitional", or + "virtio". See + <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. </dd> <dt><code>mdev</code></dt> <dd>For mediated devices (<span class="since">Since 3.2.0</span>) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8811cf7e45..36531a1c24 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4630,6 +4630,15 @@ <attribute name="type"> <value>scsi_host</value> </attribute> + <optional> + <attribute name="model"> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> + </attribute> + </optional> <element name="source"> <choice> <group> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e29f143f3d..9f58418c89 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -780,6 +780,14 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIHostProtocol, "vhost", ); +VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIVHostModel, + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_LAST, + "default", + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); + VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST, "storage", "misc", @@ -7800,6 +7808,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, int ret = -1; virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi; + virDomainHostdevSubsysSCSIVHostPtr scsihostsrc = &def->source.subsys.u.scsi_host; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev; /* @managed can be read from the xml document - it is always an @@ -7882,14 +7891,26 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, } } - if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) { + if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV && + def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { if (model) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'model' attribute in <hostdev> is only supported " - "when type='mdev'")); + virReportError(VIR_ERR_XML_ERROR, + _("'model' attribute in <hostdev> is not supported " + "for type='%s'"), + virDomainHostdevSubsysTypeToString(def->source.subsys.type)); goto cleanup; } - } else { + } + + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + if (model && + ((scsihostsrc->model = virDomainHostdevSubsysSCSIVHostModelTypeFromString(model)) < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown hostdev model '%s'"), + model); + goto cleanup; + } + } else if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) { if (!model) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing 'model' attribute in mediated device's " @@ -27301,6 +27322,7 @@ virDomainHostdevDefFormat(virBufferPtr buf, const char *mode = virDomainHostdevModeTypeToString(def->mode); virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev; + virDomainHostdevSubsysSCSIVHostPtr scsihostsrc = &def->source.subsys.u.scsi_host; const char *type; if (!mode) { @@ -27351,6 +27373,12 @@ virDomainHostdevDefFormat(virBufferPtr buf, virTristateBoolTypeToString(scsisrc->rawio)); } + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST && + scsihostsrc->model) { + virBufferAsprintf(buf, " model='%s'", + virDomainHostdevSubsysSCSIVHostModelTypeToString(scsihostsrc->model)); + } + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) { virBufferAsprintf(buf, " model='%s'", virMediatedDeviceModelTypeToString(mdevsrc->model)); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ecf8b06c2e..dccdc42ed2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -394,11 +394,23 @@ typedef enum { VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol); +typedef enum { + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_DEFAULT, + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO, + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL, + + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_LAST, +} virDomainHostdevSubsysSCSIVHostModelType; + +VIR_ENUM_DECL(virDomainHostdevSubsysSCSIVHostModel); + typedef struct _virDomainHostdevSubsysSCSIVHost virDomainHostdevSubsysSCSIVHost; typedef virDomainHostdevSubsysSCSIVHost *virDomainHostdevSubsysSCSIVHostPtr; struct _virDomainHostdevSubsysSCSIVHost { int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */ char *wwpn; + int model; /* enum virDomainHostdevSubsysSCSIVHostModelType */ }; typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index aeedb1834c..32ad42282a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -408,6 +408,8 @@ virDomainHostdevInsert; virDomainHostdevModeTypeToString; virDomainHostdevRemove; virDomainHostdevSubsysPCIBackendTypeToString; +virDomainHostdevSubsysSCSIVHostModelTypeFromString; +virDomainHostdevSubsysSCSIVHostModelTypeToString; virDomainHostdevSubsysTypeToString; virDomainHPTResizingTypeToString; virDomainHubTypeFromString; diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 827b4070d4..9c38d713b2 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -27,12 +27,15 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.2,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ +-device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ +bus=pci.3,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 9a0eb9a1f3..82255909c4 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -27,12 +27,15 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.2,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ +-device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ +bus=pci.3,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 72d92ba720..4cbf4b0893 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -15,6 +15,9 @@ <mac address='00:11:22:33:44:55'/> <model type='virtio-non-transitional'/> </interface> + <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> + <source protocol='vhost' wwpn='naa.5123456789abcde0'/> + </hostdev> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index ed0d3b7f7a..d5d0c3eaf7 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -27,12 +27,15 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ bus=pci.2,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ +-device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ +bus=pci.3,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 46e139d492..dab25ba2e8 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -27,12 +27,15 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x2,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ +-device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ +bus=pci.3,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index a35a2e9cb4..591ea47952 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -15,6 +15,9 @@ <mac address='00:11:22:33:44:55'/> <model type='virtio-transitional'/> </interface> + <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> + <source protocol='vhost' wwpn='naa.5123456789abcde0'/> + </hostdev> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index f0dc7c0833..2af5195dfd 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -40,6 +40,11 @@ <target chassis='3' port='0xa'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> + <controller type='pci' index='4' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='4' port='0xb'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/> + </controller> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-non-transitional'/> @@ -47,6 +52,10 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> + <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> + <source protocol='vhost' wwpn='naa.5123456789abcde0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + </hostdev> <memballoon model='none'/> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index f9729391a5..ce7b109845 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -39,6 +39,11 @@ <target chassis='3' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> + <controller type='pci' index='4' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='4' port='0xa'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-transitional'/> @@ -46,6 +51,10 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> + <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> + <source protocol='vhost' wwpn='naa.5123456789abcde0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + </hostdev> <memballoon model='none'/> </devices> </domain> -- 2.20.1

Add <hostdev> protocol=vhost model handling for virtio transitional devices. Ex: <hostdev mode='subsystem' type='scsi_host' model='virtio-transitional'> <source protocol='vhost' wwpn=X/> </hostdev> * "virtio-transitional" maps to qemu "vhost-scsi-pci-transitional" * "virtio-non-transitional" maps to qemu "vhost-scsi-pci-non-transitional" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 8 ++++++- src/qemu/qemu_domain_address.c | 22 ++++++++++++++++--- .../virtio-non-transitional.x86_64-3.1.0.args | 4 ++-- ...virtio-non-transitional.x86_64-latest.args | 4 ++-- .../virtio-transitional.x86_64-3.1.0.args | 5 ++--- .../virtio-transitional.x86_64-latest.args | 5 ++--- .../virtio-transitional.xml | 7 +----- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 552f4c0807..15857f484a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -485,12 +485,18 @@ qemuBuildVirtioDevStr(virBufferPtr buf, "virtio-non-transitional"); break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + if (device.data.hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) + return 0; + has_tmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: - case VIR_DOMAIN_DEVICE_HOSTDEV: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_GRAPHICS: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5920439a96..283c3246b1 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -794,11 +794,27 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, return pcieFlags; /* according to pbonzini, from the guest PoV vhost-scsi devices - * are the same as virtio-scsi, so they should use virtioFlags - * (same as virtio-scsi) to determine Express vs. legacy placement + * are the same as virtio-scsi, so they should follow virtio logic */ - if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) + if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + switch ((virDomainHostdevSubsysSCSIVHostModelType) hostdev->source.subsys.u.scsi_host.model) { + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO: + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_DEFAULT: + return virtioFlags; + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_LAST: + break; + } + return 0; + + /* Transitional devices only work in conventional PCI slots */ + if (hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags; + } if (!(pciDev = virPCIDeviceNew(hostAddr->domain, hostAddr->bus, diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 9c38d713b2..500c03bdc3 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -34,8 +34,8 @@ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ --device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.3,addr=0x0 \ +-device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.3,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 82255909c4..c8dbffda65 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -34,8 +34,8 @@ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ --device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.3,addr=0x0 \ +-device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ +id=hostdev0,bus=pci.3,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index d5d0c3eaf7..d4d2b8ec35 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -27,15 +27,14 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ bus=pci.2,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ --device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.3,addr=0x0 \ +-device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index dab25ba2e8..ab2c35514d 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -27,15 +27,14 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x2,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ --device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.3,addr=0x0 \ +-device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ +id=hostdev0,bus=pci.2,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index ce7b109845..8c1baced0e 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -39,11 +39,6 @@ <target chassis='3' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> - <controller type='pci' index='4' model='pcie-root-port'> - <model name='pcie-root-port'/> - <target chassis='4' port='0xa'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> - </controller> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-transitional'/> @@ -53,7 +48,7 @@ <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> </hostdev> <memballoon model='none'/> </devices> -- 2.20.1

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote: [...]
- if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) + if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + switch ((virDomainHostdevSubsysSCSIVHostModelType) hostdev->source.subsys.u.scsi_host.model) { + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO: + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_DEFAULT: + return virtioFlags; + case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_LAST: + break; + } + return 0; + + /* Transitional devices only work in conventional PCI slots */ + if (hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags;
These last 5 lines are a leftover from v2, please get rid of them. Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add new <rng> model values for virtio transitional devices. Ex: <rng model='virtio-transitional'> ... </rng> * "virtio-transitional" maps to qemu "virtio-rng-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-rng-pci-non-transitional" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 4 ++++ docs/schemas/domaincommon.rng | 6 +++++- src/conf/domain_conf.c | 5 ++++- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 6 +++++- src/qemu/qemu_domain.c | 5 +++++ src/qemu/qemu_domain_address.c | 4 ++++ .../virtio-non-transitional.x86_64-3.1.0.args | 4 ++++ .../virtio-non-transitional.x86_64-latest.args | 3 +++ tests/qemuxml2argvdata/virtio-non-transitional.xml | 3 +++ .../virtio-transitional.x86_64-3.1.0.args | 3 +++ .../virtio-transitional.x86_64-latest.args | 2 ++ tests/qemuxml2argvdata/virtio-transitional.xml | 3 +++ tests/qemuxml2xmloutdata/virtio-non-transitional.xml | 9 +++++++++ tests/qemuxml2xmloutdata/virtio-transitional.xml | 4 ++++ 15 files changed, 60 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b7cea098bd..674616f7b4 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8012,7 +8012,11 @@ qemu-kvm -net nic,model=? /dev/null </p> <ul> <li>'virtio' - supported by qemu and virtio-rng kernel module</li> + <li>'virtio-transitional' <span class='since'>Since 5.1.0</span></li> + <li>'virtio-non-transitional' <span class='since'>Since 5.1.0</span></li> </ul> + See <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. </dd> <dt><code>rate</code></dt> <dd> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 36531a1c24..e91eb1395e 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5455,7 +5455,11 @@ <define name="rng"> <element name="rng"> <attribute name="model"> - <value>virtio</value> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> </attribute> <interleave> <ref name="rng-backend"/> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9f58418c89..eab70ba807 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -947,7 +947,10 @@ VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST, VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, - "virtio"); + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); VIR_ENUM_IMPL(virDomainRNGBackend, VIR_DOMAIN_RNG_BACKEND_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dccdc42ed2..2a209a04c2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2127,6 +2127,8 @@ struct _virBlkioDevice { typedef enum { VIR_DOMAIN_RNG_MODEL_VIRTIO, + VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL, VIR_DOMAIN_RNG_MODEL_LAST } virDomainRNGModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 15857f484a..3ef26bb494 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -492,6 +492,11 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_RNG: + has_tmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -510,7 +515,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf, case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_VSOCK: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 801d25a44b..4e9c179db3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4553,6 +4553,11 @@ qemuDomainRNGDefValidate(const virDomainRNGDef *def, modelIsSupported = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG); break; + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: + modelIsSupported = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL) || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)); + break; case VIR_DOMAIN_RNG_MODEL_LAST: break; } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 283c3246b1..bc8829943f 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -884,7 +884,11 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_RNG: switch ((virDomainRNGModel) dev->data.rng->model) { case VIR_DOMAIN_RNG_MODEL_VIRTIO: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: return virtioFlags; + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; case VIR_DOMAIN_RNG_MODEL_LAST: return 0; diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 500c03bdc3..10cc6236cb 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -28,6 +28,7 @@ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.2,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,9 @@ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ id=net0,mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.3,addr=0x0 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci,disable-legacy=on,disable-modern=off,rng=objrng0,\ +id=rng0,bus=pci.4,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index c8dbffda65..a0fc475c2f 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -28,6 +28,7 @@ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.2,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,8 @@ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.3,addr=0x0 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.4,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 4cbf4b0893..d49d82691f 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -18,6 +18,9 @@ <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> </hostdev> + <rng model='virtio-non-transitional'> + <backend model='random'>/dev/urandom</backend> + </rng> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index d4d2b8ec35..b21a6cadd4 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -35,6 +35,9 @@ bus=pci.2,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x3 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ +id=rng0,bus=pci.2,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index ab2c35514d..64fb4153fd 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -35,6 +35,8 @@ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.2,addr=0x3 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index 591ea47952..9643788a9a 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -18,6 +18,9 @@ <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> </hostdev> + <rng model='virtio-transitional'> + <backend model='random'>/dev/urandom</backend> + </rng> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 2af5195dfd..4a315050ab 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -45,6 +45,11 @@ <target chassis='4' port='0xb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/> </controller> + <controller type='pci' index='5' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='5' port='0xc'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/> + </controller> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-non-transitional'/> @@ -57,5 +62,9 @@ <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> </hostdev> <memballoon model='none'/> + <rng model='virtio-non-transitional'> + <backend model='random'>/dev/urandom</backend> + <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> + </rng> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 8c1baced0e..ae3789ad93 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -51,5 +51,9 @@ <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> </hostdev> <memballoon model='none'/> + <rng model='virtio-transitional'> + <backend model='random'>/dev/urandom</backend> + <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> + </rng> </devices> </domain> -- 2.20.1

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote: [...]
@@ -4553,6 +4553,11 @@ qemuDomainRNGDefValidate(const virDomainRNGDef *def, modelIsSupported = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG); break; + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: + modelIsSupported = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL) || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)); + break;
You still need to make sure QEMU_CAPS_DEVICE_VIRTIO_RNG is present when the model is virtio-(non-)transitional. [...]
@@ -884,7 +884,11 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_RNG: switch ((virDomainRNGModel) dev->data.rng->model) { case VIR_DOMAIN_RNG_MODEL_VIRTIO: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: return virtioFlags; + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags;
Nit, but for other devices so far you've put the _TRANSITIONAL case first, so please do the same here :) With all of the above addressed, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

<filesystem> devices lack the model= attribute which is used by most other device types. To eventually support virtio-9p-pci-{non-}traditional in qemu, let's add a standard model= attribute. The accepted values are: - virtio - virtio-transitional - virtio-non-transitional Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 5 +++ docs/schemas/domaincommon.rng | 9 +++++ src/conf/domain_conf.c | 33 +++++++++++++++++-- src/conf/domain_conf.h | 11 +++++++ .../virtio-non-transitional.x86_64-3.1.0.args | 11 ++++--- ...virtio-non-transitional.x86_64-latest.args | 11 ++++--- .../virtio-non-transitional.xml | 4 +++ .../virtio-transitional.x86_64-3.1.0.args | 15 +++++---- .../virtio-transitional.x86_64-latest.args | 15 +++++---- .../qemuxml2argvdata/virtio-transitional.xml | 4 +++ .../virtio-non-transitional.xml | 18 +++++++--- .../virtio-transitional.xml | 26 ++++++++++----- 12 files changed, 128 insertions(+), 34 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 674616f7b4..e84e71fda8 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3881,6 +3881,11 @@ </dd> </dl> + <span class="since">Since 5.1.0</span>, the filesystem element + has an optional attribute <code>model</code> with supported values + "virtio-transitional", "virtio-non-transitional", or "virtio". + See <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. </dd> <dt><code>driver</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e91eb1395e..a26f5d9548 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2502,6 +2502,15 @@ </element> </optional> </interleave> + <optional> + <attribute name="model"> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> + </attribute> + </optional> </element> </define> <define name="fsDriver"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index eab70ba807..5e2f24de1b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -434,6 +434,13 @@ VIR_ENUM_IMPL(virDomainFSWrpolicy, VIR_DOMAIN_FS_WRPOLICY_LAST, "immediate", ); +VIR_ENUM_IMPL(virDomainFSModel, VIR_DOMAIN_FS_MODEL_LAST, + "default", + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); + VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, "user", "ethernet", @@ -10830,6 +10837,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, char *wrpolicy = NULL; char *usage = NULL; char *units = NULL; + char *model = NULL; ctxt->node = node; @@ -10858,6 +10866,15 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; } + model = virXMLPropString(node, "model"); + if (model) { + if ((def->model = virDomainFSModelTypeFromString(model)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown model '%s'"), model); + goto error; + } + } + if (virDomainParseScaledValue("./space_hard_limit[1]", NULL, ctxt, &def->space_hard_limit, 1, ULLONG_MAX, false) < 0) @@ -10986,6 +11003,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_FREE(usage); VIR_FREE(units); VIR_FREE(format); + VIR_FREE(model); return def; @@ -22106,6 +22124,12 @@ virDomainFsDefCheckABIStability(virDomainFSDefPtr src, return false; } + if (src->model != dst->model) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target filesystem model does not match source")); + return false; + } + if (src->virtio && dst->virtio && !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; @@ -24903,10 +24927,15 @@ virDomainFSDefFormat(virBufferPtr buf, goto cleanup; } - virBufferAsprintf(buf, - "<filesystem type='%s' accessmode='%s'>\n", + "<filesystem type='%s' accessmode='%s'", type, accessmode); + if (def->model) { + virBufferAsprintf(buf, " model='%s'", + virDomainFSModelTypeToString(def->model)); + } + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); if (def->fsdriver) { virBufferAsprintf(&driverBuf, " type='%s'", fsdriver); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2a209a04c2..f836919d6f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -903,12 +903,22 @@ typedef enum { VIR_DOMAIN_FS_WRPOLICY_LAST } virDomainFSWrpolicy; +typedef enum { + VIR_DOMAIN_FS_MODEL_DEFAULT = 0, + VIR_DOMAIN_FS_MODEL_VIRTIO, + VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL, + + VIR_DOMAIN_FS_MODEL_LAST +} virDomainFSModel; + struct _virDomainFSDef { int type; int fsdriver; /* enum virDomainFSDriverType */ int accessmode; /* enum virDomainFSAccessMode */ int wrpolicy; /* enum virDomainFSWrpolicy */ int format; /* virStorageFileFormat */ + int model; /* virDomainFSModel */ unsigned long long usage; /* in bytes */ virStorageSourcePtr src; char *dst; @@ -3452,6 +3462,7 @@ VIR_ENUM_DECL(virDomainFS); VIR_ENUM_DECL(virDomainFSDriver); VIR_ENUM_DECL(virDomainFSAccessMode); VIR_ENUM_DECL(virDomainFSWrpolicy); +VIR_ENUM_DECL(virDomainFSModel); VIR_ENUM_DECL(virDomainNet); VIR_ENUM_DECL(virDomainNetBackend); VIR_ENUM_DECL(virDomainNetVirtioTxMode); diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 10cc6236cb..824737338a 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -29,17 +29,20 @@ addr=0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.2,\ +-device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ +-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ -id=net0,mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ +id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.3,addr=0x0 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.4,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=on,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.4,addr=0x0 \ +id=rng0,bus=pci.5,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index a0fc475c2f..e454eeadbd 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -29,16 +29,19 @@ addr=0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-non-transitional,scsi=off,bus=pci.2,addr=0x0,\ +-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ +-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ -mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ +mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.3,addr=0x0 \ +id=hostdev0,bus=pci.4,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.4,addr=0x0 \ +-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.5,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index d49d82691f..eec8b544e2 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -21,6 +21,10 @@ <rng model='virtio-non-transitional'> <backend model='random'>/dev/urandom</backend> </rng> + <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> + <source dir='/export/fs1'/> + <target dir='fs1'/> + </filesystem> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index b21a6cadd4..da1ce9e7dc 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -25,19 +25,22 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ --device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-pci-bridge,id=pci.3,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ -bus=pci.2,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +bus=pci.3,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ +-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ -id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ +id=net0,mac=00:11:22:33:44:55,bus=pci.3,addr=0x1 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x3 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.3,addr=0x3 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.2,addr=0x4 \ +id=rng0,bus=pci.3,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 64fb4153fd..43c1cafd45 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -25,18 +25,21 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ --device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-pci-bridge,id=pci.3,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x2,\ +-device virtio-blk-pci-transitional,scsi=off,bus=pci.3,addr=0x2,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ +-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ -mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ +mac=00:11:22:33:44:55,bus=pci.3,addr=0x1 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.2,addr=0x3 \ +id=hostdev0,bus=pci.3,addr=0x3 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x4 \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.3,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index 9643788a9a..cb23d4d7a8 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -21,6 +21,10 @@ <rng model='virtio-transitional'> <backend model='random'>/dev/urandom</backend> </rng> + <filesystem type='mount' accessmode='passthrough' model='virtio-transitional'> + <source dir='/export/fs1'/> + <target dir='fs1'/> + </filesystem> <controller type='usb' index='0' model='none'/> <memballoon model='none'/> </devices> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 4a315050ab..18ef85092a 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -18,7 +18,7 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> </disk> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> @@ -50,21 +50,31 @@ <target chassis='5' port='0xc'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/> </controller> + <controller type='pci' index='6' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='6' port='0xd'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/> + </controller> + <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> + <source dir='/export/fs1'/> + <target dir='fs1'/> + <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + </filesystem> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-non-transitional'/> - <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </hostdev> <memballoon model='none'/> <rng model='virtio-non-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> </rng> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index ae3789ad93..6e18c1c301 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -18,7 +18,7 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x02' function='0x0'/> </disk> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> @@ -30,30 +30,40 @@ <target chassis='1' port='0x8'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> </controller> - <controller type='pci' index='2' model='pcie-to-pci-bridge'> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='3' model='pcie-to-pci-bridge'> <model name='pcie-pci-bridge'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </controller> - <controller type='pci' index='3' model='pcie-root-port'> + <controller type='pci' index='4' model='pcie-root-port'> <model name='pcie-root-port'/> - <target chassis='3' port='0x9'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + <target chassis='4' port='0xa'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> + <filesystem type='mount' accessmode='passthrough' model='virtio-transitional'> + <source dir='/export/fs1'/> + <target dir='fs1'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> + </filesystem> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-transitional'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/> </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x03' function='0x0'/> </hostdev> <memballoon model='none'/> <rng model='virtio-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x04' function='0x0'/> </rng> </devices> </domain> -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote: [...]
@@ -10858,6 +10866,15 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; }
+ model = virXMLPropString(node, "model"); + if (model) { + if ((def->model = virDomainFSModelTypeFromString(model)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown model '%s'"), model); + goto error; + } + }
If we wanted to be super-duper safe, we could do if (model) { if ((def->model = virDomainFSModelTypeFromString(model)) < 0 || def->model == VIR_DOMAIN_FS_MODEL_DEFAULT) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown model '%s'"), model); goto error; } } to prevent people from using <filesystem model='default'> ... </filesystem> and same for disks and other devices for which we're introducing the concept of model just now. But it's probably okay even if we don't want to go the extra mile. Either way, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add <filesystem> model handling for virtio transitional devices. Ex: <filesystem type='mount' model='virtio-transitional'> ... </filesystem * "virtio-transitional" maps to qemu "virtio-9p-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-9p-pci-non-transitional" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 6 ++++- src/qemu/qemu_domain_address.c | 14 +++++++++-- .../virtio-non-transitional.x86_64-3.1.0.args | 3 ++- ...virtio-non-transitional.x86_64-latest.args | 3 ++- .../virtio-transitional.x86_64-3.1.0.args | 16 ++++++------- .../virtio-transitional.x86_64-latest.args | 16 ++++++------- .../virtio-transitional.xml | 23 ++++++++----------- 7 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3ef26bb494..efb108989f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -497,8 +497,12 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; break; - case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: + has_tmodel = device.data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bc8829943f..01343357f7 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -677,8 +677,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_DEVICE_FS: - /* the only type of filesystem so far is virtio-9p-pci */ - return virtioFlags; + switch ((virDomainFSModel) dev->data.fs->model) { + case VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; + case VIR_DOMAIN_FS_MODEL_VIRTIO: + case VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_FS_MODEL_DEFAULT: + return virtioFlags; + case VIR_DOMAIN_FS_MODEL_LAST: + break; + } + return 0; case VIR_DOMAIN_DEVICE_NET: { virDomainNetDefPtr net = dev->data.net; diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 824737338a..38a9cab582 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -34,7 +34,8 @@ addr=0x1 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ +-device virtio-9p-pci,disable-legacy=on,disable-modern=off,id=fs0,\ +fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index e454eeadbd..8c571c04f1 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -34,7 +34,8 @@ addr=0x1 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ +-device virtio-9p-pci-non-transitional,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ +bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index da1ce9e7dc..796a29044c 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -25,22 +25,22 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-pci-bridge,id=pci.3,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ -bus=pci.3,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +bus=pci.2,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x0 \ +-device virtio-9p-pci,disable-legacy=off,disable-modern=off,id=fs0,\ +fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ -id=net0,mac=00:11:22:33:44:55,bus=pci.3,addr=0x1 \ +id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.3,addr=0x3 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x4 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.3,addr=0x4 \ +id=rng0,bus=pci.2,addr=0x5 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 43c1cafd45..eb8da465f6 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -25,21 +25,21 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=on \ -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-pci-bridge,id=pci.3,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ +-device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-transitional,scsi=off,bus=pci.3,addr=0x2,\ +-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x3,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x0 \ +-device virtio-9p-pci-transitional,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ +bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ -mac=00:11:22:33:44:55,bus=pci.3,addr=0x1 \ +mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.3,addr=0x3 \ +id=hostdev0,bus=pci.2,addr=0x4 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.3,addr=0x4 \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x5 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 6e18c1c301..334cfaa6e4 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -18,7 +18,7 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x02' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> </disk> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> @@ -30,40 +30,35 @@ <target chassis='1' port='0x8'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/> </controller> - <controller type='pci' index='2' model='pcie-root-port'> - <model name='pcie-root-port'/> - <target chassis='2' port='0x9'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='pci' index='3' model='pcie-to-pci-bridge'> + <controller type='pci' index='2' model='pcie-to-pci-bridge'> <model name='pcie-pci-bridge'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </controller> - <controller type='pci' index='4' model='pcie-root-port'> + <controller type='pci' index='3' model='pcie-root-port'> <model name='pcie-root-port'/> - <target chassis='4' port='0xa'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + <target chassis='3' port='0x9'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/> </filesystem> <interface type='user'> <mac address='00:11:22:33:44:55'/> <model type='virtio-transitional'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/> </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x03' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> </hostdev> <memballoon model='none'/> <rng model='virtio-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x03' slot='0x04' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> </rng> </devices> </domain> -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote: [...]
@@ -677,8 +677,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break;
case VIR_DOMAIN_DEVICE_FS: - /* the only type of filesystem so far is virtio-9p-pci */ - return virtioFlags;
The comment is still entirely accurate, so I wouldn't drop it. Either way, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add new <memballoon> model values for virtio transitional devices. Ex: <memballoon model='virtio-transitional'/> * "virtio-transitional" maps to qemu "virtio-balloon-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-balloon-pci-non-transitional" Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 4 ++++ docs/schemas/domaincommon.rng | 2 ++ src/conf/domain_conf.c | 2 ++ src/conf/domain_conf.h | 2 ++ src/libxl/libxl_conf.c | 2 ++ src/qemu/qemu_command.c | 6 +++++- src/qemu/qemu_domain.c | 4 +++- src/qemu/qemu_domain_address.c | 3 +++ .../virtio-non-transitional.x86_64-3.1.0.args | 5 ++++- .../virtio-non-transitional.x86_64-latest.args | 4 +++- tests/qemuxml2argvdata/virtio-non-transitional.xml | 2 +- .../virtio-transitional.x86_64-3.1.0.args | 4 +++- .../virtio-transitional.x86_64-latest.args | 3 ++- tests/qemuxml2argvdata/virtio-transitional.xml | 2 +- tests/qemuxml2xmloutdata/virtio-non-transitional.xml | 11 +++++++++-- tests/qemuxml2xmloutdata/virtio-transitional.xml | 6 ++++-- 16 files changed, 50 insertions(+), 12 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e84e71fda8..4a1ba83cd8 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7944,8 +7944,12 @@ qemu-kvm -net nic,model=? /dev/null </p> <ul> <li>'virtio' - default with QEMU/KVM</li> + <li>'virtio-transitional' <span class="since">Since 5.1.0</span></li> + <li>'virtio-non-transitional' <span class="since">Since 5.1.0</span></li> <li>'xen' - default with Xen</li> </ul> + See <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. </dd> <dt><code>autodeflate</code></dt> <dd> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a26f5d9548..94c358b578 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4093,6 +4093,8 @@ <attribute name="model"> <choice> <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> <value>xen</value> <value>none</value> </choice> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5e2f24de1b..e4484f9982 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -593,6 +593,8 @@ VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST, "virtio", "xen", "none", + "virtio-transitional", + "virtio-non-transitional", ); VIR_ENUM_IMPL(virDomainSmbiosMode, VIR_DOMAIN_SMBIOS_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f836919d6f..40da1b40b7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1733,6 +1733,8 @@ typedef enum { VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO, VIR_DOMAIN_MEMBALLOON_MODEL_XEN, VIR_DOMAIN_MEMBALLOON_MODEL_NONE, + VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL, VIR_DOMAIN_MEMBALLOON_MODEL_LAST } virDomainMemballoonModel; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 0e08b8f0a2..c769050ff1 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -718,6 +718,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, case VIR_DOMAIN_MEMBALLOON_MODEL_XEN: break; case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO: + case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported balloon device model '%s'"), virDomainMemballoonModelTypeToString(model)); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index efb108989f..b843408402 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -502,6 +502,11 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_MEMBALLOON: + has_tmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: @@ -514,7 +519,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf, case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_CHR: - case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4e9c179db3..16929ea656 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6027,7 +6027,9 @@ qemuDomainDeviceDefValidateMemballoon(const virDomainMemballoonDef *memballoon, return 0; } - if (memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + if (memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL && + memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Memory balloon device type '%s' is not supported by this version of qemu"), virDomainMemballoonModelTypeToString(memballoon->model)); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 01343357f7..c1a6d94a4c 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -882,7 +882,10 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_MEMBALLOON: switch ((virDomainMemballoonModel) dev->data.memballoon->model) { case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO: + case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL: return virtioFlags; + case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; case VIR_DOMAIN_MEMBALLOON_MODEL_XEN: case VIR_DOMAIN_MEMBALLOON_MODEL_NONE: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 38a9cab582..30e8e4244e 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -30,6 +30,7 @@ addr=0x1 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -41,9 +42,11 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.4,addr=0x0 \ +-device virtio-balloon-pci,disable-legacy=on,disable-modern=off,id=balloon0,\ +bus=pci.5,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=on,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.5,addr=0x0 \ +id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 8c571c04f1..dbf7a4ef15 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -30,6 +30,7 @@ addr=0x1 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -41,8 +42,9 @@ bus=pci.1,addr=0x0 \ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.4,addr=0x0 \ +-device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.5,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.5,addr=0x0 \ +-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index eec8b544e2..6d9691c1e5 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -26,6 +26,6 @@ <target dir='fs1'/> </filesystem> <controller type='usb' index='0' model='none'/> - <memballoon model='none'/> + <memballoon model='virtio-non-transitional'/> </devices> </domain> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index 796a29044c..b7cb304891 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -38,9 +38,11 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x4 \ +-device virtio-balloon-pci,disable-legacy=off,disable-modern=off,id=balloon0,\ +bus=pci.2,addr=0x5 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.2,addr=0x5 \ +id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index eb8da465f6..77332549bf 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -38,8 +38,9 @@ bus=pci.2,addr=0x1 \ mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.2,addr=0x4 \ +-device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x5 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x5 \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index cb23d4d7a8..43c55e9d31 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -26,6 +26,6 @@ <target dir='fs1'/> </filesystem> <controller type='usb' index='0' model='none'/> - <memballoon model='none'/> + <memballoon model='virtio-transitional'/> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 18ef85092a..721dccbaef 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -55,6 +55,11 @@ <target chassis='6' port='0xd'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/> </controller> + <controller type='pci' index='7' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='7' port='0xe'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/> + </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> @@ -71,10 +76,12 @@ <source protocol='vhost' wwpn='naa.5123456789abcde0'/> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </hostdev> - <memballoon model='none'/> + <memballoon model='virtio-non-transitional'> + <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> + </memballoon> <rng model='virtio-non-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </rng> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 334cfaa6e4..2402c5f227 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -55,10 +55,12 @@ <source protocol='vhost' wwpn='naa.5123456789abcde0'/> <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> </hostdev> - <memballoon model='none'/> + <memballoon model='virtio-transitional'> + <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> + </memballoon> <rng model='virtio-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> </rng> </devices> </domain> -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote: [...]
@@ -882,7 +882,10 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_MEMBALLOON: switch ((virDomainMemballoonModel) dev->data.memballoon->model) { case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO: + case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL: return virtioFlags; + case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags;
Same nit as in 8/17, please move the _TRANSITIONAL case first. Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add <vsock> model handling for virtio transitional devices. Ex: <vsock model='virtio-transitional'> ... </vsock> * "virtio-transitional" maps to qemu "vhost-vsock-pci-transitional" * "virtio-non-transitional" maps to qemu "vhost-vsock-pci-non-transitional" Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 6 +++++- docs/schemas/domaincommon.rng | 6 +++++- src/conf/domain_conf.c | 2 ++ src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 6 +++++- src/qemu/qemu_domain_address.c | 13 ++++++++++++- .../virtio-non-transitional.x86_64-3.1.0.args | 3 +++ .../virtio-non-transitional.x86_64-latest.args | 3 +++ tests/qemuxml2argvdata/virtio-non-transitional.xml | 3 +++ .../virtio-transitional.x86_64-3.1.0.args | 2 ++ .../virtio-transitional.x86_64-latest.args | 2 ++ tests/qemuxml2argvdata/virtio-transitional.xml | 3 +++ .../qemuxml2xmloutdata/virtio-non-transitional.xml | 9 +++++++++ tests/qemuxml2xmloutdata/virtio-transitional.xml | 4 ++++ tests/qemuxml2xmltest.c | 6 ++++-- 15 files changed, 64 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 4a1ba83cd8..15aed5381f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8652,7 +8652,11 @@ qemu-kvm -net nic,model=? /dev/null <h3><a id="vsock">Vsock</a></h3> <p>A vsock host/guest interface. The <code>model</code> attribute - defaults to <code>virtio</code>. + defaults to <code>virtio</code>. <span class="since">Since 5.1.0</span> + <code>model</code> can also be 'virtio-transitional' and + 'virtio-non-transitional', see + <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. The optional attribute <code>address</code> of the <code>cid</code> element specifies the CID assigned to the guest. If the attribute <code>auto</code> is set to <code>yes</code>, libvirt diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 94c358b578..e1e5a64592 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4304,7 +4304,11 @@ <element name="vsock"> <optional> <attribute name="model"> - <value>virtio</value> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> </attribute> </optional> <interleave> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e4484f9982..22f07307ad 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -990,6 +990,8 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, "default", "virtio", + "virtio-transitional", + "virtio-non-transitional", ); VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 40da1b40b7..a236d4fc9c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2420,6 +2420,8 @@ struct _virDomainIOMMUDef { typedef enum { VIR_DOMAIN_VSOCK_MODEL_DEFAULT, VIR_DOMAIN_VSOCK_MODEL_VIRTIO, + VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL, VIR_DOMAIN_VSOCK_MODEL_LAST } virDomainVsockModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b843408402..022d5a5d90 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -507,6 +507,11 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_VSOCK: + has_tmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: @@ -525,7 +530,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf, case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_LAST: default: return 0; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index c1a6d94a4c..badf237333 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -977,7 +977,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_DEVICE_VSOCK: - return virtioFlags; + switch ((virDomainVsockModel) dev->data.vsock->model) { + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO: + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL: + return virtioFlags; + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + + case VIR_DOMAIN_VSOCK_MODEL_DEFAULT: + case VIR_DOMAIN_VSOCK_MODEL_LAST: + return 0; + } + break; /* These devices don't ever connect with PCI */ case VIR_DOMAIN_DEVICE_NVRAM: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 30e8e4244e..97df54dd77 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -31,6 +31,7 @@ addr=0x1 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -49,4 +50,6 @@ bus=pci.5,addr=0x0 \ id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\ +guest-cid=4,vhostfd=6789,bus=pci.7,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index dbf7a4ef15..2a73798ee2 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -31,6 +31,7 @@ addr=0x1 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -47,4 +48,6 @@ id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ +bus=pci.7,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 6d9691c1e5..97d9c77a73 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -27,5 +27,8 @@ </filesystem> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-non-transitional'/> + <vsock model='virtio-non-transitional'> + <cid auto='no' address='4'/> + </vsock> </devices> </domain> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index b7cb304891..c3df97ca86 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -45,4 +45,6 @@ bus=pci.2,addr=0x5 \ id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci,disable-legacy=off,disable-modern=off,id=vsock0,\ +guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 77332549bf..f3a4e0804e 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -43,4 +43,6 @@ id=hostdev0,bus=pci.2,addr=0x4 \ -device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ +bus=pci.2,addr=0x7 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index 43c55e9d31..a2ca96ed09 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -27,5 +27,8 @@ </filesystem> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-transitional'/> + <vsock model='virtio-transitional'> + <cid auto='no' address='4'/> + </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 721dccbaef..9f05de5089 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -60,6 +60,11 @@ <target chassis='7' port='0xe'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/> </controller> + <controller type='pci' index='8' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='8' port='0xf'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/> + </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> @@ -83,5 +88,9 @@ <backend model='random'>/dev/urandom</backend> <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </rng> + <vsock model='virtio-non-transitional'> + <cid auto='no' address='4'/> + <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> + </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 2402c5f227..0d99aa2ded 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -62,5 +62,9 @@ <backend model='random'>/dev/urandom</backend> <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> </rng> + <vsock model='virtio-transitional'> + <cid auto='no' address='4'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> + </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 15f0ccffb1..30954cc341 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1258,12 +1258,14 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_DEVICE_VHOST_VSOCK); DO_TEST("virtio-non-transitional", QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, + QEMU_CAPS_DEVICE_VHOST_VSOCK); if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote: [...]
@@ -977,7 +977,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break;
case VIR_DOMAIN_DEVICE_VSOCK: - return virtioFlags; + switch ((virDomainVsockModel) dev->data.vsock->model) { + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO: + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL: + return virtioFlags; + case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags;
Same nit as in 8/17. Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

<input> devices lack the model= attribute which is used by most other device types. To eventually support virtio-input-host-pci-{non-}traditional in qemu, let's add a standard model= attribute. This just adds the domain_conf wiring Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 6 ++++ docs/schemas/domaincommon.rng | 9 +++++ src/conf/domain_conf.c | 35 +++++++++++++++++++ src/conf/domain_conf.h | 11 ++++++ .../virtio-non-transitional.x86_64-3.1.0.args | 5 ++- ...virtio-non-transitional.x86_64-latest.args | 5 ++- .../virtio-non-transitional.xml | 3 ++ .../virtio-transitional.x86_64-3.1.0.args | 3 ++ .../virtio-transitional.x86_64-latest.args | 3 ++ .../qemuxml2argvdata/virtio-transitional.xml | 3 ++ .../virtio-non-transitional.xml | 11 +++++- .../virtio-transitional.xml | 9 +++++ tests/qemuxml2xmltest.c | 6 ++-- 13 files changed, 104 insertions(+), 5 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 15aed5381f..336a28e54c 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6473,6 +6473,12 @@ qemu-kvm -net nic,model=? /dev/null For type <code>passthrough</code>, the mandatory sub-element <code>source</code> must have an <code>evdev</code> attribute containing the absolute path to the event device passed through to guests. (KVM only) + + <span class="since">Since 5.1.0</span>, the <code>input</code> element + accepts a <code>model</code> attribute which has the values 'virtio', + 'virtio-transitional' and 'virtio-non-transitional'. See + <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. </p> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e1e5a64592..8d90bb4b9f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4409,6 +4409,15 @@ </element> </group> </choice> + <optional> + <attribute name="model"> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> + </attribute> + </optional> <optional> <ref name="alias"/> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 22f07307ad..4c85d030ce 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -663,6 +663,13 @@ VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "virtio", ); +VIR_ENUM_IMPL(virDomainInputModel, VIR_DOMAIN_INPUT_MODEL_LAST, + "default", + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); + VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST, "sdl", "vnc", @@ -13187,6 +13194,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, char *evdev = NULL; char *type = NULL; char *bus = NULL; + char *model = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -13195,6 +13203,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, type = virXMLPropString(node, "type"); bus = virXMLPropString(node, "bus"); + model = virXMLPropString(node, "model"); if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -13208,6 +13217,13 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } + if (model && + (def->model = virDomainInputModelTypeFromString(model)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown input model '%s'"), model); + goto error; + } + if (bus) { if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -13317,6 +13333,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_FREE(evdev); VIR_FREE(type); VIR_FREE(bus); + VIR_FREE(model); ctxt->node = save; return def; @@ -22206,6 +22223,14 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src, return false; } + if (src->model != dst->model) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target input model %s does not match source %s"), + virDomainInputBusTypeToString(dst->model), + virDomainInputBusTypeToString(src->model)); + return false; + } + if (src->virtio && dst->virtio && !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; @@ -26785,6 +26810,7 @@ virDomainInputDefFormat(virBufferPtr buf, { const char *type = virDomainInputTypeToString(def->type); const char *bus = virDomainInputBusTypeToString(def->bus); + const char *model = virDomainInputModelTypeToString(def->model); virBuffer childbuf = VIR_BUFFER_INITIALIZER; virBuffer driverBuf = VIR_BUFFER_INITIALIZER; int ret = -1; @@ -26810,6 +26836,15 @@ virDomainInputDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<input type='%s' bus='%s'", type, bus); + if (def->model) { + if (!model) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected input model %d"), def->model); + goto cleanup; + } + virBufferAsprintf(buf, " model='%s'", model); + } + virBufferSetChildIndent(&childbuf, buf); virDomainVirtioOptionsFormat(&driverBuf, def->virtio); if (virBufferCheckError(&driverBuf) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a236d4fc9c..e1c3d9e067 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1376,9 +1376,19 @@ typedef enum { VIR_DOMAIN_INPUT_BUS_LAST } virDomainInputBus; +typedef enum { + VIR_DOMAIN_INPUT_MODEL_DEFAULT, + VIR_DOMAIN_INPUT_MODEL_VIRTIO, + VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL, + + VIR_DOMAIN_INPUT_MODEL_LAST +} virDomainInputModel; + struct _virDomainInputDef { int type; int bus; + int model; /* virDomainInputModel */ struct { char *evdev; } source; @@ -3495,6 +3505,7 @@ VIR_ENUM_DECL(virDomainHub); VIR_ENUM_DECL(virDomainRedirdevBus); VIR_ENUM_DECL(virDomainInput); VIR_ENUM_DECL(virDomainInputBus); +VIR_ENUM_DECL(virDomainInputModel); VIR_ENUM_DECL(virDomainGraphics); VIR_ENUM_DECL(virDomainGraphicsListen); VIR_ENUM_DECL(virDomainGraphicsAuthConnected); diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 97df54dd77..9130572abe 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -32,6 +32,7 @@ addr=0x1 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ +-device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,addr=0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -41,6 +42,8 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ +-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.7,\ +addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-balloon-pci,disable-legacy=on,disable-modern=off,id=balloon0,\ @@ -51,5 +54,5 @@ id=rng0,bus=pci.6,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\ -guest-cid=4,vhostfd=6789,bus=pci.7,addr=0x0 \ +guest-cid=4,vhostfd=6789,bus=pci.8,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 2a73798ee2..8e0709816b 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -32,6 +32,7 @@ addr=0x1 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ +-device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,addr=0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -41,6 +42,8 @@ bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ +-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.7,\ +addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.5,addr=0x0 \ @@ -49,5 +52,5 @@ id=hostdev0,bus=pci.4,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ -bus=pci.7,addr=0x0 \ +bus=pci.8,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 97d9c77a73..43e0b89e66 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -25,6 +25,9 @@ <source dir='/export/fs1'/> <target dir='fs1'/> </filesystem> + <input type='passthrough' bus='virtio' model='virtio-non-transitional'> + <source evdev='/dev/input/event1234'/> + </input> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-non-transitional'/> <vsock model='virtio-non-transitional'> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index c3df97ca86..0286b98ece 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -27,6 +27,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ bus=pci.2,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,8 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ +-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.3,\ +addr=0x0 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x4 \ -device virtio-balloon-pci,disable-legacy=off,disable-modern=off,id=balloon0,\ diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index f3a4e0804e..24b49e6009 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -27,6 +27,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x3,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,8 @@ bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ +-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.3,\ +addr=0x0 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.2,addr=0x4 \ -device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x5 \ diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index a2ca96ed09..b60400a484 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -25,6 +25,9 @@ <source dir='/export/fs1'/> <target dir='fs1'/> </filesystem> + <input type='passthrough' bus='virtio' model='virtio-transitional'> + <source evdev='/dev/input/event1234'/> + </input> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-transitional'/> <vsock model='virtio-transitional'> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 9f05de5089..b6e762c0a7 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -65,6 +65,11 @@ <target chassis='8' port='0xf'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/> </controller> + <controller type='pci' index='9' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='9' port='0x10'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> @@ -75,6 +80,10 @@ <model type='virtio-non-transitional'/> <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/> </interface> + <input type='passthrough' bus='virtio' model='virtio-non-transitional'> + <source evdev='/dev/input/event1234'/> + <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> + </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> @@ -90,7 +99,7 @@ </rng> <vsock model='virtio-non-transitional'> <cid auto='no' address='4'/> - <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 0d99aa2ded..490b28368a 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -39,6 +39,11 @@ <target chassis='3' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> + <controller type='pci' index='4' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='4' port='0xa'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> @@ -49,6 +54,10 @@ <model type='virtio-transitional'/> <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/> </interface> + <input type='passthrough' bus='virtio' model='virtio-transitional'> + <source evdev='/dev/input/event1234'/> + <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 30954cc341..452184d84a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1259,13 +1259,15 @@ mymain(void) QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, - QEMU_CAPS_DEVICE_VHOST_VSOCK); + QEMU_CAPS_DEVICE_VHOST_VSOCK, + QEMU_CAPS_VIRTIO_INPUT_HOST); DO_TEST("virtio-non-transitional", QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, - QEMU_CAPS_DEVICE_VHOST_VSOCK); + QEMU_CAPS_DEVICE_VHOST_VSOCK, + QEMU_CAPS_VIRTIO_INPUT_HOST); if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote: [...]
@@ -13208,6 +13217,13 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; }
+ if (model && + (def->model = virDomainInputModelTypeFromString(model)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown input model '%s'"), model); + goto error; + }
Same comment as 9/17 as far as parsing the model is concerned. [...]
@@ -26810,6 +26836,15 @@ virDomainInputDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<input type='%s' bus='%s'", type, bus);
+ if (def->model) { + if (!model) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected input model %d"), def->model); + goto cleanup; + } + virBufferAsprintf(buf, " model='%s'", model); + }
Since def->model is optional, I think this would be a bit more legible as if (def->model) { const char *model = virDomainInputModelTypeToString(def->model); if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected input model %d"), def->model); goto cleanup; } virBufferAsprintf(buf, " model='%s'", model); } but either way is fine. [...]
+++ b/src/conf/domain_conf.h @@ -1376,9 +1376,19 @@ typedef enum { VIR_DOMAIN_INPUT_BUS_LAST } virDomainInputBus;
+typedef enum { + VIR_DOMAIN_INPUT_MODEL_DEFAULT, + VIR_DOMAIN_INPUT_MODEL_VIRTIO, + VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL, + + VIR_DOMAIN_INPUT_MODEL_LAST +} virDomainInputModel;
Please explicitly assign 0 to the first enum value. Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

Add <input> model handling for virtio transitional devices. Ex: <input type='passthrough' bus='virtio' model='virtio-transitional'> ... </input> * "virtio-transitional" maps to qemu "virtio-input-host-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-input-host-non-transitional" Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 8 +++++++- src/qemu/qemu_domain_address.c | 13 ++++++++++++- .../virtio-non-transitional.x86_64-3.1.0.args | 4 ++-- .../virtio-non-transitional.x86_64-latest.args | 4 ++-- .../virtio-transitional.x86_64-3.1.0.args | 7 +++---- .../virtio-transitional.x86_64-latest.args | 7 +++---- tests/qemuxml2xmloutdata/virtio-transitional.xml | 9 ++------- 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 022d5a5d90..946bc8b0b3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -512,8 +512,14 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; break; - case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: + if (device.data.input->type != VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) + return 0; + has_tmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_WATCHDOG: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index badf237333..8f505c90fd 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -949,7 +949,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: - return virtioFlags; + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + return virtioFlags; + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } + return 0; case VIR_DOMAIN_INPUT_BUS_PS2: case VIR_DOMAIN_INPUT_BUS_USB: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 9130572abe..0f5de86315 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -42,8 +42,8 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ --device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.7,\ -addr=0x0 \ +-device virtio-input-host-pci,disable-legacy=on,disable-modern=off,id=input0,\ +evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-balloon-pci,disable-legacy=on,disable-modern=off,id=balloon0,\ diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 8e0709816b..383b29f629 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -42,8 +42,8 @@ bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ --device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.7,\ -addr=0x0 \ +-device virtio-input-host-pci-non-transitional,id=input0,\ +evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.5,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index 0286b98ece..1c851b5ec4 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -27,7 +27,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ bus=pci.2,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -37,8 +36,8 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ --device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.3,\ -addr=0x0 \ +-device virtio-input-host-pci,disable-legacy=off,disable-modern=off,id=input0,\ +evdev=/dev/input/event1234,bus=pci.2,addr=0x7 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x4 \ -device virtio-balloon-pci,disable-legacy=off,disable-modern=off,id=balloon0,\ @@ -49,5 +48,5 @@ id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=off,disable-modern=off,id=vsock0,\ -guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \ +guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x8 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 24b49e6009..410eb28f0a 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -27,7 +27,6 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x3,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -37,8 +36,8 @@ bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ --device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.3,\ -addr=0x0 \ +-device virtio-input-host-pci-transitional,id=input0,\ +evdev=/dev/input/event1234,bus=pci.2,addr=0x7 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.2,addr=0x4 \ -device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x5 \ @@ -47,5 +46,5 @@ id=hostdev0,bus=pci.2,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ -bus=pci.2,addr=0x7 \ +bus=pci.2,addr=0x8 \ -msg timestamp=on diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 490b28368a..9fa9732c2d 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -39,11 +39,6 @@ <target chassis='3' port='0x9'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> - <controller type='pci' index='4' model='pcie-root-port'> - <model name='pcie-root-port'/> - <target chassis='4' port='0xa'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> - </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> @@ -56,7 +51,7 @@ </interface> <input type='passthrough' bus='virtio' model='virtio-transitional'> <source evdev='/dev/input/event1234'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> @@ -73,7 +68,7 @@ </rng> <vsock model='virtio-transitional'> <cid auto='no' address='4'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x08' function='0x0'/> </vsock> </devices> </domain> -- 2.20.1

Add controller type='virtio-serial' model handling for virtio transitional devices. Ex: <controller type='virtio-serial' model='virtio-transitional'/> * "virtio-transitional" maps to qemu "virtio-serial-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-serial-pci-non-transitional" Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 7 +++++- docs/schemas/domaincommon.rng | 9 ++++++++ src/conf/domain_conf.c | 11 ++++++++++ src/conf/domain_conf.h | 10 +++++++++ src/qemu/qemu_command.c | 10 ++++++++- src/qemu/qemu_domain_address.c | 15 ++++++++++++- .../virtio-non-transitional.x86_64-3.1.0.args | 18 +++++++++------ ...virtio-non-transitional.x86_64-latest.args | 18 +++++++++------ .../virtio-non-transitional.xml | 1 + .../virtio-transitional.x86_64-3.1.0.args | 14 +++++++----- .../virtio-transitional.x86_64-latest.args | 13 ++++++----- .../qemuxml2argvdata/virtio-transitional.xml | 1 + .../virtio-non-transitional.xml | 22 +++++++++++++------ .../virtio-transitional.xml | 15 ++++++++----- 14 files changed, 122 insertions(+), 42 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 336a28e54c..32e40e8765 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4171,7 +4171,12 @@ <dd>The <code>virtio-serial</code> controller has two additional optional attributes <code>ports</code> and <code>vectors</code>, which control how many devices can be connected through the - controller.</dd> + controller. <span class="since">Since 5.1.0</span>, it + supports an optional attribute <code>model</code> which can + be 'virtio', 'virtio-transitional', or 'virtio-non-transitional'. See + <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. + </dd> <dt><code>scsi</code></dt> <dd>A <code>scsi</code> controller has an optional attribute <code>model</code>, which is one of 'auto', 'buslogic', 'ibmvscsi', diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8d90bb4b9f..da2545b889 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2313,6 +2313,15 @@ <attribute name="type"> <value>virtio-serial</value> </attribute> + <optional> + <attribute name="model"> + <choice> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice> + </attribute> + </optional> <optional> <attribute name="ports"> <ref name="unsignedInt"/> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4c85d030ce..44c9aa5b83 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -404,6 +404,13 @@ VIR_ENUM_IMPL(virDomainControllerModelIDE, VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST, "ich6", ); +VIR_ENUM_IMPL(virDomainControllerModelVirtioSerial, + VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_LAST, + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); + VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST, "mount", "block", @@ -10426,6 +10433,8 @@ virDomainControllerModelTypeFromString(const virDomainControllerDef *def, return virDomainControllerModelPCITypeFromString(model); else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) return virDomainControllerModelIDETypeFromString(model); + else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) + return virDomainControllerModelVirtioSerialTypeFromString(model); return -1; } @@ -10443,6 +10452,8 @@ virDomainControllerModelTypeToString(virDomainControllerDefPtr def, return virDomainControllerModelPCITypeToString(model); else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) return virDomainControllerModelIDETypeToString(model); + else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) + return virDomainControllerModelVirtioSerialTypeToString(model); return NULL; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e1c3d9e067..a6b32b17bd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -789,6 +789,15 @@ typedef enum { VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST } virDomainControllerModelIDE; +typedef enum { + VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_DEFAULT = -1, + VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO, + VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL, + + VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_LAST +} virDomainControllerModelVirtioSerial; + # define IS_USB2_CONTROLLER(ctrl) \ (((ctrl)->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) && \ ((ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1 || \ @@ -3472,6 +3481,7 @@ VIR_ENUM_DECL(virDomainControllerPCIModelName); VIR_ENUM_DECL(virDomainControllerModelSCSI); VIR_ENUM_DECL(virDomainControllerModelUSB); VIR_ENUM_DECL(virDomainControllerModelIDE); +VIR_ENUM_DECL(virDomainControllerModelVirtioSerial); VIR_ENUM_DECL(virDomainFS); VIR_ENUM_DECL(virDomainFSDriver); VIR_ENUM_DECL(virDomainFSAccessMode); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 946bc8b0b3..ded9773499 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -519,11 +519,19 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_CONTROLLER: + if (device.data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { + has_tmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; + } else { + return 0; + } + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_WATCHDOG: - case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_REDIRDEV: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 8f505c90fd..78695fdc0a 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -665,7 +665,20 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - return virtioFlags; + switch ((virDomainControllerModelVirtioSerial) cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; + + case VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO: + case VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_DEFAULT: + return virtioFlags; + + case VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_LAST: + return 0; + } + break; case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 0f5de86315..7543a225cb 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -32,9 +32,13 @@ addr=0x1 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ --device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,addr=0x2 \ +-device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,\ +multifunction=on,addr=0x2 \ +-device pcie-root-port,port=0x11,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ +-device virtio-serial-pci,disable-legacy=on,disable-modern=off,\ +id=virtio-serial0,bus=pci.3,addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ +-device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.4,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci,disable-legacy=on,disable-modern=off,id=fs0,\ @@ -43,16 +47,16 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device virtio-input-host-pci,disable-legacy=on,disable-modern=off,id=input0,\ -evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \ +evdev=/dev/input/event1234,bus=pci.8,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.4,addr=0x0 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.5,addr=0x0 \ -device virtio-balloon-pci,disable-legacy=on,disable-modern=off,id=balloon0,\ -bus=pci.5,addr=0x0 \ +bus=pci.6,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=on,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.6,addr=0x0 \ +id=rng0,bus=pci.7,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\ -guest-cid=4,vhostfd=6789,bus=pci.8,addr=0x0 \ +guest-cid=4,vhostfd=6789,bus=pci.9,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 383b29f629..514db3ee7f 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -32,9 +32,13 @@ addr=0x1 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ --device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,addr=0x2 \ +-device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,\ +multifunction=on,addr=0x2 \ +-device pcie-root-port,port=0x11,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ +-device virtio-serial-pci-non-transitional,id=virtio-serial0,bus=pci.3,\ +addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ +-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.4,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci-non-transitional,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ @@ -43,14 +47,14 @@ bus=pci.1,addr=0x0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device virtio-input-host-pci-non-transitional,id=input0,\ -evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \ +evdev=/dev/input/event1234,bus=pci.8,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.4,addr=0x0 \ --device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.5,addr=0x0 \ +id=hostdev0,bus=pci.5,addr=0x0 \ +-device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.6,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \ +-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.7,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ -bus=pci.8,addr=0x0 \ +bus=pci.9,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 43e0b89e66..4e1b0084c5 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -28,6 +28,7 @@ <input type='passthrough' bus='virtio' model='virtio-non-transitional'> <source evdev='/dev/input/event1234'/> </input> + <controller type='virtio-serial' model='virtio-non-transitional'/> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-non-transitional'/> <vsock model='virtio-non-transitional'> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index 1c851b5ec4..b07f77511f 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -27,9 +27,11 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device virtio-serial-pci,disable-legacy=off,disable-modern=off,\ +id=virtio-serial0,bus=pci.2,addr=0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ -bus=pci.2,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +bus=pci.2,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci,disable-legacy=off,disable-modern=off,id=fs0,\ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ @@ -37,16 +39,16 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device virtio-input-host-pci,disable-legacy=off,disable-modern=off,id=input0,\ -evdev=/dev/input/event1234,bus=pci.2,addr=0x7 \ +evdev=/dev/input/event1234,bus=pci.2,addr=0x8 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x4 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x5 \ -device virtio-balloon-pci,disable-legacy=off,disable-modern=off,id=balloon0,\ -bus=pci.2,addr=0x5 \ +bus=pci.2,addr=0x6 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.2,addr=0x6 \ +id=rng0,bus=pci.2,addr=0x7 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=off,disable-modern=off,id=vsock0,\ -guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x8 \ +guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x9 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 410eb28f0a..6c697eba83 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -27,8 +27,9 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device virtio-serial-pci-transitional,id=virtio-serial0,bus=pci.2,addr=0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x3,\ +-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x4,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci-transitional,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ @@ -37,14 +38,14 @@ bus=pci.2,addr=0x1 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device virtio-input-host-pci-transitional,id=input0,\ -evdev=/dev/input/event1234,bus=pci.2,addr=0x7 \ +evdev=/dev/input/event1234,bus=pci.2,addr=0x8 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.2,addr=0x4 \ --device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x5 \ +id=hostdev0,bus=pci.2,addr=0x5 \ +-device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x6 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x7 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ -bus=pci.2,addr=0x8 \ +bus=pci.2,addr=0x9 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index b60400a484..ffcafedc4a 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -28,6 +28,7 @@ <input type='passthrough' bus='virtio' model='virtio-transitional'> <source evdev='/dev/input/event1234'/> </input> + <controller type='virtio-serial' model='virtio-transitional'/> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-transitional'/> <vsock model='virtio-transitional'> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index b6e762c0a7..7ef2d09c11 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -18,8 +18,11 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </disk> + <controller type='virtio-serial' index='0' model='virtio-non-transitional'> + <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> + </controller> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> @@ -68,7 +71,12 @@ <controller type='pci' index='9' model='pcie-root-port'> <model name='pcie-root-port'/> <target chassis='9' port='0x10'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='10' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='10' port='0x11'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/> </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> <source dir='/export/fs1'/> @@ -82,24 +90,24 @@ </interface> <input type='passthrough' bus='virtio' model='virtio-non-transitional'> <source evdev='/dev/input/event1234'/> - <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> </hostdev> <memballoon model='virtio-non-transitional'> - <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </memballoon> <rng model='virtio-non-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> </rng> <vsock model='virtio-non-transitional'> <cid auto='no' address='4'/> - <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/> </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 9fa9732c2d..da4fbbcdc5 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -18,8 +18,11 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> </disk> + <controller type='virtio-serial' index='0' model='virtio-transitional'> + <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> + </controller> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> @@ -51,24 +54,24 @@ </interface> <input type='passthrough' bus='virtio' model='virtio-transitional'> <source evdev='/dev/input/event1234'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x08' function='0x0'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> </hostdev> <memballoon model='virtio-transitional'> - <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> </memballoon> <rng model='virtio-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> </rng> <vsock model='virtio-transitional'> <cid auto='no' address='4'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x08' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x09' function='0x0'/> </vsock> </devices> </domain> -- 2.20.1

Add <controller type='scsi' model handling for virtio transitional devices. Ex: <controller type='scsi' model='virtio-transitional'/> * "virtio-transitional" maps to qemu "virtio-scsi-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-scsi-non-transitional" The naming here doesn't match the pre-existing model=virtio-scsi. The prescence of '-scsi' there seems kind of redundant as we have type='scsi' already, so I decided to follow the pattern of other patches and use virtio-transitional etc. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 7 +++++-- docs/schemas/domaincommon.rng | 2 ++ src/conf/domain_conf.c | 14 ++++++++----- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 5 +++++ src/qemu/qemu_domain.c | 8 +++++++- src/qemu/qemu_domain_address.c | 3 +++ src/vbox/vbox_common.c | 2 ++ src/vmx/vmx.c | 5 ++++- .../virtio-non-transitional.x86_64-3.1.0.args | 15 ++++++++------ ...virtio-non-transitional.x86_64-latest.args | 14 +++++++------ .../virtio-non-transitional.xml | 1 + .../virtio-transitional.x86_64-3.1.0.args | 14 +++++++------ .../virtio-transitional.x86_64-latest.args | 13 ++++++------ .../qemuxml2argvdata/virtio-transitional.xml | 1 + .../virtio-non-transitional.xml | 20 +++++++++++++------ .../virtio-transitional.xml | 15 ++++++++------ tests/qemuxml2xmltest.c | 6 ++++-- 18 files changed, 100 insertions(+), 47 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 32e40e8765..cd0468f3cb 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4180,8 +4180,11 @@ <dt><code>scsi</code></dt> <dd>A <code>scsi</code> controller has an optional attribute <code>model</code>, which is one of 'auto', 'buslogic', 'ibmvscsi', - 'lsilogic', 'lsisas1068', 'lsisas1078', 'virtio-scsi' or - 'vmpvscsi'.</dd> + 'lsilogic', 'lsisas1068', 'lsisas1078', 'virtio-scsi', + 'vmpvscsi', 'virtio-transitional', 'virtio-non-transitional'. See + <a href="#elementsVirtioTransitional">Virtio transitional devices</a> + for more details. + </dd> <dt><code>usb</code></dt> <dd>A <code>usb</code> controller has an optional attribute <code>model</code>, which is one of "piix3-uhci", "piix4-uhci", diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index da2545b889..1332e0d464 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2156,6 +2156,8 @@ <value>ibmvscsi</value> <value>virtio-scsi</value> <value>lsisas1078</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> </choice> </attribute> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 44c9aa5b83..78425d0142 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -379,7 +379,10 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS "vmpvscsi", "ibmvscsi", "virtio-scsi", - "lsisas1078"); + "lsisas1078", + "virtio-transitional", + "virtio-non-transitional", +); VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST, "piix3-uhci", @@ -4965,11 +4968,12 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev, virDomainControllerDefPtr cdev = dev->data.controller; if (cdev->iothread && - cdev->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI) { - virReportError(VIR_ERR_XML_ERROR, + cdev->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI && + cdev->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL && + cdev->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("'iothread' attribute only supported for " - "controller model '%s'"), - virDomainControllerModelSCSITypeToString(VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)); + "virtio scsi controllers")); return -1; } } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a6b32b17bd..caa018a4cf 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -756,6 +756,8 @@ typedef enum { VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078, + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST } virDomainControllerModelSCSI; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ded9773499..dbf4f7b783 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -523,6 +523,9 @@ qemuBuildVirtioDevStr(virBufferPtr buf, if (device.data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { has_tmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; has_ntmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; + } else if (device.data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { + has_tmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; } else { return 0; } @@ -2997,6 +3000,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch ((virDomainControllerModelSCSI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: if (qemuBuildVirtioDevStr(&buf, "virtio-scsi", qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 16929ea656..c83a4cd451 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5099,7 +5099,9 @@ static int qemuDomainDeviceDefValidateControllerAttributes(const virDomainControllerDef *controller) { if (!(controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI && - controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) { + (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI || + controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL || + controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL))) { if (controller->queues) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("'queues' is only supported by virtio-scsi controller")); @@ -5153,6 +5155,8 @@ qemuDomainCheckSCSIControllerModel(virQEMUCapsPtr qemuCaps, } break; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("This QEMU doesn't support " @@ -5268,6 +5272,8 @@ qemuDomainDeviceDefValidateControllerSCSI(const virDomainControllerDef *controll { switch ((virDomainControllerModelSCSI) controller->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: if (!qemuDomainCheckSCSIControllerIOThreads(controller, def)) return -1; break; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 78695fdc0a..ce3a513823 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -648,8 +648,11 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, return 0; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: return virtioFlags; + /* Transitional devices only work in conventional PCI slots */ + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 664650f217..00d43d9a83 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -406,6 +406,8 @@ vboxSetStorageController(virDomainControllerDefPtr controller, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The vbox driver does not support %s SCSI " diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index d525f187e9..75cdea9067 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -517,7 +517,10 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, "pvscsi", "UNUSED ibmvscsi", "UNUSED virtio-scsi", - "UNUSED lsisas1078"); + "UNUSED lsisas1078", + "UNUSED virtio-transitional", + "UNUSED virtio-non-transitional", +); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 7543a225cb..52f0855611 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -35,10 +35,13 @@ addr=0x1 \ -device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,\ multifunction=on,addr=0x2 \ -device pcie-root-port,port=0x11,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ +-device pcie-root-port,port=0x12,chassis=11,id=pci.11,bus=pcie.0,addr=0x2.0x2 \ +-device virtio-scsi-pci,disable-legacy=on,disable-modern=off,id=scsi0,\ +bus=pci.4,addr=0x0 \ -device virtio-serial-pci,disable-legacy=on,disable-modern=off,\ id=virtio-serial0,bus=pci.3,addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.4,\ +-device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.5,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci,disable-legacy=on,disable-modern=off,id=fs0,\ @@ -47,16 +50,16 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.1,addr=0x0 \ -device virtio-net-pci,disable-legacy=on,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device virtio-input-host-pci,disable-legacy=on,disable-modern=off,id=input0,\ -evdev=/dev/input/event1234,bus=pci.8,addr=0x0 \ +evdev=/dev/input/event1234,bus=pci.9,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.5,addr=0x0 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.6,addr=0x0 \ -device virtio-balloon-pci,disable-legacy=on,disable-modern=off,id=balloon0,\ -bus=pci.6,addr=0x0 \ +bus=pci.7,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=on,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.7,addr=0x0 \ +id=rng0,bus=pci.8,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\ -guest-cid=4,vhostfd=6789,bus=pci.9,addr=0x0 \ +guest-cid=4,vhostfd=6789,bus=pci.10,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 514db3ee7f..54125d2102 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -35,10 +35,12 @@ addr=0x1 \ -device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,\ multifunction=on,addr=0x2 \ -device pcie-root-port,port=0x11,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ +-device pcie-root-port,port=0x12,chassis=11,id=pci.11,bus=pcie.0,addr=0x2.0x2 \ +-device virtio-scsi-pci-non-transitional,id=scsi0,bus=pci.4,addr=0x0 \ -device virtio-serial-pci-non-transitional,id=virtio-serial0,bus=pci.3,\ addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-non-transitional,scsi=off,bus=pci.4,addr=0x0,\ +-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.5,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci-non-transitional,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ @@ -47,14 +49,14 @@ bus=pci.1,addr=0x0 \ -device virtio-net-pci-non-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device virtio-input-host-pci-non-transitional,id=input0,\ -evdev=/dev/input/event1234,bus=pci.8,addr=0x0 \ +evdev=/dev/input/event1234,bus=pci.9,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.5,addr=0x0 \ --device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.6,addr=0x0 \ +id=hostdev0,bus=pci.6,addr=0x0 \ +-device virtio-balloon-pci-non-transitional,id=balloon0,bus=pci.7,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.7,addr=0x0 \ +-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.8,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ -bus=pci.9,addr=0x0 \ +bus=pci.10,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 4e1b0084c5..adcbcec33e 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -29,6 +29,7 @@ <source evdev='/dev/input/event1234'/> </input> <controller type='virtio-serial' model='virtio-non-transitional'/> + <controller type='scsi' model='virtio-non-transitional'/> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-non-transitional'/> <vsock model='virtio-non-transitional'> diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index b07f77511f..4f8958f336 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -27,11 +27,13 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device virtio-scsi-pci,disable-legacy=off,disable-modern=off,id=scsi0,\ +bus=pci.2,addr=0x4 \ -device virtio-serial-pci,disable-legacy=off,disable-modern=off,\ id=virtio-serial0,bus=pci.2,addr=0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=off,disable-modern=off,scsi=off,\ -bus=pci.2,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ +bus=pci.2,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci,disable-legacy=off,disable-modern=off,id=fs0,\ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ @@ -39,16 +41,16 @@ fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ -device virtio-net-pci,disable-legacy=off,disable-modern=off,netdev=hostnet0,\ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device virtio-input-host-pci,disable-legacy=off,disable-modern=off,id=input0,\ -evdev=/dev/input/event1234,bus=pci.2,addr=0x8 \ +evdev=/dev/input/event1234,bus=pci.2,addr=0x9 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ -wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x5 \ +wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x6 \ -device virtio-balloon-pci,disable-legacy=off,disable-modern=off,id=balloon0,\ -bus=pci.2,addr=0x6 \ +bus=pci.2,addr=0x7 \ -object rng-random,id=objrng0,filename=/dev/urandom \ -device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ -id=rng0,bus=pci.2,addr=0x7 \ +id=rng0,bus=pci.2,addr=0x8 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=off,disable-modern=off,id=vsock0,\ -guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x9 \ +guest-cid=4,vhostfd=6789,bus=pci.2,addr=0xa \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 6c697eba83..49cfd12b92 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -27,9 +27,10 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ -device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device virtio-scsi-pci-transitional,id=scsi0,bus=pci.2,addr=0x4 \ -device virtio-serial-pci-transitional,id=virtio-serial0,bus=pci.2,addr=0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x4,\ +-device virtio-blk-pci-transitional,scsi=off,bus=pci.2,addr=0x5,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ -device virtio-9p-pci-transitional,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ @@ -38,14 +39,14 @@ bus=pci.2,addr=0x1 \ -device virtio-net-pci-transitional,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x2 \ -device virtio-input-host-pci-transitional,id=input0,\ -evdev=/dev/input/event1234,bus=pci.2,addr=0x8 \ +evdev=/dev/input/event1234,bus=pci.2,addr=0x9 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.2,addr=0x5 \ --device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x6 \ +id=hostdev0,bus=pci.2,addr=0x6 \ +-device virtio-balloon-pci-transitional,id=balloon0,bus=pci.2,addr=0x7 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x7 \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x8 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\ -bus=pci.2,addr=0x9 \ +bus=pci.2,addr=0xa \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index ffcafedc4a..35613069d9 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -29,6 +29,7 @@ <source evdev='/dev/input/event1234'/> </input> <controller type='virtio-serial' model='virtio-transitional'/> + <controller type='scsi' model='virtio-transitional'/> <controller type='usb' index='0' model='none'/> <memballoon model='virtio-transitional'/> <vsock model='virtio-transitional'> diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 7ef2d09c11..4e7d1ee3b1 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -18,11 +18,14 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> </disk> <controller type='virtio-serial' index='0' model='virtio-non-transitional'> <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> </controller> + <controller type='scsi' index='0' model='virtio-non-transitional'> + <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> + </controller> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> @@ -78,6 +81,11 @@ <target chassis='10' port='0x11'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/> </controller> + <controller type='pci' index='11' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='11' port='0x12'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/> + </controller> <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> <source dir='/export/fs1'/> <target dir='fs1'/> @@ -90,24 +98,24 @@ </interface> <input type='passthrough' bus='virtio' model='virtio-non-transitional'> <source evdev='/dev/input/event1234'/> - <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-non-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </hostdev> <memballoon model='virtio-non-transitional'> - <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> </memballoon> <rng model='virtio-non-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> </rng> <vsock model='virtio-non-transitional'> <cid auto='no' address='4'/> - <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/> </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index da4fbbcdc5..2293e5be3e 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -18,11 +18,14 @@ <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='vda' bus='virtio'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> </disk> <controller type='virtio-serial' index='0' model='virtio-transitional'> <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> </controller> + <controller type='scsi' index='0' model='virtio-transitional'> + <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/> + </controller> <controller type='usb' index='0' model='none'/> <controller type='sata' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> @@ -54,24 +57,24 @@ </interface> <input type='passthrough' bus='virtio' model='virtio-transitional'> <source evdev='/dev/input/event1234'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x08' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x09' function='0x0'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='scsi_host' managed='no' model='virtio-transitional'> <source protocol='vhost' wwpn='naa.5123456789abcde0'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x05' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> </hostdev> <memballoon model='virtio-transitional'> - <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> </memballoon> <rng model='virtio-transitional'> <backend model='random'>/dev/urandom</backend> - <address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x08' function='0x0'/> </rng> <vsock model='virtio-transitional'> <cid auto='no' address='4'/> - <address type='pci' domain='0x0000' bus='0x02' slot='0x09' function='0x0'/> + <address type='pci' domain='0x0000' bus='0x02' slot='0x0a' function='0x0'/> </vsock> </devices> </domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 452184d84a..0a441da143 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1260,14 +1260,16 @@ mymain(void) QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, QEMU_CAPS_DEVICE_VHOST_VSOCK, - QEMU_CAPS_VIRTIO_INPUT_HOST); + QEMU_CAPS_VIRTIO_INPUT_HOST, + QEMU_CAPS_VIRTIO_SCSI); DO_TEST("virtio-non-transitional", QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, QEMU_CAPS_DEVICE_VHOST_VSOCK, - QEMU_CAPS_VIRTIO_INPUT_HOST); + QEMU_CAPS_VIRTIO_INPUT_HOST, + QEMU_CAPS_VIRTIO_SCSI); if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote:
Add <controller type='scsi' model handling for virtio transitional devices. Ex:
<controller type='scsi' model='virtio-transitional'/>
* "virtio-transitional" maps to qemu "virtio-scsi-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-scsi-non-transitional"
The naming here doesn't match the pre-existing model=virtio-scsi. The prescence of '-scsi' there seems kind of redundant as we have type='scsi' already, so I decided to follow the pattern of other patches and use virtio-transitional etc.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 7 +++++-- docs/schemas/domaincommon.rng | 2 ++ src/conf/domain_conf.c | 14 ++++++++----- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 5 +++++ src/qemu/qemu_domain.c | 8 +++++++- src/qemu/qemu_domain_address.c | 3 +++ src/vbox/vbox_common.c | 2 ++ src/vmx/vmx.c | 5 ++++- .../virtio-non-transitional.x86_64-3.1.0.args | 15 ++++++++------ ...virtio-non-transitional.x86_64-latest.args | 14 +++++++------ .../virtio-non-transitional.xml | 1 + .../virtio-transitional.x86_64-3.1.0.args | 14 +++++++------ .../virtio-transitional.x86_64-latest.args | 13 ++++++------ .../qemuxml2argvdata/virtio-transitional.xml | 1 + .../virtio-non-transitional.xml | 20 +++++++++++++------ .../virtio-transitional.xml | 15 ++++++++------ tests/qemuxml2xmltest.c | 6 ++++-- 18 files changed, 100 insertions(+), 47 deletions(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

This generates new XML like: <disk> <enum name='model'> <value>virtio</value> <value>virtio-transitional</value> <value>virtio-non-transitional</value> </enum> </disk> Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/domain_capabilities.c | 1 + src/conf/domain_capabilities.h | 1 + src/qemu/qemu_capabilities.c | 10 ++ .../bhyve_basic.x86_64.xml | 1 + .../bhyve_fbuf.x86_64.xml | 1 + .../bhyve_uefi.x86_64.xml | 1 + tests/domaincapsschemadata/full.xml | 6 + .../domaincapsschemadata/libxl-xenfv-usb.xml | 1 + .../domaincapsschemadata/libxl-xenpv-usb.xml | 1 + .../qemu_1.7.0.x86_64.xml | 3 + .../qemu_2.12.0-virt.aarch64.xml | 5 + .../qemu_2.12.0.ppc64.xml | 5 + .../qemu_2.12.0.s390x.xml | 5 + .../qemu_2.12.0.x86_64.xml | 5 + .../qemu_2.6.0-virt.aarch64.xml | 5 + .../qemu_2.6.0.aarch64.xml | 5 + .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 5 + .../qemu_2.6.0.x86_64.xml | 5 + .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 5 + .../qemu_2.8.0-tcg.x86_64.xml | 5 + .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 5 + .../qemu_2.8.0.x86_64.xml | 5 + .../qemu_2.9.0-q35.x86_64.xml | 5 + .../qemu_2.9.0-tcg.x86_64.xml | 5 + .../qemu_2.9.0.x86_64.xml | 5 + .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 5 + .../qemu_4.0.0.x86_64.xml | 153 ++++++++++++++++++ tests/domaincapstest.c | 4 + 28 files changed, 263 insertions(+) create mode 100644 tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 6352eda343..a6104920ab 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -482,6 +482,7 @@ virDomainCapsDeviceDiskFormat(virBufferPtr buf, ENUM_PROCESS(disk, diskDevice, virDomainDiskDeviceTypeToString); ENUM_PROCESS(disk, bus, virDomainDiskBusTypeToString); + ENUM_PROCESS(disk, model, virDomainDiskModelTypeToString); FORMAT_EPILOGUE(disk); } diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 15e065359b..4a9a717539 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -65,6 +65,7 @@ struct _virDomainCapsDeviceDisk { bool supported; virDomainCapsEnum diskDevice; /* Info about virDomainDiskDevice enum values */ virDomainCapsEnum bus; /* Info about virDomainDiskBus enum values */ + virDomainCapsEnum model; /* Info about virDomainDiskModel enum values */ /* add new fields here */ }; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8e42c1c51c..f69de29b81 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5278,6 +5278,16 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SATA); + /* disk->model values */ + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, VIR_DOMAIN_DISK_MODEL_VIRTIO); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY) || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL)) { + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL); + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL); + } + return 0; } diff --git a/tests/domaincapsschemadata/bhyve_basic.x86_64.xml b/tests/domaincapsschemadata/bhyve_basic.x86_64.xml index d6ecf061d0..bdf2c4eee8 100644 --- a/tests/domaincapsschemadata/bhyve_basic.x86_64.xml +++ b/tests/domaincapsschemadata/bhyve_basic.x86_64.xml @@ -21,6 +21,7 @@ <value>virtio</value> <value>sata</value> </enum> + <enum name='model'/> </disk> <graphics supported='no'/> <video supported='no'/> diff --git a/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml b/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml index 1a5aad7bce..f998c457c1 100644 --- a/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml +++ b/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml @@ -30,6 +30,7 @@ <value>virtio</value> <value>sata</value> </enum> + <enum name='model'/> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml b/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml index b624fd0799..18f90023d5 100644 --- a/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml +++ b/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml @@ -30,6 +30,7 @@ <value>virtio</value> <value>sata</value> </enum> + <enum name='model'/> </disk> <graphics supported='no'/> <video supported='no'/> diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemadata/full.xml index eafba1ae5b..28263466a4 100644 --- a/tests/domaincapsschemadata/full.xml +++ b/tests/domaincapsschemadata/full.xml @@ -51,6 +51,12 @@ <value>sata</value> <value>sd</value> </enum> + <enum name='model'> + <value>default</value> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/libxl-xenfv-usb.xml b/tests/domaincapsschemadata/libxl-xenfv-usb.xml index 29fe1f9aa3..4efc137c97 100644 --- a/tests/domaincapsschemadata/libxl-xenfv-usb.xml +++ b/tests/domaincapsschemadata/libxl-xenfv-usb.xml @@ -34,6 +34,7 @@ <value>scsi</value> <value>xen</value> </enum> + <enum name='model'/> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/libxl-xenpv-usb.xml b/tests/domaincapsschemadata/libxl-xenpv-usb.xml index b9f3ca736b..70e598fe9e 100644 --- a/tests/domaincapsschemadata/libxl-xenpv-usb.xml +++ b/tests/domaincapsschemadata/libxl-xenpv-usb.xml @@ -24,6 +24,7 @@ <value>scsi</value> <value>xen</value> </enum> + <enum name='model'/> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml index 3d73133919..497363bbe9 100644 --- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml @@ -68,6 +68,9 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml index 56e403c4c7..7639df44c6 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml @@ -74,6 +74,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml index d0b9c3fdef..f10d361359 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -40,6 +40,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml index 8742dce530..41a81ff02f 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml @@ -133,6 +133,11 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml index a8d6a4d629..5913e7fc63 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml @@ -98,6 +98,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml index b3e85de1d3..9ee801092e 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml @@ -71,6 +71,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml index 0fcc715940..4dd0b52ed3 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml @@ -71,6 +71,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml index f2dff05ff8..aa982d237e 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml @@ -44,6 +44,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml index c6d9fd8b37..6aa3f52ee4 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml @@ -72,6 +72,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml index 0c48bd6c75..8daa15ab9d 100644 --- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml @@ -38,6 +38,11 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml index 1cb843d5d1..081805aa4a 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml @@ -73,6 +73,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml index 7293d89ae7..62c51e4087 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml @@ -119,6 +119,11 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml index 8391603a3b..1bb034aa4f 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml @@ -73,6 +73,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml index c341de3ce2..67c6d5e77e 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml @@ -81,6 +81,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml index 4336e65dc8..588ef08199 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml @@ -105,6 +105,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml index 8e842b89fd..598937a971 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml @@ -82,6 +82,11 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml index 97231e044f..1d97f1f344 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -139,6 +139,11 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> </disk> <graphics supported='yes'> <enum name='type'> diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml new file mode 100644 index 0000000000..df66be9e29 --- /dev/null +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -0,0 +1,153 @@ +<domainCapabilities> + <path>/usr/bin/qemu-system-x86_64</path> + <domain>kvm</domain> + <machine>pc-i440fx-4.0</machine> + <arch>x86_64</arch> + <vcpu max='255'/> + <iothreads supported='yes'/> + <os supported='yes'> + <loader supported='yes'> + <value>/usr/share/AAVMF/AAVMF_CODE.fd</value> + <value>/usr/share/AAVMF/AAVMF32_CODE.fd</value> + <value>/usr/share/OVMF/OVMF_CODE.fd</value> + <enum name='type'> + <value>rom</value> + <value>pflash</value> + </enum> + <enum name='readonly'> + <value>yes</value> + <value>no</value> + </enum> + </loader> + </os> + <cpu> + <mode name='host-passthrough' supported='yes'/> + <mode name='host-model' supported='yes'> + <model fallback='forbid'>Skylake-Client-IBRS</model> + <vendor>Intel</vendor> + <feature policy='require' name='ss'/> + <feature policy='require' name='hypervisor'/> + <feature policy='require' name='tsc_adjust'/> + <feature policy='require' name='clflushopt'/> + <feature policy='require' name='umip'/> + <feature policy='require' name='arch-capabilities'/> + <feature policy='require' name='ssbd'/> + <feature policy='require' name='xsaves'/> + <feature policy='require' name='pdpe1gb'/> + <feature policy='require' name='invtsc'/> + </mode> + <mode name='custom' supported='yes'> + <model usable='yes'>qemu64</model> + <model usable='yes'>qemu32</model> + <model usable='no'>phenom</model> + <model usable='yes'>pentium3</model> + <model usable='yes'>pentium2</model> + <model usable='yes'>pentium</model> + <model usable='yes'>n270</model> + <model usable='yes'>kvm64</model> + <model usable='yes'>kvm32</model> + <model usable='yes'>coreduo</model> + <model usable='yes'>core2duo</model> + <model usable='no'>athlon</model> + <model usable='yes'>Westmere-IBRS</model> + <model usable='yes'>Westmere</model> + <model usable='no'>Skylake-Server-IBRS</model> + <model usable='no'>Skylake-Server</model> + <model usable='yes'>Skylake-Client-IBRS</model> + <model usable='yes'>Skylake-Client</model> + <model usable='yes'>SandyBridge-IBRS</model> + <model usable='yes'>SandyBridge</model> + <model usable='yes'>Penryn</model> + <model usable='no'>Opteron_G5</model> + <model usable='no'>Opteron_G4</model> + <model usable='no'>Opteron_G3</model> + <model usable='yes'>Opteron_G2</model> + <model usable='yes'>Opteron_G1</model> + <model usable='yes'>Nehalem-IBRS</model> + <model usable='yes'>Nehalem</model> + <model usable='yes'>IvyBridge-IBRS</model> + <model usable='yes'>IvyBridge</model> + <model usable='no'>Icelake-Server</model> + <model usable='no'>Icelake-Client</model> + <model usable='yes'>Haswell-noTSX-IBRS</model> + <model usable='yes'>Haswell-noTSX</model> + <model usable='yes'>Haswell-IBRS</model> + <model usable='yes'>Haswell</model> + <model usable='no'>EPYC-IBPB</model> + <model usable='no'>EPYC</model> + <model usable='yes'>Conroe</model> + <model usable='yes'>Broadwell-noTSX-IBRS</model> + <model usable='yes'>Broadwell-noTSX</model> + <model usable='yes'>Broadwell-IBRS</model> + <model usable='yes'>Broadwell</model> + <model usable='yes'>486</model> + </mode> + </cpu> + <devices> + <disk supported='yes'> + <enum name='diskDevice'> + <value>disk</value> + <value>cdrom</value> + <value>floppy</value> + <value>lun</value> + </enum> + <enum name='bus'> + <value>ide</value> + <value>fdc</value> + <value>scsi</value> + <value>virtio</value> + <value>usb</value> + <value>sata</value> + </enum> + <enum name='model'> + <value>virtio</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </enum> + </disk> + <graphics supported='yes'> + <enum name='type'> + <value>sdl</value> + <value>vnc</value> + <value>spice</value> + </enum> + </graphics> + <video supported='yes'> + <enum name='modelType'> + <value>vga</value> + <value>cirrus</value> + <value>vmvga</value> + <value>qxl</value> + <value>virtio</value> + </enum> + </video> + <hostdev supported='yes'> + <enum name='mode'> + <value>subsystem</value> + </enum> + <enum name='startupPolicy'> + <value>default</value> + <value>mandatory</value> + <value>requisite</value> + <value>optional</value> + </enum> + <enum name='subsysType'> + <value>usb</value> + <value>pci</value> + <value>scsi</value> + </enum> + <enum name='capsType'/> + <enum name='pciBackend'> + <value>default</value> + <value>kvm</value> + <value>vfio</value> + </enum> + </hostdev> + </devices> + <features> + <gic supported='no'/> + <vmcoreinfo supported='yes'/> + <genid supported='yes'/> + <sev supported='no'/> + </features> +</domainCapabilities> diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 7f52058bad..4ec2dc72b6 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -94,6 +94,7 @@ fillAllCaps(virDomainCapsPtr domCaps) disk->supported = true; SET_ALL_BITS(disk->diskDevice); SET_ALL_BITS(disk->bus); + SET_ALL_BITS(disk->model); graphics->supported = true; SET_ALL_BITS(graphics->type); @@ -502,6 +503,9 @@ mymain(void) "/usr/bin/qemu-system-s390x", NULL, "s390x", VIR_DOMAIN_VIRT_KVM); + DO_TEST_QEMU("4.0.0", "caps_4.0.0", + "/usr/bin/qemu-system-x86_64", NULL, + "x86_64", VIR_DOMAIN_VIRT_KVM); virObjectUnref(cfg); #endif /* WITH_QEMU */ -- 2.20.1

On Fri, 2019-02-08 at 17:12 -0500, Cole Robinson wrote:
This generates new XML like:
<disk> <enum name='model'> <value>virtio</value> <value>virtio-transitional</value> <value>virtio-non-transitional</value> </enum> </disk>
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/domain_capabilities.c | 1 + src/conf/domain_capabilities.h | 1 + src/qemu/qemu_capabilities.c | 10 ++ .../bhyve_basic.x86_64.xml | 1 + .../bhyve_fbuf.x86_64.xml | 1 + .../bhyve_uefi.x86_64.xml | 1 + tests/domaincapsschemadata/full.xml | 6 + .../domaincapsschemadata/libxl-xenfv-usb.xml | 1 + .../domaincapsschemadata/libxl-xenpv-usb.xml | 1 + .../qemu_1.7.0.x86_64.xml | 3 + .../qemu_2.12.0-virt.aarch64.xml | 5 + .../qemu_2.12.0.ppc64.xml | 5 + .../qemu_2.12.0.s390x.xml | 5 + .../qemu_2.12.0.x86_64.xml | 5 + .../qemu_2.6.0-virt.aarch64.xml | 5 + .../qemu_2.6.0.aarch64.xml | 5 + .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 5 + .../qemu_2.6.0.x86_64.xml | 5 + .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 5 + .../qemu_2.8.0-tcg.x86_64.xml | 5 + .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 5 + .../qemu_2.8.0.x86_64.xml | 5 + .../qemu_2.9.0-q35.x86_64.xml | 5 + .../qemu_2.9.0-tcg.x86_64.xml | 5 + .../qemu_2.9.0.x86_64.xml | 5 + .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 5 + .../qemu_4.0.0.x86_64.xml | 153 ++++++++++++++++++ tests/domaincapstest.c | 4 + 28 files changed, 263 insertions(+) create mode 100644 tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml
This did not apply correctly for me on top of 1620bb0a3050373d059b0, but after regenerating output files the resulting diff looks sane enough so I'll assume everything is fine and you'll take care of it before pushing anyway. [...]
+++ b/src/conf/domain_capabilities.h @@ -65,6 +65,7 @@ struct _virDomainCapsDeviceDisk { bool supported; virDomainCapsEnum diskDevice; /* Info about virDomainDiskDevice enum values */ virDomainCapsEnum bus; /* Info about virDomainDiskBus enum values */ + virDomainCapsEnum model; /* Info about virDomainDiskModel enum values */ /* add new fields here */ };
Might as well keep those comments aligned... [...]
+++ b/tests/domaincapstest.c @@ -94,6 +94,7 @@ fillAllCaps(virDomainCapsPtr domCaps) disk->supported = true; SET_ALL_BITS(disk->diskDevice); SET_ALL_BITS(disk->bus); + SET_ALL_BITS(disk->model);
graphics->supported = true; SET_ALL_BITS(graphics->type); @@ -502,6 +503,9 @@ mymain(void) "/usr/bin/qemu-system-s390x", NULL, "s390x", VIR_DOMAIN_VIRT_KVM);
+ DO_TEST_QEMU("4.0.0", "caps_4.0.0", + "/usr/bin/qemu-system-x86_64", NULL, + "x86_64", VIR_DOMAIN_VIRT_KVM);
As mentioned during the previous rounf of reviews, this hunk (and the resulting output file) belong in a separate patch. Please make ure you split these unrelated changes off before pushing. With that addressed, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote:
v2 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00877.html v1 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00593.html Previous incomplete RFC here: https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html qemu patches, queued for qemu 4.0.0: https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html Previous libvirt discussion around this: https://www.redhat.com/archives/libvir-list/2018-August/msg01073.html
Changes since v2: * Some prep patches merged * filesystem model dropped the -9p naming, now uses virtio-{non-}transitional like other devices * Now uses a single capability QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL which is set whenever any of the -transitional or -non-transitional devices are present. * Add a formatdomain section 'Virtio transitional devices' and reference it from each relevant device section * if virtio-transitional specified, and qemu is too old but has the disable_X options, convert it to explicit disable-legacy=off,disable-modern=off * Misc small changes pointed out in review
Oh, and this definitely deserves to be mentioned in the release notes! Can you please post a 18/17 or a separate patch that adds the corresponding entry? -- Andrea Bolognani / Red Hat / Virtualization

On 2/13/19 3:31 AM, Andrea Bolognani wrote:
On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote:
v2 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00877.html v1 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00593.html Previous incomplete RFC here: https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html qemu patches, queued for qemu 4.0.0: https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html Previous libvirt discussion around this: https://www.redhat.com/archives/libvir-list/2018-August/msg01073.html
Changes since v2: * Some prep patches merged * filesystem model dropped the -9p naming, now uses virtio-{non-}transitional like other devices * Now uses a single capability QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL which is set whenever any of the -transitional or -non-transitional devices are present. * Add a formatdomain section 'Virtio transitional devices' and reference it from each relevant device section * if virtio-transitional specified, and qemu is too old but has the disable_X options, convert it to explicit disable-legacy=off,disable-modern=off * Misc small changes pointed out in review
Thanks for the reviews, I fixed all the issues you pointed out and pushed the patches here: https://github.com/crobinso/libvirt/tree/virtio-v4 I'll wait to push until after 5.2.0 is out, so we have a longer window to tweak things if eduardo's responses change anything, and to discuss the controller type=scsi model=virtio patch I think you have pending...
Oh, and this definitely deserves to be mentioned in the release notes! Can you please post a 18/17 or a separate patch that adds the corresponding entry?
I'll send one after I push the commits Thanks, Cole

On 2/20/19 3:46 PM, Cole Robinson wrote:
On 2/13/19 3:31 AM, Andrea Bolognani wrote:
On Fri, 2019-02-08 at 17:11 -0500, Cole Robinson wrote:
v2 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00877.html v1 libvirt patches: https://www.redhat.com/archives/libvir-list/2019-January/msg00593.html Previous incomplete RFC here: https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html qemu patches, queued for qemu 4.0.0: https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg00923.html Previous libvirt discussion around this: https://www.redhat.com/archives/libvir-list/2018-August/msg01073.html
Changes since v2: * Some prep patches merged * filesystem model dropped the -9p naming, now uses virtio-{non-}transitional like other devices * Now uses a single capability QEMU_CAPS_VIRTIO_PCI_NON_TRANSITIONAL which is set whenever any of the -transitional or -non-transitional devices are present. * Add a formatdomain section 'Virtio transitional devices' and reference it from each relevant device section * if virtio-transitional specified, and qemu is too old but has the disable_X options, convert it to explicit disable-legacy=off,disable-modern=off * Misc small changes pointed out in review
Thanks for the reviews, I fixed all the issues you pointed out and pushed the patches here:
https://github.com/crobinso/libvirt/tree/virtio-v4
I'll wait to push until after 5.2.0 is out, so we have a longer window to tweak things if eduardo's responses change anything, and to discuss the controller type=scsi model=virtio patch I think you have pending...
I meant version 5.1.0 - Cole
participants (2)
-
Andrea Bolognani
-
Cole Robinson