mirror of https://gitee.com/openkylin/libvirt.git
tests: Add test cases for external swtpm TPM emulator
This patch adds extensions to existing test cases and specific test cases for the tpm-emulator. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
69122bc2f1
commit
f264df2d9e
|
@ -0,0 +1,32 @@
|
|||
LC_ALL=C \
|
||||
PATH=/bin \
|
||||
HOME=/home/test \
|
||||
USER=test \
|
||||
LOGNAME=test \
|
||||
QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-system-x86_64 \
|
||||
-name guest=TPM-VM,debug-threads=on \
|
||||
-S \
|
||||
-object secret,id=masterKey0,format=raw,\
|
||||
file=/tmp/lib/domain--1-TPM-VM/master-key.aes \
|
||||
-machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
|
||||
-m 2048 \
|
||||
-realtime mlock=off \
|
||||
-smp 1,sockets=1,cores=1,threads=1 \
|
||||
-uuid 11d7cd22-da89-3094-6212-079a48a309a1 \
|
||||
-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 \
|
||||
-boot menu=on,strict=on \
|
||||
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
|
||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||
-chardev socket,id=chrtpm,path=/dev/test \
|
||||
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 \
|
||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
-msg timestamp=on
|
|
@ -548,6 +548,19 @@ testCompareXMLToArgv(const void *data)
|
|||
vsockPriv->vhostfd = 6789;
|
||||
}
|
||||
|
||||
if (vm->def->tpm) {
|
||||
switch (vm->def->tpm->type) {
|
||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
||||
if (VIR_STRDUP(vm->def->tpm->data.emulator.source.data.file.path,
|
||||
"/dev/test") < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||
case VIR_DOMAIN_TPM_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI,
|
||||
(flags & FLAG_FIPS), false,
|
||||
VIR_QEMU_PROCESS_START_COLD))) {
|
||||
|
@ -2025,7 +2038,7 @@ mymain(void)
|
|||
QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_CRB);
|
||||
DO_TEST_PARSE_ERROR("tpm-no-backend-invalid",
|
||||
QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
|
||||
|
||||
DO_TEST_CAPS_LATEST("tpm-emulator");
|
||||
|
||||
DO_TEST_PARSE_ERROR("pci-domain-invalid", NONE);
|
||||
DO_TEST_PARSE_ERROR("pci-bus-invalid", NONE);
|
||||
|
|
Loading…
Reference in New Issue