1 # Test for multiprocess qemu
3 # This work is licensed under the terms of the GNU GPL, version 2 or
4 # later. See the COPYING file in the top-level directory.
10 from avocado_qemu
import Test
11 from avocado_qemu
import wait_for_console_pattern
12 from avocado_qemu
import exec_command
13 from avocado_qemu
import exec_command_and_wait_for_pattern
15 class Multiprocess(Test
):
17 :avocado: tags=multiprocess
19 KERNEL_COMMON_COMMAND_LINE
= 'printk.time=0 '
21 def do_test(self
, kernel_url
, initrd_url
, kernel_command_line
,
23 """Main test method"""
24 self
.require_accelerator('kvm')
26 # Create socketpair to connect proxy and remote processes
27 proxy_sock
, remote_sock
= socket
.socketpair(socket
.AF_UNIX
,
29 os
.set_inheritable(proxy_sock
.fileno(), True)
30 os
.set_inheritable(remote_sock
.fileno(), True)
32 kernel_path
= self
.fetch_asset(kernel_url
)
33 initrd_path
= self
.fetch_asset(initrd_url
)
35 # Create remote process
36 remote_vm
= self
.get_vm()
37 remote_vm
.add_args('-machine', 'x-remote')
38 remote_vm
.add_args('-nodefaults')
39 remote_vm
.add_args('-device', 'lsi53c895a,id=lsi1')
40 remote_vm
.add_args('-object', 'x-remote-object,id=robj1,'
41 'devid=lsi1,fd='+str(remote_sock
.fileno()))
44 # Create proxy process
46 self
.vm
.add_args('-machine', machine_type
)
47 self
.vm
.add_args('-accel', 'kvm')
48 self
.vm
.add_args('-cpu', 'host')
49 self
.vm
.add_args('-object',
50 'memory-backend-memfd,id=sysmem-file,size=2G')
51 self
.vm
.add_args('--numa', 'node,memdev=sysmem-file')
52 self
.vm
.add_args('-m', '2048')
53 self
.vm
.add_args('-kernel', kernel_path
,
54 '-initrd', initrd_path
,
55 '-append', kernel_command_line
)
56 self
.vm
.add_args('-device',
58 'id=lsi1,fd='+str(proxy_sock
.fileno()))
60 wait_for_console_pattern(self
, 'as init process',
61 'Kernel panic - not syncing')
62 exec_command(self
, 'mount -t sysfs sysfs /sys')
63 exec_command_and_wait_for_pattern(self
,
64 'cat /sys/bus/pci/devices/*/uevent',
67 def test_multiprocess_x86_64(self
):
69 :avocado: tags=arch:x86_64
71 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
72 '/linux/releases/31/Everything/x86_64/os/images'
74 initrd_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
75 '/linux/releases/31/Everything/x86_64/os/images'
76 '/pxeboot/initrd.img')
77 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
78 'console=ttyS0 rdinit=/bin/bash')
80 self
.do_test(kernel_url
, initrd_url
, kernel_command_line
, machine_type
)
82 def test_multiprocess_aarch64(self
):
84 :avocado: tags=arch:aarch64
86 kernel_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
87 '/linux/releases/31/Everything/aarch64/os/images'
89 initrd_url
= ('https://archives.fedoraproject.org/pub/archive/fedora'
90 '/linux/releases/31/Everything/aarch64/os/images'
91 '/pxeboot/initrd.img')
92 kernel_command_line
= (self
.KERNEL_COMMON_COMMAND_LINE
+
93 'rdinit=/bin/bash console=ttyAMA0')
94 machine_type
= 'virt,gic-version=3'
95 self
.do_test(kernel_url
, initrd_url
, kernel_command_line
, machine_type
)