All my computer CPUs are Intel, but it doesn't look like the type of
the CPU matters. The qemu application locks up even with an emulated
CPU. The Linux kernel seems to make a difference.

Here a script I use for testing:

----------------------------------------------
BB_HD_FS='ext4'
BB_HD_FILE="rootfs.$BB_HD_FS"
BB_HD_SIZE='2G'
BB_DISTRIBUTION='unstable'
BB_TAR_FILE='rootfs.tar'

mmdebstrap \
    --variant        minbase \
    --include        linux-image-amd64 \
    --include        dbus \
    --include        qemu-system-x86 \
    --include        systemd-resolved \
    --include        systemd-sysv \
    --customize-hook "printf
'[Match]\\nName=en*\\n[Network]\\nDHCP=yes\\n' >
\$1/etc/systemd/network/20-wired.network" \
    --customize-hook 'chroot $1 systemctl enable systemd-networkd' \
    --customize-hook 'chroot $1 passwd -d root' \
    --customize-hook 'copy-out /boot .' \
    "$BB_DISTRIBUTION" \
    "$BB_TAR_FILE"

/usr/sbin/mke2fs -d "$BB_TAR_FILE" -t "$BB_HD_FS" "$BB_HD_FILE" "$BB_HD_SIZE"

qemu-system-x86_64 \
    -nodefaults \
    -no-user-config \
    -nographic \
    -m      2G \
    -serial mon:stdio \
    -kernel boot/vmlinuz-* \
    -initrd boot/initrd.img-* \
    -append 'console=ttyS0,115200 root=/dev/vda rw' \
    -drive  format=raw,file="$BB_HD_FILE",if=virtio,cache=unsafe \
    -nic    user
----------------------------------------------

If I change BB_DISTRIBUTION to 'stable', everything works fine, even
with qemu version 9.0.2 from backports. When I chroot into a stable
root filesystem, 7.2.11 works, but 9.0.2 locks up. The only difference
is the kernel, which is the latest 'unstable' kernel:

$ uname -a
Linux hostname 6.10.4-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.10.4-1
(2024-08-12) x86_64 GNU/Linux


When I run qemu with strace I receive the following messages:

...
[pid 79820] access("/var/run/qemu/Debian_1_9.0.2+ds-4/audio-sdl.so",
F_OK) = -1 ENOENT (No such file or directory)
[pid 79820] mmap(NULL, 528384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f784f25d000
[pid 79820] sysinfo({uptime=9691, loads=[18144, 13152, 20160],
totalram=16691961856, freeram=12934176768, sharedram=36306944, buffe
[pid 79820] mmap(NULL, 1073741824, PROT_NONE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7808000000
[pid 79820] madvise(0x7f7808000000, 1073741824, MADV_HUGEPAGE) = 0
[pid 79820] mprotect(0x7f7808000000, 1073737728,
PROT_READ|PROT_WRITE|PROT_EXEC) = 0
[pid 79820] rt_sigprocmask(SIG_BLOCK, [CHLD], [BUS USR1 ALRM IO], 8) = 0
[pid 79820] access("/usr/bin/qemu-bundle", R_OK) = -1 ENOENT (No such
file or directory)
[pid 79820] socketpair(AF_UNIX, SOCK_STREAM, 0, [3, 8]) = 0
[pid 79820] clone(child_stack=NULL,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process
79822 attached
, child_tidptr=0x7f784f9901d0) = 79822
[pid 79822] set_robust_list(0x7f784f9901e0, 24 <unfinished ...>
[pid 79820] close(8 <unfinished ...>
[pid 79822] <... set_robust_list resumed>) = 0
[pid 79820] <... close resumed>)        = 0
[pid 79820] recvmsg(3,  <unfinished ...>
[pid 79822] prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1073741816,
rlim_max=1073741816}) = 0
[pid 79822] close(3)                    = 0
[pid 79822] close(4)                    = 0
[pid 79822] close(5)                    = 0
[pid 79822] close(6)                    = 0
[pid 79822] close(7)                    = 0
[pid 79822] close(9)                    = -1 EBADF (Bad file descriptor)
[pid 79822] close(10)                   = -1 EBADF (Bad file descriptor)
[pid 79822] close(11)                   = -1 EBADF (Bad file descriptor)
[pid 79822] close(12)                   = -1 EBADF (Bad file descriptor)
[pid 79822] close(13)                   = -1 EBADF (Bad file descriptor)
[pid 79822] close(14)                   = -1 EBADF (Bad file descriptor)
...
[pid 79822] close(45485)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45486)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45487)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45488)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45489)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45490)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45491)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45492)                = -1 EBADF (Bad file descriptor)
[pid 79822] close(45493)                = -1 EBADF (Bad file descriptor)
... forever

On Sat, Aug 17, 2024 at 11:35 PM Michael Tokarev <m...@tls.msk.ru> wrote:
>
> 17.08.2024 15:33, bblinux wrote:
> > Here is a way I tried to replicate in a more isolated environment:
> >
> > # mmdebstrap --variant minbase --include qemu-system-x86 unstable
> > rootfs-unstable
> > # chroot rootfs-unstable
> > (chroot)# qemu-system-x86_64 --version
> > QEMU emulator version 9.0.2 (Debian 1:9.0.2+ds-4)
> > Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
> > (chroot)# qemu-system-x86_64 -netdev bridge,id=n1
> > - Locks up
>
> It works (or fails) for me exactly as per your "stable" variant:
>
> /tmp# mmdebstrap --variant minbase --include qemu-system-x86 unstable sid
> I: automatically chosen mode: root
> I: chroot architecture amd64 is equal to the host's architecture
> ...
> I: success in 9.3555 seconds
> /tmp# chroot sid
> /# qemu-system-x86_64 -netdev bridge,id=n1
> failed to parse default acl file `/etc/qemu/bridge.conf'
> qemu-system-x86_64: -netdev bridge,id=n1: bridge helper failed
> /# qemu-system-x86_64 -netdev tap,id=n1
> qemu-system-x86_64: -netdev tap,id=n1: could not open /dev/net/tun: No such 
> file or directory
> /#
> exit
> /tmp# cd sid
> /tmp/sid# mount --bind /dev dev
> /tmp/sid# chroot .
> /# qemu-system-x86_64 -netdev tap,id=n1
> W: /etc/qemu-ifup: not doing any bridge processing: neither ip nor brctl 
> utility not found
> qemu-system-x86_64: warning: netdev n1 has no peer
> VNC server running on 127.0.0.1:5900
> ^C
>
> >
> > # mmdebstrap --variant minbase --include qemu-system-x86 stable 
> > rootfs-stable
> > # chroot rootfs-stable
> > (chroot)# qemu-system-x86_64 --version
> > QEMU emulator version 7.2.11 (Debian 1:7.2+dfsg-7+deb12u6)
> > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> > (chroot)# qemu-system-x86_64 -netdev bridge,id=n1
> > qemu: module ui-ui-gtk not found, do you want to install
> > qemu-system-gui package?
> > qemu: module ui-ui-sdl not found, do you want to install
> > qemu-system-gui package?
> > failed to parse default acl file `/etc/qemu/bridge.conf'
> > qemu-system-x86_64: -netdev bridge,id=n1: bridge helper failed
> > - The error is expected
>
> Yes, this is what I see for stable as well.  And exactly the same happens
> for unstable too.
>
> There's one significant difference between our systems though: you run
> Linux 6.10.3-amd64 while mine is 6.1.0-23-amd64.  Lemme try 6.10.3 too..
>
> ..nope, with 6.10.3 it works exactly the same way.  Works fine with bridge
> or tap network.
>
> Please run your hanging qemu under strace (strace -f) and see what it is
> doing.
>
> This is a very basic networking setup - maybe not bridge directly, but
> tap is for *sure*, it is the most common setup used by many people.  If
> this problem were common, it would be reported very loudly already, by
> multiple people.  So far, it only affects your system(s).  I'm just
> thinking out loud, trying to collect what we know.
>
> BTW, what's your CPU?  It looks like I don't have machine with an Intel
> CPU around anymore (where I can experiment with the kernel anyway).
>
> Thanks,
>
> /mjt

Reply via email to