From c6da5913d993f9f5e1650ca1677e11e25b594e2e Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 17 Jun 2019 17:17:56 +0200 Subject: [PATCH] qemu: Add support for controling qemu capabilities via the qemu XML namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similarly how we allow adding arbitrary command line arguments and environment variables this patch introduces the ability to control libvirt's perception of the qemu process by tweaking the capability bits for testing purposes. The idea is to allow developers and users either test a new feature by enabling it early or disabling it to see whether it introduced regressions. This feature is not meant for production use though, so users should handle it with care. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- docs/drvqemu.html.in | 30 ++++++++++++ docs/schemas/domaincommon.rng | 19 ++++++++ src/qemu/qemu_domain.c | 76 +++++++++++++++++++++++++++++- src/qemu/qemu_domain.h | 6 +++ tests/qemuxml2argvdata/qemu-ns.xml | 5 ++ 5 files changed, 134 insertions(+), 2 deletions(-) diff --git a/docs/drvqemu.html.in b/docs/drvqemu.html.in index cf36f6cc7b..aa61ee5ced 100644 --- a/docs/drvqemu.html.in +++ b/docs/drvqemu.html.in @@ -519,6 +519,36 @@ mount -t cgroup none /dev/cgroup -o devices <qemu:env name='QEMU_ENV' value='VAL'/> </qemu:commandline> </domain> + + +

QEMU feature configuration for testing

+ +

+ In some cases e.g. when developing a new feature or for testing it may + be required to control a given qemu feature (or qemu capability) to test + it before it's complete or disable it for debugging purposes. + Since 5.5.0 it's possible to use the same + special qemu namespace as above + (http://libvirt.org/schemas/domain/qemu/1.0) and use + <qemu:capabilities> element to add + (<qemu:add capability="capname"/>) or remove + (<qemu:del capability="capname"/>) capability bits. + The naming of the feature bits is the same libvirt uses in the status + XML. Note that this feature is meant for experiments only and should + _not_ be used in production. +

+ +

Example:

+<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
+  <name>testvm</name>
+
+   [...]
+
+  <qemu:capabilities>
+    <qemu:add capability='blockdev'/>
+    <qemu:del capability='drive'/>
+  </qemu:capabilities>
+</domain>
 

Example domain XML config

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0f490deecd..31db599ab9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -72,6 +72,9 @@ + + + @@ -6197,6 +6200,22 @@ + + + + + + + + + + + + + + + +