1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: Add per-VM control of deprecation behavior

Similar to the qemu.conf knob 'deprecation_behavior' add a per-VM knob
in the QEMU namespace:

  <qemu:deprecation behavior='...'/>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2021-03-15 15:06:29 +01:00
parent ceb00a5ade
commit a6444c8019
6 changed files with 80 additions and 1 deletions

View File

@ -523,6 +523,54 @@ Example:
</qemu:capabilities>
</domain>
Control of QEMU deprecation warnings
------------------------------------
The following knob controls how QEMU behaves towards deprecated commands and
arguments used by libvirt:
::
<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>testvm</name>
[...]
<qemu:deprecation behavior='crash'/>
This setting is meant for developers and CI efforts to make it obvious when
libvirt relies on fields which are deprecated so that it can be fixes as soon
as possible.
Possible options are:
``none``
(default) qemu is supposed to accept and output deprecated fields and commands
``omit``
qemu is instructed to omit deprecated fields on output, behaviour towards
fields and commands from libvirtd is not changed
``reject``
qemu is instructed to report an error if a deprecated command or field is
used by libvirtd
``crash``
qemu crashes when an deprecated command or field is used by libvirtd
For both "reject" and "crash" qemu is instructed to omit any deprecated fields
on output.
The "reject" option is less harsh towards the VMs but some code paths ignore
errors reported by qemu and thus it may not be obvious that a deprecated
command/field was used, thus it's suggested to use the "crash" option instead.
In cases when qemu doesn't support configuring the behaviour this setting is
silently ignored to allow testing older qemu versions without having to
reconfigure libvirtd.
*DO NOT* use in production.
Example domain XML config
-------------------------

View File

@ -77,6 +77,9 @@
<optional>
<ref name="qemucapabilities"/>
</optional>
<optional>
<ref name="qemudeprecation"/>
</optional>
<optional>
<ref name="lxcsharens"/>
</optional>
@ -7270,6 +7273,19 @@
</element>
</define>
<define name="qemudeprecation">
<element name="deprecation" ns="http://libvirt.org/schemas/domain/qemu/1.0">
<attribute name="behavior">
<choice>
<value>none</value>
<value>omit</value>
<value>reject</value>
<value>crash</value>
</choice>
</attribute>
</element>
</define>
<!--
Optional hypervisor extensions in their own namespace:

View File

@ -3316,6 +3316,8 @@ qemuDomainXmlNsDefFree(qemuDomainXmlNsDefPtr def)
virStringListFreeCount(def->capsadd, def->ncapsadd);
virStringListFreeCount(def->capsdel, def->ncapsdel);
g_free(def->deprecationBehavior);
g_free(def);
}
@ -3468,8 +3470,11 @@ qemuDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
qemuDomainDefNamespaceParseCaps(nsdata, ctxt) < 0)
goto cleanup;
nsdata->deprecationBehavior = virXPathString("string(./qemu:deprecation/@behavior)", ctxt);
if (nsdata->num_args > 0 || nsdata->num_env > 0 ||
nsdata->ncapsadd > 0 || nsdata->ncapsdel > 0)
nsdata->ncapsadd > 0 || nsdata->ncapsdel > 0 ||
nsdata->deprecationBehavior)
*data = g_steal_pointer(&nsdata);
ret = 0;
@ -3539,6 +3544,9 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
qemuDomainDefNamespaceFormatXMLCommandline(buf, cmd);
qemuDomainDefNamespaceFormatXMLCaps(buf, cmd);
virBufferEscapeString(buf, "<qemu:deprecation behavior='%s'/>\n",
cmd->deprecationBehavior);
return 0;
}

View File

@ -485,6 +485,11 @@ struct _qemuDomainXmlNsDef {
size_t ncapsdel;
char **capsdel;
/* We deliberatly keep this as a string so that it's parsed only when
* starting the VM to avoid any form of errors in the parser or when
* changing qemu versions. The knob is mainly for development/CI purposes */
char *deprecationBehavior;
};

View File

@ -32,4 +32,5 @@
<qemu:add capability="blockdev"/>
<qemu:del capability="name"/>
</qemu:capabilities>
<qemu:deprecation behavior='crash'/>
</domain>

View File

@ -48,4 +48,5 @@
<qemu:add capability='blockdev'/>
<qemu:del capability='name'/>
</qemu:capabilities>
<qemu:deprecation behavior='crash'/>
</domain>