[PATCH] qemu_process: Destroy domain's namespace after killing QEMU

Michal Privoznik posted 1 patch 1 year, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/19e2675e75cd58f0444558a72e733a0c86390994.1659610363.git.mprivozn@redhat.com
src/qemu/qemu_process.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] qemu_process: Destroy domain's namespace after killing QEMU
Posted by Michal Privoznik 1 year, 9 months ago
After QEMU is killed in qemuProcessStop() its mount namespace
doesn't exist anymore, because it was the only process running
there. Thus we should clear our internal flag that the domain has
namespace enabled so that seclabel restore code does not try to
enter it. We do the same in qemuProcessHandleMonitorEOF() but
when it is us, who decides to kill QEMU rather than QEMU quitting
we haven't seen EOF by the time qemuProcessStop() is called.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 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 d29da63242..fbf460595b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8265,6 +8265,9 @@ void qemuProcessStop(virQEMUDriver *driver,
                                  VIR_QEMU_PROCESS_KILL_FORCE|
                                  VIR_QEMU_PROCESS_KILL_NOCHECK));
 
+    /* Its namespace is also gone then. */
+    qemuDomainDestroyNamespace(driver, vm);
+
     qemuDomainCleanupRun(driver, vm);
 
     qemuExtDevicesStop(driver, vm);
-- 
2.35.1
Re: [PATCH] qemu_process: Destroy domain's namespace after killing QEMU
Posted by Martin Kletzander 1 year, 9 months ago
On Thu, Aug 04, 2022 at 12:52:43PM +0200, Michal Privoznik wrote:
>After QEMU is killed in qemuProcessStop() its mount namespace
>doesn't exist anymore, because it was the only process running
>there. Thus we should clear our internal flag that the domain has
>namespace enabled so that seclabel restore code does not try to
>enter it. We do the same in qemuProcessHandleMonitorEOF() but
>when it is us, who decides to kill QEMU rather than QEMU quitting
>we haven't seen EOF by the time qemuProcessStop() is called.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

>---
> 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 d29da63242..fbf460595b 100644
>--- a/src/qemu/qemu_process.c
>+++ b/src/qemu/qemu_process.c
>@@ -8265,6 +8265,9 @@ void qemuProcessStop(virQEMUDriver *driver,
>                                  VIR_QEMU_PROCESS_KILL_FORCE|
>                                  VIR_QEMU_PROCESS_KILL_NOCHECK));
>
>+    /* Its namespace is also gone then. */
>+    qemuDomainDestroyNamespace(driver, vm);
>+
>     qemuDomainCleanupRun(driver, vm);
>
>     qemuExtDevicesStop(driver, vm);
>-- 
>2.35.1
>