Skip to contentSkip to conversation

Hang when using 9p mounts after last Seabios update

Qemu-devel Daniel P. Berrange 4 participants 6 messages Sep 22, 2011 – Oct 11, 2011

lore
Share & tools
lore
#0 lore raw

I'm doing some experimentation with application sandboxing and running QEMU with the following command line:

  exec $QEMU \
    -m 64 \
    -nographic \
    -nodefconfig \
    -nodefaults \
    -kernel ./kernel-2.6.40.4-5.fc15.x86_64 \
    -initrd ./initrd-2.6.40.4-5.fc15.x86_64 \
    -append 'init=/bin/sh console=ttyS0 debug' \
    -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/ \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=org.virttools.sandbox:/ \
    -serial stdio

On 0.14, 0.15 releaes, this all works just fine. On current GIT master, the guest OS will hang during boot.

The hang always appears to occur when attempting to mount the *last* virtio9p filesystem exported to the guest.

ie, in the above command line it hangs when mounting the root. If I passthrough 2 more directories, eg

    -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/custom-home \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=org.virttools.sandbox:/home \
    -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/custom-tmp \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=org.virttools.sandbox:/tmp \

then it will hang on the 3rd mount

[    0.798208] virtio-pci 0000:00:05.0: irq 45 for MSI/MSI-X

virt-sandbox-init: insmod /lib/modules/kernel/drivers/net/virtio_net.ko
virt-sandbox-init: insmod /lib/modules/kernel/drivers/virtio/virtio_balloon.ko
virt-sandbox-init: mounting new root on /tmproot
virt-sandbox-init: org.virttools.sandbox:/ -> /tmproot
virt-sandbox-init: chroot
virt-sandbox-init: /dev (tmpfs)
virt-sandbox-init: /dev/pts (devpts)
virt-sandbox-init: /root (tmpfs)
virt-sandbox-init: /sys (sysfs)
virt-sandbox-init: /proc (proc)
virt-sandbox-init: /selinux (selinuxfs)
virt-sandbox-init: org.virttools.sandbox:/home -> /home
virt-sandbox-init: org.virttools.sandbox:/tmp -> /tmp

[    1.036163] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input2

..hang...

Now the really wierd thing.... if I add certain extra PCI device onto the QEMU command line after all of the 9p filesystem devices, then the hang goes away. Specifically adding '-vga std' or '-device e1000' stops it hanging. Adding '-device virtio-balloon' or '-device i6300esb' does not prevent the hang.

I bisected the problem in QEMU master to this change which pulls in a new SeaBios:

commit d67c3f2cd92aed2247bfa8a9da61a902b7b2ff09
Author: Gerd Hoffmann <[email protected]>
Date: Wed Aug 10 17:34:13 2011 +0200

seabios: update to master

commit 8e301472e324b6d6496d8b4ffc66863e99d7a505

user visible changes in seabios:
* ahci is enabled by default (and thus in this build).
* bootorder support for ahci.
* two-pass pci allocator (orders bars by size for better packing).

I further bisected SeaBios between their 0.6.2 release and the changeset mentioned above, and got to this changeset in SeaBios:

commit 01a5c8813b2e709809c07c5d7fab9d1c3ddb4989
Author: Gerd Hoffmann <[email protected]>
Date: Mon Jul 11 09:20:29 2011 +0200

pci: activate two-pass pci initialization code

This patch actually enables the two-pass pci initialization and deactivates the old pci initialization bits.

Before this changeset everything works fine, after it, i get a hang on 9p mounts.

To reproduce this you will need my custom initrd for mounting 9p filesystems as the root FS. You can get that here:

http://berrange.com/~dan/qemu-serial-hang-demo.tar.gz

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#1 lore raw
Quoted 17 lines · Daniel P. Berrange

I'm doing some experimentation with application sandboxing and running QEMU with the following command line:

  exec $QEMU \
    -m 64 \
    -nographic \
    -nodefconfig \
    -nodefaults \
    -kernel ./kernel-2.6.40.4-5.fc15.x86_64 \
    -initrd ./initrd-2.6.40.4-5.fc15.x86_64 \
    -append 'init=/bin/sh console=ttyS0 debug' \
    -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/ \
    -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=org.virttools.sandbox:/ \
    -serial stdio

On 0.14, 0.15 releaes, this all works just fine. On current GIT master, the guest OS will hang during boot.

[...]

Quoted 7 lines

I further bisected SeaBios between their 0.6.2 release and the changeset mentioned above, and got to this changeset in SeaBios:

commit 01a5c8813b2e709809c07c5d7fab9d1c3ddb4989
Author: Gerd Hoffmann <[email protected]>
Date: Mon Jul 11 09:20:29 2011 +0200

Gerd, any thoughts on what could cause this?

-Kevin

#2 lore raw
In reply to Daniel P. Berrange
Quoted 2 lines · Daniel P. Berrange

On 0.14, 0.15 releaes, this all works just fine. On current GIT master, the guest OS will hang during boot.

[...]

Quoted 4 lines

To reproduce this you will need my custom initrd for mounting 9p filesystems as the root FS. You can get that here:

http://berrange.com/~dan/qemu-serial-hang-demo.tar.gz

Thanks for the detailed report.

I've confirmed the issue and tracked it down. The current SeaBIOS code gets confused during alignment checking if there are no prefmem regions found.

The patch below should fix the issue.

Richard, can you also check to see if this seabios patch fixes your issue?

-Kevin

Author: Kevin O'Connor <[email protected]>
Date:   Sat Oct 1 12:35:32 2011 -0400

Fix alignment bug in pci_bios_init_root_regions().

If there are no memory allocations for a given type then the "max" bar size is zero. However, ALIGN_DOWN does not handle an alignment of zero properly. Catch and handle the zero case.

src/pciinit.c +1 -1
index a857da0..0d8758e 100644
@@ -536,7 +536,7 @@ static void pci_bios_init_bus_bases(struct pci_bus *bus)
     }
 }
 
-#define ROOT_BASE(top, sum, align) ALIGN_DOWN((top)-(sum),(align))
+#define ROOT_BASE(top, sum, max) ALIGN_DOWN((top)-(sum),(max) ?: 1)
 
 static int pci_bios_init_root_regions(u32 start, u32 end)
 {
#3 lore raw
Quoted 11 lines · Kevin O'Connor
Quoted 2 lines · Daniel P. Berrange

On 0.14, 0.15 releaes, this all works just fine. On current GIT master, the guest OS will hang during boot.

[...]

Quoted 4 lines

To reproduce this you will need my custom initrd for mounting 9p filesystems as the root FS. You can get that here:

http://berrange.com/~dan/qemu-serial-hang-demo.tar.gz

Thanks for the detailed report.

Quoted 8 lines

I've confirmed the issue and tracked it down. The current SeaBIOS code gets confused during alignment checking if there are no prefmem regions found.

The patch below should fix the issue.

Richard, can you also check to see if this seabios patch fixes your issue?

Yes, I can confirm that this fixes the issue.

What I did to test this:

- tried my boot test, and it failed as before

- git clone git://git.linuxtogo.org/home/kevin/seabios.git

- noticed that this patch is already applied to git

- make clean; make

- cp out/bios.bin ../qemu/pc-bios/bios.bin

- repeated my boot test, and it was successful

Thanks!

Rich.

Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
#4 lore raw
In reply to Kevin O'Connor
Quoted 9 lines · Kevin O'Connor
Quoted 2 lines · Daniel P. Berrange

On 0.14, 0.15 releaes, this all works just fine. On current GIT master, the guest OS will hang during boot.

[...]

Quoted 4 lines

To reproduce this you will need my custom initrd for mounting 9p filesystems as the root FS. You can get that here:

http://berrange.com/~dan/qemu-serial-hang-demo.tar.gz

Quoted 7 lines

Thanks for the detailed report.

I've confirmed the issue and tracked it down. The current SeaBIOS code gets confused during alignment checking if there are no prefmem regions found.

The patch below should fix the issue.

Thanks, I have tested Seabios 1.6.3 which includes that patch, and can confirm that it does fix the hang I saw.

Anthony/Gerd: we can get QEMU master updated to Seabios 1.6.3 before the 1.0 release ?

Quoted 16 lines
Author: Kevin O'Connor <[email protected]>
Date:   Sat Oct 1 12:35:32 2011 -0400

Fix alignment bug in pci_bios_init_root_regions().

If there are no memory allocations for a given type then the "max" bar size is zero. However, ALIGN_DOWN does not handle an alignment of zero properly. Catch and handle the zero case.

src/pciinit.c +0 -0
index a857da0..0d8758e 100644

src/pciinit.c static void pci_bios_init_bus_bases(struct pci_bus *bus) · line 542

Quoted 8 lines
src/pciinit.c +1 -1
@@ -536,7 +536,7 @@ static void pci_bios_init_bus_bases(struct pci_bus *bus)
     }
 }
 
-#define ROOT_BASE(top, sum, align) ALIGN_DOWN((top)-(sum),(align))
+#define ROOT_BASE(top, sum, max) ALIGN_DOWN((top)-(sum),(max) ?: 1)
 
 static int pci_bios_init_root_regions(u32 start, u32 end)
 {

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#5 lore raw
Quoted 41 lines · Daniel P. Berrange
Quoted 7 lines · Kevin O'Connor
Quoted 2 lines · Daniel P. Berrange

On 0.14, 0.15 releaes, this all works just fine. On current GIT master, the guest OS will hang during boot.

[...]

Quoted 3 lines

To reproduce this you will need my custom initrd for mounting 9p filesystems as the root FS. You can get that here:

Quoted 8 lines
Quoted 1 line

http://berrange.com/~dan/qemu-serial-hang-demo.tar.gz

Thanks for the detailed report.

I've confirmed the issue and tracked it down. The current SeaBIOS code gets confused during alignment checking if there are no prefmem regions found.

The patch below should fix the issue.

Thanks, I have tested Seabios 1.6.3 which includes that patch, and can confirm that it does fix the hang I saw.

Anthony/Gerd: we can get QEMU master updated to Seabios 1.6.3 before the 1.0 release ?

Quoted 19 lines
Author: Kevin O'Connor<[email protected]>
Date:   Sat Oct 1 12:35:32 2011 -0400

Fix alignment bug in pci_bios_init_root_regions().

If there are no memory allocations for a given type then the "max" bar size is zero. However, ALIGN_DOWN does not handle an alignment of zero properly. Catch and handle the zero case.

src/pciinit.c +0 -0
index a857da0..0d8758e 100644
@@ -536,7 +536,7 @@ static void pci_bios_init_bus_bases(struct pci_bus *bus)
      }
  }
 
Quoted 2 lines

src/pciinit.c static void pci_bios_init_bus_bases(struct pci_bus *bus) · line 539

Quoted 2 lines
src/pciinit.c +1 -1
-#define ROOT_BASE(top, sum, align) ALIGN_DOWN((top)-(sum),(align))
+#define ROOT_BASE(top, sum, max) ALIGN_DOWN((top)-(sum),(max) ?: 1)

Hello,

This is adding a GNUism, can this be: (max)?(max):1

Thanks

Chris

Quoted 5 lines

src/pciinit.c static void pci_bios_init_bus_bases(struct pci_bus *bus) · line 542

Quoted 3 lines
src/pciinit.c +0 -0
  static int pci_bios_init_root_regions(u32 start, u32 end)
  {

Regards,
Daniel