From cc0933d3501229cdc8cf183a52a14c9b1c8de666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Mon, 8 Aug 2016 15:42:18 +0200 Subject: [PATCH] Add virtio-related options to input devices https://bugzilla.redhat.com/show_bug.cgi?id=1283251 Reviewed-by: Pavel Hrdina --- docs/formatdomain.html.in | 7 +++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 18 ++++++++++++++++++ src/conf/domain_conf.h | 1 + .../qemuxml2argv-virtio-options.xml | 4 ++++ 5 files changed, 35 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d7af60fbd8..52119f0a0a 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5715,6 +5715,13 @@ qemu-kvm -net nic,model=? /dev/null event device passed through to guests. (KVM only)

+

+ The subelement driver can be used to tune the virtio + options of the device: + Virtio-specific options can also be + set. (Since 3.5.0) +

+

Hub devices

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0955fc8764..4950ddc109 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3990,6 +3990,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d3bbbac441..5c32f93681 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1400,6 +1400,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def) virDomainDeviceInfoClear(&def->info); VIR_FREE(def->source.evdev); + VIR_FREE(def->virtio); VIR_FREE(def); } @@ -11614,6 +11615,9 @@ virDomainInputDefParseXML(const virDomainDef *dom, goto error; } + if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0) + goto error; + cleanup: VIR_FREE(evdev); VIR_FREE(type); @@ -19354,6 +19358,10 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src, return false; } + if (src->virtio && dst->virtio && + !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + return false; + if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) return false; @@ -23448,6 +23456,7 @@ virDomainInputDefFormat(virBufferPtr buf, const char *type = virDomainInputTypeToString(def->type); const char *bus = virDomainInputBusTypeToString(def->bus); virBuffer childbuf = VIR_BUFFER_INITIALIZER; + virBuffer driverBuf = VIR_BUFFER_INITIALIZER; /* don't format keyboard into migratable XML for backward compatibility */ if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && @@ -23471,6 +23480,15 @@ virDomainInputDefFormat(virBufferPtr buf, type, bus); virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2); + virDomainVirtioOptionsFormat(&driverBuf, def->virtio); + if (virBufferCheckError(&driverBuf) < 0) + return -1; + + if (virBufferUse(&driverBuf)) { + virBufferAddLit(&childbuf, "\n"); + } virBufferEscapeString(&childbuf, "\n", def->source.evdev); if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a692c32e1a..e67b6fd4f9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1282,6 +1282,7 @@ struct _virDomainInputDef { char *evdev; } source; virDomainDeviceInfo info; + virDomainVirtioOptionsPtr virtio; }; typedef enum { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml index 85d1145263..773038a320 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml @@ -54,15 +54,19 @@

+
+
+
+