update patch with openeuler !57
Signed-off-by: yezengruan <yezengruan@huawei.com>
This commit is contained in:
parent
4d80e9430b
commit
d5507264fd
108
Revert-libvirt-support-aarch64-vtpm-with-parameter-t.patch
Normal file
108
Revert-libvirt-support-aarch64-vtpm-with-parameter-t.patch
Normal file
@ -0,0 +1,108 @@
|
||||
From 78c25600daf2a2822e7ecec2af9e7458b9f44eff Mon Sep 17 00:00:00 2001
|
||||
From: yezengruan <yezengruan@huawei.com>
|
||||
Date: Sat, 12 Mar 2022 09:35:07 +0800
|
||||
Subject: [PATCH 1/6] Revert libvirt: support aarch64 vtpm with parameter
|
||||
tpm-tis-device
|
||||
|
||||
Before backport the patch support aarch64 vtpm, let's
|
||||
revert it first.
|
||||
|
||||
Signed-off-by: yezengruan <yezengruan@huawei.com>
|
||||
---
|
||||
src/conf/domain_conf.c | 1 -
|
||||
src/conf/domain_conf.h | 1 -
|
||||
src/qemu/qemu_capabilities.c | 9 +--------
|
||||
src/qemu/qemu_capabilities.h | 4 +---
|
||||
src/qemu/qemu_domain.c | 3 ---
|
||||
5 files changed, 2 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index 4e3bcf479c..54228a2151 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -1141,7 +1141,6 @@ VIR_ENUM_IMPL(virDomainTPMModel,
|
||||
"tpm-tis",
|
||||
"tpm-crb",
|
||||
"tpm-spapr",
|
||||
- "tpm-tis-device",
|
||||
);
|
||||
|
||||
VIR_ENUM_IMPL(virDomainTPMBackend,
|
||||
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
||||
index ccee986849..e057c384c6 100644
|
||||
--- a/src/conf/domain_conf.h
|
||||
+++ b/src/conf/domain_conf.h
|
||||
@@ -1280,7 +1280,6 @@ typedef enum {
|
||||
VIR_DOMAIN_TPM_MODEL_TIS,
|
||||
VIR_DOMAIN_TPM_MODEL_CRB,
|
||||
VIR_DOMAIN_TPM_MODEL_SPAPR,
|
||||
- VIR_DOMAIN_TPM_MODEL_TIS_DEVICE,
|
||||
|
||||
VIR_DOMAIN_TPM_MODEL_LAST
|
||||
} virDomainTPMModel;
|
||||
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
||||
index 6013be9d05..0fb3e74c77 100644
|
||||
--- a/src/qemu/qemu_capabilities.c
|
||||
+++ b/src/qemu/qemu_capabilities.c
|
||||
@@ -568,9 +568,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
|
||||
"blockdev-snapshot.allow-write-only-overlay",
|
||||
"blockdev-reopen",
|
||||
"storage.werror",
|
||||
-
|
||||
- /* 360 */
|
||||
- "tpm-tis-device",
|
||||
+
|
||||
"migration-param.bandwidth",
|
||||
"migration-param.downtime",
|
||||
"migration-param.xbzrle-cache-size",
|
||||
@@ -1292,7 +1290,6 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
|
||||
{ "rng-builtin", QEMU_CAPS_OBJECT_RNG_BUILTIN },
|
||||
{ "tpm-spapr", QEMU_CAPS_DEVICE_TPM_SPAPR },
|
||||
{ "vhost-user-fs-device", QEMU_CAPS_DEVICE_VHOST_USER_FS },
|
||||
- { "tpm-tis-device", QEMU_CAPS_DEVICE_TPM_TIS_DEVICE },
|
||||
};
|
||||
|
||||
static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
|
||||
@@ -3100,10 +3097,6 @@ const struct tpmTypeToCaps virQEMUCapsTPMModelsToCaps[] = {
|
||||
.type = VIR_DOMAIN_TPM_MODEL_SPAPR,
|
||||
.caps = QEMU_CAPS_DEVICE_TPM_SPAPR,
|
||||
},
|
||||
- {
|
||||
- .type = VIR_DOMAIN_TPM_MODEL_TIS_DEVICE,
|
||||
- .caps = QEMU_CAPS_DEVICE_TPM_TIS_DEVICE,
|
||||
- },
|
||||
};
|
||||
|
||||
static int
|
||||
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
|
||||
index 5f28006b48..10a6ce50e7 100644
|
||||
--- a/src/qemu/qemu_capabilities.h
|
||||
+++ b/src/qemu/qemu_capabilities.h
|
||||
@@ -549,9 +549,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
|
||||
QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_WRITE_ONLY, /* blockdev-snapshot has the 'allow-write-only-overlay' feature */
|
||||
QEMU_CAPS_BLOCKDEV_REOPEN, /* 'blockdev-reopen' qmp command is supported */
|
||||
QEMU_CAPS_STORAGE_WERROR, /* virtio-blk,scsi-hd.werror */
|
||||
-
|
||||
- /* 360 */
|
||||
- QEMU_CAPS_DEVICE_TPM_TIS_DEVICE, /* -device tpm-tis-device */
|
||||
+
|
||||
QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH, /* max-bandwidth field in migrate-set-parameters */
|
||||
QEMU_CAPS_MIGRATION_PARAM_DOWNTIME, /* downtime-limit field in migrate-set-parameters */
|
||||
QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE, /* xbzrle-cache-size field in migrate-set-parameters */
|
||||
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||
index 2351cac120..cb2fbdc179 100644
|
||||
--- a/src/qemu/qemu_domain.c
|
||||
+++ b/src/qemu/qemu_domain.c
|
||||
@@ -8130,9 +8130,6 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
|
||||
case VIR_DOMAIN_TPM_MODEL_SPAPR:
|
||||
flag = QEMU_CAPS_DEVICE_TPM_SPAPR;
|
||||
break;
|
||||
- case VIR_DOMAIN_TPM_MODEL_TIS_DEVICE:
|
||||
- flag = QEMU_CAPS_DEVICE_TPM_TIS_DEVICE;
|
||||
- break;
|
||||
case VIR_DOMAIN_TPM_MODEL_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainTPMModel, tpm->model);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
16
libvirt.spec
16
libvirt.spec
@ -101,7 +101,7 @@
|
||||
Summary: Library providing a simple virtualization API
|
||||
Name: libvirt
|
||||
Version: 6.2.0
|
||||
Release: 33
|
||||
Release: 34
|
||||
License: LGPLv2+
|
||||
URL: https://libvirt.org/
|
||||
|
||||
@ -223,6 +223,12 @@ Patch0110: qemu-Avoid-deprecated-migrate-set-cache-size-QMP-com.patch
|
||||
Patch0111: qemu-Track-numa-mem-supported-machine-attribute.patch
|
||||
Patch0112: qemuBuildNumaArgStr-Switch-order-of-if-and-for.patch
|
||||
Patch0113: qemuBuildNumaArgStr-Use-modern-numa-memdev-if-old-nu.patch
|
||||
Patch0114: Revert-libvirt-support-aarch64-vtpm-with-parameter-t.patch
|
||||
Patch0115: qemu-Fix-swtpm-device-with-aarch64.patch
|
||||
Patch0116: qemu-Fix-libvirt-hang-due-to-early-TPM-device-stop.patch
|
||||
Patch0117: qemu_tpm-Move-logfile-path-generation-into-a-separat.patch
|
||||
Patch0118: qemu_tpm-Generate-log-file-path-among-with-storage-p.patch
|
||||
Patch0119: virtpm-Fix-path-handling-in-virTPMEmulatorInit.patch
|
||||
|
||||
Requires: libvirt-daemon = %{version}-%{release}
|
||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||
@ -1957,6 +1963,14 @@ exit 0
|
||||
|
||||
|
||||
%changelog
|
||||
* Sat Mar 12 2022 yezengruan <yezengruan@huawei.com>
|
||||
- Revert libvirt: support aarch64 vtpm with parameter tpm-tis-device
|
||||
- qemu: Fix swtpm device with aarch64
|
||||
- qemu: Fix libvirt hang due to early TPM device stop
|
||||
- qemu_tpm: Move logfile path generation into a separate function
|
||||
- qemu_tpm: Generate log file path among with storage path
|
||||
- virtpm: Fix @path handling in virTPMEmulatorInit()
|
||||
|
||||
* Fri Mar 11 2022 yezengruan <yezengruan@huawei.com>
|
||||
- qemu: Probe for a few params supported by migrate-set-parameters
|
||||
- qemu: Avoid deprecated migrate_set_speed QMP command
|
||||
|
||||
51
qemu-Fix-libvirt-hang-due-to-early-TPM-device-stop.patch
Normal file
51
qemu-Fix-libvirt-hang-due-to-early-TPM-device-stop.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 6d4e247786117b0b9b57722778c26328993a8f52 Mon Sep 17 00:00:00 2001
|
||||
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
|
||||
Date: Fri, 19 Feb 2021 10:57:41 -0500
|
||||
Subject: [PATCH 3/6] qemu: Fix libvirt hang due to early TPM device stop
|
||||
|
||||
This patch partially reverts commit 5cde9dee where the qemuExtDevicesStop()
|
||||
was moved to a location before the QEMU process is stopped. It may be
|
||||
alright to tear down some devices before QEMU is stopped, but it doesn't work
|
||||
for the external TPM (swtpm) which assumes that QEMU sends it a signal to stop
|
||||
it before libvirt may try to clean it up. So this patch moves the
|
||||
virFileDeleteTree() calls after the call to qemuExtDevicesStop() so that the
|
||||
pid file of virtiofsd is not deleted before that call.
|
||||
|
||||
Afftected libvirt versions are 6.10 and 7.0.
|
||||
|
||||
Fixes: 5cde9dee8c70b17c458d031ab6cf71dce476eea2
|
||||
Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
|
||||
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Signed-off-by: yezengruan <yezengruan@huawei.com>
|
||||
---
|
||||
src/qemu/qemu_process.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index 4f7bd0586d..d9209ac6d2 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -7410,9 +7410,6 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
||||
/* Do this before we delete the tree and remove pidfile. */
|
||||
qemuProcessKillManagedPRDaemon(vm);
|
||||
|
||||
- virFileDeleteTree(priv->libDir);
|
||||
- virFileDeleteTree(priv->channelTargetDir);
|
||||
-
|
||||
ignore_value(virDomainChrDefForeach(vm->def,
|
||||
false,
|
||||
qemuProcessCleanupChardevDevice,
|
||||
@@ -7432,6 +7429,9 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
||||
|
||||
vm->def->id = -1;
|
||||
|
||||
+ virFileDeleteTree(priv->libDir);
|
||||
+ virFileDeleteTree(priv->channelTargetDir);
|
||||
+
|
||||
/* Stop autodestroy in case guest is restarted */
|
||||
qemuProcessAutoDestroyRemove(driver, vm);
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
208
qemu-Fix-swtpm-device-with-aarch64.patch
Normal file
208
qemu-Fix-swtpm-device-with-aarch64.patch
Normal file
@ -0,0 +1,208 @@
|
||||
From 2480d7857c6ea384567009840040b900f5440616 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Fehlig <jfehlig@suse.com>
|
||||
Date: Tue, 9 Feb 2021 14:57:22 -0700
|
||||
Subject: [PATCH 2/6] qemu: Fix swtpm device with aarch64
|
||||
|
||||
Starting a VM with swtpm device fails with qemu-system-aarch64.
|
||||
E.g. with TPM device config
|
||||
|
||||
<tpm model='tpm-tis'>
|
||||
<backend type='emulator' version='2.0'/>
|
||||
</tpm>
|
||||
|
||||
QEMU reports the following error
|
||||
|
||||
error: internal error: process exited while connecting to monitor:
|
||||
2021-02-07T05:15:35.378927Z qemu-system-aarch64: -device
|
||||
tpm-tis,tpmdev=tpm-tpm0,id=tpm0: 'tpm-tis' is not a valid device model name
|
||||
|
||||
Indeed the TPM device name is 'tpm-tis-device' [1][2] for aarch64,
|
||||
versus the shorter 'tpm-tis' for x86. The devices are the same from
|
||||
a functional POV, i.e. they both emulate a TPM device conforming to
|
||||
the TIS specification. Account for the unfortunate name difference
|
||||
when building the TPM device option in qemuBuildTPMDevStr(). Also
|
||||
include a test case for 'tpm-tis-device'.
|
||||
|
||||
[1] https://qemu.readthedocs.io/en/latest/specs/tpm.html
|
||||
[2] https://github.com/qemu/qemu/commit/c294ac327ca99342b90bd3a83d2cef9b447afaa7
|
||||
|
||||
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
||||
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
||||
Signed-off-by: yezengruan <yezengruan@huawei.com>
|
||||
---
|
||||
src/qemu/qemu_command.c | 3 ++
|
||||
.../caps_5.0.0.aarch64.replies | 15 ++++++++
|
||||
.../caps_5.0.0.aarch64.xml | 3 ++
|
||||
.../aarch64-tpm.aarch64-latest.args | 35 +++++++++++++++++++
|
||||
tests/qemuxml2argvdata/aarch64-tpm.xml | 15 ++++++++
|
||||
tests/qemuxml2argvtest.c | 1 +
|
||||
6 files changed, 72 insertions(+)
|
||||
create mode 100644 tests/qemuxml2argvdata/aarch64-tpm.aarch64-latest.args
|
||||
create mode 100644 tests/qemuxml2argvdata/aarch64-tpm.xml
|
||||
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index f8331a7455..d5d46c0892 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -9232,6 +9232,9 @@ qemuBuildTPMDevStr(const virDomainDef *def,
|
||||
virDomainTPMDef *tpm = def->tpm;
|
||||
const char *model = virDomainTPMModelTypeToString(tpm->model);
|
||||
|
||||
+ if (tpm->model == VIR_DOMAIN_TPM_MODEL_TIS && def->os.arch == VIR_ARCH_AARCH64)
|
||||
+ model = "tpm-tis-device";
|
||||
+
|
||||
virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
|
||||
model, tpm->info.alias, tpm->info.alias);
|
||||
|
||||
diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.replies b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.replies
|
||||
index a3136a0966..e848860e45 100644
|
||||
--- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.replies
|
||||
+++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.replies
|
||||
@@ -2734,6 +2734,10 @@
|
||||
"name": "armv7m_systick",
|
||||
"parent": "sys-bus-device"
|
||||
},
|
||||
+ {
|
||||
+ "name": "tpm-emulator",
|
||||
+ "parent": "tpm-backend"
|
||||
+ },
|
||||
{
|
||||
"name": "imx6ul.ccm",
|
||||
"parent": "imx.ccm"
|
||||
@@ -3198,6 +3202,10 @@
|
||||
"name": "authz-list",
|
||||
"parent": "authz"
|
||||
},
|
||||
+ {
|
||||
+ "name": "tpm-passthrough",
|
||||
+ "parent": "tpm-backend"
|
||||
+ },
|
||||
{
|
||||
"name": "xlnx.ps7-spi",
|
||||
"parent": "sys-bus-device"
|
||||
@@ -3286,6 +3294,10 @@
|
||||
"name": "bcm2835-peripherals",
|
||||
"parent": "sys-bus-device"
|
||||
},
|
||||
+ {
|
||||
+ "name": "tpm-tis-device",
|
||||
+ "parent": "sys-bus-device"
|
||||
+ },
|
||||
{
|
||||
"name": "arm-its-kvm",
|
||||
"parent": "arm-gicv3-its-common"
|
||||
@@ -7768,6 +7780,7 @@
|
||||
|
||||
{
|
||||
"return": [
|
||||
+ "tpm-tis"
|
||||
],
|
||||
"id": "libvirt-36"
|
||||
}
|
||||
@@ -7779,6 +7792,8 @@
|
||||
|
||||
{
|
||||
"return": [
|
||||
+ "passthrough",
|
||||
+ "emulator"
|
||||
],
|
||||
"id": "libvirt-37"
|
||||
}
|
||||
diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml
|
||||
index 92ad10c9b8..af282f33c1 100644
|
||||
--- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml
|
||||
+++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml
|
||||
@@ -42,6 +42,8 @@
|
||||
<flag name='rng-random'/>
|
||||
<flag name='rng-egd'/>
|
||||
<flag name='megasas'/>
|
||||
+ <flag name='tpm-passthrough'/>
|
||||
+ <flag name='tpm-tis'/>
|
||||
<flag name='pci-bridge'/>
|
||||
<flag name='vfio-pci'/>
|
||||
<flag name='mem-merge'/>
|
||||
@@ -150,6 +152,7 @@
|
||||
<flag name='blockdev-del'/>
|
||||
<flag name='vhost-vsock'/>
|
||||
<flag name='chardev-fd-pass'/>
|
||||
+ <flag name='tpm-emulator'/>
|
||||
<flag name='usb-storage.werror'/>
|
||||
<flag name='egl-headless'/>
|
||||
<flag name='vfio-pci.display'/>
|
||||
diff --git a/tests/qemuxml2argvdata/aarch64-tpm.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-tpm.aarch64-latest.args
|
||||
new file mode 100644
|
||||
index 0000000000..4ca09a1fb0
|
||||
--- /dev/null
|
||||
+++ b/tests/qemuxml2argvdata/aarch64-tpm.aarch64-latest.args
|
||||
@@ -0,0 +1,35 @@
|
||||
+LC_ALL=C \
|
||||
+PATH=/bin \
|
||||
+HOME=/tmp/lib/domain--1-aarch64test \
|
||||
+USER=test \
|
||||
+LOGNAME=test \
|
||||
+XDG_DATA_HOME=/tmp/lib/domain--1-aarch64test/.local/share \
|
||||
+XDG_CACHE_HOME=/tmp/lib/domain--1-aarch64test/.cache \
|
||||
+XDG_CONFIG_HOME=/tmp/lib/domain--1-aarch64test/.config \
|
||||
+QEMU_AUDIO_DRV=none \
|
||||
+/usr/bin/qemu-system-aarch64 \
|
||||
+-name guest=aarch64test,debug-threads=on \
|
||||
+-S \
|
||||
+-object secret,id=masterKey0,format=raw,\
|
||||
+file=/tmp/lib/domain--1-aarch64test/master-key.aes \
|
||||
+-machine virt,accel=tcg,usb=off,dump-guest-core=off,gic-version=2 \
|
||||
+-cpu cortex-a15 \
|
||||
+-m 1024 \
|
||||
+-overcommit mem-lock=off \
|
||||
+-smp 1,sockets=1,cores=1,threads=1 \
|
||||
+-uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
|
||||
+-display none \
|
||||
+-no-user-config \
|
||||
+-nodefaults \
|
||||
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
|
||||
+-mon chardev=charmonitor,id=monitor,mode=control \
|
||||
+-rtc base=utc \
|
||||
+-no-shutdown \
|
||||
+-no-acpi \
|
||||
+-boot strict=on \
|
||||
+-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||
+-chardev socket,id=chrtpm,path=/dev/test \
|
||||
+-device tpm-tis-device,tpmdev=tpm-tpm0,id=tpm0 \
|
||||
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
+resourcecontrol=deny \
|
||||
+-msg timestamp=on
|
||||
diff --git a/tests/qemuxml2argvdata/aarch64-tpm.xml b/tests/qemuxml2argvdata/aarch64-tpm.xml
|
||||
new file mode 100644
|
||||
index 0000000000..d338a20f17
|
||||
--- /dev/null
|
||||
+++ b/tests/qemuxml2argvdata/aarch64-tpm.xml
|
||||
@@ -0,0 +1,15 @@
|
||||
+<domain type="qemu">
|
||||
+ <name>aarch64test</name>
|
||||
+ <uuid>496d7ea8-9739-544b-4ebd-ef08be936e8b</uuid>
|
||||
+ <memory>1048576</memory>
|
||||
+ <vcpu placement='static'>1</vcpu>
|
||||
+ <os>
|
||||
+ <type arch="aarch64" machine="virt">hvm</type>
|
||||
+ </os>
|
||||
+ <devices>
|
||||
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
|
||||
+ <tpm model='tpm-tis'>
|
||||
+ <backend type='emulator' version='2.0'/>
|
||||
+ </tpm>
|
||||
+ </devices>
|
||||
+</domain>
|
||||
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
||||
index dc871d5698..47fce1c3bf 100644
|
||||
--- a/tests/qemuxml2argvtest.c
|
||||
+++ b/tests/qemuxml2argvtest.c
|
||||
@@ -2305,6 +2305,7 @@ mymain(void)
|
||||
DO_TEST_CAPS_LATEST("tpm-emulator-tpm2");
|
||||
DO_TEST_CAPS_LATEST("tpm-emulator-tpm2-enc");
|
||||
DO_TEST_CAPS_LATEST_PPC64("tpm-emulator-spapr");
|
||||
+ DO_TEST_CAPS_ARCH_LATEST("aarch64-tpm", "aarch64");
|
||||
|
||||
DO_TEST_PARSE_ERROR("pci-domain-invalid", NONE);
|
||||
DO_TEST_PARSE_ERROR("pci-bus-invalid", NONE);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
149
qemu_tpm-Generate-log-file-path-among-with-storage-p.patch
Normal file
149
qemu_tpm-Generate-log-file-path-among-with-storage-p.patch
Normal file
@ -0,0 +1,149 @@
|
||||
From 85a1643f583a46b1fc3a01d5c2e87ba6262be586 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Wed, 24 Feb 2021 17:28:42 +0100
|
||||
Subject: [PATCH 5/6] qemu_tpm: Generate log file path among with storage path
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When starting a guest with TPM of type='emulator' an external
|
||||
process is started with it (swtpm) to emulate TPM. This external
|
||||
process is passed path to a log file via --logfile. The path to
|
||||
the log file is generated in qemuTPMEmulatorPrepareHost() which
|
||||
works, until the daemon is restarted. The problem is that the
|
||||
path is not stored in private data or anywhere inside live XML
|
||||
and thus later, when qemuExtTPMStop() is called (when shutting
|
||||
off the guest) the stored logpath is NULL and thus its seclabel
|
||||
is not cleaned up (see virSecuritySELinuxRestoreTPMLabels()).
|
||||
|
||||
Fortunately, qemuExtDevicesStop() (which calls qemuExtTPMStop()
|
||||
eventually) does call qemuExtDevicesInitPaths() where the log
|
||||
path can be generated again.
|
||||
|
||||
Basically, tpm->data.emulator.storagepath is generated in
|
||||
qemuExtTPMInitPaths() and its seclabels are restored properly,
|
||||
and this commit move logfile onto the same level.
|
||||
|
||||
This means, that the log path doesn't have to be generated in
|
||||
qemuExtDevicesStart() because it was already done in
|
||||
qemuExtDevicesPrepareHost().
|
||||
|
||||
This change also renders @vmname argument of
|
||||
qemuTPMEmulatorPrepareHost() unused and thus is removed.
|
||||
|
||||
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1769196
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Signed-off-by: yezengruan <yezengruan@huawei.com>
|
||||
---
|
||||
src/qemu/qemu_extdevice.c | 6 +++---
|
||||
src/qemu/qemu_tpm.c | 22 ++++++++++++++--------
|
||||
2 files changed, 17 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
|
||||
index 5a31b4d66e..025929cbcc 100644
|
||||
--- a/src/qemu/qemu_extdevice.c
|
||||
+++ b/src/qemu/qemu_extdevice.c
|
||||
@@ -133,6 +133,9 @@ qemuExtDevicesPrepareHost(virQEMUDriverPtr driver,
|
||||
virDomainDefPtr def = vm->def;
|
||||
size_t i;
|
||||
|
||||
+ if (qemuExtDevicesInitPaths(driver, def) < 0)
|
||||
+ return -1;
|
||||
+
|
||||
if (def->tpm &&
|
||||
qemuExtTPMPrepareHost(driver, def) < 0)
|
||||
return -1;
|
||||
@@ -170,9 +173,6 @@ qemuExtDevicesStart(virQEMUDriverPtr driver,
|
||||
virDomainDefPtr def = vm->def;
|
||||
size_t i;
|
||||
|
||||
- if (qemuExtDevicesInitPaths(driver, def) < 0)
|
||||
- return -1;
|
||||
-
|
||||
for (i = 0; i < def->nvideos; i++) {
|
||||
virDomainVideoDefPtr video = def->videos[i];
|
||||
|
||||
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
|
||||
index eb155b92b0..601d5cf4e9 100644
|
||||
--- a/src/qemu/qemu_tpm.c
|
||||
+++ b/src/qemu/qemu_tpm.c
|
||||
@@ -200,11 +200,15 @@ qemuTPMCreateEmulatorSocket(const char *swtpmStateDir,
|
||||
* @tpm: TPM definition for an emulator type
|
||||
* @swtpmStorageDir: the general swtpm storage dir which is used as a base
|
||||
* directory for creating VM specific directories
|
||||
+ * @logDir: directory where swtpm writes its logs into
|
||||
+ * @vmname: name of the VM
|
||||
* @uuid: the UUID of the VM
|
||||
*/
|
||||
static int
|
||||
qemuTPMEmulatorInitPaths(virDomainTPMDefPtr tpm,
|
||||
const char *swtpmStorageDir,
|
||||
+ const char *logDir,
|
||||
+ const char *vmname,
|
||||
const unsigned char *uuid)
|
||||
{
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
@@ -217,6 +221,11 @@ qemuTPMEmulatorInitPaths(virDomainTPMDefPtr tpm,
|
||||
tpm->version)))
|
||||
return -1;
|
||||
|
||||
+ if (!tpm->data.emulator.logfile) {
|
||||
+ tpm->data.emulator.logfile = qemuTPMCreateEmulatorLogPath(logDir,
|
||||
+ vmname);
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -273,7 +282,6 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir,
|
||||
*
|
||||
* @tpm: tpm definition
|
||||
* @logDir: directory where swtpm writes its logs into
|
||||
- * @vmname: name of the VM
|
||||
* @swtpm_user: uid to run the swtpm with
|
||||
* @swtpm_group: gid to run the swtpm with
|
||||
* @swtpmStateDir: directory for swtpm's persistent state
|
||||
@@ -287,7 +295,6 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir,
|
||||
static int
|
||||
qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
|
||||
const char *logDir,
|
||||
- const char *vmname,
|
||||
uid_t swtpm_user,
|
||||
gid_t swtpm_group,
|
||||
const char *swtpmStateDir,
|
||||
@@ -306,10 +313,6 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
|
||||
VIR_DIR_CREATE_ALLOW_EXIST) < 0)
|
||||
return -1;
|
||||
|
||||
- /* create logfile name ... */
|
||||
- if (!tpm->data.emulator.logfile)
|
||||
- tpm->data.emulator.logfile = qemuTPMCreateEmulatorLogPath(logDir, vmname);
|
||||
-
|
||||
if (!virFileExists(tpm->data.emulator.logfile) &&
|
||||
virFileTouch(tpm->data.emulator.logfile, 0644) < 0) {
|
||||
return -1;
|
||||
@@ -704,7 +707,10 @@ qemuExtTPMInitPaths(virQEMUDriverPtr driver,
|
||||
|
||||
switch (def->tpm->type) {
|
||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
||||
- return qemuTPMEmulatorInitPaths(def->tpm, cfg->swtpmStorageDir,
|
||||
+ return qemuTPMEmulatorInitPaths(def->tpm,
|
||||
+ cfg->swtpmStorageDir,
|
||||
+ cfg->swtpmLogDir,
|
||||
+ def->name,
|
||||
def->uuid);
|
||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||
case VIR_DOMAIN_TPM_TYPE_LAST:
|
||||
@@ -729,7 +735,7 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver,
|
||||
return -1;
|
||||
|
||||
return qemuTPMEmulatorPrepareHost(def->tpm, cfg->swtpmLogDir,
|
||||
- def->name, cfg->swtpm_user,
|
||||
+ cfg->swtpm_user,
|
||||
cfg->swtpm_group,
|
||||
cfg->swtpmStateDir, cfg->user,
|
||||
shortName);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
57
qemu_tpm-Move-logfile-path-generation-into-a-separat.patch
Normal file
57
qemu_tpm-Move-logfile-path-generation-into-a-separat.patch
Normal file
@ -0,0 +1,57 @@
|
||||
From bad37cab00ef58f11028246fd2e302f768302dba Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Thu, 25 Feb 2021 11:41:08 +0100
|
||||
Subject: [PATCH 4/6] qemu_tpm: Move logfile path generation into a separate
|
||||
function
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Strictly not needed, but the rest of paths is generated in
|
||||
separate functions. Helps with code readability.
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Signed-off-by: yezengruan <yezengruan@huawei.com>
|
||||
---
|
||||
src/qemu/qemu_tpm.c | 17 ++++++++++++++++-
|
||||
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
|
||||
index 58dfdf689a..eb155b92b0 100644
|
||||
--- a/src/qemu/qemu_tpm.c
|
||||
+++ b/src/qemu/qemu_tpm.c
|
||||
@@ -82,6 +82,21 @@ qemuTPMCreateEmulatorStoragePath(const char *swtpmStorageDir,
|
||||
}
|
||||
|
||||
|
||||
+/**
|
||||
+ * qemuTPMCreateEmulatorLogPath:
|
||||
+ * @logDir: directory where swtpm writes its logs into
|
||||
+ * @vmname: name of the VM
|
||||
+ *
|
||||
+ * Create the swtpm's log path.
|
||||
+ */
|
||||
+static char*
|
||||
+qemuTPMCreateEmulatorLogPath(const char *logDir,
|
||||
+ const char *vmname)
|
||||
+{
|
||||
+ return g_strdup_printf("%s/%s-swtpm.log", logDir, vmname);
|
||||
+}
|
||||
+
|
||||
+
|
||||
/*
|
||||
* qemuTPMEmulatorInitStorage
|
||||
*
|
||||
@@ -293,7 +308,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
|
||||
|
||||
/* create logfile name ... */
|
||||
if (!tpm->data.emulator.logfile)
|
||||
- tpm->data.emulator.logfile = g_strdup_printf("%s/%s-swtpm.log", logDir, vmname);
|
||||
+ tpm->data.emulator.logfile = qemuTPMCreateEmulatorLogPath(logDir, vmname);
|
||||
|
||||
if (!virFileExists(tpm->data.emulator.logfile) &&
|
||||
virFileTouch(tpm->data.emulator.logfile, 0644) < 0) {
|
||||
--
|
||||
2.27.0
|
||||
|
||||
48
virtpm-Fix-path-handling-in-virTPMEmulatorInit.patch
Normal file
48
virtpm-Fix-path-handling-in-virTPMEmulatorInit.patch
Normal file
@ -0,0 +1,48 @@
|
||||
From 4fe54e0e98050bf4529d67a266b6b10286312eaa Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Thu, 25 Feb 2021 11:58:38 +0100
|
||||
Subject: [PATCH 6/6] virtpm: Fix @path handling in virTPMEmulatorInit()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This function finds "swtmp", "swtpm_setup" and "swtpm_ioctl"
|
||||
binaries in $PATH and stores resolved paths in global variables
|
||||
so that they can be obtainer later. Anyway, the resolved path is
|
||||
marked as g_autofree and to avoid its freeing later on in the
|
||||
function the variable is set to NULL manually. Well, we have
|
||||
g_steal_pointer() for that.
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Signed-off-by: yezengruan <yezengruan@huawei.com>
|
||||
---
|
||||
src/util/virtpm.c | 6 ++----
|
||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/util/virtpm.c b/src/util/virtpm.c
|
||||
index c734bf941a..1a61a92f69 100644
|
||||
--- a/src/util/virtpm.c
|
||||
+++ b/src/util/virtpm.c
|
||||
@@ -325,16 +325,14 @@ virTPMEmulatorInit(void)
|
||||
_("Could not stat %s"), path);
|
||||
goto cleanup;
|
||||
}
|
||||
- *prgs[i].path = path;
|
||||
+ *prgs[i].path = g_steal_pointer(&path);
|
||||
|
||||
if (prgs[i].caps) {
|
||||
*prgs[i].caps = virTPMGetCaps(prgs[i].typeFromStringFn,
|
||||
- path, prgs[i].parm);
|
||||
- path = NULL;
|
||||
+ *prgs[i].path, prgs[i].parm);
|
||||
if (!*prgs[i].caps)
|
||||
goto cleanup;
|
||||
}
|
||||
- path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user