[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/33] qemu-iotests: add tests for runtime fd passing
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 12/33] qemu-iotests: add tests for runtime fd passing via SCM rights |
Date: |
Fri, 13 Sep 2013 13:50:42 +0200 |
From: Wenchao Xia <address@hidden>
This case will test whether the monitor can receive fd at runtime.
To verify better, additional monitor is created to see if qemu
can handler two monitor instances correctly.
Signed-off-by: Wenchao Xia <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/045 | 51 +++++++++++++++++++++++++++++++++++++++++++++-
tests/qemu-iotests/045.out | 4 ++--
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/045 b/tests/qemu-iotests/045
index 2b6f1af..6be8fc4 100755
--- a/tests/qemu-iotests/045
+++ b/tests/qemu-iotests/045
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Tests for fdsets.
+# Tests for fdsets and getfd.
#
# Copyright (C) 2012 IBM Corp.
#
@@ -125,5 +125,54 @@ class TestFdSets(iotests.QMPTestCase):
'No file descriptor supplied via SCM_RIGHTS')
self.vm.shutdown()
+# Add fd at runtime, there are two ways: monitor related or fdset related
+class TestSCMFd(iotests.QMPTestCase):
+ def setUp(self):
+ self.vm = iotests.VM()
+ qemu_img('create', '-f', iotests.imgfmt, image0, '128K')
+ # Add an unused monitor, to verify it works fine when two monitor
+ # instances present
+ self.vm.add_monitor_telnet("0",4445)
+ self.vm.launch()
+
+ def tearDown(self):
+ self.vm.shutdown()
+ os.remove(image0)
+
+ def _send_fd_by_SCM(self):
+ ret = self.vm.send_fd_scm(image0)
+ self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+
+ def test_add_fd(self):
+ self._send_fd_by_SCM()
+ result = self.vm.qmp('add-fd', fdset_id=2, opaque='image0:r')
+ self.assert_qmp(result, 'return/fdset-id', 2)
+
+ def test_getfd(self):
+ self._send_fd_by_SCM()
+ result = self.vm.qmp('getfd', fdname='image0:r')
+ self.assert_qmp(result, 'return', {})
+
+ def test_getfd_invalid_fdname(self):
+ self._send_fd_by_SCM()
+ result = self.vm.qmp('getfd', fdname='0image0:r')
+ self.assert_qmp(result, 'error/class', 'GenericError')
+ self.assert_qmp(result, 'error/desc',
+ "Parameter 'fdname' expects a name not starting with a digit")
+
+ def test_closefd(self):
+ self._send_fd_by_SCM()
+ result = self.vm.qmp('getfd', fdname='image0:r')
+ self.assert_qmp(result, 'return', {})
+ result = self.vm.qmp('closefd', fdname='image0:r')
+ self.assert_qmp(result, 'return', {})
+
+ def test_closefd_fd_not_found(self):
+ fdname = 'image0:r'
+ result = self.vm.qmp('closefd', fdname=fdname)
+ self.assert_qmp(result, 'error/class', 'GenericError')
+ self.assert_qmp(result, 'error/desc',
+ "File descriptor named '%s' not found" % fdname)
+
if __name__ == '__main__':
iotests.main(supported_fmts=['raw'])
diff --git a/tests/qemu-iotests/045.out b/tests/qemu-iotests/045.out
index 3f8a935..e56cae0 100644
--- a/tests/qemu-iotests/045.out
+++ b/tests/qemu-iotests/045.out
@@ -1,5 +1,5 @@
-......
+...........
----------------------------------------------------------------------
-Ran 6 tests
+Ran 11 tests
OK
--
1.8.1.4
- [Qemu-devel] [PULL 04/33] block: Image file option amendment, (continued)
- [Qemu-devel] [PULL 04/33] block: Image file option amendment, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 06/33] qcow2-cluster: Expand zero clusters, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 05/33] qcow2-cache: Empty cache, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 07/33] qcow2: Save refcount order in BDRVQcowState, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 01/33] qcow2: Pass discard type to qcow2_discard_clusters(), Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 02/33] qcow2: Discard VM state in active L1 after creating snapshot, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 11/33] qemu-iotests: add infrastructure of fd passing via SCM, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 10/33] qemu-iotests: add unix socket help program, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 09/33] qemu-iotest: qcow2 image option amendment, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 08/33] qcow2: Implement bdrv_amend_options, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 12/33] qemu-iotests: add tests for runtime fd passing via SCM rights,
Kevin Wolf <=
- [Qemu-devel] [PULL 13/33] qemu-iotests: New test case in 061, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 15/33] snapshot: distinguish id and name in snapshot delete, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 14/33] snapshot: new function bdrv_snapshot_find_by_id_and_name(), Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 16/33] qmp: add internal snapshot support in qmp_transaction, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 17/33] qmp: add interface blockdev-snapshot-internal-sync, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 18/33] qmp: add interface blockdev-snapshot-delete-internal-sync, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 19/33] hmp: add interface hmp_snapshot_blkdev_internal, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 20/33] hmp: add interface hmp_snapshot_delete_blkdev_internal, Kevin Wolf, 2013/09/13