mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Do not keep swtpm pidfile around after stopping
Just like the socket, remove the pidfile when TPM emulator is being stopped. In order to make this a bit cleaner, try to remove it even if swtpm_ioctl does not exist. https://bugzilla.redhat.com/show_bug.cgi?id=2111301 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4c0310677a
commit
3c2d06d78e
@ -787,19 +787,13 @@ qemuTPMEmulatorStop(const char *swtpmStateDir,
|
|||||||
g_autofree char *pathname = NULL;
|
g_autofree char *pathname = NULL;
|
||||||
g_autofree char *errbuf = NULL;
|
g_autofree char *errbuf = NULL;
|
||||||
g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
|
g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
|
||||||
|
g_autofree char *pidfile = qemuTPMEmulatorPidFileBuildPath(swtpmStateDir,
|
||||||
|
shortName);
|
||||||
|
if (swtpm_ioctl &&
|
||||||
|
(pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)) &&
|
||||||
|
virFileExists(pathname)) {
|
||||||
|
|
||||||
if (!swtpm_ioctl)
|
cmd = virCommandNewArgList(swtpm_ioctl, "--unix", pathname, "-s", NULL);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!virFileExists(pathname))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cmd = virCommandNew(swtpm_ioctl);
|
|
||||||
|
|
||||||
virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL);
|
|
||||||
|
|
||||||
virCommandSetErrorBuffer(cmd, &errbuf);
|
virCommandSetErrorBuffer(cmd, &errbuf);
|
||||||
|
|
||||||
@ -807,6 +801,10 @@ qemuTPMEmulatorStop(const char *swtpmStateDir,
|
|||||||
|
|
||||||
/* clean up the socket */
|
/* clean up the socket */
|
||||||
unlink(pathname);
|
unlink(pathname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pidfile)
|
||||||
|
virPidFileForceCleanupPath(pidfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user