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

This series adds support for virtio-transitional and virtio-non-transitional qemu devices. 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 Previous incomplete RFC here: https://www.redhat.com/archives/libvir-list/2019-January/msg00346.html Long story short we need to expose these options so apps have a usable way to support rhel6 + virtio + q35. This series exposes the new devices as model= values. This required adding new model= attributes for several devices. Here's the breakdown. 'standard names' here means the model names virtio, virtio-transitional, and virtio-non-transitional * Simply extended: virtio-rng: extend existing <rng model=X> to handle standard names vhost-vsock: extend existing <vsock model=X> to handle standard names virtio-memballoon: extend existings <memballoon model=X> to handle standard names virtio-net: extend existing qemu <model type=X> handling to support standard names * Extended with caveats: virtio-serial: extend <controller type='virtio-serial'> to handle existing model=X attribute, with standard names virtio-scsi: extend <controller type='scsi' model=X> to handle the additional names virtio-transitional and virtio-non-transitional. model= already supports virtio-scsi here which is a departure from just model='virtio' which most others use, but I chose to not extend that pattern and stick with the names the other devices are using vhost-scsi: extend <hostdev model=X> handling for the protocol=vhost case, to accept standard names. I stuck with standard names over using vhost-transitional or similar, for consistency with other devices. * New XML elements virtio-blk: add new <disk model=X/> attribute with standard names virtio-fs: add new <filesystem model=X> attribute with standard names virtio-input-host: add new <input model=X> attribute with standard names At the end is an extension to domaincapabilities to report the disk bus model values. Until domaincapabilities is fully fleshed out with support for all the above devices, apps can use that disk model check to assume transitional devices are available for all of the above. Cole Robinson (18): tests: Add capabilities data for QEMU 4.0.0 x86_64 conf: Add <disk model='virtio-{non-}transitional'/> qemu: Support disk model=virtio-{non-}transitional conf: Add virDomainNetHasVirtioModel 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: Move memballoon validation out of command.c 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 scsi controller model=virtio-{non-}transitional qemu: Support virtio-serial controller model=virtio-{non-}transitional qemu: domcaps: Report disk <enum name="model"> docs/formatdomain.html.in | 39 +- docs/schemas/domaincommon.rng | 60 +- src/conf/domain_capabilities.c | 1 + src/conf/domain_capabilities.h | 1 + src/conf/domain_conf.c | 216 +- src/conf/domain_conf.h | 68 +- src/libvirt_private.syms | 5 + src/libxl/libxl_conf.c | 2 + src/qemu/qemu_capabilities.c | 55 + src/qemu/qemu_capabilities.h | 28 + src/qemu/qemu_command.c | 219 +- src/qemu/qemu_domain.c | 47 +- src/qemu/qemu_domain_address.c | 69 +- src/qemu/qemu_driver.c | 9 +- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_interface.c | 8 +- src/qemu/qemu_process.c | 3 +- src/security/virt-aa-helper.c | 2 +- src/vbox/vbox_common.c | 2 + src/vmx/vmx.c | 4 +- .../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 | 1 + .../qemu_2.12.0-virt.aarch64.xml | 1 + .../qemu_2.12.0.ppc64.xml | 1 + .../qemu_2.12.0.s390x.xml | 1 + .../qemu_2.12.0.x86_64.xml | 1 + .../qemu_2.6.0-virt.aarch64.xml | 1 + .../qemu_2.6.0.aarch64.xml | 1 + .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 + .../qemu_2.6.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 + .../qemu_2.8.0-tcg.x86_64.xml | 1 + .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 + .../qemu_2.8.0.x86_64.xml | 1 + .../qemu_2.9.0-q35.x86_64.xml | 1 + .../qemu_2.9.0-tcg.x86_64.xml | 1 + .../qemu_2.9.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 + .../qemu_4.0.0.x86_64.xml | 153 + tests/domaincapstest.c | 4 + .../caps_4.0.0.x86_64.replies | 23180 ++++++++++++++++ .../caps_4.0.0.x86_64.xml | 1404 + tests/qemucapabilitiestest.c | 1 + .../virtio-non-transitional.x86_64-3.1.0.args | 63 + ...virtio-non-transitional.x86_64-latest.args | 62 + .../virtio-non-transitional.xml | 40 + .../virtio-transitional.x86_64-3.1.0.args | 50 + .../virtio-transitional.x86_64-latest.args | 52 + .../qemuxml2argvdata/virtio-transitional.xml | 40 + tests/qemuxml2argvmock.c | 2 +- tests/qemuxml2argvtest.c | 6 + .../virtio-non-transitional.xml | 121 + .../virtio-transitional.xml | 80 + tests/qemuxml2xmltest.c | 17 + 59 files changed, 26031 insertions(+), 112 deletions(-) create mode 100644 tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies create mode 100644 tests/qemucapabilitiesdata/caps_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

The next release of QEMU is going to be 4.0.0. A bit early, but this adds capabilities data for x86_64 from current qemu git 15bede554162dda822cd762c689edb6fa32b6e3b Signed-off-by: Cole Robinson <crobinso@redhat.com> --- .../caps_4.0.0.x86_64.replies | 23180 ++++++++++++++++ .../caps_4.0.0.x86_64.xml | 1384 + tests/qemucapabilitiestest.c | 1 + 3 files changed, 24565 insertions(+) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml

On 01/17/2019 12:52 PM, Cole Robinson wrote:
The next release of QEMU is going to be 4.0.0. A bit early, but this adds capabilities data for x86_64 from current qemu git 15bede554162dda822cd762c689edb6fa32b6e3b
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- .../caps_4.0.0.x86_64.replies | 23180 ++++++++++++++++ .../caps_4.0.0.x86_64.xml | 1384 + tests/qemucapabilitiestest.c | 1 + 3 files changed, 24565 insertions(+) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
Snipped so it didn't get caught by the list. Full patch attached - Cole

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
The next release of QEMU is going to be 4.0.0. A bit early, but this adds capabilities data for x86_64 from current qemu git 15bede554162dda822cd762c689edb6fa32b6e3b
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- .../caps_4.0.0.x86_64.replies | 23180 ++++++++++++++++ .../caps_4.0.0.x86_64.xml | 1384 + tests/qemucapabilitiestest.c | 1 + 3 files changed, 24565 insertions(+) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
This would be https://github.com/crobinso/libvirt/commit/164b87cd146fd341dc3e0a4415c324555... Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 04:43 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
The next release of QEMU is going to be 4.0.0. A bit early, but this adds capabilities data for x86_64 from current qemu git 15bede554162dda822cd762c689edb6fa32b6e3b
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- .../caps_4.0.0.x86_64.replies | 23180 ++++++++++++++++ .../caps_4.0.0.x86_64.xml | 1384 + tests/qemucapabilitiestest.c | 1 + 3 files changed, 24565 insertions(+) create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.replies create mode 100644 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
This would be
https://github.com/crobinso/libvirt/commit/164b87cd146fd341dc3e0a4415c324555...
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Thanks, I've pushed this one now so next posting I don't need to deal with the sending issues - Cole

<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 | 10 +++++ docs/schemas/domaincommon.rng | 8 ++++ src/conf/domain_conf.c | 38 +++++++++++++++++ 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 | 18 ++++++++ .../virtio-transitional.x86_64-3.1.0.args | 34 +++++++++++++++ .../virtio-transitional.x86_64-latest.args | 34 +++++++++++++++ .../qemuxml2argvdata/virtio-transitional.xml | 18 ++++++++ tests/qemuxml2argvtest.c | 6 +++ .../virtio-non-transitional.xml | 42 +++++++++++++++++++ .../virtio-transitional.xml | 42 +++++++++++++++++++ tests/qemuxml2xmltest.c | 11 +++++ 15 files changed, 342 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 7f07bb7f55..29e4bb1bda 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2922,6 +2922,16 @@ <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" which matches the old behavior. These setting are + only applicable when using controller bus type "pci". + <span class="since">Since 5.1.0</span> + </dd> <dt><code>rawio</code></dt> <dd> Indicates whether the disk needs rawio capability. Valid diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index aa50eac424..425d7f851a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1506,6 +1506,14 @@ </interleave> </group> </choice> + <optional> + <attribute name="model"> + <choice> + <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 222bb8c482..facb84a425 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -889,6 +889,12 @@ VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DISK_DETECT_ZEROES_LAST, "on", "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", @@ -5431,6 +5437,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; } @@ -9518,6 +9535,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"); @@ -21746,6 +21771,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; @@ -24311,6 +24344,11 @@ 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 fae130668f..16c2c6e75b 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; }; @@ -3408,6 +3418,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 c3d6306809..0d6f054cf2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -343,6 +343,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..7899994622 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -0,0 +1,18 @@ +<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> + <boot dev='hd'/> + </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..678a7b9132 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -0,0 +1,18 @@ +<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> + <boot dev='hd'/> + </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 2cb8860d26..8da99fc390 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3068,6 +3068,12 @@ mymain(void) DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); + /* 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 82e2c0ee0f..0eca113e23 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1265,6 +1265,17 @@ mymain(void) DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); + 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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+ <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" which matches the old behavior. These setting are
s/setting/settings/ [...]
+++ b/docs/schemas/domaincommon.rng @@ -1506,6 +1506,14 @@ </interleave> </group> </choice> + <optional> + <attribute name="model"> + <choice>
You forgot to add <value>virtio</value> here.
+ <value>virtio-transitional</value> + <value>virtio-non-transitional</value> + </choice>
[...]
@@ -24311,6 +24344,11 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<disk type='%s' device='%s'", type, device);
Empty line here, please.
+ if (def->model) { + virBufferAsprintf(buf, " model='%s'", + virDomainDiskModelTypeToString(def->model)); + }
[...]
+++ b/tests/qemuxml2xmltest.c @@ -1265,6 +1265,17 @@ mymain(void) DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO);
+ 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);
So you got rid of the macro from RFC's 2/6 completely? Despite the code duplication issue I've pointed out at the time, I'd still rather see that macro being used, after renaming it, than yet another hardcoded list of capabilities... Either way, with the schema and the other nits fixed, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 06:24 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
[...]
So you got rid of the macro from RFC's 2/6 completely? Despite the code duplication issue I've pointed out at the time, I'd still rather see that macro being used, after renaming it, than yet another hardcoded list of capabilities...
It turned out to not need too many caps adjustments throughout the series so I dropped it incase it was a distraction. It's on my list to send a separate series for DO_TEST_CAPS+qemuxml2xml, hopefully sharing more with the qemuxml2argv implementation Thanks, Cole

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_capabilities.c | 4 + src/qemu/qemu_capabilities.h | 2 + src/qemu/qemu_command.c | 90 ++++++++++++++++++- src/qemu/qemu_domain_address.c | 2 + .../caps_4.0.0.x86_64.xml | 2 + .../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 | 7 +- .../virtio-transitional.xml | 10 ++- 10 files changed, 117 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f504db7d05..b7c0387f8e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -520,6 +520,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 325 */ "memory-backend-file.pmem", "nvdimm.unarmed", + "virtio-blk-pci-transitional", + "virtio-blk-pci-non-transitional", ); @@ -1108,6 +1110,8 @@ 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_DEVICE_VIRTIO_BLK_TRANSITIONAL}, + {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6d5ed8a3cc..34265d7cc0 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -504,6 +504,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 325 */ QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM, /* -object memory-backend-file,pmem= */ QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL, /* -device virtio-blk-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL, /* -device virtio-blk-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 822d5f8669..608cd65806 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -443,6 +443,91 @@ qemuBuildVirtioDevStr(virBufferPtr buf, return 0; } +static int +qemuBuildVirtioTransitional(virBufferPtr buf, + const char *baseName, + virQEMUCapsPtr qemuCaps, + virDomainDeviceAddressType type, + int model, + virDomainDeviceType devtype) +{ + int tmodel_cap, ntmodel_cap; + bool has_tmodel, has_ntmodel; + + if (qemuBuildVirtioDevStr(buf, baseName, type) < 0) + return -1; + + switch (devtype) { + case VIR_DOMAIN_DEVICE_DISK: + has_tmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; + break; + + case VIR_DOMAIN_DEVICE_LEASE: + case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_NET: + 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 (type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + (has_tmodel || has_ntmodel)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio transitional models are not supported " + "for address type=%s"), + virDomainDeviceAddressTypeToString(type)); + return -1; + } + + if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + } + + return 0; +} + static int qemuBuildVirtioOptionsStr(virBufferPtr buf, @@ -2049,7 +2134,10 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, break; case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (qemuBuildVirtioDevStr(&opt, "virtio-blk", disk->info.type) < 0) + if (qemuBuildVirtioTransitional(&opt, "virtio-blk", qemuCaps, + disk->info.type, + disk->model, + VIR_DOMAIN_DEVICE_DISK) < 0) goto error; if (disk->iothread) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bd6c4031e0..4a7c71d76d 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -723,6 +723,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_DISK: switch ((virDomainDiskBus) dev->data.disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (dev->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags; /* only virtio disks use PCI */ case VIR_DOMAIN_DISK_BUS_IDE: diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index c2db392e83..8cf9083035 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -212,6 +212,8 @@ <flag name='memory-backend-file.align'/> <flag name='memory-backend-file.pmem'/> <flag name='nvdimm.unarmed'/> + <flag name='virtio-blk-pci-transitional'/> + <flag name='virtio-blk-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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..9c5d553077 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,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..356e8fdf4c 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -25,9 +25,10 @@ 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,\ +-device virtio-blk-pci,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 \ 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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1108,6 +1110,8 @@ 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_DEVICE_VIRTIO_BLK_TRANSITIONAL}, + {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},
There should be whitespace before and after curly braces, for consistency with existing entries. [...]
+++ b/src/qemu/qemu_capabilities.h @@ -504,6 +504,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 325 */ QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM, /* -object memory-backend-file,pmem= */ QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL, /* -device virtio-blk-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL, /* -device virtio-blk-pci-non-transitional */
A bit more verbose, but I think we should go for QEMU_CAPS_DEVICE_VIRTIO_BLK_PCI_{,NON_}TRANSITIONAL since there are several non-PCI variants of VirtIO devices. It'd also be nice if adding the capabilities and wiring up the command line generation bits happened in separate patches. [...]
+static int +qemuBuildVirtioTransitional(virBufferPtr buf, + const char *baseName, + virQEMUCapsPtr qemuCaps, + virDomainDeviceAddressType type, + int model, + virDomainDeviceType devtype) +{ + int tmodel_cap, ntmodel_cap; + bool has_tmodel, has_ntmodel; + + if (qemuBuildVirtioDevStr(buf, baseName, type) < 0) + return -1; + + switch (devtype) { + case VIR_DOMAIN_DEVICE_DISK: + has_tmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; + break;
I like this approach much better than the one used in the RFC, eg. passing two booleans to the function. Nice! What I don't like is that you're building this fairly thin wrapper around qemuBuildVirtioDevStr() when IMHO you should rather be agumenting the original function - mostly because the new name is not nearly as good :) Do you think you could make that happen? [...]
+ if (type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + (has_tmodel || has_ntmodel)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio transitional models are not supported " + "for address type=%s"),
s/transitional/(non-)transitional/ [...]
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out. [...]
@@ -723,6 +723,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_DISK: switch ((virDomainDiskBus) dev->data.disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (dev->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL) + return pciFlags;
Perhaps a short comment about how transitional VirtIO devices can only be plugged into conventional PCI slots would be appropriate here, for the benefit of those looking at the code years from now :) -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1108,6 +1110,8 @@ 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_DEVICE_VIRTIO_BLK_TRANSITIONAL}, + {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},
There should be whitespace before and after curly braces, for consistency with existing entries.
Indeed, I'll fix that in all the patches
[...]
+++ b/src/qemu/qemu_capabilities.h @@ -504,6 +504,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 325 */ QEMU_CAPS_OBJECT_MEMORY_FILE_PMEM, /* -object memory-backend-file,pmem= */ QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL, /* -device virtio-blk-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL, /* -device virtio-blk-pci-non-transitional */
A bit more verbose, but I think we should go for
QEMU_CAPS_DEVICE_VIRTIO_BLK_PCI_{,NON_}TRANSITIONAL
since there are several non-PCI variants of VirtIO devices.
Sure sounds good
It'd also be nice if adding the capabilities and wiring up the command line generation bits happened in separate patches.
[...]
OK
+static int +qemuBuildVirtioTransitional(virBufferPtr buf, + const char *baseName, + virQEMUCapsPtr qemuCaps, + virDomainDeviceAddressType type, + int model, + virDomainDeviceType devtype) +{ + int tmodel_cap, ntmodel_cap; + bool has_tmodel, has_ntmodel; + + if (qemuBuildVirtioDevStr(buf, baseName, type) < 0) + return -1; + + switch (devtype) { + case VIR_DOMAIN_DEVICE_DISK: + has_tmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; + break;
I like this approach much better than the one used in the RFC, eg. passing two booleans to the function. Nice!
What I don't like is that you're building this fairly thin wrapper around qemuBuildVirtioDevStr() when IMHO you should rather be agumenting the original function - mostly because the new name is not nearly as good :) Do you think you could make that happen?
Hmm, seems weird to make call sites that will never support the transitional naming (virtio-keyboard/mouse/tablet/gpu) have to call into this function, passing DEVICE_TYPE etc. I can split the transitional bits into their own function and not have it wrap BuildVirtioDevStr but be a follow on, so for example: if (qemuBuildVirtioDevStr(...) < 0) goto error; if (qemuBuildVirtioTransitionalStr(...) < ) goto error; Does that work?
[...]
+ if (type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + (has_tmodel || has_ntmodel)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio transitional models are not supported " + "for address type=%s"),
s/transitional/(non-)transitional/
[...]
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I'll respond separately
[...]
@@ -723,6 +723,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_DISK: switch ((virDomainDiskBus) dev->data.disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (dev->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL) + return pciFlags;
Perhaps a short comment about how transitional VirtIO devices can only be plugged into conventional PCI slots would be appropriate here, for the benefit of those looking at the code years from now :)
This same pattern is duplicated in the rest of the series, seems weird to comment one site, but commenting all of them is overkill. I guess commenting one site is the middle ground unless you have a better idea of where to put the comment Thanks for the review - Cole

On Mon, 2019-01-21 at 17:40 -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+static int +qemuBuildVirtioTransitional(virBufferPtr buf, + const char *baseName, + virQEMUCapsPtr qemuCaps, + virDomainDeviceAddressType type, + int model, + virDomainDeviceType devtype) +{ + int tmodel_cap, ntmodel_cap; + bool has_tmodel, has_ntmodel; + + if (qemuBuildVirtioDevStr(buf, baseName, type) < 0) + return -1; + + switch (devtype) { + case VIR_DOMAIN_DEVICE_DISK: + has_tmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; + break;
I like this approach much better than the one used in the RFC, eg. passing two booleans to the function. Nice!
What I don't like is that you're building this fairly thin wrapper around qemuBuildVirtioDevStr() when IMHO you should rather be agumenting the original function - mostly because the new name is not nearly as good :) Do you think you could make that happen?
Hmm, seems weird to make call sites that will never support the transitional naming (virtio-keyboard/mouse/tablet/gpu) have to call into this function, passing DEVICE_TYPE etc. I can split the transitional bits into their own function and not have it wrap BuildVirtioDevStr but be a follow on, so for example:
if (qemuBuildVirtioDevStr(...) < 0) goto error; if (qemuBuildVirtioTransitionalStr(...) < ) goto error;
Does that work?
The split version is more likely to end up being misused, so I wouldn't go down that road. As for the naming, my suggestion was to stick with the original qemuBuildVirtioDevStr() name, add parameters to it, and not introduce qemuBuildVirtioTransitional() at all, so it wouldn't look weird when called for devices that are modern only. I don't see a problem with passing devType even when you're not ultimately going to make decisions based on it for certain devices.
[...]
@@ -723,6 +723,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_DISK: switch ((virDomainDiskBus) dev->data.disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (dev->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL) + return pciFlags;
Perhaps a short comment about how transitional VirtIO devices can only be plugged into conventional PCI slots would be appropriate here, for the benefit of those looking at the code years from now :)
This same pattern is duplicated in the rest of the series, seems weird to comment one site, but commenting all of them is overkill. I guess commenting one site is the middle ground unless you have a better idea of where to put the comment
I don't think having a short comment such as /* Transitional devices only work in conventional PCI slots */ repeated a few times really counts as overkill :) So I'd go that way. -- Andrea Bolognani / Red Hat / Virtualization

On 01/22/2019 06:53 AM, Andrea Bolognani wrote:
On Mon, 2019-01-21 at 17:40 -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+static int +qemuBuildVirtioTransitional(virBufferPtr buf, + const char *baseName, + virQEMUCapsPtr qemuCaps, + virDomainDeviceAddressType type, + int model, + virDomainDeviceType devtype) +{ + int tmodel_cap, ntmodel_cap; + bool has_tmodel, has_ntmodel; + + if (qemuBuildVirtioDevStr(buf, baseName, type) < 0) + return -1; + + switch (devtype) { + case VIR_DOMAIN_DEVICE_DISK: + has_tmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; + break;
I like this approach much better than the one used in the RFC, eg. passing two booleans to the function. Nice!
What I don't like is that you're building this fairly thin wrapper around qemuBuildVirtioDevStr() when IMHO you should rather be agumenting the original function - mostly because the new name is not nearly as good :) Do you think you could make that happen?
Hmm, seems weird to make call sites that will never support the transitional naming (virtio-keyboard/mouse/tablet/gpu) have to call into this function, passing DEVICE_TYPE etc. I can split the transitional bits into their own function and not have it wrap BuildVirtioDevStr but be a follow on, so for example:
if (qemuBuildVirtioDevStr(...) < 0) goto error; if (qemuBuildVirtioTransitionalStr(...) < ) goto error;
Does that work?
The split version is more likely to end up being misused, so I wouldn't go down that road.
As for the naming, my suggestion was to stick with the original qemuBuildVirtioDevStr() name, add parameters to it, and not introduce qemuBuildVirtioTransitional() at all, so it wouldn't look weird when called for devices that are modern only.
I don't see a problem with passing devType even when you're not ultimately going to make decisions based on it for certain devices.
Okay I'll go that route
[...]
@@ -723,6 +723,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_DISK: switch ((virDomainDiskBus) dev->data.disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (dev->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL) + return pciFlags;
Perhaps a short comment about how transitional VirtIO devices can only be plugged into conventional PCI slots would be appropriate here, for the benefit of those looking at the code years from now :)
This same pattern is duplicated in the rest of the series, seems weird to comment one site, but commenting all of them is overkill. I guess commenting one site is the middle ground unless you have a better idea of where to put the comment
I don't think having a short comment such as
/* Transitional devices only work in conventional PCI slots */
repeated a few times really counts as overkill :) So I'd go that way.
Cool, I'll add it to the series Thanks, Cole

On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I don't know enough to say, CCing ehabkost and danpb for more eyes - Cole

On Mon, Jan 21, 2019 at 05:41:47PM -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I don't know enough to say, CCing ehabkost and danpb for more eyes
The QEMU code for the devices has - Original devs: disable-modern=off disable-legacy=auto - Transitional devs: disable-modern=off disable-legacy=off - Non-transitional devs: disable-modern=off disable-legacy=on IOW, in the case that -transitional is not available, we could set disable-legacy=off. Provided that we always place -transitional devices into PCI slots, never PCI-e slots, whether we set disable-legacy=off or not doesn't have any effect. None the less it would make sense to set it explicitly though as that would cause us to catch bugs if we mistakenly had a -transitional dev in a PCI-e slot. I don't see a need to set disable-modern at all, since it is defaulting to "off" in all cases. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Tue, 2019-01-22 at 09:31 +0000, Daniel P. Berrangé wrote:
On Mon, Jan 21, 2019 at 05:41:47PM -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I don't know enough to say, CCing ehabkost and danpb for more eyes
The QEMU code for the devices has
- Original devs: disable-modern=off disable-legacy=auto - Transitional devs: disable-modern=off disable-legacy=off - Non-transitional devs: disable-modern=off disable-legacy=on
IOW, in the case that -transitional is not available, we could set disable-legacy=off. Provided that we always place -transitional devices into PCI slots, never PCI-e slots, whether we set disable-legacy=off or not doesn't have any effect. None the less it would make sense to set it explicitly though as that would cause us to catch bugs if we mistakenly had a -transitional dev in a PCI-e slot.
I don't see a need to set disable-modern at all, since it is defaulting to "off" in all cases.
Wasn't there some old QEMU release where disable-modern didn't default to off? I seem to remember that. More generally, I don't see a reason *not* to specify disable-modern along with disable-legacy. Why be implicit when you can very easily be explicit instead? -- Andrea Bolognani / Red Hat / Virtualization

On Tue, Jan 22, 2019 at 12:45:59PM +0100, Andrea Bolognani wrote:
On Tue, 2019-01-22 at 09:31 +0000, Daniel P. Berrangé wrote:
On Mon, Jan 21, 2019 at 05:41:47PM -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I don't know enough to say, CCing ehabkost and danpb for more eyes
The QEMU code for the devices has
- Original devs: disable-modern=off disable-legacy=auto - Transitional devs: disable-modern=off disable-legacy=off - Non-transitional devs: disable-modern=off disable-legacy=on
IOW, in the case that -transitional is not available, we could set disable-legacy=off. Provided that we always place -transitional devices into PCI slots, never PCI-e slots, whether we set disable-legacy=off or not doesn't have any effect. None the less it would make sense to set it explicitly though as that would cause us to catch bugs if we mistakenly had a -transitional dev in a PCI-e slot.
I don't see a need to set disable-modern at all, since it is defaulting to "off" in all cases.
Wasn't there some old QEMU release where disable-modern didn't default to off? I seem to remember that.
Yes, disable-modern is "on" on 2.6 and older machine-types.
More generally, I don't see a reason *not* to specify disable-modern along with disable-legacy. Why be implicit when you can very easily be explicit instead?
Agreed. -- Eduardo

On Tue, Jan 22, 2019 at 10:44:23AM -0200, Eduardo Habkost wrote:
On Tue, Jan 22, 2019 at 12:45:59PM +0100, Andrea Bolognani wrote:
On Tue, 2019-01-22 at 09:31 +0000, Daniel P. Berrangé wrote:
On Mon, Jan 21, 2019 at 05:41:47PM -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
+ if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) + virBufferAddLit(buf, "-transitional"); + + /* No error for 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, ntmodel_cap)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=on"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I don't know enough to say, CCing ehabkost and danpb for more eyes
The QEMU code for the devices has
- Original devs: disable-modern=off disable-legacy=auto - Transitional devs: disable-modern=off disable-legacy=off - Non-transitional devs: disable-modern=off disable-legacy=on
IOW, in the case that -transitional is not available, we could set disable-legacy=off. Provided that we always place -transitional devices into PCI slots, never PCI-e slots, whether we set disable-legacy=off or not doesn't have any effect. None the less it would make sense to set it explicitly though as that would cause us to catch bugs if we mistakenly had a -transitional dev in a PCI-e slot.
I don't see a need to set disable-modern at all, since it is defaulting to "off" in all cases.
Wasn't there some old QEMU release where disable-modern didn't default to off? I seem to remember that.
Yes, disable-modern is "on" on 2.6 and older machine-types.
More generally, I don't see a reason *not* to specify disable-modern along with disable-legacy. Why be implicit when you can very easily be explicit instead?
Agreed.
Ok, I've no objection to an explicit disable-modern=off based on this info. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 01/22/2019 09:00 AM, Daniel P. Berrangé wrote:
On Tue, Jan 22, 2019 at 10:44:23AM -0200, Eduardo Habkost wrote:
On Tue, Jan 22, 2019 at 12:45:59PM +0100, Andrea Bolognani wrote:
On Tue, 2019-01-22 at 09:31 +0000, Daniel P. Berrangé wrote:
On Mon, Jan 21, 2019 at 05:41:47PM -0500, Cole Robinson wrote:
On 01/18/2019 07:33 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: > + if (has_tmodel) { > + if (virQEMUCapsGet(qemuCaps, tmodel_cap)) > + virBufferAddLit(buf, "-transitional"); > + > + /* No error for 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, ntmodel_cap)) { > + virBufferAddLit(buf, "-non-transitional"); > + } else if (virQEMUCapsGet(qemuCaps, > + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { > + virBufferAddLit(buf, ",disable-legacy=on"); > + } else { > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > + _("virtio non-transitional model not supported " > + "for this qemu")); > + return -1; > + } > + }
Would it make sense to be more explicit here? Current versions of QEMU default to disable-modern=off,disable-legacy=off for virtio-pci devices plugged into conventional PCI slots, but unless I'm mistaken that was not always the case, so it would perhaps be preferrable to not rely on that behavior and always explicitly set both disable-* options when the new devices are not available; if the options themselves are not available, then we should error out.
I don't know enough to say, CCing ehabkost and danpb for more eyes
The QEMU code for the devices has
- Original devs: disable-modern=off disable-legacy=auto - Transitional devs: disable-modern=off disable-legacy=off - Non-transitional devs: disable-modern=off disable-legacy=on
IOW, in the case that -transitional is not available, we could set disable-legacy=off. Provided that we always place -transitional devices into PCI slots, never PCI-e slots, whether we set disable-legacy=off or not doesn't have any effect. None the less it would make sense to set it explicitly though as that would cause us to catch bugs if we mistakenly had a -transitional dev in a PCI-e slot.
I don't see a need to set disable-modern at all, since it is defaulting to "off" in all cases.
Wasn't there some old QEMU release where disable-modern didn't default to off? I seem to remember that.
Yes, disable-modern is "on" on 2.6 and older machine-types.
More generally, I don't see a reason *not* to specify disable-modern along with disable-legacy. Why be implicit when you can very easily be explicit instead?
Agreed.
Ok, I've no objection to an explicit disable-modern=off based on this info.
Cool I'll make this change for the next round Thanks, Cole

This will be extended in the future, so let's simplify things by centralizing the checks. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/domain_conf.c | 47 +++++++++++++++++++--------------- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_domain_address.c | 3 +-- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_interface.c | 8 +++--- src/security/virt-aa-helper.c | 2 +- tests/qemuxml2argvmock.c | 2 +- 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index facb84a425..4fc33c7e2f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4737,7 +4737,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_NET) { virDomainNetDefPtr net = dev->data.net; - if (STRNEQ_NULLABLE(net->model, "virtio") && + if (!virDomainNetHasVirtioModel(net) && virDomainCheckVirtioOptions(net->virtio) < 0) return -1; } @@ -11329,6 +11329,22 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } + /* NIC model (see -net nic,model=?). We only check that it looks + * reasonable, not that it is a supported NIC type. FWIW kvm + * supports these types as of April 2008: + * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio + * QEMU PPC64 supports spapr-vlan + */ + if (model != NULL) { + if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Model name contains invalid characters")); + goto error; + } + def->model = model; + model = NULL; + } + switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: if (network == NULL) { @@ -11346,7 +11362,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (STRNEQ_NULLABLE(model, "virtio")) { + if (!virDomainNetHasVirtioModel(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Wrong or no <model> 'type' attribute " "specified with <interface type='vhostuser'/>. " @@ -11574,24 +11590,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ifname_guest_actual = NULL; } - /* NIC model (see -net nic,model=?). We only check that it looks - * reasonable, not that it is a supported NIC type. FWIW kvm - * supports these types as of April 2008: - * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio - * QEMU PPC64 supports spapr-vlan - */ - if (model != NULL) { - if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("Model name contains invalid characters")); - goto error; - } - def->model = model; - model = NULL; - } - if (def->type != VIR_DOMAIN_NET_TYPE_HOSTDEV && - STREQ_NULLABLE(def->model, "virtio")) { + virDomainNetHasVirtioModel(def)) { if (backend != NULL) { if ((val = virDomainNetBackendTypeFromString(backend)) < 0 || val == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT) { @@ -25478,7 +25478,7 @@ virDomainNetDefFormat(virBufferPtr buf, if (def->model) { virBufferEscapeString(buf, "<model type='%s'/>\n", def->model); - if (STREQ(def->model, "virtio")) { + if (virDomainNetHasVirtioModel(def)) { char *str = NULL, *gueststr = NULL, *hoststr = NULL; int rc = 0; @@ -29732,6 +29732,13 @@ virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface) } +bool +virDomainNetHasVirtioModel(const virDomainNetDef *iface) +{ + return STREQ_NULLABLE(iface->model, "virtio"); +} + + /* Return listens[i] from the appropriate union for the graphics * type, or NULL if this is an unsuitable type, or the index is out of * bounds. If force0 is TRUE, i == 0, and there is no listen array, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 16c2c6e75b..e3f4273b55 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3222,6 +3222,7 @@ virNetDevBandwidthPtr virDomainNetGetActualBandwidth(virDomainNetDefPtr iface); virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface); bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface); +bool virDomainNetHasVirtioModel(const virDomainNetDef *iface); int virDomainNetAppendIPAddress(virDomainNetDefPtr def, const char *address, int family, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0d6f054cf2..bd7e896654 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -470,6 +470,7 @@ virDomainNetGetActualTrustGuestRxFilters; virDomainNetGetActualType; virDomainNetGetActualVirtPortProfile; virDomainNetGetActualVlan; +virDomainNetHasVirtioModel; virDomainNetInsert; virDomainNetNotifyActualDevice; virDomainNetReleaseActualDevice; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ec6b340308..08bb2f9ebc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4573,7 +4573,7 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net) return -1; } - if (STREQ_NULLABLE(net->model, "virtio")) { + if (virDomainNetHasVirtioModel(net)) { if (net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("rx_queue_size has to be a power of two")); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 4a7c71d76d..0950197a44 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -322,8 +322,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (net->model && - STREQ(net->model, "virtio") && + if (virDomainNetHasVirtioModel(net) && net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { net->info.type = type; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a1c3ca999b..2fdc71d07b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3710,7 +3710,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } - if (olddev->model && STREQ(olddev->model, "virtio") && + if (virDomainNetHasVirtioModel(olddev) && (olddev->driver.virtio.name != newdev->driver.virtio.name || olddev->driver.virtio.txmode != newdev->driver.virtio.txmode || olddev->driver.virtio.ioeventfd != newdev->driver.virtio.ioeventfd || diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 2607dea1f5..2cbb382b10 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -261,7 +261,7 @@ qemuInterfaceDirectConnect(virDomainDefPtr def, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); unsigned int macvlan_create_flags = VIR_NETDEV_MACVLAN_CREATE_WITH_TAP; - if (net->model && STREQ(net->model, "virtio")) + if (virDomainNetHasVirtioModel(net)) macvlan_create_flags |= VIR_NETDEV_MACVLAN_VNET_HDR; if (virNetDevMacVLanCreateWithVPortProfile(net->ifname, @@ -434,7 +434,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, template_ifname = true; } - if (net->model && STREQ(net->model, "virtio")) + if (virDomainNetHasVirtioModel(net)) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, tapfdSize, @@ -533,7 +533,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, template_ifname = true; } - if (net->model && STREQ(net->model, "virtio")) + if (virDomainNetHasVirtioModel(net)) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; if (virQEMUDriverIsPrivileged(driver)) { @@ -653,7 +653,7 @@ qemuInterfaceOpenVhostNet(virDomainDefPtr def, } /* If the nic model isn't virtio, don't try to open. */ - if (!(net->model && STREQ(net->model, "virtio"))) { + if (!virDomainNetHasVirtioModel(net)) { if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_VHOST) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vhost-net is only supported for " diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 64a425671d..3bd30bb417 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1241,7 +1241,7 @@ get_files(vahControl * ctl) if (net && net->model) { if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU) continue; - if (STRNEQ(net->model, "virtio")) + if (!virDomainNetHasVirtioModel(net)) continue; } needsvhost = true; diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index b300793732..729e8146b1 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -228,7 +228,7 @@ qemuInterfaceOpenVhostNet(virDomainDefPtr def ATTRIBUTE_UNUSED, { size_t i; - if (!(net->model && STREQ(net->model, "virtio"))) { + if (!virDomainNetHasVirtioModel(net)) { *vhostfdSize = 0; return 0; } -- 2.20.1

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -11329,6 +11329,22 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; }
+ /* NIC model (see -net nic,model=?). We only check that it looks + * reasonable, not that it is a supported NIC type. FWIW kvm + * supports these types as of April 2008: + * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio + * QEMU PPC64 supports spapr-vlan + */ + if (model != NULL) { + if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Model name contains invalid characters")); + goto error; + } + def->model = model; + model = NULL; + }
Can you please split this code motion...
+ switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: if (network == NULL) { @@ -11346,7 +11362,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, break;
case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (STRNEQ_NULLABLE(model, "virtio")) { + if (!virDomainNetHasVirtioModel(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Wrong or no <model> 'type' attribute " "specified with <interface type='vhostuser'/>. "
... along with adjusting this from model to def->model, off to its own preparatory patch? [...]
+bool +virDomainNetHasVirtioModel(const virDomainNetDef *iface) +{ + return STREQ_NULLABLE(iface->model, "virtio"); +}
I'd probably call this virDomainNetIsModelVirtio() and call the argument 'net', but your version is fine too if you prefer it. With the preparatory work in a separate patch, Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 08:35 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -11329,6 +11329,22 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; }
+ /* NIC model (see -net nic,model=?). We only check that it looks + * reasonable, not that it is a supported NIC type. FWIW kvm + * supports these types as of April 2008: + * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio + * QEMU PPC64 supports spapr-vlan + */ + if (model != NULL) { + if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Model name contains invalid characters")); + goto error; + } + def->model = model; + model = NULL; + }
Can you please split this code motion...
+ switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: if (network == NULL) { @@ -11346,7 +11362,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, break;
case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (STRNEQ_NULLABLE(model, "virtio")) { + if (!virDomainNetHasVirtioModel(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Wrong or no <model> 'type' attribute " "specified with <interface type='vhostuser'/>. "
... along with adjusting this from model to def->model, off to its own preparatory patch?
[...]
+bool +virDomainNetHasVirtioModel(const virDomainNetDef *iface) +{ + return STREQ_NULLABLE(iface->model, "virtio"); +}
I'd probably call this virDomainNetIsModelVirtio() and call the argument 'net', but your version is fine too if you prefer it.
With the preparatory work in a separate patch,
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
I'll adjust it all. The iface naming was following some similar functions above it in domain_conf.c but it's certainly less common than 'net' naming Thanks, Cole - Cole

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> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97) --- src/conf/domain_conf.c | 4 +++- src/qemu/qemu_capabilities.c | 6 ++++++ src/qemu/qemu_capabilities.h | 4 ++++ src/qemu/qemu_command.c | 17 +++++++++++++---- src/qemu/qemu_domain_address.c | 8 ++++++-- .../qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 ++ .../virtio-non-transitional.x86_64-3.1.0.args | 6 +++++- .../virtio-non-transitional.x86_64-latest.args | 6 +++++- .../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 ++++ .../virtio-non-transitional.xml | 12 +++++++++++- .../qemuxml2xmloutdata/virtio-transitional.xml | 7 ++++++- 14 files changed, 77 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4fc33c7e2f..9c68e41765 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29735,7 +29735,9 @@ virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface) bool virDomainNetHasVirtioModel(const virDomainNetDef *iface) { - return STREQ_NULLABLE(iface->model, "virtio"); + return (STREQ_NULLABLE(iface->model, "virtio") || + STREQ_NULLABLE(iface->model, "virtio-transitional") || + STREQ_NULLABLE(iface->model, "virtio-non-transitional")); } diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b7c0387f8e..44c4b890b9 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -522,6 +522,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "nvdimm.unarmed", "virtio-blk-pci-transitional", "virtio-blk-pci-non-transitional", + "virtio-net-pci-transitional", + + /* 330 */ + "virtio-net-pci-non-transitional", ); @@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD }, {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL}, {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, + {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, + {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 34265d7cc0..1a92c00575 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -506,6 +506,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */ QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL, /* -device virtio-blk-pci-transitional */ QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL, /* -device virtio-blk-pci-non-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL, /* -device virtio-net-pci-transitional */ + + /* 330 */ + QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL, /* -device virtio-net-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 608cd65806..d3b74211b7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf, virQEMUCapsPtr qemuCaps, virDomainDeviceAddressType type, int model, + const char *modelstr, virDomainDeviceType devtype) { int tmodel_cap, ntmodel_cap; @@ -464,10 +465,15 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_NET: + has_tmodel = STREQ(modelstr, "virtio-transitional"); + has_ntmodel = STREQ(modelstr, "virtio-non-transitional"); + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL; + break; case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: @@ -2136,7 +2142,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, case VIR_DOMAIN_DISK_BUS_VIRTIO: if (qemuBuildVirtioTransitional(&opt, "virtio-blk", qemuCaps, disk->info.type, - disk->model, + disk->model, NULL, VIR_DOMAIN_DEVICE_DISK) < 0) goto error; @@ -3741,8 +3747,11 @@ qemuBuildNicDevStr(virDomainDefPtr def, bool usingVirtio = false; char macaddr[VIR_MAC_STRING_BUFLEN]; - if (STREQ(net->model, "virtio")) { - if (qemuBuildVirtioDevStr(&buf, "virtio-net", net->info.type) < 0) + if (virDomainNetHasVirtioModel(net)) { + if (qemuBuildVirtioTransitional(&buf, "virtio-net", qemuCaps, + net->info.type, + 0, net->model, + VIR_DOMAIN_DEVICE_NET) < 0) goto error; usingVirtio = true; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 0950197a44..654567c500 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -694,8 +694,12 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, return 0; } - if (STREQ(net->model, "virtio")) - return virtioFlags; + if (STREQ(net->model, "virtio") || + STREQ(net->model, "virtio-non-transitional")) + return virtioFlags; + + if (STREQ(net->model, "virtio-transitional")) + return pciFlags; if (STREQ(net->model, "e1000e")) return pcieFlags; diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 8cf9083035..137dcaf156 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -214,6 +214,8 @@ <flag name='nvdimm.unarmed'/> <flag name='virtio-blk-pci-transitional'/> <flag name='virtio-blk-pci-non-transitional'/> + <flag name='virtio-net-pci-transitional'/> + <flag name='virtio-net-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 9c5d553077..6eaf3086ef 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,scsi=off,bus=pci.1,addr=0x0,\ +-device virtio-blk-pci,disable-legacy=on,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,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 7899994622..a1b35d1c07 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -12,6 +12,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 356e8fdf4c..9b80cd893a 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.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,scsi=off,bus=pci.2,addr=0x1,drive=drive-virtio-disk0,\ +-device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk0,\ id=virtio-disk0,bootindex=1 \ +-netdev user,id=hostnet0 \ +-device virtio-net-pci,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 678a7b9132..18f665577a 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -12,6 +12,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 Thu, 2019-01-17 at 12:52 -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> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)
Guess this slipped in somehow :) [...]
@@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD }, {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL}, {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, + {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, + {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},
Same comments about spacing, naming the capabilities and introducing them in their separate commit as for virtio-blk apply. [...]
@@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf, virQEMUCapsPtr qemuCaps, virDomainDeviceAddressType type, int model, + const char *modelstr,
Ewww. We really, really need to make the handling of model names for network interface more sane. In the meantime, can you add some sort of (ideally compile-time) sanity check to ensure that the function is either called with model == -1 && modelStr != NULL or model >= 0 && modelStr == NULL? Or at the very least some documentation on how you're supposed to be calling it. [...]
@@ -3741,8 +3747,11 @@ qemuBuildNicDevStr(virDomainDefPtr def, bool usingVirtio = false; char macaddr[VIR_MAC_STRING_BUFLEN];
- if (STREQ(net->model, "virtio")) { - if (qemuBuildVirtioDevStr(&buf, "virtio-net", net->info.type) < 0) + if (virDomainNetHasVirtioModel(net)) { + if (qemuBuildVirtioTransitional(&buf, "virtio-net", qemuCaps, + net->info.type, + 0, net->model, + VIR_DOMAIN_DEVICE_NET) < 0)
The change from STREQ() to virDomainNetHasVirtioModel() should be squashed into the previous patch. -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 09:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -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> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)
Guess this slipped in somehow :)
[...]
@@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD }, {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL}, {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, + {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, + {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},
Same comments about spacing, naming the capabilities and introducing them in their separate commit as for virtio-blk apply.
[...]
@@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf, virQEMUCapsPtr qemuCaps, virDomainDeviceAddressType type, int model, + const char *modelstr,
Ewww.
We really, really need to make the handling of model names for network interface more sane.
In the meantime, can you add some sort of (ideally compile-time) sanity check to ensure that the function is either called with model == -1 && modelStr != NULL or model >= 0 && modelStr == NULL? Or at the very least some documentation on how you're supposed to be calling it.
I'll respond to the rest of the review in time but I just wanted to mention here: I'm working on a series to try and untangle the net model mess and it undoes this hack. It converts nearly all usage of net->model internally to use an enum, but preserves the string passthrough in xen+qemu to be dealt with separately since that will take some discussion and probably need to be phased out after a grace period. I plan to finish + post the series today unless I hit unexpected hurdles. Thanks for the reviews! - Cole

On 01/18/2019 09:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -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> (cherry picked from commit b6698b81846e2010e0cc030bcd6c2c549cf04e97)
Guess this slipped in somehow :)
[...]
@@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD }, {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL}, {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, + {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, + {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL},
Same comments about spacing, naming the capabilities and introducing them in their separate commit as for virtio-blk apply.
[...]
@@ -449,6 +449,7 @@ qemuBuildVirtioTransitional(virBufferPtr buf, virQEMUCapsPtr qemuCaps, virDomainDeviceAddressType type, int model, + const char *modelstr,
Ewww.
We really, really need to make the handling of model names for network interface more sane.
In the meantime, can you add some sort of (ideally compile-time) sanity check to ensure that the function is either called with model == -1 && modelStr != NULL or model >= 0 && modelStr == NULL? Or at the very least some documentation on how you're supposed to be calling it.
Since hopefully this will be removed by my series in the near future, I'll just add a docstring for the function to clarify its usage Thanks, Cole

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 Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 5 ++- docs/schemas/domaincommon.rng | 9 +++++ src/conf/domain_conf.c | 37 ++++++++++++++++--- 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, 95 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 29e4bb1bda..36dce863ac 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4680,7 +4680,10 @@ <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" which matches the old behavior. </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 425d7f851a..532a78ce32 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4626,6 +4626,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 9c68e41765..3776079e1d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -714,6 +714,13 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIHostProtocol, "none", "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", @@ -7597,6 +7604,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 @@ -7679,14 +7687,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 " @@ -27093,6 +27113,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) { @@ -27143,6 +27164,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 e3f4273b55..36ab544dd3 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 bd7e896654..60a193450b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -407,6 +407,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 6eaf3086ef..2eaa509c04 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,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,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 a1b35d1c07..32d2bdc638 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -16,6 +16,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 9b80cd893a..4e991d6187 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,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk0,\ id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,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 18f665577a..eddc1ce9f5 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -16,6 +16,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

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
typedef struct _virDomainHostdevSubsysSCSIVHost virDomainHostdevSubsysSCSIVHost; typedef virDomainHostdevSubsysSCSIVHost *virDomainHostdevSubsysSCSIVHostPtr; struct _virDomainHostdevSubsysSCSIVHost { int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */ char *wwpn; + int model; /* enum virDomainHostdevSubsysSCSIVHostModelType */ };
There is no check for the value of model in virDomainHostdevDefCheckABIStability(). Interestingly, the same is true for mdevs, so that looks like an oversight that can be corrected there as well. Everything else looks reasonable, including the decision to use model=virtio-* instead of model=vhost-* considering that neither approach would be completely satisfactory anyway, so Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization

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_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 16 +++++++++++----- src/qemu/qemu_domain_address.c | 8 +++++--- tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 ++ .../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 | 3 +-- .../virtio-transitional.x86_64-latest.args | 5 ++--- tests/qemuxml2xmloutdata/virtio-transitional.xml | 7 +------ 10 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 44c4b890b9..70fc510cdb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -526,6 +526,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 330 */ "virtio-net-pci-non-transitional", + "vhost-scsi-pci-transitional", + "vhost-scsi-pci-non-transitional", ); @@ -1118,6 +1120,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, + {"vhost-scsi-pci-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL}, + {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 1a92c00575..f213ad98cc 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -510,6 +510,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 330 */ QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL, /* -device virtio-net-pci-non-transitional */ + QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL, /* -device vhost-scsi-pci-transitional */ + QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL, /* -device vhost-scsi-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d3b74211b7..7cdbd215a6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -471,13 +471,18 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + has_tmodel = model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_SCSI_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: @@ -5038,10 +5043,11 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, goto cleanup; } - if (ARCH_IS_S390(def->os.arch)) - virBufferAddLit(&buf, "vhost-scsi-ccw"); - else - virBufferAddLit(&buf, "vhost-scsi-pci"); + if (qemuBuildVirtioTransitional(&buf, "vhost-scsi", qemuCaps, + dev->info->type, + hostsrc->model, NULL, + VIR_DOMAIN_DEVICE_HOSTDEV) < 0) + goto cleanup; virBufferAsprintf(&buf, ",wwpn=%s,vhostfd=%s,id=%s", hostsrc->wwpn, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 654567c500..c334ba441f 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -785,11 +785,13 @@ 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 follor 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) { + 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/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 137dcaf156..c5079c4028 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -216,6 +216,8 @@ <flag name='virtio-blk-pci-non-transitional'/> <flag name='virtio-net-pci-transitional'/> <flag name='virtio-net-pci-non-transitional'/> + <flag name='vhost-scsi-pci-transitional'/> + <flag name='vhost-scsi-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 2eaa509c04..5ab8560377 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 @@ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,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,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 4e991d6187..38a9e348b3 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,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk0,\ id=virtio-disk0,bootindex=1 \ @@ -35,7 +34,7 @@ id=virtio-disk0,bootindex=1 \ -device virtio-net-pci,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 \ +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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1118,6 +1120,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, + {"vhost-scsi-pci-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL}, + {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, };
Usual comment about capabilities. [...]
@@ -5038,10 +5043,11 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, goto cleanup; }
- if (ARCH_IS_S390(def->os.arch)) - virBufferAddLit(&buf, "vhost-scsi-ccw"); - else - virBufferAddLit(&buf, "vhost-scsi-pci"); + if (qemuBuildVirtioTransitional(&buf, "vhost-scsi", qemuCaps, + dev->info->type, + hostsrc->model, NULL, + VIR_DOMAIN_DEVICE_HOSTDEV) < 0) + goto cleanup;
This changes quite a bit: instead of basing the choice of device upon the architecture and supporting -ccw and -pci only, now we base it upon address type and potentially support -device as well as-s390. I'm assuming the latter is not going to be a problem because there are probably checks along the way preventing us to get there in the first place, but we should definitely make sure we address the former correctly, most likely by setting the address type based on the architecture in postParse(). Either way, once you've made sure the change is actually safe or added code that makes it so, you should switch from the open-coded version to qemuBuildVirtioDevStr(), and only later in a separate commit switch from that to qemuBuildVirtioTransitional().
virBufferAsprintf(&buf, ",wwpn=%s,vhostfd=%s,id=%s", hostsrc->wwpn, diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 654567c500..c334ba441f 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -785,11 +785,13 @@ 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 follor virtio logic */
s/follor/follow/ Everything else looks fine. -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 10:54 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1118,6 +1120,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL}, {"virtio-net-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL}, {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, + {"vhost-scsi-pci-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL}, + {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, };
Usual comment about capabilities.
[...]
@@ -5038,10 +5043,11 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, goto cleanup; }
- if (ARCH_IS_S390(def->os.arch)) - virBufferAddLit(&buf, "vhost-scsi-ccw"); - else - virBufferAddLit(&buf, "vhost-scsi-pci"); + if (qemuBuildVirtioTransitional(&buf, "vhost-scsi", qemuCaps, + dev->info->type, + hostsrc->model, NULL, + VIR_DOMAIN_DEVICE_HOSTDEV) < 0) + goto cleanup;
This changes quite a bit: instead of basing the choice of device upon the architecture and supporting -ccw and -pci only, now we base it upon address type and potentially support -device as well as-s390.
I'm assuming the latter is not going to be a problem because there are probably checks along the way preventing us to get there in the first place, but we should definitely make sure we address the former correctly, most likely by setting the address type based on the architecture in postParse().
Either way, once you've made sure the change is actually safe or added code that makes it so, you should switch from the open-coded version to qemuBuildVirtioDevStr(), and only later in a separate commit switch from that to qemuBuildVirtioTransitional().
If I rework BuildVirtioTransitional like I mentioned in a previous response, we don't need to touch this code. Then it can be cleaned up in a separate patch after this series Thanks, Cole

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 | 2 ++ docs/schemas/domaincommon.rng | 6 +++++- src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 14 +++++++++++--- src/qemu/qemu_domain_address.c | 10 +++++++--- tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 ++ .../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 | 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 ++++ 17 files changed, 68 insertions(+), 8 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 36dce863ac..04e6dc2721 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7971,6 +7971,8 @@ 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> </dd> <dt><code>rate</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 532a78ce32..040fa29914 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5451,7 +5451,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 3776079e1d..cc48599dd1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -858,7 +858,9 @@ 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 36ab544dd3..dc49cbe4d9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2125,6 +2125,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_capabilities.c b/src/qemu/qemu_capabilities.c index 70fc510cdb..0241353006 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -528,6 +528,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-net-pci-non-transitional", "vhost-scsi-pci-transitional", "vhost-scsi-pci-non-transitional", + "virtio-rng-pci-transitional", + "virtio-rng-pci-non-transitional", ); @@ -1122,6 +1124,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, {"vhost-scsi-pci-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL}, {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, + {"virtio-rng-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL}, + {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f213ad98cc..b01578d88a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -512,6 +512,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL, /* -device virtio-net-pci-non-transitional */ QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL, /* -device vhost-scsi-pci-transitional */ QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL, /* -device vhost-scsi-pci-non-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL, /* -device virtio-blk-rng-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL, /* -device virtio-rng-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7cdbd215a6..73f145dcd7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -477,6 +477,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_RNG: + has_tmodel = model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL; + break; case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: @@ -496,7 +502,6 @@ qemuBuildVirtioTransitional(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: @@ -5990,7 +5995,7 @@ qemuBuildRNGDevStr(const virDomainDef *def, { virBuffer buf = VIR_BUFFER_INITIALIZER; - if (dev->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || + if (dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("this qemu doesn't support RNG device type '%s'"), @@ -6002,7 +6007,10 @@ qemuBuildRNGDevStr(const virDomainDef *def, dev->source.file)) goto error; - if (qemuBuildVirtioDevStr(&buf, "virtio-rng", dev->info.type) < 0) + if (qemuBuildVirtioTransitional(&buf, "virtio-rng", qemuCaps, + dev->info.type, + dev->model, NULL, + VIR_DOMAIN_DEVICE_RNG) < 0) goto error; virBufferAsprintf(&buf, ",rng=obj%s,id=%s", diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index c334ba441f..a5491a1c0e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -366,7 +366,9 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, def->memballoon->info.type = type; for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model == VIR_DOMAIN_RNG_MODEL_VIRTIO && + if ((def->rngs[i]->model == VIR_DOMAIN_RNG_MODEL_VIRTIO || + def->rngs[i]->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL || + def->rngs[i]->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL) && def->rngs[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->rngs[i]->info.type = type; } @@ -861,7 +863,10 @@ 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: + return pciFlags; case VIR_DOMAIN_RNG_MODEL_LAST: return 0; @@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, /* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue; if (qemuDomainPCIAddressReserveNextAddr(addrs, &def->rngs[i]->info) < 0) diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index c5079c4028..e54fe53590 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -218,6 +218,8 @@ <flag name='virtio-net-pci-non-transitional'/> <flag name='vhost-scsi-pci-transitional'/> <flag name='vhost-scsi-pci-non-transitional'/> + <flag name='virtio-rng-pci-transitional'/> + <flag name='virtio-rng-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 5ab8560377..a3c81828c0 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,scsi=off,bus=pci.2,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,9 @@ 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,disable-legacy=on,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,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 32d2bdc638..2075ccbf57 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -19,6 +19,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 38a9e348b3..dc830d21b1 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,8 @@ id=virtio-disk0,bootindex=1 \ addr=0x1 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ bus=pci.2,addr=0x3 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci,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 eddc1ce9f5..82535c84d6 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -19,6 +19,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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, - "virtio"); + "virtio", + "virtio-transitional", + "virtio-non-transitional");
Since you're touching the definition, you can make it VIR_ENUM_IMPL(virDomainRNGModel, ... "virtio-non-transitional", ); so that if and when we'll need to add another model the diff will look nicer. [...]
@@ -1122,6 +1124,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, {"vhost-scsi-pci-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL}, {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, + {"virtio-rng-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL}, + {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL}, };
Same comments as for the other capabilities. [...]
@@ -5990,7 +5995,7 @@ qemuBuildRNGDevStr(const virDomainDef *def, { virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (dev->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || + if (dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("this qemu doesn't support RNG device type '%s'"),
Idea for a possible follow-up series: wouldn't it be great if we centralized capabilities checking for VirtIO devices in a function that can be called during device validation? Delaying such checks until command line generation is not optimal, and neither is having some of them centralized and some of them sprinkled around the various qemuBuild*DevStr() functions... [...]
@@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue;
I'm not convinced you can just remove the model check here... Shouldn't you extend it to include MODEL_VIRTIO_TRANSITIONAL and MODEL_VIRTIO_NON_TRANSITIONAL instead? -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 08:13 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, - "virtio"); + "virtio", + "virtio-transitional", + "virtio-non-transitional");
Since you're touching the definition, you can make it
VIR_ENUM_IMPL(virDomainRNGModel, ... "virtio-non-transitional", );
so that if and when we'll need to add another model the diff will look nicer.
Okay I'll adjust it. FWIW I like this style better but it's not well represented in domain_conf.c. I explicitly didn't make a change like this before posting because I had no idea if it would generate a complaint or not. IMO if this is the recommended style then we should fix all instances in one sweep and add a syntax-check for it
[...]
@@ -1122,6 +1124,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-net-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL}, {"vhost-scsi-pci-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_TRANSITIONAL}, {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, + {"virtio-rng-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL}, + {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL}, };
Same comments as for the other capabilities.
[...]
@@ -5990,7 +5995,7 @@ qemuBuildRNGDevStr(const virDomainDef *def, { virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (dev->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || + if (dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("this qemu doesn't support RNG device type '%s'"),
Idea for a possible follow-up series: wouldn't it be great if we centralized capabilities checking for VirtIO devices in a function that can be called during device validation? Delaying such checks until command line generation is not optimal, and neither is having some of them centralized and some of them sprinkled around the various qemuBuild*DevStr() functions...
Yeah the validation checks sprinkled all around are a pain, I hit it quite a few times in this series but I tried to resist the temptation of the rabbit hole...
[...]
@@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue;
I'm not convinced you can just remove the model check here... Shouldn't you extend it to include MODEL_VIRTIO_TRANSITIONAL and MODEL_VIRTIO_NON_TRANSITIONAL instead?
It seemed redundant... the only enum value for rng model prior to this patch was MODEL_VIRTIO, so any rng device here will by definition be MODEL_VIRTIO. Same after this patch, but plus 2 more virtio models. It's future proof if a non-PCI rng device model is added, but it causes more work when a PCI rng device model is added, so it's a toss up Elsewhere in this function, some devices use a whitelist approach (watchdog, memballoon although it's equally redundant), some use a blacklist approach (sound cards, controllers, basically everything else). By deleting the line here it essentially moves rng address allocation to a blacklist approach. So AFAICT it's safe to do, but I can move the change to a separate patch and add a comment, similar to the comment for FS devices near here Thanks, Cole

On Mon, 2019-01-21 at 19:01 -0500, Cole Robinson wrote:
On 01/21/2019 08:13 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, - "virtio"); + "virtio", + "virtio-transitional", + "virtio-non-transitional");
Since you're touching the definition, you can make it
VIR_ENUM_IMPL(virDomainRNGModel, ... "virtio-non-transitional", );
so that if and when we'll need to add another model the diff will look nicer.
Okay I'll adjust it. FWIW I like this style better but it's not well represented in domain_conf.c. I explicitly didn't make a change like this before posting because I had no idea if it would generate a complaint or not. IMO if this is the recommended style then we should fix all instances in one sweep and add a syntax-check for it
I'm not sure I would qualify this style as "recommended", but I certainly prefer it and there are instances of the pattern around the codebase, so I'll switch to it whenever I happen to be touching a VIR_ENUM_IMPL() call. I haven't had any trouble getting such changes past reviewers so far :)
[...]
@@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue;
I'm not convinced you can just remove the model check here... Shouldn't you extend it to include MODEL_VIRTIO_TRANSITIONAL and MODEL_VIRTIO_NON_TRANSITIONAL instead?
It seemed redundant... the only enum value for rng model prior to this patch was MODEL_VIRTIO, so any rng device here will by definition be MODEL_VIRTIO. Same after this patch, but plus 2 more virtio models. It's future proof if a non-PCI rng device model is added, but it causes more work when a PCI rng device model is added, so it's a toss up
When in doubt, I usually go for the safest / more explicit version. -- Andrea Bolognani / Red Hat / Virtualization

On 01/22/2019 07:03 AM, Andrea Bolognani wrote:
On Mon, 2019-01-21 at 19:01 -0500, Cole Robinson wrote:
On 01/21/2019 08:13 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, - "virtio"); + "virtio", + "virtio-transitional", + "virtio-non-transitional");
Since you're touching the definition, you can make it
VIR_ENUM_IMPL(virDomainRNGModel, ... "virtio-non-transitional", );
so that if and when we'll need to add another model the diff will look nicer.
Okay I'll adjust it. FWIW I like this style better but it's not well represented in domain_conf.c. I explicitly didn't make a change like this before posting because I had no idea if it would generate a complaint or not. IMO if this is the recommended style then we should fix all instances in one sweep and add a syntax-check for it
I'm not sure I would qualify this style as "recommended", but I certainly prefer it and there are instances of the pattern around the codebase, so I'll switch to it whenever I happen to be touching a VIR_ENUM_IMPL() call. I haven't had any trouble getting such changes past reviewers so far :)
Noted, I'll do the same
[...]
@@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue;
I'm not convinced you can just remove the model check here... Shouldn't you extend it to include MODEL_VIRTIO_TRANSITIONAL and MODEL_VIRTIO_NON_TRANSITIONAL instead?
It seemed redundant... the only enum value for rng model prior to this patch was MODEL_VIRTIO, so any rng device here will by definition be MODEL_VIRTIO. Same after this patch, but plus 2 more virtio models. It's future proof if a non-PCI rng device model is added, but it causes more work when a PCI rng device model is added, so it's a toss up
When in doubt, I usually go for the safest / more explicit version.
I mean, it's arguably safer and more explicit to duplicate every DomainValidate device whitelist check in qemu_command.c too, but it comes at the cost of more code and increased developer effort when extending related code. In this particular case it took me extra time when writing this code to figure out why the new rng models were not generating the expected addresses. How about I add a prep patch that moves the RNG model check from qemu_command.c into the qemu*Validate path, that way we are enforcing earlier that no non-virtio RNG model can even enter this part of the qemu driver. Thanks, Cole

On Tue, 2019-01-22 at 11:24 -0500, Cole Robinson wrote:
On 01/22/2019 07:03 AM, Andrea Bolognani wrote:
On Mon, 2019-01-21 at 19:01 -0500, Cole Robinson wrote:
@@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue;
I'm not convinced you can just remove the model check here... Shouldn't you extend it to include MODEL_VIRTIO_TRANSITIONAL and MODEL_VIRTIO_NON_TRANSITIONAL instead?
It seemed redundant... the only enum value for rng model prior to this patch was MODEL_VIRTIO, so any rng device here will by definition be MODEL_VIRTIO. Same after this patch, but plus 2 more virtio models. It's future proof if a non-PCI rng device model is added, but it causes more work when a PCI rng device model is added, so it's a toss up
When in doubt, I usually go for the safest / more explicit version.
I mean, it's arguably safer and more explicit to duplicate every DomainValidate device whitelist check in qemu_command.c too, but it comes at the cost of more code and increased developer effort when extending related code. In this particular case it took me extra time when writing this code to figure out why the new rng models were not generating the expected addresses.
How about I add a prep patch that moves the RNG model check from qemu_command.c into the qemu*Validate path, that way we are enforcing earlier that no non-virtio RNG model can even enter this part of the qemu driver.
Looking at the code for rng and balloon more closely it's pretty clear that, unlike what happens with most other devices, they've been implemented with the assumption that there will only ever be one model, so I guess what you suggest above would already be an improvement over the status quo while preparing them for further models would be out of scope at best, pointless at worst... Just go with the above, then. -- Andrea Bolognani / Red Hat / Virtualization

On 01/23/2019 10:40 AM, Andrea Bolognani wrote:
On Tue, 2019-01-22 at 11:24 -0500, Cole Robinson wrote:
On 01/22/2019 07:03 AM, Andrea Bolognani wrote:
On Mon, 2019-01-21 at 19:01 -0500, Cole Robinson wrote:
@@ -2290,8 +2295,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* VirtIO RNG */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue;
I'm not convinced you can just remove the model check here... Shouldn't you extend it to include MODEL_VIRTIO_TRANSITIONAL and MODEL_VIRTIO_NON_TRANSITIONAL instead?
It seemed redundant... the only enum value for rng model prior to this patch was MODEL_VIRTIO, so any rng device here will by definition be MODEL_VIRTIO. Same after this patch, but plus 2 more virtio models. It's future proof if a non-PCI rng device model is added, but it causes more work when a PCI rng device model is added, so it's a toss up
When in doubt, I usually go for the safest / more explicit version.
I mean, it's arguably safer and more explicit to duplicate every DomainValidate device whitelist check in qemu_command.c too, but it comes at the cost of more code and increased developer effort when extending related code. In this particular case it took me extra time when writing this code to figure out why the new rng models were not generating the expected addresses.
How about I add a prep patch that moves the RNG model check from qemu_command.c into the qemu*Validate path, that way we are enforcing earlier that no non-virtio RNG model can even enter this part of the qemu driver.
Looking at the code for rng and balloon more closely it's pretty clear that, unlike what happens with most other devices, they've been implemented with the assumption that there will only ever be one model, so I guess what you suggest above would already be an improvement over the status quo while preparing them for further models would be out of scope at best, pointless at worst... Just go with the above, then.
Okay, thank you. I'll also add a comment pointing out the situation, along the lines of what fs models have: /* Only support VirtIO-9p-pci so far. If that changes, * we might need to skip devices here */ Thanks, Cole

<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. This just adds the domain_conf wiring Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 4 +++ docs/schemas/domaincommon.rng | 9 ++++++ src/conf/domain_conf.c | 32 +++++++++++++++++-- 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, 126 insertions(+), 34 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 04e6dc2721..a2a0757b95 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3880,6 +3880,10 @@ </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" which matches the default behavior of the QEMU driver. </dd> <dt><code>driver</code></dt> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 040fa29914..dc570b78b8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2498,6 +2498,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 cc48599dd1..16594a302e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -408,6 +408,12 @@ VIR_ENUM_IMPL(virDomainFSWrpolicy, VIR_DOMAIN_FS_WRPOLICY_LAST, "default", "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", @@ -10626,6 +10632,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, char *wrpolicy = NULL; char *usage = NULL; char *units = NULL; + char *model = NULL; ctxt->node = node; @@ -10654,6 +10661,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) @@ -10782,6 +10798,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_FREE(usage); VIR_FREE(units); VIR_FREE(format); + VIR_FREE(model); return def; @@ -21889,6 +21906,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; @@ -24693,10 +24716,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 dc49cbe4d9..cebe8768cd 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; @@ -3445,6 +3455,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 a3c81828c0..a7b663a728 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,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,disable-legacy=on,scsi=off,bus=pci.2,addr=0x0,\ +-device virtio-blk-pci,disable-legacy=on,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,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,disable-legacy=on,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,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.4,\ +-device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.5,\ addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ 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 2075ccbf57..df19c1b540 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -22,6 +22,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 dc830d21b1..6f07d5b707 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.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,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk0,\ +-device virtio-blk-pci,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,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.2,\ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.3,\ addr=0x1 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.2,addr=0x3 \ +bus=pci.3,addr=0x3 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x4 \ +-device virtio-rng-pci,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.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 82535c84d6..1ee560212c 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -22,6 +22,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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+VIR_ENUM_IMPL(virDomainFSModel, VIR_DOMAIN_FS_MODEL_LAST, + "default", + "virtio", + "virtio-transitional", + "virtio-non-transitional")
Here as well, you can have VIR_ENUM_IMPL(virDomainFSModel, ... "virtio-non-transitional", ); to prepare for further changes. Everything else looks good, so 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_capabilities.c | 6 +++++ src/qemu/qemu_capabilities.h | 4 ++++ src/qemu/qemu_command.c | 12 ++++++++-- src/qemu/qemu_domain_address.c | 3 ++- .../caps_4.0.0.x86_64.xml | 2 ++ .../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 | 17 +++++++------- .../virtio-transitional.x86_64-latest.args | 16 ++++++------- .../virtio-transitional.xml | 23 ++++++++----------- 10 files changed, 53 insertions(+), 36 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0241353006..2f54b2c81b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -530,6 +530,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "vhost-scsi-pci-non-transitional", "virtio-rng-pci-transitional", "virtio-rng-pci-non-transitional", + + /* 335 */ + "virtio-9p-pci-transitional", + "virtio-9p-pci-non-transitional", ); @@ -1126,6 +1130,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"vhost-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_SCSI_NON_TRANSITIONAL}, {"virtio-rng-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL}, {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL}, + {"virtio-9p-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL}, + {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index b01578d88a..fef94883c9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -515,6 +515,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL, /* -device virtio-blk-rng-transitional */ QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL, /* -device virtio-rng-pci-non-transitional */ + /* 335 */ + QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL, /* -device virtio-9p-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL, /* -device virtio-9p-pci-non-transitional */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 73f145dcd7..56d52e1d7e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -483,9 +483,14 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_FS: + has_tmodel = model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_9P_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: @@ -2742,7 +2747,10 @@ qemuBuildFSDevStr(const virDomainDef *def, goto error; } - if (qemuBuildVirtioDevStr(&opt, "virtio-9p", fs->info.type) < 0) + if (qemuBuildVirtioTransitional(&opt, "virtio-9p", qemuCaps, + fs->info.type, + fs->model, NULL, + VIR_DOMAIN_DEVICE_FS) < 0) goto error; virBufferAsprintf(&opt, ",id=%s", fs->info.alias); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index a5491a1c0e..b7a1cbe2d1 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -681,7 +681,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_DEVICE_FS: - /* the only type of filesystem so far is virtio-9p-pci */ + if (dev->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags; case VIR_DOMAIN_DEVICE_NET: { diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index e54fe53590..1de12a9828 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -220,6 +220,8 @@ <flag name='vhost-scsi-pci-non-transitional'/> <flag name='virtio-rng-pci-transitional'/> <flag name='virtio-rng-pci-non-transitional'/> + <flag name='virtio-9p-pci-transitional'/> + <flag name='virtio-9p-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 a7b663a728..60c84bee29 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,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,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ +bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,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 6f07d5b707..8fbeb6e937 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -25,21 +25,20 @@ 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,scsi=off,bus=pci.3,addr=0x2,drive=drive-virtio-disk0,\ +-device virtio-blk-pci,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,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.3,\ -addr=0x1 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.2,\ +addr=0x2 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.3,addr=0x3 \ +bus=pci.2,addr=0x4 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.3,addr=0x4 \ +-device virtio-rng-pci,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/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 Thu, Jan 17, 2019 at 12:52:37PM -0500, Cole Robinson wrote:
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"
For QEMU the <filesystem> element currently implies the 9p filesystem passthrough impl. We already have a need to reuse it for USB-MTP filesystem sharing, and quite soon we'll have to support virtio-fs too. The virtio-fs module is essentially fuse-over-virtio IIUC. In fact I wonder why we're not just calling that device virtio-fuse to make it explicit ! Anyway the point is that model=virtio-transitional is potentially ambiguous, depending on how we intend to deal with this. I was at first thinking of model="virtio-9p|virtio-fs|usb-mtp" to deal with the existing issue, but you're proposing using model already. I'm a little mixed about how to best dovetail with the transitional stuff. We could use 'model' stuff but expand it: virtio-9p virtio-9p-transitional virtio-9p-non-transitional virtio-fs usb-mtp IIUC, we don't need a -transitional/-non-transitional variant for virtio-fs since it will be a modern device only - same as with virtio-gpu. Or we could do things different and invert something like a 'protocol' concept for the filesystem. <filesystem type='mount'> <target dir="foo" protocol="9p|mtp|fuse"/> </filesystem> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, 2019-01-18 at 11:44 +0000, Daniel P. Berrangé wrote:
For QEMU the <filesystem> element currently implies the 9p filesystem passthrough impl.
We already have a need to reuse it for USB-MTP filesystem sharing, and quite soon we'll have to support virtio-fs too. The virtio-fs module is essentially fuse-over-virtio IIUC. In fact I wonder why we're not just calling that device virtio-fuse to make it explicit !
Anyway the point is that model=virtio-transitional is potentially ambiguous, depending on how we intend to deal with this.
I was at first thinking of model="virtio-9p|virtio-fs|usb-mtp" to deal with the existing issue, but you're proposing using model already.
I'm a little mixed about how to best dovetail with the transitional stuff. We could use 'model' stuff but expand it:
virtio-9p virtio-9p-transitional virtio-9p-non-transitional virtio-fs usb-mtp
IIUC, we don't need a -transitional/-non-transitional variant for virtio-fs since it will be a modern device only - same as with virtio-gpu.
Or we could do things different and invert something like a 'protocol' concept for the filesystem.
<filesystem type='mount'> <target dir="foo" protocol="9p|mtp|fuse"/> </filesystem>
Welp, I wish I'd re-read this message before reviewing the previous patch :) It looks to me like 'model' as used by Cole and and 'protocol' as suggested by you are basically complementary, so having both of them seems pretty reasonable from a quick look. -- Andrea Bolognani / Red Hat / Virtualization

On 01/18/2019 06:44 AM, Daniel P. Berrangé wrote:
On Thu, Jan 17, 2019 at 12:52:37PM -0500, Cole Robinson wrote:
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"
For QEMU the <filesystem> element currently implies the 9p filesystem passthrough impl.
We already have a need to reuse it for USB-MTP filesystem sharing, and quite soon we'll have to support virtio-fs too. The virtio-fs module is essentially fuse-over-virtio IIUC. In fact I wonder why we're not just calling that device virtio-fuse to make it explicit !
Anyway the point is that model=virtio-transitional is potentially ambiguous, depending on how we intend to deal with this.
I was at first thinking of model="virtio-9p|virtio-fs|usb-mtp" to deal with the existing issue, but you're proposing using model already.
I'm a little mixed about how to best dovetail with the transitional stuff. We could use 'model' stuff but expand it:
virtio-9p virtio-9p-transitional virtio-9p-non-transitional virtio-fs usb-mtp
IIUC, we don't need a -transitional/-non-transitional variant for virtio-fs since it will be a modern device only - same as with virtio-gpu.
Or we could do things different and invert something like a 'protocol' concept for the filesystem.
<filesystem type='mount'> <target dir="foo" protocol="9p|mtp|fuse"/> </filesystem>
The 9p|mtp|fuse is certainly more generalized, but I think it's helpful for self documenting purposes to have virtio-fs somewhere in the XML, if that's what the feature will commonly be known as. Users may not even realize virtio-fs is using fuse, leading to ask questions about how to enable virtio-fs or if it's enabled in their XML. Makes me think of the ich6/ich9 vs hda naming... the former is technically more correct and follows qemu naming, yet I've had a dozen questions over the years about where the libvirt HDA option is. I'll aim for the model=virtio-9p-transitional for the next round unless somebody yells... - Cole

If we validate that memballoon is NONE or VIRTIO earlier, we can simplify some checks in some driver APIs Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_command.c | 17 ----------------- src/qemu/qemu_domain.c | 35 +++++++++++++++++++++++++++++++++- src/qemu/qemu_domain_address.c | 3 +-- src/qemu/qemu_driver.c | 9 +++------ src/qemu/qemu_process.c | 3 +-- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 56d52e1d7e..07fa2b9209 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4160,20 +4160,9 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd, { virBuffer buf = VIR_BUFFER_INITIALIZER; - if (STRPREFIX(def->os.machine, "s390-virtio") && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon) - def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE; - if (!virDomainDefHasMemballoon(def)) return 0; - if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Memory balloon device type '%s' is not supported by this version of qemu"), - virDomainMemballoonModelTypeToString(def->memballoon->model)); - return -1; - } - if (qemuBuildVirtioDevStr(&buf, "virtio-balloon", def->memballoon->info.type) < 0) { goto error; @@ -4184,12 +4173,6 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd, goto error; if (def->memballoon->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("deflate-on-oom is not supported by this QEMU binary")); - goto error; - } - virBufferAsprintf(&buf, ",deflate-on-oom=%s", virTristateSwitchTypeToString(def->memballoon->autodeflate)); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 08bb2f9ebc..d2c792e415 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3404,6 +3404,10 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, def->memballoon = memballoon; } + if (STRPREFIX(def->os.machine, "s390-virtio") && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon) + def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE; + if (addDefaultUSBKBD && def->ngraphics > 0 && virDomainDefMaybeAddInput(def, @@ -5888,6 +5892,32 @@ qemuDomainDeviceDefValidateInput(const virDomainInputDef *input, } +static int +qemuDomainDeviceDefValidateMemballoon(const virDomainMemballoonDef *memballoon, + virQEMUCapsPtr qemuCaps) +{ + if (!memballoon || + memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) + return 0; + + if (memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Memory balloon device type '%s' is not supported by this version of qemu"), + virDomainMemballoonModelTypeToString(memballoon->model)); + return -1; + } + + if (memballoon->autodeflate != VIR_TRISTATE_SWITCH_ABSENT && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deflate-on-oom is not supported by this QEMU binary")); + return -1; + } + + return 0; +} + + static int qemuDomainDeviceDefValidateZPCIAddress(virDomainDeviceInfoPtr info, virQEMUCapsPtr qemuCaps) @@ -5996,11 +6026,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, ret = qemuDomainDeviceDefValidateInput(dev->data.input, def, qemuCaps); break; + case VIR_DOMAIN_DEVICE_MEMBALLOON: + ret = qemuDomainDeviceDefValidateMemballoon(dev->data.memballoon, qemuCaps); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_HUB: - case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_MEMORY: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index b7a1cbe2d1..09e0ce12c4 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -360,8 +360,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, def->hostdevs[i]->info->type = type; } - if (def->memballoon && - def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + if (virDomainDefHasMemballoon(def) && def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->memballoon->info.type = type; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1d961707cc..949c09aba4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2436,8 +2436,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, priv = vm->privateData; if (def) { - if (!def->memballoon || - def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + if (!virDomainDefHasMemballoon(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Memory balloon model must be virtio to set the" " collection period")); @@ -2460,8 +2459,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, } if (persistentDef) { - if (!persistentDef->memballoon || - persistentDef->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + if (!virDomainDefHasMemballoon(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Memory balloon model must be virtio to set the" " collection period")); @@ -11947,8 +11945,7 @@ qemuDomainMemoryStatsInternal(virQEMUDriverPtr driver, if (virDomainObjCheckActive(vm) < 0) return -1; - if (vm->def->memballoon && - vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + if (virDomainDefHasMemballoon(vm->def)) { qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetMemoryStats(qemuDomainGetMonitor(vm), vm->def->memballoon, stats, nr_stats); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index aad6c12552..54abd9170a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7564,8 +7564,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, if (running) { virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNPAUSED); - if (vm->def->memballoon && - vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + if (virDomainDefHasMemballoon(vm->def) && vm->def->memballoon->period) { qemuDomainObjEnterMonitor(driver, vm); qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon, -- 2.20.1

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
If we validate that memballoon is NONE or VIRTIO earlier, we can simplify some checks in some driver APIs
Moving checks from the command line generation step to the domain validation step - that's what I'm talking about! \o/ [...]
+ if (STRPREFIX(def->os.machine, "s390-virtio") && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon) + def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
This hunk of code makes zero sense to me, but that's what it's looked like until now and nobody cares about s390-virtio anyway, so I guess it doesn't matter ¯\_(ツ)_/¯ [...]
+static int +qemuDomainDeviceDefValidateMemballoon(const virDomainMemballoonDef *memballoon, + virQEMUCapsPtr qemuCaps) +{ + if (!memballoon || + memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) + return 0;
This needs curly braces around the body, as per our coding style. [...]
@@ -360,8 +360,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, def->hostdevs[i]->info->type = type; }
- if (def->memballoon && - def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + if (virDomainDefHasMemballoon(def) && def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->memballoon->info.type = type;
Again, I don't think you can get away with removing the model check here. As unlikely it is that we're ever going to get non-VirtIO memory balloons down the line, this new code doesn't look quite right to me, especially... [...]
@@ -2436,8 +2436,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, priv = vm->privateData;
if (def) { - if (!def->memballoon || - def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + if (!virDomainDefHasMemballoon(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Memory balloon model must be virtio to set the" " collection period"));
... if you look at the corresponding error messages. I definitely like the change from checking def->memballoon to calling virDomainDefHasMemballoon(def), though. -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 08:55 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
If we validate that memballoon is NONE or VIRTIO earlier, we can simplify some checks in some driver APIs
Moving checks from the command line generation step to the domain validation step - that's what I'm talking about! \o/
[...]
+ if (STRPREFIX(def->os.machine, "s390-virtio") && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon) + def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
This hunk of code makes zero sense to me, but that's what it's looked like until now and nobody cares about s390-virtio anyway, so I guess it doesn't matter ¯\_(ツ)_/¯
Yeah it's a strange one for sure...
[...]
+static int +qemuDomainDeviceDefValidateMemballoon(const virDomainMemballoonDef *memballoon, + virQEMUCapsPtr qemuCaps) +{ + if (!memballoon || + memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) + return 0;
This needs curly braces around the body, as per our coding style.
Will do
[...]
@@ -360,8 +360,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, def->hostdevs[i]->info->type = type; }
- if (def->memballoon && - def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + if (virDomainDefHasMemballoon(def) && def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->memballoon->info.type = type;
Again, I don't think you can get away with removing the model check here. As unlikely it is that we're ever going to get non-VirtIO memory balloons down the line, this new code doesn't look quite right to me, especially...
[...]
@@ -2436,8 +2436,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, priv = vm->privateData;
if (def) { - if (!def->memballoon || - def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { + if (!virDomainDefHasMemballoon(def)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Memory balloon model must be virtio to set the" " collection period"));
... if you look at the corresponding error messages.
I definitely like the change from checking def->memballoon to calling virDomainDefHasMemballoon(def), though.
This discussion is a follow on from the previous one about rng... in this case I don't think it's worth extending the VIRTIO whitelist check in these two additional places, compared to just covering this at Validate time. In this StatsPeriod case, I can change this error message to "No memory balloon device configured, can not set the collection period" Thanks, Cole

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" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 2 ++ docs/schemas/domaincommon.rng | 2 ++ src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 ++ src/libxl/libxl_conf.c | 2 ++ src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 13 ++++++++++--- src/qemu/qemu_domain.c | 4 +++- src/qemu/qemu_domain_address.c | 6 ++++-- tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 ++ .../virtio-non-transitional.x86_64-3.1.0.args | 4 +++- .../virtio-non-transitional.x86_64-latest.args | 4 +++- tests/qemuxml2argvdata/virtio-non-transitional.xml | 2 +- .../virtio-transitional.x86_64-3.1.0.args | 3 ++- .../virtio-transitional.x86_64-latest.args | 3 ++- tests/qemuxml2argvdata/virtio-transitional.xml | 2 +- .../qemuxml2xmloutdata/virtio-non-transitional.xml | 11 +++++++++-- tests/qemuxml2xmloutdata/virtio-transitional.xml | 6 ++++-- 19 files changed, 61 insertions(+), 17 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index a2a0757b95..e8e255f361 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -7902,6 +7902,8 @@ qemu-kvm -net nic,model=? /dev/null </p> <ul> <li>'virtio' - default with QEMU/KVM</li> + <li>'virtio-transitional'</li> + <li>'virtio-non-transitional'</li> <li>'xen' - default with Xen</li> </ul> </dd> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index dc570b78b8..a35f802960 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4091,6 +4091,8 @@ <value>virtio</value> <value>xen</value> <value>none</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 16594a302e..b3baacf345 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -550,7 +550,9 @@ VIR_ENUM_IMPL(virDomainKeyWrapCipherName, VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST, "virtio", "xen", - "none") + "none", + "virtio-transitional", + "virtio-non-transitional") VIR_ENUM_IMPL(virDomainSmbiosMode, VIR_DOMAIN_SMBIOS_LAST, "none", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index cebe8768cd..ce3255113e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1731,6 +1731,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 73e988a3dc..4102a940b9 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_capabilities.c b/src/qemu/qemu_capabilities.c index 2f54b2c81b..59e96887df 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -534,6 +534,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 335 */ "virtio-9p-pci-transitional", "virtio-9p-pci-non-transitional", + "virtio-balloon-pci-transitional", + "virtio-balloon-pci-non-transitional", ); @@ -1132,6 +1134,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL}, {"virtio-9p-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL}, {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL}, + {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL}, + {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index fef94883c9..cd2a5d186c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -518,6 +518,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 335 */ QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL, /* -device virtio-9p-pci-transitional */ QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL, /* -device virtio-9p-pci-non-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL, /* -device virtio-balloon-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL, /* -device virtio-balloon-pci-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 07fa2b9209..dd4c2507c5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -489,6 +489,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_MEMBALLOON: + has_tmodel = model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL; + break; case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: @@ -502,7 +508,6 @@ qemuBuildVirtioTransitional(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: @@ -4163,8 +4168,10 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd, if (!virDomainDefHasMemballoon(def)) return 0; - if (qemuBuildVirtioDevStr(&buf, "virtio-balloon", - def->memballoon->info.type) < 0) { + if (qemuBuildVirtioTransitional(&buf, "virtio-balloon", qemuCaps, + def->memballoon->info.type, + def->memballoon->model, NULL, + VIR_DOMAIN_DEVICE_MEMBALLOON) < 0) { goto error; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d2c792e415..6d54727a31 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5900,7 +5900,9 @@ qemuDomainDeviceDefValidateMemballoon(const virDomainMemballoonDef *memballoon, memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) 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 09e0ce12c4..8c5c5f0477 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -851,7 +851,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: @@ -2284,8 +2287,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, } /* VirtIO balloon */ - if (def->memballoon && - def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + if (virDomainDefHasMemballoon(def) && virDeviceInfoPCIAddressIsWanted(&def->memballoon->info)) { if (qemuDomainPCIAddressReserveNextAddr(addrs, diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 1de12a9828..3461d32151 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -222,6 +222,8 @@ <flag name='virtio-rng-pci-non-transitional'/> <flag name='virtio-9p-pci-transitional'/> <flag name='virtio-9p-pci-non-transitional'/> + <flag name='virtio-balloon-pci-transitional'/> + <flag name='virtio-balloon-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 60c84bee29..71a044cd56 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,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,disable-legacy=on,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.4,addr=0x0 \ +-device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.5,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.5,\ +-device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.6,\ addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ 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 df19c1b540..e307c0491f 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -27,6 +27,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 8fbeb6e937..c35e73ec45 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -37,8 +37,9 @@ id=virtio-disk0,bootindex=1 \ addr=0x2 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ bus=pci.2,addr=0x4 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x5 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x5 \ +-device virtio-rng-pci,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.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 1ee560212c..b656f69191 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -27,6 +27,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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+++ b/docs/formatdomain.html.in @@ -7902,6 +7902,8 @@ qemu-kvm -net nic,model=? /dev/null </p> <ul> <li>'virtio' - default with QEMU/KVM</li> + <li>'virtio-transitional'</li> + <li>'virtio-non-transitional'</li> <li>'xen' - default with Xen</li> </ul>
You didn't add the "Since: 5.1.0" here. [...]
+++ b/docs/schemas/domaincommon.rng @@ -4091,6 +4091,8 @@ <value>virtio</value> <value>xen</value> <value>none</value> + <value>virtio-transitional</value> + <value>virtio-non-transitional</value> </choice>
I'd sort these new <value>s right after "virtio". [...]
@@ -550,7 +550,9 @@ VIR_ENUM_IMPL(virDomainKeyWrapCipherName, VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST, "virtio", "xen", - "none") + "none", + "virtio-transitional", + "virtio-non-transitional")
Same comment as for other VIR_ENUM_IMPL() calls, and also I'd sort the values as described above. [...]
@@ -1132,6 +1134,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL}, {"virtio-9p-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_TRANSITIONAL}, {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL}, + {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL}, + {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, };
Usual comment for capabilities. [...]
@@ -2284,8 +2287,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, }
/* VirtIO balloon */ - if (def->memballoon && - def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO && + if (virDomainDefHasMemballoon(def) && virDeviceInfoPCIAddressIsWanted(&def->memballoon->info)) {
See comments on the previous patch for why I don't think this is correct; either way, it should have been part of *that* patch, no? -- 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" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 4 +++- docs/schemas/domaincommon.rng | 6 +++++- src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_capabilities.c | 6 ++++++ src/qemu/qemu_capabilities.h | 4 ++++ src/qemu/qemu_command.c | 17 +++++++++++------ src/qemu/qemu_domain_address.c | 13 ++++++++++++- .../qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 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 | 1 + .../virtio-transitional.x86_64-latest.args | 2 ++ tests/qemuxml2argvdata/virtio-transitional.xml | 3 +++ .../virtio-non-transitional.xml | 9 +++++++++ .../qemuxml2xmloutdata/virtio-transitional.xml | 4 ++++ tests/qemuxml2xmltest.c | 6 ++++-- 18 files changed, 80 insertions(+), 12 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e8e255f361..5c342cfcfb 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8606,7 +8606,9 @@ 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' 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 a35f802960..54541b1148 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4300,7 +4300,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 b3baacf345..79b2ab35c0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -893,7 +893,9 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, "default", - "virtio") + "virtio", + "virtio-transitional", + "virtio-non-transitional") VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, "default", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ce3255113e..5b9325a6d5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2418,6 +2418,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_capabilities.c b/src/qemu/qemu_capabilities.c index 59e96887df..954ba5a171 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -536,6 +536,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-9p-pci-non-transitional", "virtio-balloon-pci-transitional", "virtio-balloon-pci-non-transitional", + "vhost-vsock-pci-transitional", + + /* 340 */ + "vhost-vsock-pci-non-transitional", ); @@ -1136,6 +1140,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL}, {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL}, {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, + {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, + {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index cd2a5d186c..99e3b3c5ca 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -520,6 +520,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL, /* -device virtio-9p-pci-non-transitional */ QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL, /* -device virtio-balloon-pci-transitional */ QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL, /* -device virtio-balloon-pci-transitional */ + QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL, /* -device vhost-vsock-pci-transitional */ + + /* 340 */ + QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL, /* -device vhost-vsock-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dd4c2507c5..67e54d42b8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -495,6 +495,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_VSOCK: + has_tmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; + break; case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT: @@ -514,7 +520,6 @@ qemuBuildVirtioTransitional(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; @@ -10471,11 +10476,11 @@ qemuBuildVsockDevStr(virDomainDefPtr def, virBuffer buf = VIR_BUFFER_INITIALIZER; char *ret = NULL; - if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { - virBufferAddLit(&buf, "vhost-vsock-ccw"); - } else { - virBufferAddLit(&buf, "vhost-vsock-pci"); - } + if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps, + vsock->info.type, + vsock->model, NULL, + VIR_DOMAIN_DEVICE_VSOCK) < 0) + goto cleanup; virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 8c5c5f0477..1b476bbc15 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -945,7 +945,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/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 3461d32151..b5861b1982 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -224,6 +224,8 @@ <flag name='virtio-9p-pci-non-transitional'/> <flag name='virtio-balloon-pci-transitional'/> <flag name='virtio-balloon-pci-non-transitional'/> + <flag name='vhost-vsock-pci-transitional'/> + <flag name='vhost-vsock-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 71a044cd56..100348bf1a 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,scsi=off,bus=pci.3,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -48,4 +49,6 @@ id=hostdev0,bus=pci.4,addr=0x0 \ addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci,disable-legacy=on,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 e307c0491f..5795f2fdc5 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -28,5 +28,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 c35e73ec45..d2429d2d2c 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -42,4 +42,5 @@ bus=pci.2,addr=0x4 \ -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ +-device vhost-vsock-pci,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 b656f69191..d9a0288387 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -28,5 +28,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 0eca113e23..1a6eddf3b7 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1269,12 +1269,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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -893,7 +893,9 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST,
VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, "default", - "virtio") + "virtio", + "virtio-transitional", + "virtio-non-transitional")
Same comment as always for VIR_ENUM_IMPL(). [...]
@@ -1136,6 +1140,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL}, {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL}, {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, + {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, + {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, };
Same comment as always for capabilities. [...]
@@ -495,6 +495,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_VSOCK: + has_tmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; + break;
case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT:
Sorry I didn't point this out until now, but having an empty line after each 'break;' would be nice from the visual point of view... [...]
@@ -10471,11 +10476,11 @@ qemuBuildVsockDevStr(virDomainDefPtr def, virBuffer buf = VIR_BUFFER_INITIALIZER; char *ret = NULL;
- if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { - virBufferAddLit(&buf, "vhost-vsock-ccw"); - } else { - virBufferAddLit(&buf, "vhost-vsock-pci"); - } + if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps, + vsock->info.type, + vsock->model, NULL, + VIR_DOMAIN_DEVICE_VSOCK) < 0) + goto cleanup;
Similar comment as vhost-scsi in 7/18: you should make sure this is actually safe, and either way move to qemuBuildVirtioDevStr() first and only then to qemuBuildVirtioTransitional(). [...]
+++ b/tests/qemuxml2xmltest.c @@ -1269,12 +1269,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);
This could have gone into patch 2/18. -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 10:48 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -893,7 +893,9 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST,
VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, "default", - "virtio") + "virtio", + "virtio-transitional", + "virtio-non-transitional")
Same comment as always for VIR_ENUM_IMPL().
[...]
@@ -1136,6 +1140,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-9p-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_9P_NON_TRANSITIONAL}, {"virtio-balloon-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL}, {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, + {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, + {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, };
Same comment as always for capabilities.
[...]
@@ -495,6 +495,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_VSOCK: + has_tmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; + break;
case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_INPUT:
Sorry I didn't point this out until now, but having an empty line after each 'break;' would be nice from the visual point of view...
Will do
[...]
@@ -10471,11 +10476,11 @@ qemuBuildVsockDevStr(virDomainDefPtr def, virBuffer buf = VIR_BUFFER_INITIALIZER; char *ret = NULL;
- if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { - virBufferAddLit(&buf, "vhost-vsock-ccw"); - } else { - virBufferAddLit(&buf, "vhost-vsock-pci"); - } + if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps, + vsock->info.type, + vsock->model, NULL, + VIR_DOMAIN_DEVICE_VSOCK) < 0) + goto cleanup;
Similar comment as vhost-scsi in 7/18: you should make sure this is actually safe, and either way move to qemuBuildVirtioDevStr() first and only then to qemuBuildVirtioTransitional().
I'll split this out too.
[...]
+++ b/tests/qemuxml2xmltest.c @@ -1269,12 +1269,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);
This could have gone into patch 2/18.
Seems a little strange since it only became relevant with this patch, but I'll change it - Cole

On Tue, 2019-01-22 at 12:31 -0500, Cole Robinson wrote:
On 01/21/2019 10:48 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+++ b/tests/qemuxml2xmltest.c @@ -1269,12 +1269,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);
This could have gone into patch 2/18.
Seems a little strange since it only became relevant with this patch, but I'll change it
Fair enough. Feel free to leave this, and others, as is. -- Andrea Bolognani / Red Hat / Virtualization

<input> 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. This just adds the domain_conf wiring Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 4 +++ docs/schemas/domaincommon.rng | 9 +++++ src/conf/domain_conf.c | 34 +++++++++++++++++++ src/conf/domain_conf.h | 15 ++++++-- .../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, 103 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 5c342cfcfb..63bdf2c86b 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6431,6 +6431,10 @@ 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'. </p> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 54541b1148..58c449ca80 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4405,6 +4405,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 79b2ab35c0..cbba02929c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -612,6 +612,12 @@ VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "parallels", "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", @@ -12982,6 +12988,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, char *evdev = NULL; char *type = NULL; char *bus = NULL; + char *model = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -12990,6 +12997,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, type = virXMLPropString(node, "type"); bus = virXMLPropString(node, "bus"); + model = virXMLPropString(node, "model"); if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -13003,6 +13011,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, @@ -13112,6 +13127,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_FREE(evdev); VIR_FREE(type); VIR_FREE(bus); + VIR_FREE(model); ctxt->node = save; return def; @@ -21988,6 +22004,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; @@ -26574,6 +26598,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; @@ -26599,6 +26624,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 5b9325a6d5..ded84f52d5 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 type; /* virDomainInputType */ + int bus; /* virDomainInputBus */ + int model; /* virDomainInputModel */ struct { char *evdev; } source; @@ -3488,6 +3498,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 100348bf1a..5952008b28 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,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,disable-legacy=on,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,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.5,addr=0x0 \ @@ -50,5 +53,5 @@ addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=on,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.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 5795f2fdc5..596aa1015b 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -26,6 +26,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 d2429d2d2c..06fe70bb11 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,scsi=off,bus=pci.2,addr=0x3,drive=drive-virtio-disk0,\ id=virtio-disk0,bootindex=1 \ @@ -35,6 +36,8 @@ id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,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,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ bus=pci.2,addr=0x4 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x5 \ 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 d9a0288387..90fba68d9f 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -26,6 +26,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 1a6eddf3b7..9fe2b8e8a2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1270,13 +1270,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 Thu, Jan 17, 2019 at 12:52:41PM -0500, Cole Robinson wrote:
<input> 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. This just adds the domain_conf wiring
s/9p/input-host/ I notice you've not supported virtio-{keyboard,mouse,tablet} which is good as they are modern only. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+VIR_ENUM_IMPL(virDomainInputModel, VIR_DOMAIN_INPUT_MODEL_LAST, + "default", + "virtio", + "virtio-transitional", + "virtio-non-transitional")
Same comment as always for VIR_ENUM_IMPL(). [...]
@@ -13003,6 +13011,13 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; }
+ if (model && + ((def->model = virDomainInputModelTypeFromString(model)) < 0)) {
You might have gone a bit overboard with the parentheses here :)) [...]
struct _virDomainInputDef { - int type; - int bus; + int type; /* virDomainInputType */ + int bus; /* virDomainInputBus */
This hunk should be in a separate, trivial patch. [...]
+++ b/tests/qemuxml2xmltest.c @@ -1270,13 +1270,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);
This too could go into 2/18. -- 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" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 12 ++++++++++-- src/qemu/qemu_domain_address.c | 9 +++++++++ tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 ++ .../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 ++------- 10 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 954ba5a171..f5b9bc6937 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -540,6 +540,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 340 */ "vhost-vsock-pci-non-transitional", + "virtio-input-host-pci-transitional", + "virtio-input-host-pci-non-transitional", ); @@ -1142,6 +1144,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, + {"virtio-input-host-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL}, + {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 99e3b3c5ca..91aae8df5b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -524,6 +524,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 340 */ QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL, /* -device vhost-vsock-pci-non-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL, /* -device virtio-input-host-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL, /* -device virtio-input-host-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 67e54d42b8..4d14ac9e5d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -501,9 +501,14 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_INPUT: + has_tmodel = model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL; + break; case VIR_DOMAIN_DEVICE_LEASE: - case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_WATCHDOG: @@ -4286,7 +4291,10 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, goto error; break; case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: - if (qemuBuildVirtioDevStr(&buf, "virtio-input-host", dev->info.type) < 0) + if (qemuBuildVirtioTransitional(&buf, "virtio-input-host", qemuCaps, + dev->info.type, + dev->model, NULL, + VIR_DOMAIN_DEVICE_INPUT) < 0) goto error; break; case VIR_DOMAIN_INPUT_TYPE_LAST: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 1b476bbc15..70591dce25 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags; case VIR_DOMAIN_INPUT_BUS_PS2: diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index b5861b1982..d5bbbc40f7 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -226,6 +226,8 @@ <flag name='virtio-balloon-pci-non-transitional'/> <flag name='vhost-vsock-pci-transitional'/> <flag name='vhost-vsock-pci-non-transitional'/> + <flag name='virtio-input-host-pci-transitional'/> + <flag name='virtio-input-host-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 5952008b28..fc183757b0 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 @@ bus=pci.1,addr=0x0 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,disable-legacy=on,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,id=input0,\ +evdev=/dev/input/event1234,bus=pci.7,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.4,addr=0x0 \ -device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.5,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 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 06fe70bb11..8046e5c102 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,scsi=off,bus=pci.2,addr=0x3,drive=drive-virtio-disk0,\ id=virtio-disk0,bootindex=1 \ @@ -36,8 +35,8 @@ id=virtio-disk0,bootindex=1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,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,id=input0,evdev=/dev/input/event1234,bus=pci.2,\ +addr=0x7 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ bus=pci.2,addr=0x4 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x5 \ @@ -45,5 +44,5 @@ bus=pci.2,addr=0x4 \ -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ --device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \ +-device vhost-vsock-pci,id=vsock0,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

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1142,6 +1144,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, + {"virtio-input-host-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL}, + {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, };
Same comment as always for capabilities. [...]
@@ -501,9 +501,14 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; break;
Empty line here. [...]
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned. -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 11:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1142,6 +1144,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, + {"virtio-input-host-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL}, + {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, };
Same comment as always for capabilities.
[...]
@@ -501,9 +501,14 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; break;
Empty line here.
[...]
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned.
Oops good catch Thanks, Cole

On 01/22/2019 12:32 PM, Cole Robinson wrote:
On 01/21/2019 11:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
@@ -1142,6 +1144,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-balloon-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BALLOON_NON_TRANSITIONAL}, {"vhost-vsock-pci-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL}, {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, + {"virtio-input-host-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL}, + {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, };
Same comment as always for capabilities.
[...]
@@ -501,9 +501,14 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL; break;
Empty line here.
[...]
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned.
Oops good catch
Actually this missed a case: at least DEFAULT (meaning no model= specified) should return virtioFlags, since this block is already conditional on bus='virtio'. I'll have DEFAULT return virtioFlags and LAST return 0; - Cole

On Wed, 2019-01-23 at 13:30 -0500, Cole Robinson wrote:
On 01/22/2019 12:32 PM, Cole Robinson wrote:
On 01/21/2019 11:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned.
Oops good catch
Actually this missed a case: at least DEFAULT (meaning no model= specified) should return virtioFlags, since this block is already conditional on bus='virtio'. I'll have DEFAULT return virtioFlags and LAST return 0;
Now that you mention it, for devices such as <input> and <disk>, where we're introducing the model attribute just now, we should make sure that we expand the default correctly, such that eg. <disk type='file' device='disk'> <target dev='vda' bus='virtio'/> </disk> is formatted back as <disk type='file' device='disk' model='virtio'> <target dev='vda' bus='virtio'/> </disk> We might have to be careful when formatting the XML for migration and scrub model='virtio' in that case in order not to break backwards migration, as we already do for plenty of other cases. Once that's done, then you'll be guaranteed the model above is never going to be DEFAULT. -- Andrea Bolognani / Red Hat / Virtualization

On 01/24/2019 09:48 AM, Andrea Bolognani wrote:
On Wed, 2019-01-23 at 13:30 -0500, Cole Robinson wrote:
On 01/22/2019 12:32 PM, Cole Robinson wrote:
On 01/21/2019 11:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned.
Oops good catch
Actually this missed a case: at least DEFAULT (meaning no model= specified) should return virtioFlags, since this block is already conditional on bus='virtio'. I'll have DEFAULT return virtioFlags and LAST return 0;
Now that you mention it, for devices such as <input> and <disk>, where we're introducing the model attribute just now, we should make sure that we expand the default correctly, such that eg.
<disk type='file' device='disk'> <target dev='vda' bus='virtio'/> </disk>
is formatted back as
<disk type='file' device='disk' model='virtio'> <target dev='vda' bus='virtio'/> </disk>
We might have to be careful when formatting the XML for migration and scrub model='virtio' in that case in order not to break backwards migration, as we already do for plenty of other cases.
Once that's done, then you'll be guaranteed the model above is never going to be DEFAULT.
IMO extending the XML we generate by default should only be done for very good reasons, the migration compat issue is not a trivial extension and comes with issues of its own. For example, say we turn model=DEFAULT into model=VIRTIO in the qemu driver. In generic domain format code, we would do: if (!MIGRATABLE || disk->model != VIRTIO) <format disk->model in the XML> But the MIGRATABLE checking is very crude. It doesn't consider version or capabilities of the remote libvirt. We could be migrating to an identical qemu and libvirt version, but we still drop the model=VIRTIO from the XML. Basically for the indefinite future, disk->model=VIRTIO in the XML is never going to be accounted for in migration. This can cause theoretical future issues if non-qemu drivers (or other qemu configs) support model=VIRTIO but it's not their default. For those non-qemu drivers, if disk->model=VIRTIO is present in the XML, the user explicitly requested it, but generic formatting code will never send the value during migration. Let's say we skip the MIGRATABLE check. In fact for most of the cases in this patch series (except maybe for <controller> devs), this would work fine. If we are migrating to same or newer libvirt+qemu, all is good. If we migrate to older libvirt, it won't know to check disk->model at all so won't complain, maybe migration would fail due to qemu compat issues but that's unavoidable. However, the NEXT time we make a similar change, let's say filling in disk->model=FOO for bus=ide, or more likely, input->model=QEMUTABLET for input->bus=usb + input->type=tablet. Now we have to blacklist model=QEMUTABLET from the migratable XML for the indefinite future, because older libvirt _may_ know enough to parse input->model, but doesn't have QEMUTABLET in the enum, and parsing fails. Okay, this is what the MIGRATABLE flag is all about. But it's exposing us to the issue with other drivers mentioned above. And this model=QEMUTABLET MIGRATABLE issue is theoretical but it's an exact case that has happened before, with controller models at least. Basically once you open that door of adding new default output to the XML for common cases, you can't ever close it again for that enum property. Plus there's other downsides for outputting new properties by default: * massive test suite churn: every single virtio disk in the XML2XML tests will now spit out model='virtio', plus all the other devices. This makes backporting suck * libvirt downgrade issues. Previous times we added new output, like input type=keyboard, there were lots of complaints like: I upgraded libvirt via virt-preview to see if it fixed a bug, type=keyboard was added by default, I downgraded libvirt back to regular distro version, my VM disappeared, because the XML parser choked on unknown type=keyboard. Again in this particular case it likely won't cause those issues because model= is new everywhere, but the pattern basically can't be extended forward beyond this one instance. Here's the benefits I see of outputing model=virtio by default * Reports more accurate XML. Minor IMO. * Better chance of maintaining qemu compat across libvirt/qemu upgrades. Encoding model=virtio means we will always try that. Hypothetically 5 years from now libvirt starts defaulting to model=virtio-non-transitional, you might upgrade libvirt and your windows virtio VM doesn't boot. Yeah that's not nice, but it's fixable (user sets model=virtio in the XML). Same reasoning basically applies to migration compat as well I don't think the benefits outweigh the downsides. Of course I may be missing plenty of things so please correct me if I'm wrong Thanks, Cole

On Thu, 2019-01-24 at 12:05 -0500, Cole Robinson wrote:
On 01/24/2019 09:48 AM, Andrea Bolognani wrote:
Now that you mention it, for devices such as <input> and <disk>, where we're introducing the model attribute just now, we should make sure that we expand the default correctly, such that eg.
<disk type='file' device='disk'> <target dev='vda' bus='virtio'/> </disk>
is formatted back as
<disk type='file' device='disk' model='virtio'> <target dev='vda' bus='virtio'/> </disk>
We might have to be careful when formatting the XML for migration and scrub model='virtio' in that case in order not to break backwards migration, as we already do for plenty of other cases.
Once that's done, then you'll be guaranteed the model above is never going to be DEFAULT.
IMO extending the XML we generate by default should only be done for very good reasons, the migration compat issue is not a trivial extension and comes with issues of its own.
For example, say we turn model=DEFAULT into model=VIRTIO in the qemu driver. In generic domain format code, we would do:
if (!MIGRATABLE || disk->model != VIRTIO) <format disk->model in the XML>
But the MIGRATABLE checking is very crude. It doesn't consider version or capabilities of the remote libvirt. We could be migrating to an identical qemu and libvirt version, but we still drop the model=VIRTIO from the XML. Basically for the indefinite future, disk->model=VIRTIO in the XML is never going to be accounted for in migration. This can cause theoretical future issues if non-qemu drivers (or other qemu configs) support model=VIRTIO but it's not their default. For those non-qemu drivers, if disk->model=VIRTIO is present in the XML, the user explicitly requested it, but generic formatting code will never send the value during migration.
Let's say we skip the MIGRATABLE check. In fact for most of the cases in this patch series (except maybe for <controller> devs), this would work fine. If we are migrating to same or newer libvirt+qemu, all is good. If we migrate to older libvirt, it won't know to check disk->model at all so won't complain, maybe migration would fail due to qemu compat issues but that's unavoidable.
However, the NEXT time we make a similar change, let's say filling in disk->model=FOO for bus=ide, or more likely, input->model=QEMUTABLET for input->bus=usb + input->type=tablet. Now we have to blacklist model=QEMUTABLET from the migratable XML for the indefinite future, because older libvirt _may_ know enough to parse input->model, but doesn't have QEMUTABLET in the enum, and parsing fails. Okay, this is what the MIGRATABLE flag is all about. But it's exposing us to the issue with other drivers mentioned above.
We have qemuDomainDefFormatBufInternal(), where at least some of the MIGRATABLE tweaks (PCI and USB controllers, serial devices) are performed. I haven't looked into the call graph but I think it's fair to assume that what's safe for pci-root is safe for pretty much anything else :) So that should rule out at least the concern with messing with other drivers.
And this model=QEMUTABLET MIGRATABLE issue is theoretical but it's an exact case that has happened before, with controller models at least. Basically once you open that door of adding new default output to the XML for common cases, you can't ever close it again for that enum property.
Plus there's other downsides for outputting new properties by default:
* massive test suite churn: every single virtio disk in the XML2XML tests will now spit out model='virtio', plus all the other devices. This makes backporting suck
We cause test suite churn all the time, and while it's true that it makes backporting more annoying most of the time it's just a matter of using REGENERATE_OUTPUT=1 and notifying the reviewer.
* libvirt downgrade issues. Previous times we added new output, like input type=keyboard, there were lots of complaints like: I upgraded libvirt via virt-preview to see if it fixed a bug, type=keyboard was added by default, I downgraded libvirt back to regular distro version, my VM disappeared, because the XML parser choked on unknown type=keyboard. Again in this particular case it likely won't cause those issues because model= is new everywhere, but the pattern basically can't be extended forward beyond this one instance.
People who install from virt-preview are going to be either developers, who should have no problem dealing with the situation, or users that are being guided through the analysis process in the first place, so they won't be on their own when guests disappear.
Here's the benefits I see of outputing model=virtio by default
* Reports more accurate XML. Minor IMO.
I remember various occasions in which not formatting a value caused grief down the line, but I can't recall a single time when the opposite was true. So maybe I'm focusing on this more than I should, but past experiences have certainly colored my perception :)
* Better chance of maintaining qemu compat across libvirt/qemu upgrades. Encoding model=virtio means we will always try that. Hypothetically 5 years from now libvirt starts defaulting to model=virtio-non-transitional, you might upgrade libvirt and your windows virtio VM doesn't boot. Yeah that's not nice, but it's fixable (user sets model=virtio in the XML). Same reasoning basically applies to migration compat as well
If we don't format the value from day one, then we *cannot ever* change the default. But I guess that ship has sailed because the XML missing model='...' might come from an old libvirt version, so we can't have that mean anything but model='virtio'.
I don't think the benefits outweigh the downsides. Of course I may be missing plenty of things so please correct me if I'm wrong
I still think we should format the model, but let Dan (now CC'd) weigh in as well :) -- Andrea Bolognani / Red Hat / Virtualization

On Mon, Jan 28, 2019 at 05:17:38PM +0100, Andrea Bolognani wrote:
On Thu, 2019-01-24 at 12:05 -0500, Cole Robinson wrote:
* libvirt downgrade issues. Previous times we added new output, like input type=keyboard, there were lots of complaints like: I upgraded libvirt via virt-preview to see if it fixed a bug, type=keyboard was added by default, I downgraded libvirt back to regular distro version, my VM disappeared, because the XML parser choked on unknown type=keyboard. Again in this particular case it likely won't cause those issues because model= is new everywhere, but the pattern basically can't be extended forward beyond this one instance.
People who install from virt-preview are going to be either developers, who should have no problem dealing with the situation, or users that are being guided through the analysis process in the first place, so they won't be on their own when guests disappear.
NB, downgrading of libvirt is explicitly unsupported. You might get lucky and have it work between some versions, but this is not something we ever care about guaranteeing. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, Jan 24, 2019 at 12:05:11PM -0500, Cole Robinson wrote:
On 01/24/2019 09:48 AM, Andrea Bolognani wrote:
On Wed, 2019-01-23 at 13:30 -0500, Cole Robinson wrote:
On 01/22/2019 12:32 PM, Cole Robinson wrote:
On 01/21/2019 11:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
@@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_INPUT: switch ((virDomainInputBus) dev->data.input->bus) { case VIR_DOMAIN_INPUT_BUS_VIRTIO: + switch ((virDomainInputModel) dev->data.input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + return pciFlags; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + case VIR_DOMAIN_INPUT_MODEL_LAST: + break; + } return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned.
Oops good catch
Actually this missed a case: at least DEFAULT (meaning no model= specified) should return virtioFlags, since this block is already conditional on bus='virtio'. I'll have DEFAULT return virtioFlags and LAST return 0;
Now that you mention it, for devices such as <input> and <disk>, where we're introducing the model attribute just now, we should make sure that we expand the default correctly, such that eg.
<disk type='file' device='disk'> <target dev='vda' bus='virtio'/> </disk>
is formatted back as
<disk type='file' device='disk' model='virtio'> <target dev='vda' bus='virtio'/> </disk>
We might have to be careful when formatting the XML for migration and scrub model='virtio' in that case in order not to break backwards migration, as we already do for plenty of other cases.
Once that's done, then you'll be guaranteed the model above is never going to be DEFAULT.
IMO extending the XML we generate by default should only be done for very good reasons, the migration compat issue is not a trivial extension and comes with issues of its own.
For example, say we turn model=DEFAULT into model=VIRTIO in the qemu driver. In generic domain format code, we would do:
if (!MIGRATABLE || disk->model != VIRTIO) <format disk->model in the XML>
But the MIGRATABLE checking is very crude. It doesn't consider version or capabilities of the remote libvirt. We could be migrating to an identical qemu and libvirt version, but we still drop the model=VIRTIO from the XML. Basically for the indefinite future, disk->model=VIRTIO in the XML is never going to be accounted for in migration. This can cause theoretical future issues if non-qemu drivers (or other qemu configs) support model=VIRTIO but it's not their default. For those non-qemu drivers, if disk->model=VIRTIO is present in the XML, the user explicitly requested it, but generic formatting code will never send the value during migration.
Let's say we skip the MIGRATABLE check. In fact for most of the cases in this patch series (except maybe for <controller> devs), this would work fine. If we are migrating to same or newer libvirt+qemu, all is good. If we migrate to older libvirt, it won't know to check disk->model at all so won't complain, maybe migration would fail due to qemu compat issues but that's unavoidable.
However, the NEXT time we make a similar change, let's say filling in disk->model=FOO for bus=ide, or more likely, input->model=QEMUTABLET for input->bus=usb + input->type=tablet. Now we have to blacklist model=QEMUTABLET from the migratable XML for the indefinite future, because older libvirt _may_ know enough to parse input->model, but doesn't have QEMUTABLET in the enum, and parsing fails. Okay, this is what the MIGRATABLE flag is all about. But it's exposing us to the issue with other drivers mentioned above.
And this model=QEMUTABLET MIGRATABLE issue is theoretical but it's an exact case that has happened before, with controller models at least. Basically once you open that door of adding new default output to the XML for common cases, you can't ever close it again for that enum property.
Plus there's other downsides for outputting new properties by default:
* massive test suite churn: every single virtio disk in the XML2XML tests will now spit out model='virtio', plus all the other devices. This makes backporting suck
* libvirt downgrade issues. Previous times we added new output, like input type=keyboard, there were lots of complaints like: I upgraded libvirt via virt-preview to see if it fixed a bug, type=keyboard was added by default, I downgraded libvirt back to regular distro version, my VM disappeared, because the XML parser choked on unknown type=keyboard. Again in this particular case it likely won't cause those issues because model= is new everywhere, but the pattern basically can't be extended forward beyond this one instance.
Here's the benefits I see of outputing model=virtio by default
* Reports more accurate XML. Minor IMO.
* Better chance of maintaining qemu compat across libvirt/qemu upgrades. Encoding model=virtio means we will always try that. Hypothetically 5 years from now libvirt starts defaulting to model=virtio-non-transitional, you might upgrade libvirt and your windows virtio VM doesn't boot. Yeah that's not nice, but it's fixable (user sets model=virtio in the XML). Same reasoning basically applies to migration compat as well
Realistically we can never change the defaults for anything in libvirt, it has to be done at a layer above. Previously when we've added elements to the XML that were not previously present, we have done this to capture some aspect of the guest ABI that was not previously recorded by libvirt. I see value in that. I don't think that is actually the case this time though. The model=virtio addition is just duplcating what is already perfectly well expressed in the existing bus=virtio attribute. There's no aspect of the guest ABI that was missing that we've added here. Only model=virtio-transitional / model=virtio-non-transitional add new information wrt the ABI. model=virtio is merely a redundant convenience we've added for sake of symmetry. So on this basis, I think there's not a compelling reason to output it in the XML if the user didn't explicitly set it themselves. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 2/6/19 12:03 PM, Daniel P. Berrangé wrote:
On Thu, Jan 24, 2019 at 12:05:11PM -0500, Cole Robinson wrote:
On 01/24/2019 09:48 AM, Andrea Bolognani wrote:
On Wed, 2019-01-23 at 13:30 -0500, Cole Robinson wrote:
On 01/22/2019 12:32 PM, Cole Robinson wrote:
On 01/21/2019 11:20 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: > @@ -917,6 +917,15 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, > case VIR_DOMAIN_DEVICE_INPUT: > switch ((virDomainInputBus) dev->data.input->bus) { > case VIR_DOMAIN_INPUT_BUS_VIRTIO: > + switch ((virDomainInputModel) dev->data.input->model) { > + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: > + return pciFlags; > + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: > + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: > + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: > + case VIR_DOMAIN_INPUT_MODEL_LAST: > + break; > + } > return virtioFlags;
VIR_DOMAIN_INPUT_MODEL_DEFAULT and VIR_DOMAIN_INPUT_MODEL_LAST should result in 0 rather than virtioFlags being returned.
Oops good catch
Actually this missed a case: at least DEFAULT (meaning no model= specified) should return virtioFlags, since this block is already conditional on bus='virtio'. I'll have DEFAULT return virtioFlags and LAST return 0;
Now that you mention it, for devices such as <input> and <disk>, where we're introducing the model attribute just now, we should make sure that we expand the default correctly, such that eg.
<disk type='file' device='disk'> <target dev='vda' bus='virtio'/> </disk>
is formatted back as
<disk type='file' device='disk' model='virtio'> <target dev='vda' bus='virtio'/> </disk>
We might have to be careful when formatting the XML for migration and scrub model='virtio' in that case in order not to break backwards migration, as we already do for plenty of other cases.
Once that's done, then you'll be guaranteed the model above is never going to be DEFAULT.
IMO extending the XML we generate by default should only be done for very good reasons, the migration compat issue is not a trivial extension and comes with issues of its own.
For example, say we turn model=DEFAULT into model=VIRTIO in the qemu driver. In generic domain format code, we would do:
if (!MIGRATABLE || disk->model != VIRTIO) <format disk->model in the XML>
But the MIGRATABLE checking is very crude. It doesn't consider version or capabilities of the remote libvirt. We could be migrating to an identical qemu and libvirt version, but we still drop the model=VIRTIO from the XML. Basically for the indefinite future, disk->model=VIRTIO in the XML is never going to be accounted for in migration. This can cause theoretical future issues if non-qemu drivers (or other qemu configs) support model=VIRTIO but it's not their default. For those non-qemu drivers, if disk->model=VIRTIO is present in the XML, the user explicitly requested it, but generic formatting code will never send the value during migration.
Let's say we skip the MIGRATABLE check. In fact for most of the cases in this patch series (except maybe for <controller> devs), this would work fine. If we are migrating to same or newer libvirt+qemu, all is good. If we migrate to older libvirt, it won't know to check disk->model at all so won't complain, maybe migration would fail due to qemu compat issues but that's unavoidable.
However, the NEXT time we make a similar change, let's say filling in disk->model=FOO for bus=ide, or more likely, input->model=QEMUTABLET for input->bus=usb + input->type=tablet. Now we have to blacklist model=QEMUTABLET from the migratable XML for the indefinite future, because older libvirt _may_ know enough to parse input->model, but doesn't have QEMUTABLET in the enum, and parsing fails. Okay, this is what the MIGRATABLE flag is all about. But it's exposing us to the issue with other drivers mentioned above.
And this model=QEMUTABLET MIGRATABLE issue is theoretical but it's an exact case that has happened before, with controller models at least. Basically once you open that door of adding new default output to the XML for common cases, you can't ever close it again for that enum property.
Plus there's other downsides for outputting new properties by default:
* massive test suite churn: every single virtio disk in the XML2XML tests will now spit out model='virtio', plus all the other devices. This makes backporting suck
* libvirt downgrade issues. Previous times we added new output, like input type=keyboard, there were lots of complaints like: I upgraded libvirt via virt-preview to see if it fixed a bug, type=keyboard was added by default, I downgraded libvirt back to regular distro version, my VM disappeared, because the XML parser choked on unknown type=keyboard. Again in this particular case it likely won't cause those issues because model= is new everywhere, but the pattern basically can't be extended forward beyond this one instance.
Here's the benefits I see of outputing model=virtio by default
* Reports more accurate XML. Minor IMO.
* Better chance of maintaining qemu compat across libvirt/qemu upgrades. Encoding model=virtio means we will always try that. Hypothetically 5 years from now libvirt starts defaulting to model=virtio-non-transitional, you might upgrade libvirt and your windows virtio VM doesn't boot. Yeah that's not nice, but it's fixable (user sets model=virtio in the XML). Same reasoning basically applies to migration compat as well
Realistically we can never change the defaults for anything in libvirt, it has to be done at a layer above.
Previously when we've added elements to the XML that were not previously present, we have done this to capture some aspect of the guest ABI that was not previously recorded by libvirt. I see value in that.
I don't think that is actually the case this time though. The model=virtio addition is just duplcating what is already perfectly well expressed in the existing bus=virtio attribute. There's no aspect of the guest ABI that was missing that we've added here.
Only model=virtio-transitional / model=virtio-non-transitional add new information wrt the ABI. model=virtio is merely a redundant convenience we've added for sake of symmetry.
So on this basis, I think there's not a compelling reason to output it in the XML if the user didn't explicitly set it themselves.
Okay thanks for the response, I'll skip this for my series then. FWIW if we change our minds later I don't think there's any special downsides to doing it in a follow up series. - Cole

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 | 4 ++-- docs/schemas/domaincommon.rng | 2 ++ src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 18 +++++++++++++-- src/qemu/qemu_domain.c | 8 ++++++- src/qemu/qemu_domain_address.c | 2 ++ src/vbox/vbox_common.c | 2 ++ src/vmx/vmx.c | 4 +++- .../caps_4.0.0.x86_64.xml | 2 ++ .../virtio-non-transitional.x86_64-3.1.0.args | 17 ++++++++------ ...virtio-non-transitional.x86_64-latest.args | 17 ++++++++------ .../virtio-non-transitional.xml | 1 + .../virtio-transitional.x86_64-3.1.0.args | 13 ++++++----- .../virtio-transitional.x86_64-latest.args | 13 ++++++----- .../qemuxml2argvdata/virtio-transitional.xml | 1 + .../virtio-non-transitional.xml | 22 +++++++++++++------ .../virtio-transitional.xml | 15 ++++++++----- tests/qemuxml2xmltest.c | 6 +++-- 21 files changed, 111 insertions(+), 48 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 63bdf2c86b..bdf533ba3e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4139,8 +4139,8 @@ <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'</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 58c449ca80..242f237360 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2152,6 +2152,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 cbba02929c..76955b6d78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -359,7 +359,9 @@ 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", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ded84f52d5..9771b0b3d7 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_capabilities.c b/src/qemu/qemu_capabilities.c index f5b9bc6937..0838f2a406 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -542,6 +542,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "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", ); @@ -1146,6 +1148,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, {"virtio-input-host-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL}, {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, + {"virtio-scsi-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL}, + {"virtio-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 91aae8df5b..d23bd251f2 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -526,6 +526,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL, /* -device vhost-vsock-pci-non-transitional */ QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL, /* -device virtio-input-host-pci-transitional */ QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL, /* -device virtio-input-host-pci-non-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL, /* -device virtio-scsi-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL, /* -device virtio-scsi-pci-non-transitional */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4d14ac9e5d..50042b2919 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -507,12 +507,20 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_CONTROLLER: + if (strstr(baseName, "scsi")) { + has_tmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL; + break; + } + return 0; 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: @@ -2971,8 +2979,14 @@ 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", def->info.type) < 0) + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: + if (qemuBuildVirtioTransitional(&buf, "virtio-scsi", qemuCaps, + def->info.type, + def->model, NULL, + VIR_DOMAIN_DEVICE_CONTROLLER) < 0) { goto error; + } if (def->iothread) { virBufferAsprintf(&buf, ",iothread=iothread%u", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6d54727a31..85f7b6a4c8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4972,7 +4972,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")); @@ -5026,6 +5028,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 " @@ -5141,6 +5145,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 70591dce25..9d07fa133e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -651,8 +651,10 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, return 0; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: return virtioFlags; + 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 92601291fd..a853c05e86 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -517,7 +517,9 @@ 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/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index d5bbbc40f7..aa9a0d2d3b 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -228,6 +228,8 @@ <flag name='vhost-vsock-pci-non-transitional'/> <flag name='virtio-input-host-pci-transitional'/> <flag name='virtio-input-host-pci-non-transitional'/> + <flag name='virtio-scsi-pci-transitional'/> + <flag name='virtio-scsi-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 fc183757b0..6fea53fa6e 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,12 @@ 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-scsi-pci,disable-legacy=on,id=scsi0,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,scsi=off,bus=pci.3,addr=0x0,\ +-device virtio-blk-pci,disable-legacy=on,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,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ @@ -43,15 +46,15 @@ bus=pci.1,addr=0x0 \ -device virtio-net-pci,disable-legacy=on,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device virtio-input-host-pci,disable-legacy=on,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,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.4,addr=0x0 \ --device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.5,addr=0x0 \ +id=hostdev0,bus=pci.5,addr=0x0 \ +-device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.6,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.6,\ +-device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.7,\ addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=on,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.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 383b29f629..ad644de35d 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -32,9 +32,12 @@ 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-scsi-pci-non-transitional,id=scsi0,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 +46,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 596aa1015b..03273dc2d9 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -29,6 +29,7 @@ <input type='passthrough' bus='virtio' model='virtio-non-transitional'> <source evdev='/dev/input/event1234'/> </input> + <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 8046e5c102..e8b3712acb 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.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-scsi-pci,id=scsi0,bus=pci.2,addr=0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x3,drive=drive-virtio-disk0,\ +-device virtio-blk-pci,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,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ @@ -36,13 +37,13 @@ id=virtio-disk0,bootindex=1 \ -device virtio-net-pci,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.2,\ -addr=0x7 \ +addr=0x8 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.2,addr=0x4 \ --device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x5 \ +bus=pci.2,addr=0x5 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x6 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ +-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x7 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ --device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x8 \ +-device vhost-vsock-pci,id=vsock0,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..95d20f8579 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-scsi-pci-transitional,id=scsi0,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 90fba68d9f..1616cb137b 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -29,6 +29,7 @@ <input type='passthrough' bus='virtio' model='virtio-transitional'> <source evdev='/dev/input/event1234'/> </input> + <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 b6e762c0a7..56b673d7fa 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='scsi' 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..cf6c43bcb0 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='scsi' 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> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 9fe2b8e8a2..114ceca16c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1271,14 +1271,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 Thu, 2019-01-17 at 12:52 -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.
Completely agree with the rationale here; however, in order to really match the way other devices are handled, I think we should make it so you can use <controller type='scsi' model='virtio'/> as well, which of course would behave the same as the currently available version. What do you think? [...]
+++ b/src/conf/domain_conf.c @@ -359,7 +359,9 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS "vmpvscsi", "ibmvscsi", "virtio-scsi", - "lsisas1078"); + "lsisas1078", + "virtio-transitional", + "virtio-non-transitional");
Same comment as always for VIR_ENUM_IMPL(). [...]
@@ -1146,6 +1148,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"vhost-vsock-pci-non-transitional", QEMU_CAPS_DEVICE_VHOST_VSOCK_NON_TRANSITIONAL}, {"virtio-input-host-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL}, {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, + {"virtio-scsi-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL}, + {"virtio-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL}, };
Same comment as always for capabilities. [...]
@@ -507,12 +507,20 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL; break;
Empty line here.
+ case VIR_DOMAIN_DEVICE_CONTROLLER: + if (strstr(baseName, "scsi")) { + has_tmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL; + break; + } + return 0;
Using strstr() here is kinda crude, especially since the caller has enough information to pass the appropriate virDomainControllerType value, both in this case and later on for serial controllers. I'd say just add yet another argument to the function. Yeah, it starts to get quite unsightly, but I'd really rather not resort to string comparison when a nice, type safe enum will do. [...]
+++ b/tests/qemuxml2xmltest.c @@ -1271,14 +1271,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);
This too could go in patch 2/18. -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 11:49 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -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.
Completely agree with the rationale here; however, in order to really match the way other devices are handled, I think we should make it so you can use
<controller type='scsi' model='virtio'/>
as well, which of course would behave the same as the currently available version. What do you think?
Yes I agree it would be nice to add that option. I suggest we make it a separate issue from this series though incase it's a contentious idea, v2 is already shaping up to be ~30 patches...
+ case VIR_DOMAIN_DEVICE_CONTROLLER: + if (strstr(baseName, "scsi")) { + has_tmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL; + break; + } + return 0;
Using strstr() here is kinda crude, especially since the caller has enough information to pass the appropriate virDomainControllerType value, both in this case and later on for serial controllers.
I'd say just add yet another argument to the function. Yeah, it starts to get quite unsightly, but I'd really rather not resort to string comparison when a nice, type safe enum will do.
Yeah it's hacky. Adding another arg here is going to add extra pain if when this is merged into qemuBuildVirtioStr, most callers are going have NULL arguments, and an increased chance of new future callers passing in incorrect values and accidentally triggering a wrong code path. I feel like this is another argument for the separated BuildTransitional or whatever, but I'm not sold either way so I'll stick with your suggestion Thanks, Cole

On 01/22/2019 12:39 PM, Cole Robinson wrote:
On 01/21/2019 11:49 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -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.
Completely agree with the rationale here; however, in order to really match the way other devices are handled, I think we should make it so you can use
<controller type='scsi' model='virtio'/>
as well, which of course would behave the same as the currently available version. What do you think?
Yes I agree it would be nice to add that option. I suggest we make it a separate issue from this series though incase it's a contentious idea, v2 is already shaping up to be ~30 patches...
+ case VIR_DOMAIN_DEVICE_CONTROLLER: + if (strstr(baseName, "scsi")) { + has_tmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL; + break; + } + return 0;
Using strstr() here is kinda crude, especially since the caller has enough information to pass the appropriate virDomainControllerType value, both in this case and later on for serial controllers.
I'd say just add yet another argument to the function. Yeah, it starts to get quite unsightly, but I'd really rather not resort to string comparison when a nice, type safe enum will do.
Yeah it's hacky. Adding another arg here is going to add extra pain if when this is merged into qemuBuildVirtioStr, most callers are going have NULL arguments, and an increased chance of new future callers passing in incorrect values and accidentally triggering a wrong code path. I feel like this is another argument for the separated BuildTransitional or whatever, but I'm not sold either way so I'll stick with your suggestion
What do you think of this approach? See the attached two patches. It adds a domain_conf.c function virDomainDeviceSetData which makes it easier to create a virDomainDeviceDef. qemuBuildVirtioDevStr callers now pass in a virDomainDeviceType and the specific DefPtr for their device (virDomainDiskDefPtr, virDomainNetDefPtr etc). qemuBuildVirtioDevStr then turns that into a virDomainDeviceDef and acts on that locally. Saves having to extend the argument list several times (like this example above, and the net->model string example). Seperately I think virDomainDeviceSetData can be used to clean up some device interactions elsewhere too Thanks, Cole

On Tue, 2019-01-22 at 16:27 -0500, Cole Robinson wrote:
On 01/22/2019 12:39 PM, Cole Robinson wrote:
On 01/21/2019 11:49 AM, Andrea Bolognani wrote:
Completely agree with the rationale here; however, in order to really match the way other devices are handled, I think we should make it so you can use
<controller type='scsi' model='virtio'/>
as well, which of course would behave the same as the currently available version. What do you think?
Yes I agree it would be nice to add that option. I suggest we make it a separate issue from this series though incase it's a contentious idea, v2 is already shaping up to be ~30 patches...
I don't think that's going to be particularly controversial, and we should really make sure we get all the user-facing bits in at the same time IMHO, so I'd say go for it... If you're really unsure about it you can add that model in a separate patch right after this one, that way if someone happens not to like that we can drop it and otherwise we can squash them together before pushing.
Using strstr() here is kinda crude, especially since the caller has enough information to pass the appropriate virDomainControllerType value, both in this case and later on for serial controllers.
I'd say just add yet another argument to the function. Yeah, it starts to get quite unsightly, but I'd really rather not resort to string comparison when a nice, type safe enum will do.
Yeah it's hacky. Adding another arg here is going to add extra pain if when this is merged into qemuBuildVirtioStr, most callers are going have NULL arguments, and an increased chance of new future callers passing in incorrect values and accidentally triggering a wrong code path. I feel like this is another argument for the separated BuildTransitional or whatever, but I'm not sold either way so I'll stick with your suggestion
What do you think of this approach? See the attached two patches. It adds a domain_conf.c function virDomainDeviceSetData which makes it easier to create a virDomainDeviceDef. qemuBuildVirtioDevStr callers now pass in a virDomainDeviceType and the specific DefPtr for their device (virDomainDiskDefPtr, virDomainNetDefPtr etc). qemuBuildVirtioDevStr then turns that into a virDomainDeviceDef and acts on that locally.
Saves having to extend the argument list several times (like this example above, and the net->model string example). Seperately I think virDomainDeviceSetData can be used to clean up some device interactions elsewhere too
I like it! I actually wanted to suggest something like that earlier, but for some reason I thought it would be more complicated than it turned out to be... Better yet, you don't even need to add that switch statement to qemuBuildVirtioDevStr(): you can just use virDomainDeviceGetInfo() instead, thus making the code shorter and nicer :) -- Andrea Bolognani / Red Hat / Virtualization

On 01/23/2019 07:08 AM, Andrea Bolognani wrote:
On Tue, 2019-01-22 at 16:27 -0500, Cole Robinson wrote:
On 01/22/2019 12:39 PM, Cole Robinson wrote:
On 01/21/2019 11:49 AM, Andrea Bolognani wrote:
Completely agree with the rationale here; however, in order to really match the way other devices are handled, I think we should make it so you can use
<controller type='scsi' model='virtio'/>
as well, which of course would behave the same as the currently available version. What do you think?
Yes I agree it would be nice to add that option. I suggest we make it a separate issue from this series though incase it's a contentious idea, v2 is already shaping up to be ~30 patches...
I don't think that's going to be particularly controversial, and we should really make sure we get all the user-facing bits in at the same time IMHO, so I'd say go for it... If you're really unsure about it you can add that model in a separate patch right after this one, that way if someone happens not to like that we can drop it and otherwise we can squash them together before pushing.
Alright will do
Using strstr() here is kinda crude, especially since the caller has enough information to pass the appropriate virDomainControllerType value, both in this case and later on for serial controllers.
I'd say just add yet another argument to the function. Yeah, it starts to get quite unsightly, but I'd really rather not resort to string comparison when a nice, type safe enum will do.
Yeah it's hacky. Adding another arg here is going to add extra pain if when this is merged into qemuBuildVirtioStr, most callers are going have NULL arguments, and an increased chance of new future callers passing in incorrect values and accidentally triggering a wrong code path. I feel like this is another argument for the separated BuildTransitional or whatever, but I'm not sold either way so I'll stick with your suggestion
What do you think of this approach? See the attached two patches. It adds a domain_conf.c function virDomainDeviceSetData which makes it easier to create a virDomainDeviceDef. qemuBuildVirtioDevStr callers now pass in a virDomainDeviceType and the specific DefPtr for their device (virDomainDiskDefPtr, virDomainNetDefPtr etc). qemuBuildVirtioDevStr then turns that into a virDomainDeviceDef and acts on that locally.
Saves having to extend the argument list several times (like this example above, and the net->model string example). Seperately I think virDomainDeviceSetData can be used to clean up some device interactions elsewhere too
I like it! I actually wanted to suggest something like that earlier, but for some reason I thought it would be more complicated than it turned out to be...
Better yet, you don't even need to add that switch statement to qemuBuildVirtioDevStr(): you can just use virDomainDeviceGetInfo() instead, thus making the code shorter and nicer :)
Ah good catch, though the switch statement will end up in the final result anyways with all the transitional additions Thanks, Cole

On Wed, 2019-01-23 at 07:52 -0500, Cole Robinson wrote:
On 01/23/2019 07:08 AM, Andrea Bolognani wrote:
Better yet, you don't even need to add that switch statement to qemuBuildVirtioDevStr(): you can just use virDomainDeviceGetInfo() instead, thus making the code shorter and nicer :)
Ah good catch, though the switch statement will end up in the final result anyways with all the transitional additions
That's a very solid point :) Sorry for the noise. -- Andrea Bolognani / Red Hat / Virtualization

On 01/23/2019 07:52 AM, Cole Robinson wrote:
On 01/23/2019 07:08 AM, Andrea Bolognani wrote:
On Tue, 2019-01-22 at 16:27 -0500, Cole Robinson wrote:
On 01/22/2019 12:39 PM, Cole Robinson wrote:
On 01/21/2019 11:49 AM, Andrea Bolognani wrote:
Completely agree with the rationale here; however, in order to really match the way other devices are handled, I think we should make it so you can use
<controller type='scsi' model='virtio'/>
as well, which of course would behave the same as the currently available version. What do you think?
Yes I agree it would be nice to add that option. I suggest we make it a separate issue from this series though incase it's a contentious idea, v2 is already shaping up to be ~30 patches...
I don't think that's going to be particularly controversial, and we should really make sure we get all the user-facing bits in at the same time IMHO, so I'd say go for it... If you're really unsure about it you can add that model in a separate patch right after this one, that way if someone happens not to like that we can drop it and otherwise we can squash them together before pushing.
Alright will do
I'm realizing now I forgot this, sorry. I'll add it to my todo list Thanks, Cole

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" Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/formatdomain.html.in | 4 +++- docs/schemas/domaincommon.rng | 9 +++++++++ src/conf/domain_conf.c | 10 ++++++++++ src/conf/domain_conf.h | 10 ++++++++++ src/qemu/qemu_capabilities.c | 6 ++++++ src/qemu/qemu_capabilities.h | 4 ++++ src/qemu/qemu_command.c | 11 +++++++++- src/qemu/qemu_domain_address.c | 2 ++ .../caps_4.0.0.x86_64.xml | 2 ++ .../virtio-non-transitional.x86_64-3.1.0.args | 15 ++++++++------ ...virtio-non-transitional.x86_64-latest.args | 15 ++++++++------ .../virtio-non-transitional.xml | 1 + .../virtio-transitional.x86_64-3.1.0.args | 13 ++++++------ .../virtio-transitional.x86_64-latest.args | 13 ++++++------ .../qemuxml2argvdata/virtio-transitional.xml | 1 + .../virtio-non-transitional.xml | 20 +++++++++++++------ .../virtio-transitional.xml | 15 ++++++++------ 17 files changed, 113 insertions(+), 38 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index bdf533ba3e..1bba2ca284 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4135,7 +4135,9 @@ <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'</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 242f237360..99987b4a3a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2311,6 +2311,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 76955b6d78..46fbc0befc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -384,6 +384,12 @@ VIR_ENUM_IMPL(virDomainControllerModelIDE, VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST, "piix4", "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", @@ -10222,6 +10228,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; } @@ -10239,6 +10247,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 9771b0b3d7..0d801b0d6d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -791,6 +791,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 || \ @@ -3467,6 +3476,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_capabilities.c b/src/qemu/qemu_capabilities.c index 0838f2a406..1ddb4317f3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -544,6 +544,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-input-host-pci-non-transitional", "virtio-scsi-pci-transitional", "virtio-scsi-pci-non-transitional", + + /* 345 */ + "virtio-serial-pci-transitional", + "virtio-serial-pci-non-transitional", ); @@ -1150,6 +1154,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { {"virtio-input-host-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_INPUT_HOST_NON_TRANSITIONAL}, {"virtio-scsi-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL}, {"virtio-scsi-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL}, + {"virtio-serial-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_SERIAL_TRANSITIONAL}, + {"virtio-serial-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_SERIAL_NON_TRANSITIONAL}, }; static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index d23bd251f2..0bb215130b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -529,6 +529,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL, /* -device virtio-scsi-pci-transitional */ QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL, /* -device virtio-scsi-pci-non-transitional */ + /* 345 */ + QEMU_CAPS_DEVICE_VIRTIO_SERIAL_TRANSITIONAL, /* -device virtio-serial-pci-transitional */ + QEMU_CAPS_DEVICE_VIRTIO_SERIAL_NON_TRANSITIONAL, /* -device virtio-serial-pci-non-transitional */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 50042b2919..940d55b1b1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -514,6 +514,12 @@ qemuBuildVirtioTransitional(virBufferPtr buf, tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SCSI_NON_TRANSITIONAL; break; + } else if (strstr(baseName, "serial")) { + has_tmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; + tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SERIAL_TRANSITIONAL; + ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_SERIAL_NON_TRANSITIONAL; + break; } return 0; @@ -3026,7 +3032,10 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, break; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - if (qemuBuildVirtioDevStr(&buf, "virtio-serial", def->info.type) < 0) + if (qemuBuildVirtioTransitional(&buf, "virtio-serial", qemuCaps, + def->info.type, + def->model, NULL, + VIR_DOMAIN_DEVICE_CONTROLLER) < 0) goto error; virBufferAsprintf(&buf, ",id=%s", def->info.alias); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9d07fa133e..50cc47b7b3 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -670,6 +670,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags; case VIR_DOMAIN_CONTROLLER_TYPE_FDC: diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index aa9a0d2d3b..aaf7d404eb 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -230,6 +230,8 @@ <flag name='virtio-input-host-pci-non-transitional'/> <flag name='virtio-scsi-pci-transitional'/> <flag name='virtio-scsi-pci-non-transitional'/> + <flag name='virtio-serial-pci-transitional'/> + <flag name='virtio-serial-pci-non-transitional'/> <version>3001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>446361</microcodeVersion> 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 6fea53fa6e..60ef581744 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,9 +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,disable-legacy=on,id=scsi0,bus=pci.3,addr=0x0 \ +-device virtio-serial-pci,disable-legacy=on,id=virtio-serial0,bus=pci.4,\ +addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,disable-legacy=on,scsi=off,bus=pci.4,addr=0x0,\ +-device virtio-blk-pci,disable-legacy=on,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,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,\ @@ -46,15 +49,15 @@ bus=pci.1,addr=0x0 \ -device virtio-net-pci,disable-legacy=on,netdev=hostnet0,id=net0,\ mac=00:11:22:33:44:55,bus=pci.2,addr=0x0 \ -device virtio-input-host-pci,disable-legacy=on,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,wwpn=naa.5123456789abcde0,vhostfd=3,\ -id=hostdev0,bus=pci.5,addr=0x0 \ --device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.6,addr=0x0 \ +id=hostdev0,bus=pci.6,addr=0x0 \ +-device virtio-balloon-pci,disable-legacy=on,id=balloon0,bus=pci.7,addr=0x0 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.7,\ +-device virtio-rng-pci,disable-legacy=on,rng=objrng0,id=rng0,bus=pci.8,\ addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -device vhost-vsock-pci,disable-legacy=on,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.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index ad644de35d..f9cc136f70 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -35,9 +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.3,addr=0x0 \ +-device virtio-serial-pci-non-transitional,id=virtio-serial0,bus=pci.4,\ +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,\ @@ -46,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 03273dc2d9..a269658520 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -30,6 +30,7 @@ <source evdev='/dev/input/event1234'/> </input> <controller type='scsi' model='virtio-non-transitional'/> + <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 e8b3712acb..e495ab3747 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -28,8 +28,9 @@ 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,id=scsi0,bus=pci.2,addr=0x3 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.2,addr=0x4 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ --device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x4,drive=drive-virtio-disk0,\ +-device virtio-blk-pci,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,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.2,addr=0x1 \ @@ -37,13 +38,13 @@ id=virtio-disk0,bootindex=1 \ -device virtio-net-pci,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.2,\ -addr=0x8 \ +addr=0x9 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,\ -bus=pci.2,addr=0x5 \ --device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x6 \ +bus=pci.2,addr=0x6 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x7 \ -object rng-random,id=objrng0,filename=/dev/urandom \ --device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x7 \ +-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.2,addr=0x8 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ --device vhost-vsock-pci,id=vsock0,guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x9 \ +-device vhost-vsock-pci,id=vsock0,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 95d20f8579..506cca1107 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -28,8 +28,9 @@ 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=0x3 \ +-device virtio-serial-pci-transitional,id=virtio-serial0,bus=pci.2,addr=0x4 \ -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 1616cb137b..ac9ae43ef6 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -30,6 +30,7 @@ <source evdev='/dev/input/event1234'/> </input> <controller type='scsi' model='virtio-transitional'/> + <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 56b673d7fa..e00962d513 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='scsi' index='0' model='virtio-non-transitional'> <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/> </controller> + <controller type='virtio-serial' 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 cf6c43bcb0..af02183fe2 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='scsi' index='0' model='virtio-transitional'> <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/> </controller> + <controller type='virtio-serial' 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> -- 2.20.1

On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+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;
Do we even need MODEL_VIRTIO_SERIAL_DEFAULT here? Honest question :) [...]
@@ -670,6 +670,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break;
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags;
I'd prefer to see the kind of switch statement you added for VIR_DOMAIN_DEVICE_VSOCK here as well. -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 11:59 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+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;
Do we even need MODEL_VIRTIO_SERIAL_DEFAULT here? Honest question :)
The DEFAULT = -1 is the pattern used by other controller models, and I believe it's kinda enforced by ControllerDefNew which sets cont->model = -1. It might not serve any purpose in this particular case besides consistency. Working in this area made me explore enum DEFAULT/NONE naming a bit and there's definitely a lot of room for making things consistent. controller models are the oddball here with the -1 value but I think that's to do with some old XML migration compat that can be unwound in a different way. Another task for another day
[...]
@@ -670,6 +670,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, break;
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL) + return pciFlags; return virtioFlags;
I'd prefer to see the kind of switch statement you added for VIR_DOMAIN_DEVICE_VSOCK here as well.
Okay I'll try to expand that pattern out to other patches too - Cole

On Tue, 2019-01-22 at 12:46 -0500, Cole Robinson wrote:
On 01/21/2019 11:59 AM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote: [...]
+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;
Do we even need MODEL_VIRTIO_SERIAL_DEFAULT here? Honest question :)
The DEFAULT = -1 is the pattern used by other controller models, and I believe it's kinda enforced by ControllerDefNew which sets cont->model = -1. It might not serve any purpose in this particular case besides consistency.
I see.
Working in this area made me explore enum DEFAULT/NONE naming a bit and there's definitely a lot of room for making things consistent. controller models are the oddball here with the -1 value but I think that's to do with some old XML migration compat that can be unwound in a different way. Another task for another day
Definitely :) -- Andrea Bolognani / Red Hat / Virtualization

This generates new XML like: <disk> <enum name='model'> <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 | 7 + .../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 | 1 + .../qemu_2.12.0-virt.aarch64.xml | 1 + .../qemu_2.12.0.ppc64.xml | 1 + .../qemu_2.12.0.s390x.xml | 1 + .../qemu_2.12.0.x86_64.xml | 1 + .../qemu_2.6.0-virt.aarch64.xml | 1 + .../qemu_2.6.0.aarch64.xml | 1 + .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 + .../qemu_2.6.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 + .../qemu_2.8.0-tcg.x86_64.xml | 1 + .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 + .../qemu_2.8.0.x86_64.xml | 1 + .../qemu_2.9.0-q35.x86_64.xml | 1 + .../qemu_2.9.0-tcg.x86_64.xml | 1 + .../qemu_2.9.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 + .../qemu_4.0.0.x86_64.xml | 153 ++++++++++++++++++ tests/domaincapstest.c | 4 + 28 files changed, 194 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 ba2b6ba70f..4ed255d328 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -481,6 +481,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 1ddb4317f3..290d44fb14 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5286,6 +5286,13 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SATA); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL)) + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_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..a26cff6b1d 100644 --- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml @@ -68,6 +68,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..9dddca6652 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml @@ -74,6 +74,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..f75655452a 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -40,6 +40,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..891fa89616 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml @@ -133,6 +133,7 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'/> </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..3fc54b3d64 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml @@ -98,6 +98,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..88d471258b 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml @@ -71,6 +71,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..155fd04c90 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml @@ -71,6 +71,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..0aefab3320 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml @@ -44,6 +44,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..326772c715 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml @@ -72,6 +72,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..c2d741a57f 100644 --- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml @@ -38,6 +38,7 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'/> </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..a67223f422 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,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..8e2282d2c6 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml @@ -119,6 +119,7 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'/> </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..3f6feefc2b 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml @@ -73,6 +73,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..81401f9b5c 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,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..624ccbdb9a 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,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..5ad54aff81 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml @@ -82,6 +82,7 @@ <value>usb</value> <value>sata</value> </enum> + <enum name='model'/> </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..7f5ea8e463 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -139,6 +139,7 @@ <value>scsi</value> <value>virtio</value> </enum> + <enum name='model'/> </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..38a075aa00 --- /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='vmx'/> + <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-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 Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
This generates new XML like:
<disk> <enum name='model'> <value>virtio-transitional</value> <value>virtio-non-transitional</value> </enum> </disk>
<value>virtio</value> should appear in the output as well... [...]
@@ -5286,6 +5286,13 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SATA);
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL)) + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL)) + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL);
... but it seems we don't have a capability for that? Weird. The approach looks sane otherwise. -- Andrea Bolognani / Red Hat / Virtualization

On 01/21/2019 12:04 PM, Andrea Bolognani wrote:
On Thu, 2019-01-17 at 12:52 -0500, Cole Robinson wrote:
This generates new XML like:
<disk> <enum name='model'> <value>virtio-transitional</value> <value>virtio-non-transitional</value> </enum> </disk>
<value>virtio</value> should appear in the output as well...
[...]
@@ -5286,6 +5286,13 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_SATA);
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL)) + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL)) + VIR_DOMAIN_CAPS_ENUM_SET(disk->model, + VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL);
... but it seems we don't have a capability for that? Weird.
Okay I'll fix. Thank you very much for the timely and thorough reviews Andrea! Thanks, Cole
participants (4)
-
Andrea Bolognani
-
Cole Robinson
-
Daniel P. Berrangé
-
Eduardo Habkost