|
|
acda74 |
From 42803b023873d2e416a58b4663c4679006f03253 Mon Sep 17 00:00:00 2001
|
|
|
acda74 |
Message-Id: <42803b023873d2e416a58b4663c4679006f03253@dist-git>
|
|
|
acda74 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
acda74 |
Date: Thu, 16 Feb 2023 12:07:42 +0100
|
|
|
acda74 |
Subject: [PATCH] qemu_passt: Deduplicate passt killing code
|
|
|
acda74 |
|
|
|
acda74 |
There are two places where we kill passt:
|
|
|
acda74 |
|
|
|
acda74 |
1) qemuPasstStop() - called transitively from qemuProcessStop(),
|
|
|
acda74 |
2) qemuPasstStart() - after failed start.
|
|
|
acda74 |
|
|
|
acda74 |
Now, the code from 2) lack error preservation (so if there's
|
|
|
acda74 |
another error during cleanup we might overwrite the original
|
|
|
acda74 |
error). Therefore, move the internals of qemuPasstStop() into a
|
|
|
acda74 |
separate function and call it from both places.
|
|
|
acda74 |
|
|
|
acda74 |
Resolves: https://bugzilla.redhat.com/2169244
|
|
|
acda74 |
|
|
|
acda74 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
acda74 |
Reviewed-by: Laine Stump <laine@redhat.com>
|
|
|
acda74 |
(cherry picked from commit e5bfc661bc181a36fa70250470554b20002fb84d)
|
|
|
acda74 |
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
|
acda74 |
---
|
|
|
acda74 |
src/qemu/qemu_passt.c | 23 +++++++++++++----------
|
|
|
acda74 |
1 file changed, 13 insertions(+), 10 deletions(-)
|
|
|
acda74 |
|
|
|
acda74 |
diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
|
|
|
acda74 |
index c082c149cd..2733f8e03f 100644
|
|
|
acda74 |
--- a/src/qemu/qemu_passt.c
|
|
|
acda74 |
+++ b/src/qemu/qemu_passt.c
|
|
|
acda74 |
@@ -102,11 +102,9 @@ qemuPasstAddNetProps(virDomainObj *vm,
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
|
|
|
acda74 |
-void
|
|
|
acda74 |
-qemuPasstStop(virDomainObj *vm,
|
|
|
acda74 |
- virDomainNetDef *net)
|
|
|
acda74 |
+static void
|
|
|
acda74 |
+qemuPasstKill(const char *pidfile)
|
|
|
acda74 |
{
|
|
|
acda74 |
- g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net);
|
|
|
acda74 |
virErrorPtr orig_err;
|
|
|
acda74 |
|
|
|
acda74 |
virErrorPreserveLast(&orig_err);
|
|
|
acda74 |
@@ -118,6 +116,16 @@ qemuPasstStop(virDomainObj *vm,
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
|
|
|
acda74 |
+void
|
|
|
acda74 |
+qemuPasstStop(virDomainObj *vm,
|
|
|
acda74 |
+ virDomainNetDef *net)
|
|
|
acda74 |
+{
|
|
|
acda74 |
+ g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net);
|
|
|
acda74 |
+
|
|
|
acda74 |
+ qemuPasstKill(pidfile);
|
|
|
acda74 |
+}
|
|
|
acda74 |
+
|
|
|
acda74 |
+
|
|
|
acda74 |
int
|
|
|
acda74 |
qemuPasstSetupCgroup(virDomainObj *vm,
|
|
|
acda74 |
virDomainNetDef *net,
|
|
|
acda74 |
@@ -147,7 +155,6 @@ qemuPasstStart(virDomainObj *vm,
|
|
|
acda74 |
g_autofree char *errbuf = NULL;
|
|
|
acda74 |
char macaddr[VIR_MAC_STRING_BUFLEN];
|
|
|
acda74 |
size_t i;
|
|
|
acda74 |
- pid_t pid = (pid_t) -1;
|
|
|
acda74 |
int exitstatus = 0;
|
|
|
acda74 |
int cmdret = 0;
|
|
|
acda74 |
|
|
|
acda74 |
@@ -273,10 +280,6 @@ qemuPasstStart(virDomainObj *vm,
|
|
|
acda74 |
return 0;
|
|
|
acda74 |
|
|
|
acda74 |
error:
|
|
|
acda74 |
- ignore_value(virPidFileReadPathIfLocked(pidfile, &pid));
|
|
|
acda74 |
- if (pid != -1)
|
|
|
acda74 |
- virProcessKillPainfully(pid, true);
|
|
|
acda74 |
- unlink(pidfile);
|
|
|
acda74 |
-
|
|
|
acda74 |
+ qemuPasstKill(pidfile);
|
|
|
acda74 |
return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
--
|
|
|
acda74 |
2.39.2
|
|
|
acda74 |
|