Merge ~lvoytek/ubuntu/+source/libvirt:fix-pid-duplication-lunar into ubuntu/+source/libvirt:ubuntu/devel

Proposed by Lena Voytek
Status: Merged
Approved by: git-ubuntu bot
Approved revision: not available
Merged at revision: a2f0ab86cee9e0cc4ed3857d88dde9528459956c
Proposed branch: ~lvoytek/ubuntu/+source/libvirt:fix-pid-duplication-lunar
Merge into: ubuntu/+source/libvirt:ubuntu/devel
Diff against target: 85 lines (+60/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/series (+1/-0)
debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch (+52/-0)
Reviewer Review Type Date Requested Status
git-ubuntu bot Approve
Christian Ehrhardt  (community) Approve
Canonical Server Reporter Pending
Review via email: mp+433390@code.launchpad.net

Description of the change

Cleaning up swtpm pid file after a vm shuts down

PPA: https://launchpad.net/~lvoytek/+archive/ubuntu/libvirt-fix-swtpm-pid-duplication

Testing:

# apt install virt-manager swtpm

Create a vm in virt-manager and on the last page

> Select "Customize configuration before install"
> Click Finish

> Click Add Hardware
> Select TPM with Model "TIS" and version 2.0

> Click "Begin Installation"

Turn the vm off and on a few times then check /run/libvirt/qemu/swtpm:

# ls -la /run/libvirt/qemu/swtpm

In the original version multiple pid files will show up, e.g.

drwxrwx--- 2 libvirt-qemu swtpm 80 Nov 17 13:34 .
drwxr-xr-x 5 root root 180 Nov 17 13:34 ..
-rw-r--r-- 1 root root 5 Nov 17 12:57 1-win11-swtpm.pid
-rw-r--r-- 1 root root 5 Nov 17 13:34 2-win11-swtpm.pid

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

LGTM +1
I'd like to save the builders and tests some effort and combine it with others.

WDYT of
https://code.launchpad.net/~paelzer/ubuntu/+source/libvirt/+git/libvirt/+merge/433429

review: Approve
Revision history for this message
git-ubuntu bot (git-ubuntu-bot) wrote :

Approvers: paelzer, lvoytek
Uploaders: paelzer
MP auto-approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 22a9983..d3ccbfa 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+libvirt (8.6.0-0ubuntu4) lunar; urgency=medium
7+
8+ * d/p/u/fix-swtpm-pid-duplication.patch: Clean up swtpm pids after a vm
9+ shuts down (LP: #1997269)
10+
11+ -- Lena Voytek <lena.voytek@canonical.com> Mon, 21 Nov 2022 11:16:40 -0700
12+
13 libvirt (8.6.0-0ubuntu3) kinetic; urgency=medium
14
15 * d/p/u/lp-1990499-virt-aa-helper-allow-common-riscv64-loader-paths.patch:
16diff --git a/debian/patches/series b/debian/patches/series
17index c2f6adb..8d27373 100644
18--- a/debian/patches/series
19+++ b/debian/patches/series
20@@ -14,6 +14,7 @@ ubuntu/lp-1861125-ubuntu-models.patch
21 ubuntu/dnsmasq-as-priv-user
22 ubuntu/ovmf_paths.patch
23 ubuntu/wait-for-qemu-kvm.patch
24+ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch
25
26 # Ubuntu Apparmor Changes
27 ubuntu-aa/0020-virt-aa-helper-ubuntu-storage-paths.patch
28diff --git a/debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch b/debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch
29new file mode 100644
30index 0000000..ac4dfc9
31--- /dev/null
32+++ b/debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch
33@@ -0,0 +1,52 @@
34+Description: Do not keep swtpm pidfile around after stopping qemu vm
35+Author: Martin Kletzander <mkletzan@redhat.com>
36+Origin: upstream, https://gitlab.com/libvirt/libvirt/-/commit/3c2d06d78e1bd2d9298276b44a6ab09cc3b36e5a
37+Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2111301
38+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1997269
39+Last-Update: 2022-11-21
40+---
41+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
42+--- a/src/qemu/qemu_tpm.c
43++++ b/src/qemu/qemu_tpm.c
44+@@ -793,28 +793,25 @@
45+ g_autofree char *pathname = NULL;
46+ g_autofree char *errbuf = NULL;
47+ g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
48++ g_autofree char *pidfile = qemuTPMEmulatorPidFileBuildPath(swtpmStateDir,
49++ shortName);
50+
51+- if (!swtpm_ioctl)
52+- return;
53++ if (swtpm_ioctl &&
54++ (pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)) &&
55++ virFileExists(pathname)) {
56+
57+- if (!(pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)))
58+- return;
59++ cmd = virCommandNewArgList(swtpm_ioctl, "--unix", pathname, "-s", NULL);
60+
61+- if (!virFileExists(pathname))
62+- return;
63++ virCommandSetErrorBuffer(cmd, &errbuf);
64+
65+- cmd = virCommandNew(swtpm_ioctl);
66+- if (!cmd)
67+- return;
68++ ignore_value(virCommandRun(cmd, NULL));
69+
70+- virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL);
71++ /* clean up the socket */
72++ unlink(pathname);
73++ }
74+
75+- virCommandSetErrorBuffer(cmd, &errbuf);
76+-
77+- ignore_value(virCommandRun(cmd, NULL));
78+-
79+- /* clean up the socket */
80+- unlink(pathname);
81++ if (pidfile)
82++ virPidFileForceCleanupPath(pidfile);
83+ }
84+
85+

Subscribers

People subscribed via source and target branches