qemu -drive boot=on flag causes boot to hang.

Bug #591423 reported by Mike Mestnik
28
This bug affects 5 people
Affects Status Importance Assigned to Milestone
libvirt
Invalid
Undecided
Unassigned
qemu-kvm
Fix Released
Undecided
Unassigned
libvirt (Ubuntu)
Invalid
Medium
Unassigned

Bug Description

Binary package hint: qemu-kvm

I'm working on getting a UI to start qemu. In debugging I am working exclusively on the command line. I'm able to reproduce and correct this bug from the command line. The UI is libvirt.

The testing I did was to remove part of the command each part at a time and add it back in until I discovered the one option that caused the problem.

This command boot's just fine.
/usr/bin/qemu -snapshot -M pc-0.12 -no-kvm -m 1024 -smp 1 -localtime -boot c -drive file=/dev/sda,if=ide,index=0 -serial none -parallel none -usb -usbdevice tablet -vga cirrus

These commands do not:
/usr/bin/qemu -snapshot -M pc-0.12 -no-kvm -m 1024 -smp 1 -localtime -boot c -drive file=/dev/sda,if=ide,index=0,boot=on -serial none -parallel none -usb -usbdevice tablet -vga cirrus
/usr/bin/qemu -snapshot -M pc-0.12 -no-kvm -m 1024 -smp 1 -localtime -drive file=/dev/sda,if=ide,index=0,boot=on -serial none -parallel none -usb -usbdevice tablet -vga cirrus
/usr/bin/qemu -snapshot -boot c -drive file=/dev/sda,boot=on
/usr/bin/qemu -snapshot -drive file=/dev/sda,boot=on
/usr/bin/qemu -boot c -drive file=/dev/sda,boot=on
/usr/bin/qemu -drive file=/dev/sda,boot=on

The boot hangs presumably when the BIOS passes control to the MBR or during the MBR load, ect, ect, ect. In other words the BIOS parts seam to work, except it never boots anything.

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: qemu 0.12.3+noroms-0ubuntu9
ProcVersionSignature: Ubuntu 2.6.32-22.33-generic-pae 2.6.32.11+drm33.2
Uname: Linux 2.6.32-22-generic-pae i686
Architecture: i386
Date: Tue Jun 8 14:17:31 2010
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release i386 (20100427.1)
KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
MachineType: Dell Inc. OptiPlex GX620
ProcCmdLine: BOOT_IMAGE=/boot/vmlinuz-2.6.32-22-generic-pae root=/dev/mapper/Chrome-root ro quiet splash
ProcEnviron:
 LANG=en_US.utf8
 SHELL=/bin/bash
SourcePackage: qemu-kvm
dmi.bios.date: 11/30/2006
dmi.bios.vendor: Dell Inc.
dmi.bios.version: A11
dmi.board.name: 0HH807
dmi.board.vendor: Dell Inc.
dmi.chassis.type: 6
dmi.chassis.vendor: Dell Inc.
dmi.modalias: dmi:bvnDellInc.:bvrA11:bd11/30/2006:svnDellInc.:pnOptiPlexGX620:pvr:rvnDellInc.:rn0HH807:rvr:cvnDellInc.:ct6:cvr:
dmi.product.name: OptiPlex GX620
dmi.sys.vendor: Dell Inc.

Revision history for this message
Mike Mestnik (cheako) wrote :
Revision history for this message
Mike Mestnik (cheako) wrote :

I wrote a little script that should have solved my problems, however libvirt has other ideas.

http://pastebin.com/HgwtQ3iL
#!/bin/bash
out_args=( )
while (( $# ))
 do if [[ "$1" = "-drive" ]]
  then out_args+=( "$1" "$(<<<"$2" sed \
    -e s/,boot=on//g \
    -e s/boot=on,//g \
    -e s/boot=on//g \
   )" )
  shift 2
  else out_args+=( "$1" )
  shift
  fi
 done
exec "${0}-original" "${out_args[@]}"

http://pastebin.com/7SKxnJGV
Some strace output, the exec on line 15 fails with a permission problem.

Revision history for this message
Mike Mestnik (cheako) wrote :

(04:12:14 PM) cheako: operation="exec" pid=24359 parent=1 profile="libvirt-02e3d7e8-79e5-6dc3-2954-d43fe1130cdf" requested_mask="x::" denied_mask="x::" fsuid=0 ouid=0 name="/usr/bin/qemu-original"
(04:12:25 PM) cheako: operation="mknod" pid=24361 parent=24360 profile="libvirt-02e3d7e8-79e5-6dc3-2954-d43fe1130cdf" requested_mask="c::" denied_mask="c::" fsuid=0 ouid=0 name="/tmp/sh-thd-1276031548"
(04:12:39 PM) cheako: operation="open" pid=24359 parent=1 profile="libvirt-02e3d7e8-79e5-6dc3-2954-d43fe1130cdf" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/usr/bin/qemu-original"

tags: added: apparmor
Revision history for this message
Thierry Carrez (ttx) wrote :

I can't see reference to boot=on as a valid -drive option in qemu manpage... So that would be a libvirt bug ?
Your workaround fails due to apparmor protections around libvirt profiles.

affects: qemu-kvm (Ubuntu) → libvirt (Ubuntu)
Changed in libvirt (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

FWIW, regarding the flag itself:
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/19242

Still it works for me on x86_64 (where /usr/bin/qemu-original isn't
used). Is it worth updating the apparmor profile?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Mike, to libvirt your wrapper script is a new emulator and you must add a rule or rules for it in /etc/apparmor.d/abstractions/libvirt-qemu.

However, looking at the CurrentDmesg.txt file attached to this bug, there is nothing to indicate the original problem is an apparmor issue.

Revision history for this message
Mike Mestnik (cheako) wrote :

This bug is about qemu's option, if it's not a bug in qemu then this is a bug in libvirt for using this option. As for the selinux and apparmor issues these are bugs in my solution and have nothing to do with the bug being reported, but instead are related to one of it's /incomplete/ solutions.

Revision history for this message
Mike Mestnik (cheako) wrote :

That was simple add the following to the apparmor file:
  /usr/bin/qemu-original rmix,
  /bin/sed rmix,
  /tmp/sh-thd-* rw,

Also the dmsg statements that apparmor makes are not recognized by the SELinux ppl, they should all indicate from whence they hail.

Revision history for this message
Mike Mestnik (cheako) wrote :

The BUG here in qemu is that it starts, but then hangs!

Revision history for this message
Soren Hansen (soren) wrote :

> I can't see reference to boot=on as a valid -drive option in qemu manpage...

It's valid. It's used to tell qemu's extboot option rom to boot from the given device. It's the only way to boot from e.g. virtio devices (since they are not handled by the BIOS in qemu).

Revision history for this message
Mike Mestnik (cheako) wrote :

After reading the posted email thread, I've come to the conclusion that the -boot argument is missdocumented/missleading. In actuality it's "c" parameter is more like the "boot from first or selected hard disk" and "d" would be "boot from first or selected cdrom".

I think it would be best to remove this parameter, perhaps replacing it with a parameter to force a particular behavior(like the option to what format a block device is in). The boot sequence should attempt a cdrom boot, since this would fail quickly I'd imagine if the image was not an iso. Then booting the device like a hard disk or crash trying.

Revision history for this message
Mike Mestnik (cheako) wrote :

I made a change to my script.

#!/bin/bash
out_args=( )
while (( $# ))
 do if [[ "$1" = "-drive" ]]
  then out_args+=( "$1" "$(<<<"$2" sed \
    -e s/,boot=on//g \
    -e s/boot=on,//g \
    -e s/boot=on//g \
   )" )
  shift 2
  else out_args+=( "$1" )
  shift
  fi
 done
exec -a "$0" "${0}-original" "${out_args[@]}"

tags: removed: apparmor
Revision history for this message
Mike Mestnik (cheako) wrote :

Now I see the true bug here. I setup WindowsXP to use the virtio block driver and now as predicted I can't boot from it. After removing the wrapper script it seams that GRUB hangs during boot.

Could there be a problem with the int13h driver?

Revision history for this message
Mike Mestnik (cheako) wrote :

After doing some digging I've made the assumption that this is a missing feature of the BIOS(seabios). I've build the latest code from GIT and am getting the same result. Using KVM this is working, can that be used to correct QEMU?

Revision history for this message
Mike Mestnik (cheako) wrote :

Hmm, wait there are two bugs here. I'm not sure if I can help get either of them fixed.

1. There is a bug in QEMU(perhaps related to the same bug in seabios) where when using "-boot a" and the "-drive" flag "boot=on" the system fails to boot. However removing the "boot=on" flag corrects this and there is a script above and minor edits to apparmor to correct for this.

2. Seabios lacks support for virtio-blk devices, or the same bug as above is interfering with the boot. To boot from virtio-blk one needs to use the "boot=on" flag.

Revision history for this message
Mike Mestnik (cheako) wrote :

Fails to boot is described above, however a recap here would be nice. The boot process hangs(idle for ever) during the BIOS and/or MBR stage of the boot.

Revision history for this message
ilia (ilia) wrote :

SF bug 1977971 talks about boot from iso image and considered not a bug (according to comment 1)

Changed in libvirt:
importance: Unknown → Undecided
status: Unknown → New
Revision history for this message
Mike Mestnik (cheako) wrote :

ilia,
  What SF project, a link would be nice. The current link is kinda fun it links to that number "locally".

Revision history for this message
Mike Mestnik (cheako) wrote :

I have this working at home under KVM, it's the software emulator that this is broken on.

http://sourceforge.net/tracker/index.php?func=detail&aid=1977971&group_id=180599&atid=893831
This is also something to keep in mind, with or w/o "-boot c" it's the same.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

The commit c0897e0cb94e83ec1098867b81870e4f51f225b9 in qemu-kvm
will fix this. Unfortunately the patch is not a simple one to cherry-pick. The
0.13.0 qemu-kvm release should be out soon, and should include this fix.
We will update the maverick qemu package to this release when it comes out.

Changed in qemu-kvm:
status: New → Confirmed
Changed in libvirt (Ubuntu):
importance: Low → Medium
status: Incomplete → Triaged
Revision history for this message
Mike Mestnik (cheako) wrote :

Just to be clear the bug was reported while using GRUB, not the Windows XP loader. Grub did not start, so the config entry for XP shouldn't be an issue.

Though I can see where the BIOS would need to have the drive attached(and fully detected) if it's going to boot to it.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Mike - thanks, yes, that's also the bug I'm seeing - using a debian VM with
qemu (--no-kvm) inside a maverick kvm VM. Not at all a windows issue.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Note that installing qemu from git fixes the issue for me. When 0.13.0 with this fix
is released and packaged I'll drop a note here to ask for confirmation that it fixes
your bug.

thanks,
-serge

Changed in libvirt (Ubuntu):
milestone: none → maverick-alpha-3
Changed in qemu-kvm:
assignee: nobody → Serge Hallyn (serge-hallyn)
Revision history for this message
Thierry Carrez (ttx) wrote :

Milestoning in Ubuntu is used by the release management in conjunction with "Target to release" maverick, to identify milestone release blockers... I'm not sure this one should be considered a blocker. If you just intend to fix it by alpha3, you don't need to milestone it.

Changed in libvirt (Ubuntu):
assignee: nobody → Serge Hallyn (serge-hallyn)
milestone: maverick-alpha-3 → none
Revision history for this message
gold (dgoleshchikhin) wrote :

I needed to add "media=disk" option also to boot Windows XP properly on my Intel Atom D510 based system (Linux 2.6.32-24-generic #39-Ubuntu SMP Wed Jul 28 05:14:15 UTC 2010 x86_64 GNU/Linux). So the Mike`s script for me is:

#!/bin/bash

out_args=( )
while (( $# ))
 do if [[ "$1" = "-drive" ]]
  then out_args+=( "$1" "$(<<<"$2" sed \
    -e s/,boot=on/,media=disk/g \
    -e s/boot=on,/media=disk,/g \
    -e s/boot=on/media=disk/g \
   )" )
  shift 2
  else out_args+=( "$1" )
  shift
  fi
 done
exec -a "$0" "${0}-original" "${out_args[@]}"

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

It looks like this fix should be in v0.12.5 which is now packaged in maverick.

Changed in qemu-kvm:
status: Confirmed → Fix Committed
Changed in libvirt (Ubuntu):
status: Triaged → Fix Committed
Changed in libvirt:
status: New → Fix Committed
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

(Marked as invalid against libvirt since it was purely a qemu bug)

Changed in libvirt (Ubuntu):
status: Fix Committed → Invalid
Changed in libvirt:
status: Fix Committed → Invalid
Changed in qemu-kvm:
assignee: Serge Hallyn (serge-hallyn) → nobody
Changed in libvirt (Ubuntu):
assignee: Serge Hallyn (serge-hallyn) → nobody
Changed in qemu-kvm:
assignee: nobody → Serge Hallyn (serge-hallyn)
status: Fix Committed → Fix Released
assignee: Serge Hallyn (serge-hallyn) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.