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
diff --git a/debian/changelog b/debian/changelog
index 22a9983..d3ccbfa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1libvirt (8.6.0-0ubuntu4) lunar; urgency=medium
2
3 * d/p/u/fix-swtpm-pid-duplication.patch: Clean up swtpm pids after a vm
4 shuts down (LP: #1997269)
5
6 -- Lena Voytek <lena.voytek@canonical.com> Mon, 21 Nov 2022 11:16:40 -0700
7
1libvirt (8.6.0-0ubuntu3) kinetic; urgency=medium8libvirt (8.6.0-0ubuntu3) kinetic; urgency=medium
29
3 * d/p/u/lp-1990499-virt-aa-helper-allow-common-riscv64-loader-paths.patch:10 * d/p/u/lp-1990499-virt-aa-helper-allow-common-riscv64-loader-paths.patch:
diff --git a/debian/patches/series b/debian/patches/series
index c2f6adb..8d27373 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -14,6 +14,7 @@ ubuntu/lp-1861125-ubuntu-models.patch
14ubuntu/dnsmasq-as-priv-user14ubuntu/dnsmasq-as-priv-user
15ubuntu/ovmf_paths.patch15ubuntu/ovmf_paths.patch
16ubuntu/wait-for-qemu-kvm.patch16ubuntu/wait-for-qemu-kvm.patch
17ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch
1718
18# Ubuntu Apparmor Changes19# Ubuntu Apparmor Changes
19ubuntu-aa/0020-virt-aa-helper-ubuntu-storage-paths.patch20ubuntu-aa/0020-virt-aa-helper-ubuntu-storage-paths.patch
diff --git a/debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch b/debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch
20new file mode 10064421new file mode 100644
index 0000000..ac4dfc9
--- /dev/null
+++ b/debian/patches/ubuntu/lp-1997269-fix-swtpm-pid-duplication.patch
@@ -0,0 +1,52 @@
1Description: Do not keep swtpm pidfile around after stopping qemu vm
2Author: Martin Kletzander <mkletzan@redhat.com>
3Origin: upstream, https://gitlab.com/libvirt/libvirt/-/commit/3c2d06d78e1bd2d9298276b44a6ab09cc3b36e5a
4Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2111301
5Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1997269
6Last-Update: 2022-11-21
7---
8This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
9--- a/src/qemu/qemu_tpm.c
10+++ b/src/qemu/qemu_tpm.c
11@@ -793,28 +793,25 @@
12 g_autofree char *pathname = NULL;
13 g_autofree char *errbuf = NULL;
14 g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
15+ g_autofree char *pidfile = qemuTPMEmulatorPidFileBuildPath(swtpmStateDir,
16+ shortName);
17
18- if (!swtpm_ioctl)
19- return;
20+ if (swtpm_ioctl &&
21+ (pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)) &&
22+ virFileExists(pathname)) {
23
24- if (!(pathname = qemuTPMEmulatorSocketBuildPath(swtpmStateDir, shortName)))
25- return;
26+ cmd = virCommandNewArgList(swtpm_ioctl, "--unix", pathname, "-s", NULL);
27
28- if (!virFileExists(pathname))
29- return;
30+ virCommandSetErrorBuffer(cmd, &errbuf);
31
32- cmd = virCommandNew(swtpm_ioctl);
33- if (!cmd)
34- return;
35+ ignore_value(virCommandRun(cmd, NULL));
36
37- virCommandAddArgList(cmd, "--unix", pathname, "-s", NULL);
38+ /* clean up the socket */
39+ unlink(pathname);
40+ }
41
42- virCommandSetErrorBuffer(cmd, &errbuf);
43-
44- ignore_value(virCommandRun(cmd, NULL));
45-
46- /* clean up the socket */
47- unlink(pathname);
48+ if (pidfile)
49+ virPidFileForceCleanupPath(pidfile);
50 }
51
52

Subscribers

People subscribed via source and target branches