On Thu, Nov 30, 2023 at 05:04:11PM -0600, Jonathon Jongsma wrote:
Sorry for the delay in getting out a new version. Thanksgiving break
in
the USA, etc.
... followed by holidays in Europe. We still have a few days to get
this into 10.0.0 though :)
+++ b/meson_options.txt
@@ -104,7 +104,8 @@ option('loader_nvram', type: 'string', value:
'', description: 'Pass list of pai
option('login_shell', type: 'feature', value: 'auto',
description: 'build virt-login-shell')
option('nss', type: 'feature', value: 'auto', description:
'enable Name Service Switch plugin for resolving guest IP addresses')
option('numad', type: 'feature', value: 'auto', description:
'use numad to manage CPU placement dynamically')
-option('nbdkit', type: 'feature', value: 'auto', description:
'use nbdkit to access network disks')
+option('nbdkit', type: 'feature', value: 'auto', description:
'Build nbdkit storage backend')
+option('nbdkit_config_default', type: 'feature', value:
'disabled', description: 'Whether to use nbdkit storage backend for network
disks by default (configurable)')
You can have 'auto' as the default value here, it's still going to
behave the same as 'disabled' due to the way you've implemented the
meson.build part but it'll appear more consistent with existing
options.
+++ b/src/qemu/qemu.conf.in
@@ -974,3 +974,16 @@
# "full" - both QEMU and its helper processes are placed into separate
# scheduling group
#sched_core = "none"
+
+@CUT_WITH_NBDKIT@
+# Using nbdkit to access remote disk sources
+#
+# If this is set then libvirt will use nbdkit to access remote disk sources
+# when available. nbdkit will export an NBD share to QEMU rather than having
+# QEMU attempt to access the remote server directly.
+#
+# Possible values are 0 or 1. Default value is @USE_NBDKIT_DEFAULT@. Please
+# note that the default might change in future releases.
+#
+# storage_use_nbdkit = @USE_NBDKIT_DEFAULT@
+@END@
I think this is unnecessary. It's okay to leave the comment in there
even if ndbkit support is compiled out. More on this below.
Either way, the line for the option itself needs to look like
#storage_use_nbdkit = @USE_NBDKIT_DEFAULT@
Note the lack of whitespace between the comment marker and the option
name. That's not just for looks: the augeas test requires this
specific arrangement.
To make the augeas test I've just mentioned work, you also need to
squash in the following:
diff --git a/src/qemu/test_libvirtd_qemu.aug.in
b/src/qemu/test_libvirtd_qemu.aug.in
index c730df40b0..e4cfde6cc7 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -117,3 +117,4 @@ module Test_libvirtd_qemu =
}
{ "deprecation_behavior" = "none" }
{ "sched_core" = "none" }
+{ "storage_use_nbdkit" = "@USE_NBDKIT_DEFAULT@" }
This demonstrates that augeas is really picking up the value for the
option and interpreting it correctly.
+++ b/src/qemu/meson.build
@@ -137,9 +137,41 @@ if conf.has('WITH_QEMU')
+ # preprocess config files to remove items related to features that are not
+ # compiled in
+ preprocess_config_files = [
+ {
+ 'inpath': 'qemu.conf.in',
+ 'outpath': 'qemu.conf.tmp',
+ 'outvar': 'qemu_conf_tmp',
+ },
+ {
+ 'inpath': 'libvirtd_qemu.aug.in',
+ 'outpath': 'libvirtd_qemu.aug',
+ 'outvar': 'libvirtd_qemu_aug',
+ }
+ ]
+ foreach item : preprocess_config_files
+ if conf.has('WITH_NBDKIT')
+ preprocess_cmd = [ 'sed', '-e',
'/[@]CUT_WITH_NBDKIT[@]/d', '-e', '/[@]END[@]/d',
'@INPUT@' ]
+ else
+ preprocess_cmd = [ 'sed', '-e',
'/[@]CUT_WITH_NBDKIT[@]/,/[@]END[@]/d', '@INPUT@' ]
+ endif
+
+ tmp = configure_file(
+ input: item['inpath'],
+ output: item['outpath'],
+ command: preprocess_cmd,
+ capture: true,
+ )
+ set_variable(item['outvar'], tmp)
+ endforeach
Once you stop cutting out the bits of the config file related to
nbdkit when nbdkit support is compiled out, you no longer need any of
this additional complexity.
+++ b/src/qemu/qemu_conf.c
@@ -1065,6 +1066,19 @@ virQEMUDriverConfigLoadCapsFiltersEntry(virQEMUDriverConfig *cfg,
}
+#if WITH_NBDKIT
+static int
+virQEMUDriverConfigLoadStorageEntry(virQEMUDriverConfig *cfg,
+ virConf *conf)
+{
+ if (virConfGetValueBool(conf, "storage_use_nbdkit",
&cfg->storageUseNbdkit) < 0)
+ return -1;
+
+ return 0;
+}
+#endif /* WITH_NBDKIT */
When parsing the configuration file, we shouldn't make this part
conditional. If the user tries to enable nbdkit usage with a build of
libvirt that doesn't include support, it's a *good thing* to report
an error rather than silently ignoring that request. Hence, we want
something like
#if !WITH_NDBKIT
if (cfg->storageUseNbdkit) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s",
_("ndbkit support is not compiled in"));
return -1;
}
#endif /* WITH_NBDKIT */
here.
Since I'm not 100% sure everything I've explained will come through
successfully (feeling a bit tired right now) I've just pushed a
commit with all the changes I'm suggesting here:
https://gitlab.com/abologna/libvirt/-/commit/abae4deaa68b9123a59d58b5a0ba...
--
Andrea Bolognani / Red Hat / Virtualization