Hi Ján,
I apply your patches of virtio compatibility attribute. And I find virtio video and input
devices using virtio modern when set compatibility as legacy.
The xml:
<video>
<driver compatibility='legacy'/>
<model type='virtio' heads='1' primary='yes'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
</video>
<input type='mouse' bus='virtio'>
<driver compatibility='legacy'/>
<alias name='input1'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x09' function='0x0'/>
</input>
<input type='keyboard' bus='virtio'>
<driver compatibility='legacy'/>
<alias name='input2'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x0a' function='0x0'/>
</input>
Check virtio version in guest:
# for i in `find /sys/devices -name 'virtio[0-9]*'`;do
echo -e $(lspci -s $(echo $i|egrep -o
'[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[01][0-9a-fA-F]\.[0-7]'))'\t'$(cat
$i/features|cut -c 33)
done
00:02.0 VGA compatible controller: Red Hat, Inc Virtio GPU (rev 01) 1
00:03.0 Ethernet controller: Red Hat, Inc Virtio network device 1
00:05.0 Communication controller: Red Hat, Inc Virtio console 1
00:07.0 SCSI storage controller: Red Hat, Inc Virtio block device 1
00:08.0 Unclassified device [00ff]: Red Hat, Inc Virtio memory balloon 1
00:09.0 Mouse controller: Red Hat, Inc Virtio input (rev 01) 1
00:0a.0 Keyboard controller: Red Hat, Inc Virtio input (rev 01) 1
For the issue I got Gerd's reply on virt-devel:
<snippet>
Right now the default is
"disable-legacy=off,disable-modern=on" (with
the exception of virtio-input and virtio-gpu, those two are newer than
virtio 1.0 and thus don't support legacy virtio).
</snippet>
So, maybe we should make compatibility='legacy' invalid in virtio video and input
devices in case of confusion.
----- Original Message -----
From: "Ján Tomko" <jtomko(a)redhat.com>
To: libvir-list(a)redhat.com
Sent: Tuesday, August 23, 2016 6:20:53 PM
Subject: [libvirt] [PATCHv5 11/13] Add compatibility attribute to video
<video>
<driver compatibility='modern'/>
<model type='virtio' heads='1' primary='yes'/>
</video>
https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
docs/formatdomain.html.in | 8 ++++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 17 +++++++++++++++--
src/conf/domain_conf.h | 1 +
tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 1 +
.../qemuxml2xmlout-virtio-revision.xml | 1 +
6 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 41a9325..d640e8d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5641,6 +5641,14 @@ qemu-kvm -net nic,model=? /dev/null
The optional <code>address</code> sub-element can be used to
tie the video device to a particular PCI slot.
</dd>
+
+ <dt><code>driver</code></dt>
+ <dd>
+ The <code>compatibility</code> attribute can be used to specify the
+ compatibility of virtio devices. Allowed values are
<code>legacy</code>,
+ <code>transitional</code> and <code>modern</code>.
+ <span class="since">Since 2.2.0</span>.
+ </dd>
</dl>
<h4><a name="elementsConsole">Consoles, serial, parallel
& channel devices</a></h4>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ed00ace..f250cbc 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3080,6 +3080,11 @@
<define name="video">
<element name="video">
<optional>
+ <element name="driver">
+ <ref name="compatibility"/>
+ </element>
+ </optional>
+ <optional>
<element name="model">
<choice>
<attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 166f5fb..03c856c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12605,11 +12605,13 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
static virDomainVideoDefPtr
virDomainVideoDefParseXML(xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
const virDomainDef *dom,
unsigned int flags)
{
virDomainVideoDefPtr def;
xmlNodePtr cur;
+ xmlNodePtr saved = ctxt->node;
char *type = NULL;
char *heads = NULL;
char *vram = NULL;
@@ -12618,6 +12620,8 @@ virDomainVideoDefParseXML(xmlNodePtr node,
char *vgamem = NULL;
char *primary = NULL;
+ ctxt->node = node;
+
if (VIR_ALLOC(def) < 0)
return NULL;
@@ -12719,7 +12723,12 @@ virDomainVideoDefParseXML(xmlNodePtr node,
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
goto error;
+ if (virDomainDriverCompatibilityParseXML(ctxt, &def->compatibility) < 0)
+ goto error;
+
cleanup:
+ ctxt->node = saved;
+
VIR_FREE(type);
VIR_FREE(ram);
VIR_FREE(vram);
@@ -13414,7 +13423,7 @@ virDomainDeviceDefParse(const char *xmlStr,
goto error;
break;
case VIR_DOMAIN_DEVICE_VIDEO:
- if (!(dev->data.video = virDomainVideoDefParseXML(node, def, flags)))
+ if (!(dev->data.video = virDomainVideoDefParseXML(node, ctxt, def, flags)))
goto error;
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
@@ -17084,7 +17093,7 @@ virDomainDefParseXML(xmlDocPtr xml,
virDomainVideoDefPtr video;
ssize_t insertAt = -1;
- if (!(video = virDomainVideoDefParseXML(nodes[i], def, flags)))
+ if (!(video = virDomainVideoDefParseXML(nodes[i], ctxt, def, flags)))
goto error;
if (video->primary) {
@@ -21896,6 +21905,10 @@ virDomainVideoDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "<video>\n");
virBufferAdjustIndent(buf, 2);
+ if (def->compatibility) {
+ virBufferAsprintf(buf, "<driver compatibility='%s'/>\n",
+
virDomainDriverCompatibilityTypeToString(def->compatibility));
+ }
virBufferAsprintf(buf, "<model type='%s'",
model);
if (def->ram)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 342218e..ecccc0a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1322,6 +1322,7 @@ struct _virDomainVideoDef {
bool primary;
virDomainVideoAccelDefPtr accel;
virDomainDeviceInfo info;
+ virDomainDriverCompatibility compatibility;
};
/* graphics console modes */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
index 5b9726a..fecf9e5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
@@ -86,6 +86,7 @@
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<video>
+ <driver compatibility='modern'/>
<model type='virtio' heads='1' primary='yes'>
<acceleration accel3d='yes'/>
</model>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
index ab69bb7..f1c728e 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
@@ -86,6 +86,7 @@
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<video>
+ <driver compatibility='modern'/>
<model type='virtio' heads='1' primary='yes'>
<acceleration accel3d='yes'/>
</model>
--
2.7.3
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list