qemu: conf: Add debug option to allow disabling qemu capabilities

In cases when e.g. a new feature breaks upstream behaviour it's useful
to allow users to disable the new feature to verify the regression and
possibly use it as a workaround until a fix is available.

The new qemu.conf option named "capability_filters" allows to remove
qemu capabilities from the detected bitmap.

This patch introduces the configuration infrastructure to parse the
option and pass it around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-06-18 09:46:22 +02:00
parent a7d3599a4e
commit 30ce8f3163
5 changed files with 32 additions and 0 deletions

View File

@ -126,6 +126,8 @@ module Libvirtd_qemu =
let swtpm_entry = str_entry "swtpm_user" let swtpm_entry = str_entry "swtpm_user"
| str_entry "swtpm_group" | str_entry "swtpm_group"
let capability_filters_entry = str_array_entry "capability_filters"
(* Each entry in the config is one of the following ... *) (* Each entry in the config is one of the following ... *)
let entry = default_tls_entry let entry = default_tls_entry
| vnc_entry | vnc_entry
@ -147,6 +149,7 @@ module Libvirtd_qemu =
| vxhs_entry | vxhs_entry
| nbd_entry | nbd_entry
| swtpm_entry | swtpm_entry
| capability_filters_entry
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
let empty = [ label "#empty" . eol ] let empty = [ label "#empty" . eol ]

View File

@ -825,3 +825,10 @@
# #
#swtpm_user = "tss" #swtpm_user = "tss"
#swtpm_group = "tss" #swtpm_group = "tss"
# For debugging and testing purposes it's sometimes useful to be able to disable
# libvirt behaviour based on the capabilities of the qemu process. This option
# allows to do so. DO _NOT_ use in production and beaware that the behaviour
# may change across versions.
#
#capability_filters = [ "capname" ]

View File

@ -381,6 +381,8 @@ static void virQEMUDriverConfigDispose(void *obj)
VIR_FREE(cfg->memoryBackingDir); VIR_FREE(cfg->memoryBackingDir);
VIR_FREE(cfg->swtpmStorageDir); VIR_FREE(cfg->swtpmStorageDir);
virStringListFree(cfg->capabilityfilters);
} }
@ -984,6 +986,18 @@ virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg,
} }
static int
virQEMUDriverConfigLoadCapsFiltersEntry(virQEMUDriverConfigPtr cfg,
virConfPtr conf)
{
if (virConfGetValueStringList(conf, "capability_filters", false,
&cfg->capabilityfilters) < 0)
return -1;
return 0;
}
int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
const char *filename, const char *filename,
bool privileged) bool privileged)
@ -1053,6 +1067,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
if (virQEMUDriverConfigLoadSWTPMEntry(cfg, conf) < 0) if (virQEMUDriverConfigLoadSWTPMEntry(cfg, conf) < 0)
goto cleanup; goto cleanup;
if (virQEMUDriverConfigLoadCapsFiltersEntry(cfg, conf) < 0)
goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:

View File

@ -209,6 +209,8 @@ struct _virQEMUDriverConfig {
uid_t swtpm_user; uid_t swtpm_user;
gid_t swtpm_group; gid_t swtpm_group;
char **capabilityfilters;
}; };
/* Main driver state */ /* Main driver state */

View File

@ -104,3 +104,6 @@ module Test_libvirtd_qemu =
{ "pr_helper" = "/usr/bin/qemu-pr-helper" } { "pr_helper" = "/usr/bin/qemu-pr-helper" }
{ "swtpm_user" = "tss" } { "swtpm_user" = "tss" }
{ "swtpm_group" = "tss" } { "swtpm_group" = "tss" }
{ "capability_filters"
{ "1" = "capname" }
}