82 lines
2.7 KiB
Diff
82 lines
2.7 KiB
Diff
From 23c8e64cbbd9fe642f47808b19aba6cd5177fdd2 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <23c8e64cbbd9fe642f47808b19aba6cd5177fdd2@dist-git>
|
|
From: Michal Privoznik <mprivozn@redhat.com>
|
|
Date: Thu, 16 Feb 2023 11:46:55 +0100
|
|
Subject: [PATCH] qemu_passt: Let passt write the PID file
|
|
|
|
The way we start passt currently is: we use
|
|
virCommandSetPidFile() to use our virCommand machinery to acquire
|
|
the PID file and leak opened FD into passt. Then, we use
|
|
virPidFile*() APIs to read the PID file (which is needed when
|
|
placing it into CGroups or killing it). But this does not fly
|
|
really because passt daemonizes itself. Thus the process we
|
|
started dies soon and thus the PID file is closed and unlocked.
|
|
|
|
We could work around this by passing '--foreground' argument, but
|
|
that weakens passt as it can't create new PID namespace (because
|
|
it doesn't fork()).
|
|
|
|
The solution is to let passt write the PID file, but since it
|
|
does not lock the file and closes it as soon as it is written, we
|
|
have to switch to those virPidFile APIs which don't expect PID
|
|
file to be locked.
|
|
|
|
Resolves: https://bugzilla.redhat.com/2169244
|
|
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Reviewed-by: Laine Stump <laine@redhat.com>
|
|
(cherry picked from commit 029a892abdb2fe508f3fb77af00a14464b98b824)
|
|
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
---
|
|
src/qemu/qemu_passt.c | 11 +++++++----
|
|
1 file changed, 7 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
|
|
index 2733f8e03f..1217a6a087 100644
|
|
--- a/src/qemu/qemu_passt.c
|
|
+++ b/src/qemu/qemu_passt.c
|
|
@@ -72,7 +72,7 @@ qemuPasstGetPid(virDomainObj *vm,
|
|
{
|
|
g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net);
|
|
|
|
- return virPidFileReadPathIfLocked(pidfile, pid);
|
|
+ return virPidFileReadPath(pidfile, pid);
|
|
}
|
|
|
|
|
|
@@ -106,11 +106,14 @@ static void
|
|
qemuPasstKill(const char *pidfile)
|
|
{
|
|
virErrorPtr orig_err;
|
|
+ pid_t pid = 0;
|
|
|
|
virErrorPreserveLast(&orig_err);
|
|
|
|
- if (virPidFileForceCleanupPath(pidfile) < 0)
|
|
- VIR_WARN("Unable to kill passt process");
|
|
+ ignore_value(virPidFileReadPath(pidfile, &pid));
|
|
+ if (pid != 0)
|
|
+ virProcessKillPainfully(pid, true);
|
|
+ unlink(pidfile);
|
|
|
|
virErrorRestore(&orig_err);
|
|
}
|
|
@@ -161,13 +164,13 @@ qemuPasstStart(virDomainObj *vm,
|
|
cmd = virCommandNew(PASST);
|
|
|
|
virCommandClearCaps(cmd);
|
|
- virCommandSetPidFile(cmd, pidfile);
|
|
virCommandSetErrorBuffer(cmd, &errbuf);
|
|
|
|
virCommandAddArgList(cmd,
|
|
"--one-off",
|
|
"--socket", passtSocketName,
|
|
"--mac-addr", virMacAddrFormat(&net->mac, macaddr),
|
|
+ "--pid", pidfile,
|
|
NULL);
|
|
|
|
if (net->mtu) {
|
|
--
|
|
2.39.2
|
|
|