From 80154bb3eaa603ce5a21592bccf5d11da0f2ebfe Mon Sep 17 00:00:00 2001 From: Yanan Fu Date: Fri, 14 Feb 2020 15:15:28 +0800 Subject: [PATCH] virtio_serial: accept specified chardev_path and serial_name Some test need use specified chardev_path and serial_name for testing, make it accept these definiation. If it is not defined, use the default value that generated by the test framework. Signed-off-by: Yanan Fu --- virttest/qemu_vm.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/virttest/qemu_vm.py b/virttest/qemu_vm.py index 51ba849686..de88b458f6 100644 --- a/virttest/qemu_vm.py +++ b/virttest/qemu_vm.py @@ -1756,8 +1756,14 @@ def sort_key(dev): 5000, 5899, len(serials), host) reg_count = 0 for index, serial in enumerate(serials): - serial_filename = vm.get_serial_console_filename(serial) serial_params = params.object_params(serial) + serial_filename = serial_params.get('chardev_path') + if serial_filename: + serial_dirname = os.path.dirname(serial_filename) + if not os.path.isdir(serial_dirname): + os.makedirs(serial_dirname) + else: + serial_filename = vm.get_serial_console_filename(serial) # Workaround for console issue, details: # http://lists.gnu.org/archive/html/qemu-ppc/2013-10/msg00129.html if 'ppc' in params.get('vm_arch_name', arch.ARCH)\ @@ -1771,9 +1777,11 @@ def sort_key(dev): serial_params['chardev_host'] = host serial_params['chardev_port'] = free_ports[index] prefix = serial_params.get('virtio_port_name_prefix') - serial_name = prefix + str(len(self.virtio_ports))\ - if prefix else serial - serial_params['serial_name'] = serial_name + serial_name = serial_params.get('serial_name') + if not serial_name: + serial_name = prefix + str(len(self.virtio_ports))\ + if prefix else serial + serial_params['serial_name'] = serial_name serial_devices = devices.serials_define_by_params( serial, serial_params, serial_filename)