1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

tests: qemuxml2argv: modernize TPM passthrough tests

All supported qemus support FD passing so modify the tests to test the
proper code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Peter Krempa 2018-08-14 13:50:01 +02:00
parent 09e45e8a9b
commit 3411fd4db4
4 changed files with 25 additions and 5 deletions

View File

@ -21,7 +21,8 @@ server,nowait \
-no-shutdown \
-boot menu=on \
-usb \
-tpmdev passthrough,id=tpm-tpm0,path=/dev/tpm0,\
cancel-path=/sys/class/misc/tpm0/device/cancel \
-tpmdev passthrough,id=tpm-tpm0,path=/dev/fdset/0,cancel-path=/dev/fdset/1 \
-add-fd set=0,fd=1730 \
-add-fd set=1,fd=1731 \
-device tpm-crb,tpmdev=tpm-tpm0,id=tpm0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

View File

@ -21,7 +21,8 @@ server,nowait \
-no-shutdown \
-boot menu=on \
-usb \
-tpmdev passthrough,id=tpm-tpm0,path=/dev/tpm0,\
cancel-path=/sys/class/misc/tpm0/device/cancel \
-tpmdev passthrough,id=tpm-tpm0,path=/dev/fdset/0,cancel-path=/dev/fdset/1 \
-add-fd set=0,fd=1730 \
-add-fd set=1,fd=1731 \
-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

View File

@ -186,7 +186,7 @@ virNetDevRunEthernetScript(const char *ifname ATTRIBUTE_UNUSED,
static void (*real_virCommandPassFD)(virCommandPtr cmd, int fd, unsigned int flags);
static const int testCommandPassSafeFDs[] = { -1 };
static const int testCommandPassSafeFDs[] = { 1730, 1731 };
void
virCommandPassFD(virCommandPtr cmd,
@ -247,3 +247,19 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev ATTRIBUTE_UNUSED)
abort();
return 1729;
}
int
qemuBuildTPMOpenBackendFDs(const char *tpmdev ATTRIBUTE_UNUSED,
const char *cancel_path ATTRIBUTE_UNUSED,
int *tpmfd,
int *cancelfd)
{
if (fcntl(1730, F_GETFD) != -1 ||
fcntl(1731, F_GETFD) != -1)
abort();
*tpmfd = 1730;
*cancelfd = 1731;
return 0;
}

View File

@ -2118,8 +2118,10 @@ mymain(void)
QEMU_CAPS_KVM);
DO_TEST("tpm-passthrough",
QEMU_CAPS_ADD_FD,
QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
DO_TEST("tpm-passthrough-crb",
QEMU_CAPS_ADD_FD,
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);