On 2022-03-09 11:23, Maximilian Engelhardt wrote:
> What I noticed after booting the autopkgtest image is the following:
>
> ttyAMA0 inside the vm is ttyS0 outside
> hvc0 inside the vm is hvc1 outside
> hcv1 inside the vm is hvc2 outside
> hvc0 outside the vm doesn't seem to do anything
>
> So that's the problem, the hvc console numbers are all shifted by one. If you
> leave out hvc2 in the qemu command line (to get the same as done by
> autopkgtest), then hcv1 inside the vm does not exist: "No such device".
Based on this observation from Maximilian I've tried the following, which seems
to address the issue on arm64. Patch is also attached.
diff --git a/lib/autopkgtest_qemu.py b/lib/autopkgtest_qemu.py
index f958e0f..0cf307d 100644
--- a/lib/autopkgtest_qemu.py
+++ b/lib/autopkgtest_qemu.py
@@ -206,7 +206,7 @@ class Qemu:
subdirectory of $TMPDIR)
"""
- self.consoles = set(['hvc0', 'hvc1'])
+ self.consoles = set(['hvc0', 'hvc1', 'hvc2'])
self.cpus = cpus
self.images = [] # type: List[QemuImage]
self.overlay_dir = overlay_dir
@@ -359,7 +359,7 @@ class Qemu:
) % self.shareddir,
])
- for hvc in ('hvc0', 'hvc1'):
+ for hvc in self.consoles:
if hvc == 'hvc0' and self.qemu_architecture == 'ppc64le':
# The first -serial argument shows up as /dev/hvc0 in
# the VM on ppc64le, so identify it as such
diff --git a/virt/autopkgtest-virt-qemu b/virt/autopkgtest-virt-qemu
index 2b5b3fe..a92cee5 100755
--- a/virt/autopkgtest-virt-qemu
+++ b/virt/autopkgtest-virt-qemu
@@ -151,7 +151,7 @@ def setup_shell() -> str:
user = args.user
password = args.password
- for name in ('hvc1', 'ttyS1'):
+ for name in ('hvc1', 'ttyS1', 'hvc2'):
# if the VM is already prepared to start a root shell on ttyS1, just
use it
if name not in qemu.consoles:
continue
Here's what the debug logs have to say. Note that the shell is found on
hvc2:
autopkgtest [17:10:10]: starting date: 2022-10-13
autopkgtest [17:10:10]: version 5.26
autopkgtest [17:10:10]: host ariel; command line: /usr/bin/autopkgtest -- qemu
-d --cpus=2 --qemu-architecture=aarch64 /var/tmp/autopkgtest-unstable-arm64.img
autopkgtest-virt-qemu: DBG: executing open
autopkgtest-virt-qemu: DBG: find_free_port: trying 10022
autopkgtest-virt-qemu: DBG: find_free_port: 10022 is free
autopkgtest-virt-qemu: DBG: qemu architecture: aarch64
[...]
autopkgtest-virt-qemu: DBG: full qemu command-line: ['qemu-system-aarch64',
'-machine', 'virt', '-cpu', 'cortex-a53', '-m', '1024', '-smp', '2',
'-nographic', '-net', 'nic,model=virtio', '-net',
'user,hostfwd=tcp:127.0.0.1:10022-:22', '-object',
'rng-random,filename=/dev/urandom,id=rng0', '-device',
'virtio-rng-pci,rng=rng0,id=rng-device0', '-monitor',
'unix:/tmp/autopkgtest-qemu.bkj2lum4/monitor,server=on,wait=off', '-virtfs',
'local,id=autopkgtest,path=/tmp/autopkgtest-qemu.bkj2lum4/shared,security_model=none,mount_tag=autopkgtest',
'-chardev',
'socket,path=/tmp/autopkgtest-qemu.bkj2lum4/hvc0,server=on,wait=off,id=hvc0',
'-device', 'virtio-serial', '-device', 'virtconsole,chardev=hvc0', '-chardev',
'socket,path=/tmp/autopkgtest-qemu.bkj2lum4/hvc2,server=on,wait=off,id=hvc2',
'-device', 'virtio-serial', '-device', 'virtconsole,chardev=hvc2', '-chardev',
'socket,path=/tmp/autopkgtest-qemu.bkj2lum4/hvc1,server=on,wait=off,id=hvc1',
'-device', 'virtio-serial', '-device', 'virtconsole,chardev=hvc1', '-serial',
'unix:/tmp/autopkgtest-qemu.bkj2lum4/ttyS0,server=on,wait=off', '-drive',
'index=0,file=/tmp/autopkgtest-qemu.bkj2lum4/overlay.img,cache=unsafe,if=virtio,discard=unmap,format=qcow2',
'-drive',
'if=pflash,format=raw,unit=0,read-only=on,file=/usr/share/AAVMF/AAVMF_CODE.fd',
'-drive',
'if=pflash,format=raw,unit=1,file=/tmp/autopkgtest-qemu.bkj2lum4/efivars.fd']
autopkgtest-virt-qemu: DBG: expect: b' login: '
autopkgtest-virt-qemu: DBG: expect: found "'login prompt on serial console'"
autopkgtest-virt-qemu: DBG: expect: b'ok'
autopkgtest-virt-qemu: DBG: expect: b'ok'
autopkgtest-virt-qemu: DBG: expect: found "b'ok'"
autopkgtest-virt-qemu: DBG: setup_shell(): there already is a shell on hvc2
diff --git a/lib/autopkgtest_qemu.py b/lib/autopkgtest_qemu.py
index f958e0f..0cf307d 100644
--- a/lib/autopkgtest_qemu.py
+++ b/lib/autopkgtest_qemu.py
@@ -206,7 +206,7 @@ class Qemu:
subdirectory of $TMPDIR)
"""
- self.consoles = set(['hvc0', 'hvc1'])
+ self.consoles = set(['hvc0', 'hvc1', 'hvc2'])
self.cpus = cpus
self.images = [] # type: List[QemuImage]
self.overlay_dir = overlay_dir
@@ -359,7 +359,7 @@ class Qemu:
) % self.shareddir,
])
- for hvc in ('hvc0', 'hvc1'):
+ for hvc in self.consoles:
if hvc == 'hvc0' and self.qemu_architecture == 'ppc64le':
# The first -serial argument shows up as /dev/hvc0 in
# the VM on ppc64le, so identify it as such
diff --git a/virt/autopkgtest-virt-qemu b/virt/autopkgtest-virt-qemu
index 2b5b3fe..a92cee5 100755
--- a/virt/autopkgtest-virt-qemu
+++ b/virt/autopkgtest-virt-qemu
@@ -151,7 +151,7 @@ def setup_shell() -> str:
user = args.user
password = args.password
- for name in ('hvc1', 'ttyS1'):
+ for name in ('hvc1', 'ttyS1', 'hvc2'):
# if the VM is already prepared to start a root shell on ttyS1, just use it
if name not in qemu.consoles:
continue