[nbdkit PATCH] tests: Better quoting for cleanup_fn
by Eric Blake
Testing with:
===
#!/bin/bash
. tests/functions.sh
cleanup_fn echo 'a b'
cleanup_fn echo 'c d'
===
gives output:
===
a b
c d
===
That is, our commands were munged by IFS splitting, because we stored
commands in a flat variable. Fix it by instead using an array
variable per cleanup_fn invocation.
This does not fix the issue that commands are run in FIFO order; the
comments in the recent test-nbd-client.sh mention that reverse order
might be nicer, however, our existing kill_nbdkit() function assumes
that it can call cleanup_fn during an existing cleanup function and
that such cleanups will still be reached. Running cleanups in reverse
order from the top level while still allowing multiple rounds of
cleanup once cleanup is started is harder to achieve.
---
If we like this, I'll apply the same patch to libnbd.
Running the cleanups in reverse order is a tougher nut to crack; the
nbdkit testsuite passed 'make check' when I did that (basically, swap
the iteration of the for loop over _i in _run_cleanup_hooks), but that
only tests the success paths, and it is the failure path of
kill_nbdkit() where sane semantics are harder to guarantee with
reverse ordering.
tests/functions.sh.in | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 6c5c481a..82f284a7 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -65,15 +65,18 @@ largest_qemu_disk=9223372035781033984
#
# Run the command ‘cmd [args]’ when the test script exits. This is
# run in all cases when the script exits, so is a reliable way to
-# clean up test files, external processes etc.
+# clean up test files, external processes etc. Cleanup hooks are run
+# in the order of registration.
#
# Examples:
# cleanup_fn rm -f test.out
# cleanup_fn kill $pid
-declare -a _cleanup_hook
+_cleanup_hook_count=0
cleanup_fn ()
{
- _cleanup_hook[${#_cleanup_hook[@]}]="$@"
+ local _hook=_cleanup_hook$((_cleanup_hook_count++))
+ declare -ag $_hook
+ eval "$_hook=(\"\$@\")"
}
_run_cleanup_hooks ()
@@ -84,8 +87,9 @@ _run_cleanup_hooks ()
trap '' INT QUIT TERM EXIT ERR
echo $0: run cleanup hooks: exit code $_status
- for (( _i = 0; _i < ${#_cleanup_hook[@]}; ++_i )); do
- ${_cleanup_hook[_i]}
+ for (( _i = 0; _i < $_cleanup_hook_count; ++_i )); do
+ local -n _hook=_cleanup_hook$_i
+ "${_hook[@]}"
done
exit $_status
--
2.37.1
2 years, 4 months
[v2v PATCH v2] output/create_libvirt_xml: relax VCPU feature checking for "qemu64"
by Laszlo Ersek
When the source domain doesn't specify a VCPU model ("s_cpu_model" is
None), and the guest OS is assumed to work with the default VCPU model
("gcaps_default_cpu" is true), we don't output any <cpu> element. In that
case, libvirtd augments the domain config with:
[1] <cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>qemu64</model>
</cpu>
where the @check='none' attribute ensures that the converted domain will
be launched, for example, on an Intel host, despite the "qemu64" VCPU
model containing AMD-only feature flags such as "svm".
However, if the source domain explicitly specifies the "qemu64" model
(mostly seen with "-i libvirt -ic qemu://..."), we presently output
[2] <cpu match='minimum'>
<model fallback='allow'>qemu64</model>
</cpu>
which libvirtd completes as
[3] <cpu mode='custom' match='minimum' check='partial'>
<model fallback='allow'>qemu64</model>
</cpu>
In [3], cpu/@match='minimum' and cpu/model/@fallback='allow' are both
laxer than @match='exact' and @fallback='forbid', respectively, in [1].
However, cpu/@check='partial' in [3] is stricter than @check='none' in
[1]; it causes libvirtd to catch the "svm" feature flag on an Intel host,
and prevents the converted domain from starting.
The "qemu64" VCPU model is supposed to run on every possible host
<https://gitlab.com/qemu-project/qemu/-/blob/master/docs/system/cpu-models...>,
therefore make an exception for the explicitly specified "qemu64" VCPU
model, and generate the @check='none' attribute.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2107503
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
Notes:
v2:
- make the attribute dependent on "qemu64" [Rich]
- retrofit the commit message
v1:
- https://listman.redhat.com/archives/libguestfs/2022-July/029504.html
output/create_libvirt_xml.ml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
index 531a4f75bf3e..bd01304df674 100644
--- a/output/create_libvirt_xml.ml
+++ b/output/create_libvirt_xml.ml
@@ -192,6 +192,8 @@ let create_libvirt_xml ?pool source inspect
List.push_back cpu_attrs ("mode", "host-passthrough");
| Some model ->
List.push_back cpu_attrs ("match", "minimum");
+ if model = "qemu64" then
+ List.push_back cpu_attrs ("check", "none");
(match source.s_cpu_vendor with
| None -> ()
| Some vendor ->
--
2.19.1.3.g30247aa5d201
2 years, 4 months
[v2v PATCH] output/create_libvirt_xml: generate @check='none' CPU attribute
by Laszlo Ersek
We currently don't generate any @check attribute for the /domain/cpu
element, which causes the following libvirtd behavior
<https://libvirt.org/formatdomain.html#cpu-model-and-topology>:
> Once the domain starts, libvirt will automatically change the check
> attribute to the best supported value to ensure the virtual CPU does not
> change when the domain is migrated to another host
Vera Wu reports that in practice, at least when the source CPU model is
explicitly "qemu64", libvirtd sets @check='partial'. That's defined as:
> Libvirt will check the guest CPU specification before starting a domain
This is a problem: the default "qemu64" CPU model exposes the SVM CPU
flag, and that's unsupportable on Intel hosts. SVM is the AMD counterpart
of VT-x; IOW, the flag effectively advertizes AMD-specific nesting to
guests.
With @check='partial', libvirt prevents the converted domain from starting
on Intel hosts; but with @check='none',
> Libvirt does no checking and it is up to the hypervisor to refuse to
> start the domain if it cannot provide the requested CPU. With QEMU this
> means no checking is done at all since the default behavior of QEMU is
> to emit warnings, but start the domain anyway.
We don't care about the migratability of the converted domain, so relax
the libvirtd checks, by generating the @check='none' attribute.
Consider adding @check='none' in two cases:
(1) When the source domain specifies a CPU model.
Generating @check='none' in this case fixes the issue reported by Vera.
(2) When the source domain does not specify a CPU model, and the guest OS
is assumed to work well with the default CPU model.
Generating @check='none' in this case is actually a no-op. Going from "no
CPU element" to "<cpu check='none'/>" does not change how libvirtd
augments the domain config. Namely,
(2.1) for x86 guests, we get
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>qemu64</model>
</cpu>
either way,
(2.2) for aarch64 guests, we get
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>cortex-a15</model>
</cpu>
either way.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2107503
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
output/create_libvirt_xml.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
index 531a4f75bf3e..0343d3194268 100644
--- a/output/create_libvirt_xml.ml
+++ b/output/create_libvirt_xml.ml
@@ -192,6 +192,7 @@ let create_libvirt_xml ?pool source inspect
List.push_back cpu_attrs ("mode", "host-passthrough");
| Some model ->
List.push_back cpu_attrs ("match", "minimum");
+ List.push_back cpu_attrs ("check", "none");
(match source.s_cpu_vendor with
| None -> ()
| Some vendor ->
--
2.19.1.3.g30247aa5d201
2 years, 4 months
[p2v PATCH] virt-p2v-make-*.in: make @datadir@ and @libdir@ resolvable
by Laszlo Ersek
./configure expands @datadir@ and @libdir@ to "${prefix}/share" and
"${exec_prefix}/lib" by default (verbatim); $prefix and $exec_prefix are
supposed to be substituted by the shell when the generated shell scripts
are executed.
For this, capture the prefix and exec_prefix values at the time
./configure runs.
This fixes failures such as
> $ virt-p2v-make-kickstart fedora
> base64: /share/virt-p2v/issue: No such file or directory
for such scripts that were installed with "make install".
Note that the patch does not help when running virt-p2v-make-* from a git
checkout that was just built, such as
> $ ./virt-p2v-make-kickstart fedora
In that case, VIRT_P2V_DATA_DIR still needs to be set to $PWD, as there is
no "share" subdirectory in the checkout.
Suggested-by: Richard W.M. Jones <rjones(a)redhat.com>
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
virt-p2v-make-disk.in | 2 ++
virt-p2v-make-kickstart.in | 2 ++
virt-p2v-make-kiwi.in | 2 ++
3 files changed, 6 insertions(+)
diff --git a/virt-p2v-make-disk.in b/virt-p2v-make-disk.in
index ac477eb39be8..218ff1531872 100644
--- a/virt-p2v-make-disk.in
+++ b/virt-p2v-make-disk.in
@@ -20,6 +20,8 @@ unset CDPATH
program="virt-p2v-make-disk"
version="@PACKAGE_VERSION@"
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
if [ -n "$VIRT_P2V_DATA_DIR" ]; then
datadir="$VIRT_P2V_DATA_DIR"
diff --git a/virt-p2v-make-kickstart.in b/virt-p2v-make-kickstart.in
index d139c9bb554b..1706102d05c7 100644
--- a/virt-p2v-make-kickstart.in
+++ b/virt-p2v-make-kickstart.in
@@ -20,6 +20,8 @@ unset CDPATH
program="virt-p2v-make-kickstart"
version="@PACKAGE_VERSION@"
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
# Parse the command line arguments.
shortopts=o:vV
diff --git a/virt-p2v-make-kiwi.in b/virt-p2v-make-kiwi.in
index 987de11b54aa..a648f6a3886c 100644
--- a/virt-p2v-make-kiwi.in
+++ b/virt-p2v-make-kiwi.in
@@ -20,6 +20,8 @@ unset CDPATH
program="virt-p2v-make-kiwi"
version="@PACKAGE_VERSION@"
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
# Parse the command line arguments.
shortopts=o:V
--
2.19.1.3.g30247aa5d201
2 years, 4 months