mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemuSlirpStop: Simplify helper kill
Now, that we know that the slirp helper will have the pidfile open and locked we can use virPidFileForceCleanupPath() to kill it and unlink the pidfile. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
a02c589886
commit
1566be99be
@ -246,8 +246,6 @@ qemuSlirpStop(qemuSlirpPtr slirp,
|
|||||||
g_autofree char *dbus_path = NULL;
|
g_autofree char *dbus_path = NULL;
|
||||||
g_autofree char *id = qemuSlirpGetDBusVMStateId(net);
|
g_autofree char *id = qemuSlirpGetDBusVMStateId(net);
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
pid_t pid;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (!(pidfile = qemuSlirpCreatePidFilename(cfg, vm->def, net->info.alias))) {
|
if (!(pidfile = qemuSlirpCreatePidFilename(cfg, vm->def, net->info.alias))) {
|
||||||
VIR_WARN("Unable to construct slirp pidfile path");
|
VIR_WARN("Unable to construct slirp pidfile path");
|
||||||
@ -261,17 +259,11 @@ qemuSlirpStop(qemuSlirpPtr slirp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virErrorPreserveLast(&orig_err);
|
virErrorPreserveLast(&orig_err);
|
||||||
rc = virPidFileReadPathIfAlive(pidfile, &pid, cfg->slirpHelperName);
|
if (virPidFileForceCleanupPath(pidfile) < 0) {
|
||||||
if (rc >= 0 && pid != (pid_t) -1)
|
VIR_WARN("Unable to kill slirp process");
|
||||||
virProcessKillPainfully(pid, true);
|
} else {
|
||||||
|
slirp->pid = 0;
|
||||||
if (unlink(pidfile) < 0 &&
|
|
||||||
errno != ENOENT) {
|
|
||||||
virReportSystemError(errno,
|
|
||||||
_("Unable to remove stale pidfile %s"),
|
|
||||||
pidfile);
|
|
||||||
}
|
}
|
||||||
slirp->pid = 0;
|
|
||||||
|
|
||||||
dbus_path = qemuSlirpGetDBusPath(cfg, vm->def, net->info.alias);
|
dbus_path = qemuSlirpGetDBusPath(cfg, vm->def, net->info.alias);
|
||||||
if (dbus_path) {
|
if (dbus_path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user