]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemuxml2argv: modernize TPM passthrough tests
authorPeter Krempa <pkrempa@redhat.com>
Tue, 14 Aug 2018 11:50:01 +0000 (13:50 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 24 Aug 2018 13:58:34 +0000 (15:58 +0200)
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>
tests/qemuxml2argvdata/tpm-passthrough-crb.args
tests/qemuxml2argvdata/tpm-passthrough.args
tests/qemuxml2argvmock.c
tests/qemuxml2argvtest.c

index 8c73bc6706b41d995b9332710aedb6ab236cfb48..4da8be1a73a3fa3df0058da08c0707c20a3ea3b0 100644 (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
index d4dd371f0614975ceba666e510ad74bc138d3d89..8ab7693009840f88dd28dc555ee966ef5564af51 100644 (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
index 581f7202278eed7c464e10cd6790b3aba7db57d8..4b4a6f764f67919d1907e02825ed10bcc69f6eb5 100644 (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;
+}
index 82b5b7bbeac6d6d336fc9a7743a974f51d3873d0..06b62b91aeb05d62802ec0f0a36ba0e07be351b8 100644 (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);