From 6a12fe27ae845099741dec4df0cc2135f24f4064 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 6 Dec 2022 09:57:41 +0100 Subject: [PATCH] libvirt-8.10.0-2.el9 - qemu_process: Document qemuProcessPrepare{Domain,Host}() order (rhbz#2150760) - qemu_extdevice: Init paths in qemuExtDevicesPrepareDomain() (rhbz#2150760) - qemu_extdevice: Expose qemuExtDevicesInitPaths() (rhbz#2150760) - qemu: Init ext devices paths on reconnect (rhbz#2150760) Resolves: rhbz#2150760 --- ...-Init-ext-devices-paths-on-reconnect.patch | 41 ++++++++++++++ ...evice-Expose-qemuExtDevicesInitPaths.patch | 55 +++++++++++++++++++ ...paths-in-qemuExtDevicesPrepareDomain.patch | 50 +++++++++++++++++ ...qemuProcessPrepare-Domain-Host-order.patch | 54 ++++++++++++++++++ libvirt.spec | 13 ++++- 5 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 libvirt-qemu-Init-ext-devices-paths-on-reconnect.patch create mode 100644 libvirt-qemu_extdevice-Expose-qemuExtDevicesInitPaths.patch create mode 100644 libvirt-qemu_extdevice-Init-paths-in-qemuExtDevicesPrepareDomain.patch create mode 100644 libvirt-qemu_process-Document-qemuProcessPrepare-Domain-Host-order.patch diff --git a/libvirt-qemu-Init-ext-devices-paths-on-reconnect.patch b/libvirt-qemu-Init-ext-devices-paths-on-reconnect.patch new file mode 100644 index 0000000..a08a427 --- /dev/null +++ b/libvirt-qemu-Init-ext-devices-paths-on-reconnect.patch @@ -0,0 +1,41 @@ +From aeb0e68bdfee244d14bdd5177b1f559bff76f473 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Mon, 5 Dec 2022 13:08:39 +0100 +Subject: [PATCH] qemu: Init ext devices paths on reconnect +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Paths for external devices (well, so far only vTPM) are not +stored in the status XML. Therefore, we need to regenerate them +after we've been restarted and reconnecting to a running domain. +Otherwise these will remain NULL which may later lead to a NULL +dereference. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2150760 +Signed-off-by: Michal Privoznik +Reviewed-by: Ján Tomko +(cherry picked from commit 7a2034127010598b91fa576f72f330baf50c1085) +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_process.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index 19b9242623..c542be5036 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -8896,6 +8896,9 @@ qemuProcessReconnect(void *opaque) + if (qemuDomainMasterKeyReadFile(priv) < 0) + goto error; + ++ if (qemuExtDevicesInitPaths(driver, obj->def) < 0) ++ goto error; ++ + /* If we are connecting to a guest started by old libvirt there is no + * allowReboot in status XML and we need to initialize it. */ + qemuProcessPrepareAllowReboot(obj); +-- +2.38.1 + diff --git a/libvirt-qemu_extdevice-Expose-qemuExtDevicesInitPaths.patch b/libvirt-qemu_extdevice-Expose-qemuExtDevicesInitPaths.patch new file mode 100644 index 0000000..6d9514b --- /dev/null +++ b/libvirt-qemu_extdevice-Expose-qemuExtDevicesInitPaths.patch @@ -0,0 +1,55 @@ +From 32fd470a01fc0e9890a2c5e5a347322254c90b0d Mon Sep 17 00:00:00 2001 +Message-Id: <32fd470a01fc0e9890a2c5e5a347322254c90b0d@dist-git> +From: Michal Privoznik +Date: Mon, 5 Dec 2022 13:08:25 +0100 +Subject: [PATCH] qemu_extdevice: Expose qemuExtDevicesInitPaths() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This function is going to be called outside of qemu_extdevice.c. +Expose it to the rest of the driver. + +Signed-off-by: Michal Privoznik +Reviewed-by: Ján Tomko +(cherry picked from commit 3458c3ff8c2c5fa071243b85aa5f3d48b31b1b28) + +https://bugzilla.redhat.com/show_bug.cgi?id=2150760 +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_extdevice.c | 2 +- + src/qemu/qemu_extdevice.h | 5 +++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c +index 34454891f6..d5c3e8ed71 100644 +--- a/src/qemu/qemu_extdevice.c ++++ b/src/qemu/qemu_extdevice.c +@@ -64,7 +64,7 @@ qemuExtDeviceLogCommand(virQEMUDriver *driver, + * stored and we can remove directories and files in case of domain XML + * changes. + */ +-static int ++int + qemuExtDevicesInitPaths(virQEMUDriver *driver, + virDomainDef *def) + { +diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h +index 86e7133a2a..d4ac9f395c 100644 +--- a/src/qemu/qemu_extdevice.h ++++ b/src/qemu/qemu_extdevice.h +@@ -30,6 +30,11 @@ int qemuExtDeviceLogCommand(virQEMUDriver *driver, + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) + G_GNUC_WARN_UNUSED_RESULT; + ++int ++qemuExtDevicesInitPaths(virQEMUDriver *driver, ++ virDomainDef *def) ++ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; ++ + int qemuExtDevicesPrepareDomain(virQEMUDriver *driver, + virDomainObj *vm) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) +-- +2.38.1 + diff --git a/libvirt-qemu_extdevice-Init-paths-in-qemuExtDevicesPrepareDomain.patch b/libvirt-qemu_extdevice-Init-paths-in-qemuExtDevicesPrepareDomain.patch new file mode 100644 index 0000000..6312ae8 --- /dev/null +++ b/libvirt-qemu_extdevice-Init-paths-in-qemuExtDevicesPrepareDomain.patch @@ -0,0 +1,50 @@ +From 1d90c111815d3c96446b83f2f389363f44592a7a Mon Sep 17 00:00:00 2001 +Message-Id: <1d90c111815d3c96446b83f2f389363f44592a7a@dist-git> +From: Michal Privoznik +Date: Mon, 5 Dec 2022 12:27:24 +0100 +Subject: [PATCH] qemu_extdevice: Init paths in qemuExtDevicesPrepareDomain() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The path generation phase belongs conceptually into domain +preparation phase and not host preparation. Move +qemuExtDevicesInitPaths() call from qemuExtDevicesPrepareHost() +into qemuExtDevicesPrepareDomain(). + +Signed-off-by: Michal Privoznik +Reviewed-by: Ján Tomko +(cherry picked from commit f1958a3e5e465c389ce3c8cae2a26c5b00775440) +https://bugzilla.redhat.com/show_bug.cgi?id=2150760 +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_extdevice.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c +index 3eaf6571a2..34454891f6 100644 +--- a/src/qemu/qemu_extdevice.c ++++ b/src/qemu/qemu_extdevice.c +@@ -97,6 +97,9 @@ qemuExtDevicesPrepareDomain(virQEMUDriver *driver, + int ret = 0; + size_t i; + ++ if (qemuExtDevicesInitPaths(driver, vm->def) < 0) ++ return -1; ++ + for (i = 0; i < vm->def->nvideos; i++) { + virDomainVideoDef *video = vm->def->videos[i]; + +@@ -134,9 +137,6 @@ qemuExtDevicesPrepareHost(virQEMUDriver *driver, + virDomainDef *def = vm->def; + size_t i; + +- if (qemuExtDevicesInitPaths(driver, def) < 0) +- return -1; +- + for (i = 0; i < def->ntpms; i++) { + virDomainTPMDef *tpm = def->tpms[i]; + +-- +2.38.1 + diff --git a/libvirt-qemu_process-Document-qemuProcessPrepare-Domain-Host-order.patch b/libvirt-qemu_process-Document-qemuProcessPrepare-Domain-Host-order.patch new file mode 100644 index 0000000..5963851 --- /dev/null +++ b/libvirt-qemu_process-Document-qemuProcessPrepare-Domain-Host-order.patch @@ -0,0 +1,54 @@ +From e7f2bfc6db3b35dc9b76ce56abec636ed9c7f85a Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Mon, 5 Dec 2022 12:18:50 +0100 +Subject: [PATCH] qemu_process: Document qemuProcessPrepare{Domain,Host}() + order +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The domain startup process is split into multiple phases. One of +them is preparing the domain (at that point live) XML, private +data, various paths, etc - see qemuProcessPrepareDomain(); the +other prepares the host - see qemuProcessPrepareHost(). It's +obvious that the domain XML preparation function must be called +before the host preparation function (e.g. the host preparation +might try to create a file which path is generated in the domain +preparation phase). Nevertheless, let's document this +expectation. + +Signed-off-by: Michal Privoznik +Reviewed-by: Ján Tomko +(cherry picked from commit 107ebe62f4d9cf620608b2a58ba874a5fc83d41a) +https://bugzilla.redhat.com/show_bug.cgi?id=2150760 +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_process.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index e1c18dde90..19b9242623 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -6634,6 +6634,8 @@ qemuProcessPrepareChardevSource(virDomainDef *def, + * start the domain but create a valid qemu command. If some code shouldn't be + * executed in this case, make sure to check this flag. + * ++ * This function MUST be called before qemuProcessPrepareHost(). ++ * + * TODO: move all XML modification from qemuBuildCommandLine into this function + */ + int +@@ -7151,6 +7153,8 @@ qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, + * update live XML) to prepare environment for a domain which is about to start + * and it's the only place to do those modifications. + * ++ * This function MUST be called only after qemuProcessPrepareDomain(). ++ * + * TODO: move all host modification from qemuBuildCommandLine into this function + */ + int +-- +2.38.1 + diff --git a/libvirt.spec b/libvirt.spec index a370eee..749269f 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -230,7 +230,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 8.10.0 -Release: 1%{?dist}%{?extra_release} +Release: 2%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -239,6 +239,11 @@ URL: https://libvirt.org/ %endif Source: https://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.xz Source1: symlinks +Patch1: libvirt-qemu_process-Document-qemuProcessPrepare-Domain-Host-order.patch +Patch2: libvirt-qemu_extdevice-Init-paths-in-qemuExtDevicesPrepareDomain.patch +Patch3: libvirt-qemu_extdevice-Expose-qemuExtDevicesInitPaths.patch +Patch4: libvirt-qemu-Init-ext-devices-paths-on-reconnect.patch + Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2422,6 +2427,12 @@ exit 0 %endif %changelog +* Tue Dec 6 2022 Jiri Denemark - 8.10.0-2 +- qemu_process: Document qemuProcessPrepare{Domain,Host}() order (rhbz#2150760) +- qemu_extdevice: Init paths in qemuExtDevicesPrepareDomain() (rhbz#2150760) +- qemu_extdevice: Expose qemuExtDevicesInitPaths() (rhbz#2150760) +- qemu: Init ext devices paths on reconnect (rhbz#2150760) + * Thu Dec 1 2022 Jiri Denemark - 8.10.0-1 - Rebased to libvirt-8.10.0 (rhbz#2124466) - The rebase also fixes the following bugs: