[libvirt] [PATCH RFC 0/8] qemu: allow disabling certain virtio revisions

For https://bugzilla.redhat.com/show_bug.cgi?id=1227354 some users might want to adjust the QEMU defaults and disable either virtio 0.9 or virtio 1.0 (spelled out as disable-legacy and disable-modern on qemu command line). This series uses a separate <virtio revision="x"> element right under the relevant device element for consistency, even though it might fit better in different subelemets for some of them. Ján Tomko (8): Fix indentation Add virtio revision attribute to memballoon Add virtio revision attribute to disks Add virtio revision attribute to controllers Add virtio revision attribute to filesystems Add virtio revision attribute to intefaces Add virtio revision to rng devices qemu: format options for enforcing virtio revisions docs/formatdomain.html.in | 51 ++++++++++ docs/schemas/domaincommon.rng | 29 ++++++ src/conf/domain_conf.c | 72 +++++++++++++- src/conf/domain_conf.h | 14 +++ src/qemu/qemu_command.c | 31 ++++++ .../qemuxml2argv-virtio-revision.args | 58 +++++++++++ .../qemuxml2argv-virtio-revision.xml | 107 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 10 ++ .../qemuxml2xmlout-virtio-revision.xml | 107 +++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 10 files changed, 480 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml -- 2.7.3

--- src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a56e0f5..4999dea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8824,7 +8824,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, vlanNode = virXPathNode("./vlan", ctxt); if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &actual->vlan) < 0) - goto error; + goto error; *def = actual; actual = NULL; -- 2.7.3

On Fri, 2016-07-29 at 15:37 +0200, Ján Tomko wrote:
--- src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a56e0f5..4999dea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8824,7 +8824,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, vlanNode = virXPathNode("./vlan", ctxt); if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &actual->vlan) < 0) - goto error; + goto error; *def = actual; actual = NULL;
I think you can safely push this one without waiting for feedback on the rest of the series or a respin :) ACK -- Andrea Bolognani / Red Hat / Virtualization

<memballoon model='virtio'> <virtio revision='0'/> </memballoon> https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 9 ++++ docs/schemas/domaincommon.rng | 14 ++++++ src/conf/domain_conf.c | 46 +++++++++++++++++++ src/conf/domain_conf.h | 9 ++++ .../qemuxml2argv-virtio-revision.xml | 53 ++++++++++++++++++++++ .../qemuxml2xmlout-virtio-revision.xml | 53 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 7 files changed, 186 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8efd6af..3c3ec32 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6379,6 +6379,15 @@ qemu-kvm -net nic,model=? /dev/null <span class='since'>Since 1.1.1, requires QEMU 1.5</span> </p> </dd> + <dt><code>virtio</code></dt> + <dd> + <p> + An optional <code>virtio</code> can be used to enforce a particular + virtio revision in QEMU. The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>. + <span class='since'>Since 2.2.0</span> + </p> + </dd> </dl> <h4><a name="elementsRng">Random number generator device</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 741f268..7043cee 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3570,6 +3570,9 @@ </attribute> </element> </optional> + <optional> + <ref name="virtioRevision"/> + </optional> </interleave> </element> </define> @@ -4776,6 +4779,17 @@ </element> </define> + <define name="virtioRevision"> + <element name="virtio"> + <attribute name="revision"> + <choice> + <value>0</value> + <value>1</value> + </choice> + </attribute> + </element> + </define> + <define name="usbmaster"> <element name="master"> <attribute name="startport"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4999dea..7ae07e8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -831,6 +831,12 @@ VIR_ENUM_IMPL(virDomainLoader, "rom", "pflash") +VIR_ENUM_IMPL(virDomainVirtioRevision, + VIR_DOMAIN_VIRTIO_REVISION_LAST, + "default", + "0", + "1") + /* Internal mapping: subset of block job types that can be present in * <mirror> XML (remaining types are not two-phase). */ VIR_ENUM_DECL(virDomainBlockJob) @@ -1056,6 +1062,41 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) return &xmlopt->ns; } +static int +virDomainVirtioRevisionParseXML(xmlXPathContextPtr ctxt, + virDomainVirtioRevision *res) +{ + char *str = virXPathString("string(./virtio/@revision)", ctxt); + int ret = -1; + int val; + + if (!str) + return 0; + + if ((val = virDomainVirtioRevisionTypeFromString(str)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Unable to parse virtio revision: '%s'"), + str); + goto cleanup; + } + + ret = 0; + *res = val; + cleanup: + VIR_FREE(str); + return ret; +} + + +static void +virDomainVirtioRevisionFormatXML(virBufferPtr buf, + virDomainVirtioRevision val) +{ + if (val != VIR_DOMAIN_VIRTIO_REVISION_DEFAULT) + virBufferAsprintf(buf, "<virtio revision='%s'/>\n", + virDomainVirtioRevisionTypeToString(val)); +} + void virBlkioDeviceArrayClear(virBlkioDevicePtr devices, @@ -12058,6 +12099,9 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) goto error; + if (virDomainVirtioRevisionParseXML(ctxt, &def->virtio_rev) < 0) + goto error; + cleanup: VIR_FREE(model); VIR_FREE(deflate); @@ -21446,6 +21490,8 @@ virDomainMemballoonDefFormat(virBufferPtr buf, return -1; } + virDomainVirtioRevisionFormatXML(&childrenBuf, def->virtio_rev); + if (!virBufferUse(&childrenBuf)) { virBufferAddLit(buf, "/>\n"); } else { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3c2f182..ba5ad70 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -154,6 +154,13 @@ typedef virDomainTPMDef *virDomainTPMDefPtr; typedef struct _virDomainIOMMUDef virDomainIOMMUDef; typedef virDomainIOMMUDef *virDomainIOMMUDefPtr; +typedef enum { + VIR_DOMAIN_VIRTIO_REVISION_DEFAULT, + VIR_DOMAIN_VIRTIO_REVISION_HERITAGE, + VIR_DOMAIN_VIRTIO_REVISION_CONTEMPORARY, + VIR_DOMAIN_VIRTIO_REVISION_LAST, +} virDomainVirtioRevision; + /* Flags for the 'type' field in virDomainDeviceDef */ typedef enum { VIR_DOMAIN_DEVICE_NONE = 0, @@ -1544,6 +1551,7 @@ struct _virDomainMemballoonDef { virDomainDeviceInfo info; int period; /* seconds between collections */ int autodeflate; /* enum virTristateSwitch */ + virDomainVirtioRevision virtio_rev; }; struct _virDomainNVRAMDef { @@ -3016,6 +3024,7 @@ VIR_ENUM_DECL(virDomainTPMBackend) VIR_ENUM_DECL(virDomainMemoryModel) VIR_ENUM_DECL(virDomainMemoryBackingModel) VIR_ENUM_DECL(virDomainIOMMUModel) +VIR_ENUM_DECL(virDomainVirtioRevision) /* from libvirt.h */ VIR_ENUM_DECL(virDomainState) VIR_ENUM_DECL(virDomainNostateReason) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml new file mode 100644 index 0000000..efa94fe --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml @@ -0,0 +1,53 @@ +<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='pc'>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</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <controller type='virtio-serial' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> + </controller> + <input type='mouse' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> + </input> + <input type='keyboard' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/> + </input> + <input type='tablet' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/> + </input> + <input type='passthrough' bus='virtio'> + <source evdev='/dev/input/event1234'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/> + </input> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <video> + <model type='virtio' heads='1' primary='yes'> + <acceleration accel3d='yes'/> + </model> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/> + <virtio revision='0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml new file mode 100644 index 0000000..efa94fe --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml @@ -0,0 +1,53 @@ +<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='pc'>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</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <controller type='virtio-serial' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> + </controller> + <input type='mouse' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> + </input> + <input type='keyboard' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/> + </input> + <input type='tablet' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/> + </input> + <input type='passthrough' bus='virtio'> + <source evdev='/dev/input/event1234'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/> + </input> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <video> + <model type='virtio' heads='1' primary='yes'> + <acceleration accel3d='yes'/> + </model> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/> + <virtio revision='0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5f04b8b..96265b3 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -882,6 +882,8 @@ mymain(void) DO_TEST("virtio-input"); DO_TEST("virtio-input-passthrough"); + DO_TEST_FULL("virtio-revision", WHEN_BOTH, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, NONE); + virObjectUnref(cfg); DO_TEST("acpi-table"); -- 2.7.3

On Fri, Jul 29, 2016 at 03:37:38PM +0200, Ján Tomko wrote:
<memballoon model='virtio'> <virtio revision='0'/> </memballoon>
https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 9 ++++ docs/schemas/domaincommon.rng | 14 ++++++ src/conf/domain_conf.c | 46 +++++++++++++++++++ src/conf/domain_conf.h | 9 ++++ .../qemuxml2argv-virtio-revision.xml | 53 ++++++++++++++++++++++ .../qemuxml2xmlout-virtio-revision.xml | 53 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 7 files changed, 186 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8efd6af..3c3ec32 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6379,6 +6379,15 @@ qemu-kvm -net nic,model=? /dev/null <span class='since'>Since 1.1.1, requires QEMU 1.5</span> </p> </dd> + <dt><code>virtio</code></dt> + <dd> + <p> + An optional <code>virtio</code> can be used to enforce a particular + virtio revision in QEMU. The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>.
Per your cover letter the actual versions are 0.9 and 1.0, so I think we should use those and not shorten it to just 0 & 1. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

<disk ...> <virtio revision="0"/> </disk> https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 9 +++++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 4 ++++ src/conf/domain_conf.h | 1 + tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 14 ++++++++++++++ .../qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 14 ++++++++++++++ 6 files changed, 45 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3c3ec32..6ddd7ef 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2776,6 +2776,15 @@ </dd> </dl> </dd> + <dt><code>virtio</code></dt> + <dd> + <p> + An optional <code>virtio</code> element can be used to enforce a particular + virtio revision in QEMU. The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>. + <span class='since'>Since 2.2.0</span> + </p> + </dd> </dl> <h4><a name="elementsFilesystems">Filesystems</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 7043cee..41a00a2 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1183,6 +1183,9 @@ </data> </element> </optional> + <optional> + <ref name="virtioRevision"/> + </optional> </interleave> </define> <define name="snapshot"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7ae07e8..3a64c35 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7673,6 +7673,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } } + if (virDomainVirtioRevisionParseXML(ctxt, &def->virtio_rev) < 0) + goto error; + /* Disk volume types will have authentication information handled in * virStorageTranslateDiskSourcePool */ @@ -20055,6 +20058,7 @@ virDomainDiskDefFormat(virBufferPtr buf, if (virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) < 0) return -1; + virDomainVirtioRevisionFormatXML(buf, def->virtio_rev); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</disk>\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ba5ad70..0dbd3fd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -620,6 +620,7 @@ struct _virDomainDiskDef { unsigned int iothread; /* unused = 0, > 0 specific thread # */ int detect_zeroes; /* enum virDomainDiskDetectZeroes */ char *domain_name; /* backend domain name */ + virDomainVirtioRevision virtio_rev; }; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml index efa94fe..691fd5b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml @@ -14,6 +14,20 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/var/lib/libvirt/images/img1'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> + <virtio revision='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/var/lib/libvirt/images/img2'/> + <target dev='vdb' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> + <virtio revision='1'/> + </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml index efa94fe..691fd5b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml @@ -14,6 +14,20 @@ <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/var/lib/libvirt/images/img1'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> + <virtio revision='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/var/lib/libvirt/images/img2'/> + <target dev='vdb' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> + <virtio revision='1'/> + </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> -- 2.7.3

<controller type='scsi' index='0' model='virtio-scsi'> <virtio revision='0'/> </controller> https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 8 ++++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 4 ++++ src/conf/domain_conf.h | 1 + tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 10 ++++++++++ tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 10 ++++++++++ 6 files changed, 36 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6ddd7ef..703dd26 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3116,6 +3116,14 @@ additional attributes that control specific features, such as: </p> + <p> + For virtio controllers, an optional <code>virtio</code> element + can be used to enforce a particular virtio revision in QEMU. + The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>. + <span class='since'>Since 2.2.0</span> + </p> + <dl> <dt><code>virtio-serial</code></dt> <dd>The <code>virtio-serial</code> controller has two additional diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 41a00a2..c24a060 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1926,6 +1926,9 @@ </optional> </element> </optional> + <optional> + <ref name="virtioRevision"/> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3a64c35..844cd4b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8285,6 +8285,9 @@ virDomainControllerDefParseXML(xmlNodePtr node, cur = cur->next; } + if (virDomainVirtioRevisionParseXML(ctxt, &def->virtio_rev) < 0) + goto error; + /* node is parsed differently from target attributes because * someone thought it should be a subelement instead... */ @@ -20210,6 +20213,7 @@ virDomainControllerDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<pcihole64 unit='KiB'>%lu</" "pcihole64>\n", def->opts.pciopts.pcihole64size); } + virDomainVirtioRevisionFormatXML(buf, def->virtio_rev); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</controller>\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0dbd3fd..18b5bbd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -761,6 +761,7 @@ struct _virDomainControllerDef { virDomainUSBControllerOpts usbopts; } opts; virDomainDeviceInfo info; + virDomainVirtioRevision virtio_rev; }; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml index 691fd5b..b8fa986 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml @@ -28,12 +28,22 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> <virtio revision='1'/> </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/var/lib/libvirt/images/img3'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> + <virtio revision='0'/> + </controller> <controller type='pci' index='0' model='pci-root'/> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml index 691fd5b..b8fa986 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml @@ -28,12 +28,22 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> <virtio revision='1'/> </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/var/lib/libvirt/images/img3'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> + <controller type='scsi' index='0' model='virtio-scsi'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> + <virtio revision='0'/> + </controller> <controller type='pci' index='0' model='pci-root'/> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> -- 2.7.3

<filesystem ...> ... <virtio revision='1'/> </filesystem> https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 10 ++++++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 13 +++++++++++++ tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 13 +++++++++++++ 6 files changed, 46 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 703dd26..fa8124d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2963,6 +2963,16 @@ hard limit is enforced. <span class="since">Since 0.9.13</span> </dd> + + <dt><code>virtio</code></dt> + <dd> + <p> + An optional <code>virtio</code> element can be used to enforce a particular + virtio revision in QEMU. The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>. + <span class='since'>Since 2.2.0</span> + </p> + </dd> </dl> <h4><a name="elementsAddress">Device Addresses</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c24a060..24616a9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2079,6 +2079,9 @@ <ref name='scaledInteger'/> </element> </optional> + <optional> + <ref name="virtioRevision"/> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 844cd4b..7fa50d3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8688,6 +8688,9 @@ virDomainFSDefParseXML(xmlNodePtr node, goto error; } + if (virDomainVirtioRevisionParseXML(ctxt, &def->virtio_rev) < 0) + goto error; + def->src->path = source; source = NULL; def->dst = target; @@ -20334,6 +20337,9 @@ virDomainFSDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<space_soft_limit unit='bytes'>" "%llu</space_soft_limit>\n", def->space_soft_limit); } + + virDomainVirtioRevisionFormatXML(buf, def->virtio_rev); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</filesystem>\n"); return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 18b5bbd..af46c64 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -824,6 +824,7 @@ struct _virDomainFSDef { unsigned long long space_hard_limit; /* in bytes */ unsigned long long space_soft_limit; /* in bytes */ bool symlinksResolved; + virDomainVirtioRevision virtio_rev; }; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml index b8fa986..2ee3533 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml @@ -48,6 +48,19 @@ <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </controller> + <filesystem type='mount' accessmode='passthrough'> + <source dir='/export/fs1'/> + <target dir='fs1'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + <virtio revision='0'/> + </filesystem> + <filesystem type='mount' accessmode='mapped'> + <driver type='path' wrpolicy='immediate'/> + <source dir='/export/fs2'/> + <target dir='fs2'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + <virtio revision='1'/> + </filesystem> <input type='mouse' bus='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> </input> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml index b8fa986..2ee3533 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml @@ -48,6 +48,19 @@ <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </controller> + <filesystem type='mount' accessmode='passthrough'> + <source dir='/export/fs1'/> + <target dir='fs1'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + <virtio revision='0'/> + </filesystem> + <filesystem type='mount' accessmode='mapped'> + <driver type='path' wrpolicy='immediate'/> + <source dir='/export/fs2'/> + <target dir='fs2'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + <virtio revision='1'/> + </filesystem> <input type='mouse' bus='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> </input> -- 2.7.3

<interface type='user'> <mac address='52:54:56:5a:5c:5e'/> <model type='virtio'/> <virtio revision='1'/> </interface> https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 8 +++++++- docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 5 +++++ src/conf/domain_conf.h | 1 + tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 12 ++++++++++++ tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 12 ++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index fa8124d..6c8ea15 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4012,6 +4012,12 @@ attribute <code>type='pci'</code> as <a href="#elementsAddress">documented above</a>. </p> + <p> + An optional <code>virtio</code> element can be used to enforce a particular + virtio revision in QEMU. The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>. + <span class='since'>Since 2.2.0</span> + </p> <h5><a name="elementsNICSVirtual">Virtual network</a></h5> @@ -6409,7 +6415,7 @@ qemu-kvm -net nic,model=? /dev/null <dt><code>virtio</code></dt> <dd> <p> - An optional <code>virtio</code> can be used to enforce a particular + An optional <code>virtio</code> element can be used to enforce a particular virtio revision in QEMU. The valid values for the <code>revision</code> are <code>0</code> and <code>1</code>. <span class='since'>Since 2.2.0</span> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 24616a9..05351a0 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2372,6 +2372,9 @@ <ref name="virYesNo"/> </attribute> </optional> + <optional> + <ref name="virtioRevision"/> + </optional> </element> </define> <!-- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7fa50d3..bb91b0c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9666,6 +9666,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } + if (virDomainVirtioRevisionParseXML(ctxt, &def->virtio_rev) < 0) + goto error; + cleanup: ctxt->node = oldnode; VIR_FREE(macaddr); @@ -21073,6 +21076,8 @@ virDomainNetDefFormat(virBufferPtr buf, | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0) return -1; + virDomainVirtioRevisionFormatXML(buf, def->virtio_rev); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</interface>\n"); return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index af46c64..880930f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -991,6 +991,7 @@ struct _virDomainNetDef { virNetDevVlan vlan; int trustGuestRxFilters; /* enum virTristateBool */ int linkstate; + virDomainVirtioRevision virtio_rev; }; /* Used for prefix of ifname of any network name generated dynamically diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml index 2ee3533..2e13808 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml @@ -61,6 +61,18 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> <virtio revision='1'/> </filesystem> + <interface type='user'> + <mac address='52:54:56:58:5a:5c'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + <virtio revision='0'/> + </interface> + <interface type='user'> + <mac address='52:54:56:5a:5c:5e'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + <virtio revision='1'/> + </interface> <input type='mouse' bus='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> </input> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml index 2ee3533..2e13808 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml @@ -61,6 +61,18 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> <virtio revision='1'/> </filesystem> + <interface type='user'> + <mac address='52:54:56:58:5a:5c'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + <virtio revision='0'/> + </interface> + <interface type='user'> + <mac address='52:54:56:5a:5c:5e'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + <virtio revision='1'/> + </interface> <input type='mouse' bus='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/> </input> -- 2.7.3

<rng model='virtio'> <backend model='random'>/dev/random</backend> <virtio revision='1'/> </rng> https://bugzilla.redhat.com/show_bug.cgi?id=1227354 --- docs/formatdomain.html.in | 9 +++++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 5 +++++ src/conf/domain_conf.h | 1 + tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 5 +++++ tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 5 +++++ 6 files changed, 28 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6c8ea15..bc9a3db 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6502,6 +6502,15 @@ qemu-kvm -net nic,model=? /dev/null </dd> </dl> </dd> + <dt><code>virtio</code></dt> + <dd> + <p> + An optional <code>virtio</code> element can be used to enforce a particular + virtio revision in QEMU. The valid values for the <code>revision</code> + are <code>0</code> and <code>1</code>. + <span class='since'>Since 2.2.0</span> + </p> + </dd> </dl> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 05351a0..dbaa1d7 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4750,6 +4750,9 @@ <optional> <ref name="address"/> </optional> + <optional> + <ref name="virtioRevision"/> + </optional> </interleave> </element> </define> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bb91b0c..9f1f20f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12046,6 +12046,9 @@ virDomainRNGDefParseXML(xmlNodePtr node, if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) goto error; + if (virDomainVirtioRevisionParseXML(ctxt, &def->virtio_rev) < 0) + goto error; + cleanup: VIR_FREE(model); VIR_FREE(backend); @@ -21690,6 +21693,8 @@ virDomainRNGDefFormat(virBufferPtr buf, return -1; } + virDomainVirtioRevisionFormatXML(buf, def->virtio_rev); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</rng>\n"); return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 880930f..9c806a4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1942,6 +1942,7 @@ struct _virDomainRNGDef { } source; virDomainDeviceInfo info; + virDomainVirtioRevision virtio_rev; }; typedef enum { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml index 2e13808..94c844e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml @@ -98,5 +98,10 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/> <virtio revision='0'/> </memballoon> + <rng model='virtio'> + <backend model='random'>/dev/random</backend> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/> + <virtio revision='1'/> + </rng> </devices> </domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml index 2e13808..94c844e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml @@ -98,5 +98,10 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/> <virtio revision='0'/> </memballoon> + <rng model='virtio'> + <backend model='random'>/dev/random</backend> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/> + <virtio revision='1'/> + </rng> </devices> </domain> -- 2.7.3

https://bugzilla.redhat.com/show_bug.cgi?id=1227354 Translate the optional <virtio revision> attribute to disable-legacy=on/off and disable-modern=on/off options for the following devices: <memballoon> virtio-balloon-pci <disk> virtio-blk-pci <controller> virtio-scsi-pci virtio-serial-pci <filesystem> virtio-9p-pci <interface> virtio-net-pci <rng> virtio-rng-pci --- src/qemu/qemu_command.c | 31 ++++++++++++ .../qemuxml2argv-virtio-revision.args | 58 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 10 ++++ 3 files changed, 99 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5325f48..db38279 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -386,6 +386,23 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, return ret; } +static void +qemuBuildVirtioRevisionStr(virBufferPtr buf, + virDomainVirtioRevision rev) +{ + switch (rev) { + case VIR_DOMAIN_VIRTIO_REVISION_HERITAGE: + virBufferAddLit(buf, ",disable-legacy=off,disable-modern=on"); + break; + case VIR_DOMAIN_VIRTIO_REVISION_CONTEMPORARY: + virBufferAddLit(buf, ",disable-legacy=on,disable-modern=off"); + break; + case VIR_DOMAIN_VIRTIO_REVISION_DEFAULT: + case VIR_DOMAIN_VIRTIO_REVISION_LAST: + break; + } +} + static int qemuBuildRomStr(virBufferPtr buf, virDomainDeviceInfoPtr info) @@ -1992,6 +2009,9 @@ qemuBuildDriveDevStr(const virDomainDef *def, (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) ? "on" : "off"); } + + qemuBuildVirtioRevisionStr(&opt, disk->virtio_rev); + if (qemuBuildDeviceAddressStr(&opt, def, &disk->info, qemuCaps) < 0) goto error; break; @@ -2311,6 +2331,8 @@ qemuBuildFSDevStr(const virDomainDef *def, QEMU_FSDEV_HOST_PREFIX, fs->info.alias); virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst); + qemuBuildVirtioRevisionStr(&opt, fs->virtio_rev); + if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0) goto error; @@ -2568,6 +2590,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, def->iothread); } } + qemuBuildVirtioRevisionStr(&buf, def->virtio_rev); break; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: virBufferAddLit(&buf, "lsi"); @@ -2613,6 +2636,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, virBufferAsprintf(&buf, ",vectors=%d", def->opts.vioserial.vectors); } + qemuBuildVirtioRevisionStr(&buf, def->virtio_rev); break; case VIR_DOMAIN_CONTROLLER_TYPE_CCID: @@ -3557,6 +3581,9 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",id=%s", net->info.alias); virBufferAsprintf(&buf, ",mac=%s", virMacAddrFormat(&net->mac, macaddr)); + + qemuBuildVirtioRevisionStr(&buf, net->virtio_rev); + if (qemuBuildDeviceAddressStr(&buf, def, &net->info, qemuCaps) < 0) goto error; if (qemuBuildRomStr(&buf, &net->info) < 0) @@ -3827,6 +3854,8 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd, virTristateSwitchTypeToString(def->memballoon->autodeflate)); } + qemuBuildVirtioRevisionStr(&buf, def->memballoon->virtio_rev); + virCommandAddArg(cmd, "-device"); virCommandAddArgBuffer(cmd, &buf); return 0; @@ -5564,6 +5593,8 @@ qemuBuildRNGDevStr(const virDomainDef *def, virBufferAddLit(&buf, ",period=1000"); } + qemuBuildVirtioRevisionStr(&buf, dev->virtio_rev); + if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) goto error; if (virBufferCheckError(&buf) < 0) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args new file mode 100644 index 0000000..9ba70af --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args @@ -0,0 +1,58 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-device virtio-scsi-pci,disable-legacy=off,disable-modern=on,id=scsi0,\ +bus=pci.0,addr=0x8 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x9 \ +-usb \ +-drive file=/var/lib/libvirt/images/img1,format=raw,if=none,\ +id=drive-virtio-disk0 \ +-device virtio-blk-pci,disable-legacy=off,disable-modern=on,bus=pci.0,addr=0xa,\ +drive=drive-virtio-disk0,id=virtio-disk0 \ +-drive file=/var/lib/libvirt/images/img2,format=raw,if=none,\ +id=drive-virtio-disk1 \ +-device virtio-blk-pci,disable-legacy=on,disable-modern=off,bus=pci.0,addr=0xb,\ +drive=drive-virtio-disk1,id=virtio-disk1 \ +-drive file=/var/lib/libvirt/images/img3,format=raw,if=none,\ +id=drive-scsi0-0-0-0 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ +-fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ +-device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,disable-legacy=off,\ +disable-modern=on,bus=pci.0,addr=0x3 \ +-fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs1,\ +path=/export/fs2 \ +-device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,disable-legacy=on,\ +disable-modern=off,bus=pci.0,addr=0x4 \ +-device virtio-net-pci,vlan=0,id=net0,mac=52:54:56:58:5a:5c,disable-legacy=off,\ +disable-modern=on,bus=pci.0,addr=0x6 \ +-net user,vlan=0,name=hostnet0 \ +-device virtio-net-pci,vlan=1,id=net1,mac=52:54:56:5a:5c:5e,disable-legacy=on,\ +disable-modern=off,bus=pci.0,addr=0x7 \ +-net user,vlan=1,name=hostnet1 \ +-device virtio-mouse-pci,id=input0,bus=pci.0,addr=0xe \ +-device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x10 \ +-device virtio-tablet-pci,id=input2,bus=pci.0,addr=0x11 \ +-device virtio-input-host-pci,id=input3,evdev=/dev/input/event1234,bus=pci.0,\ +addr=0x12 \ +-device virtio-vga,id=video0,virgl=on,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0xc,disable-legacy=off,\ +disable-modern=on \ +-object rng-random,id=objrng0,filename=/dev/random \ +-device virtio-rng-pci,rng=objrng0,id=rng0,disable-legacy=on,\ +disable-modern=off,bus=pci.0,addr=0xd diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a5d51a8..1d64324 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2072,6 +2072,16 @@ mymain(void) DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU); + DO_TEST("virtio-revision", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD, + QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET, + QEMU_CAPS_VIRTIO_INPUT_HOST, + QEMU_CAPS_FSDEV, QEMU_CAPS_FSDEV_WRITEOUT, + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL, + QEMU_CAPS_DEVICE_VIRTIO_RNG, + QEMU_CAPS_OBJECT_RNG_RANDOM, + QEMU_CAPS_DEVICE_VIDEO_PRIMARY); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.7.3

On Fri, Jul 29, 2016 at 03:37:44PM +0200, Ján Tomko wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1227354
Translate the optional <virtio revision> attribute to disable-legacy=on/off and disable-modern=on/off options for the following devices:
<memballoon> virtio-balloon-pci <disk> virtio-blk-pci <controller> virtio-scsi-pci virtio-serial-pci <filesystem> virtio-9p-pci <interface> virtio-net-pci <rng> virtio-rng-pci
What about <input> and <video>. The latter in fact only supports v1.0, but we should still have the config there I think Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 07/29/2016 09:37 AM, Ján Tomko wrote:
For https://bugzilla.redhat.com/show_bug.cgi?id=1227354
some users might want to adjust the QEMU defaults and disable either virtio 0.9 or virtio 1.0 (spelled out as disable-legacy and disable-modern on qemu command line).
This series uses a separate <virtio revision="x"> element right under the relevant device element for consistency, even though it might fit better in different subelemets for some of them.
Ján Tomko (8): Fix indentation Add virtio revision attribute to memballoon Add virtio revision attribute to disks Add virtio revision attribute to controllers Add virtio revision attribute to filesystems Add virtio revision attribute to intefaces Add virtio revision to rng devices qemu: format options for enforcing virtio revisions
1) I don't see anything in this series checking that the qemu binary recognizes the disable-legacy or disable-binary options for any of the devices. I don't know if both options were added to all devices in the same release (so that there could be a single capability flag) or if they were added at different times (requiring multiple capability flags). 2) To assure that the actual device presented to the guest doesn't change in the future when defaults are changed, we may want to autofill "version" even when none is specified. (We would of course be stuck with the unfortunate problem of what to do with existing configs) 3) Although there are curently only 2 versions, it may end up in the future that we want to specify something like "minVersion='1.0'" without giving a "maxVersion" (this would be useful in a template config to suppress IO port usage by the device without locking to a specific virtio version). Of course, it's possible that virtio 1.0 is perfect, and we'll never need another version :-) (seriously, since we'd *want* to lock down to a specific version as soon as the template config became a real config, I guess we can just have a version attribute now, and easily add (min|maxVersion) in the future if/when there is a virtio 2.0)
docs/formatdomain.html.in | 51 ++++++++++ docs/schemas/domaincommon.rng | 29 ++++++ src/conf/domain_conf.c | 72 +++++++++++++- src/conf/domain_conf.h | 14 +++ src/qemu/qemu_command.c | 31 ++++++ .../qemuxml2argv-virtio-revision.args | 58 +++++++++++ .../qemuxml2argv-virtio-revision.xml | 107 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 10 ++ .../qemuxml2xmlout-virtio-revision.xml | 107 +++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 10 files changed, 480 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml

On Mon, 2016-08-01 at 10:02 -0400, Laine Stump wrote:
2) To assure that the actual device presented to the guest doesn't change in the future when defaults are changed, we may want to autofill "version" even when none is specified. (We would of course be stuck with the unfortunate problem of what to do with existing configs)
I don't think we should worry too much about this: since we lock on a versioned machine type on guest creation, and we can assume the default virtio version will only change along with a bump in machine type version[1], we'll always present the same hardware to the guest. [1] What would be the point in versioned machine types otherwise? :) -- Andrea Bolognani / Red Hat / Virtualization

On 08/04/2016 11:11 AM, Andrea Bolognani wrote:
On Mon, 2016-08-01 at 10:02 -0400, Laine Stump wrote:
2) To assure that the actual device presented to the guest doesn't change in the future when defaults are changed, we may want to autofill "version" even when none is specified. (We would of course be stuck with the unfortunate problem of what to do with existing configs) I don't think we should worry too much about this: since we lock on a versioned machine type on guest creation, and we can assume the default virtio version will only change along with a bump in machine type version[1], we'll always present the same hardware to the guest.
Hmm, and anyway, lack of a version means "be compatible with *all* the versions", so there isn't any single value of version that could be filled in. <EmilyLitella>nevermind</EmilyLitella> It does somehow bother me that a single attribute is being used to control two separate options in qemu. I suppose, though, that this is okay, because those two options have a possibility of 4 different combinations, with one of those combinations being nonsensical (disable_modern and disable_legacy both set to yes), so the remaining three combinations map to version = (nothing), "0.9", and "1.0".
[1] What would be the point in versioned machine types otherwise? :)
Oh, there are plenty of other things aside from device default option settings that are preserved by versioned machinetypes.
participants (4)
-
Andrea Bolognani
-
Daniel P. Berrange
-
Ján Tomko
-
Laine Stump