mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +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,26 +787,24 @@ qemuTPMEmulatorStop(const char *swtpmStateDir,
|
||||
g_autofree char *pathname = NULL;
|
||||
g_autofree char *errbuf = NULL;
|
||||
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)
|
||||
return;
|
||||
cmd = virCommandNewArgList(swtpm_ioctl, "--unix", pathname, "-s", NULL);
|
||||
|
||||
if (!(pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)))
|
||||
return;
|
||||
virCommandSetErrorBuffer(cmd, &errbuf);
|
||||
|
||||
if (!virFileExists(pathname))
|
||||
return;
|
||||
ignore_value(virCommandRun(cmd, NULL));
|
||||
|
||||
cmd = virCommandNew(swtpm_ioctl);
|
||||
/* clean up the socket */
|
||||
unlink(pathname);
|
||||
}
|
||||
|
||||
virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL);
|
||||
|
||||
virCommandSetErrorBuffer(cmd, &errbuf);
|
||||
|
||||
ignore_value(virCommandRun(cmd, NULL));
|
||||
|
||||
/* clean up the socket */
|
||||
unlink(pathname);
|
||||
if (pidfile)
|
||||
virPidFileForceCleanupPath(pidfile);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user