Notes on libguestfs with Ubuntu 12.04 (Precise)
Ubuntu are now supplying a libguestfs package (or to be more accurate, they are just copying the Debian package) but it doesn't work out of the box. There is a bug in apt which we worked around in febootstrap 3.14, but the supplied version of febootstap is only 3.12. Hence you will get errors like this during installation: febootstrap: aptitude: error: no file was downloaded corresponding to package <some package name> and you'll get the same error if you try to build from source. The solution is to build febootstrap 3.14: cd /tmp sudo apt-get build-dep febootstrap sudo apt-get install devscripts apt-get source febootstrap wget http://people.redhat.com/~rjones/febootstrap/files/febootstrap-3.14.tar.gz tar zxf febootstrap-3.14.tar.gz cd febootstrap-3.14 rm -rf debian cp -a ../febootstrap-3.12/debian . vi debian/changelog # change the first line: 3.12 -> 3.14 debuild -i -uc -us -b That will create an febootstrap 3.14 .deb file in /tmp which you can install: sudo dpkg -i ../febootstrap_3.14-1_amd64.deb Then you can go ahead and use the libguestfs package: sudo update-guestfs-appliance or compile libguestfs from source. There is another problem which you may hit, if you add a completely blank disk to libguestfs (this also affects libguestfs-test-tool): https://bugs.launchpad.net/ubuntu/+source/linux/+bug/931371 https://bugzilla.kernel.org/show_bug.cgi?id=42778 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
On Wed, Apr 04, 2012 at 02:08:33PM +0100, Richard W.M. Jones wrote:
Ubuntu are now supplying a libguestfs package (or to be more accurate, they are just copying the Debian package) but it doesn't work out of the box.
There is a bug in apt which we worked around in febootstrap 3.14, but the supplied version of febootstap is only 3.12. Hence you will get errors like this during installation:
febootstrap: aptitude: error: no file was downloaded corresponding to package <some package name>
and you'll get the same error if you try to build from source.
The solution is to build febootstrap 3.14:
cd /tmp sudo apt-get build-dep febootstrap sudo apt-get install devscripts apt-get source febootstrap wget http://people.redhat.com/~rjones/febootstrap/files/febootstrap-3.14.tar.gz tar zxf febootstrap-3.14.tar.gz cd febootstrap-3.14 rm -rf debian cp -a ../febootstrap-3.12/debian . vi debian/changelog # change the first line: 3.12 -> 3.14 debuild -i -uc -us -b
That will create an febootstrap 3.14 .deb file in /tmp which you can install:
sudo dpkg -i ../febootstrap_3.14-1_amd64.deb
Then you can go ahead and use the libguestfs package:
sudo update-guestfs-appliance
or compile libguestfs from source.
There is another problem which you may hit, if you add a completely blank disk to libguestfs (this also affects libguestfs-test-tool):
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/931371 https://bugzilla.kernel.org/show_bug.cgi?id=42778
I've found a way around the last problem, which seems to be caused by the version of qemu-kvm in Ubuntu, not the kernel. If you compile qemu from source and use that, then it works (for me). Do: git clone git://git.qemu.org/qemu.git cd qemu ./configure make Then create a 'qemu.wrapper' file containing (edited): #!/bin/sh - qemudir=/home/user/d/qemu exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "$@" and: chmod +x qemu.wrapper (See: http://libguestfs.org/guestfs.3.html#qemu_wrappers ) Then set the environment variable: export LIBGUESTFS_QEMU=/home/user/d/qemu/qemu.wrapper Then run libguestfs / virt-tools programs as normal (albeit slower because it's qemu, not full upstream KVM). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Sat, Apr 14, 2012 at 09:49:03PM +0100, Richard W.M. Jones wrote:
There is another problem which you may hit, if you add a completely blank disk to libguestfs (this also affects libguestfs-test-tool):
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/931371 https://bugzilla.kernel.org/show_bug.cgi?id=42778
I've now identified the bug, and provided a fix. The bug in fact is in SeaBIOS (not the kernel as originally thought): https://bugs.launchpad.net/ubuntu/+source/linux/+bug/931371/comments/12 To recompile SeaBIOS with this fix on Ubuntu 12.04, do: apt-get source seabios cd seabios-0.6.2/debian/patches # Download the patch attached to this email into this directory. echo 0001-Fix-alignment-bug-in-pci_bios_init_root_regions.patch >> series cd ../.. debuild -i -uc -us -b cd .. sudo dpkg -i seabios_0.6.2-0ubuntu2_all.deb After this, libguestfs should work normally. (Note you may also need to do the febootstrap update from the previous email and rebuild the appliance). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Sun, Apr 15, 2012 at 09:05:49PM +0100, Richard W.M. Jones wrote:
I've now identified the bug, and provided a fix. The bug in fact is in SeaBIOS (not the kernel as originally thought):
You may have identified the very bug which caused one facility I work with to dump Ubuntu server entirely due to unreliability as a VM hosting system.
On Sun, Apr 15, 2012 at 09:05:49PM +0100, Richard W.M. Jones wrote:
On Sat, Apr 14, 2012 at 09:49:03PM +0100, Richard W.M. Jones wrote:
There is another problem which you may hit, if you add a completely blank disk to libguestfs (this also affects libguestfs-test-tool):
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/931371 https://bugzilla.kernel.org/show_bug.cgi?id=42778
I've now identified the bug, and provided a fix. The bug in fact is in SeaBIOS (not the kernel as originally thought):
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/931371/comments/12
To recompile SeaBIOS with this fix on Ubuntu 12.04, do:
apt-get source seabios cd seabios-0.6.2/debian/patches
# Download the patch attached to this email into this directory.
echo 0001-Fix-alignment-bug-in-pci_bios_init_root_regions.patch >> series cd ../.. debuild -i -uc -us -b
cd .. sudo dpkg -i seabios_0.6.2-0ubuntu2_all.deb
After this, libguestfs should work normally. (Note you may also need to do the febootstrap update from the previous email and rebuild the appliance).
I had a bit of a delay on things... I did a dselect and didn't realize that it had just updated over top of the seabios package I had just rebuilt. I have, with many error messages that may or may not be specificly relevant to my test disk, seen a virt-rescue prompt for the first time ever. I am still not sure whether it has actually 'worked' as the "vda: vda1 vda2" seems to have only shown me a /dev/vda but not the partitions. Not sure why yet: a cfdisk does show that /dev/vda has the correct partition table, etc. But it is 0420 here and I'm about half past useless myself at this point. ;-) And I might just try a kpartx to see what happens.
On Mon, Apr 16, 2012 at 04:21:46AM +0100, Dale Amon wrote:
I am still not sure whether it has actually 'worked' as the "vda: vda1 vda2" seems to have only shown me a /dev/vda but not the partitions. Not sure why yet: a cfdisk does show that /dev/vda has the correct partition table, etc.
Just do:
<rescue> mount /dev/vda1 /sysroot
and see what it says. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Mon, Apr 16, 2012 at 08:37:33AM +0100, Richard W.M. Jones wrote:
Just do:
<rescue> mount /dev/vda1 /sysroot and see what it says.
What was going on may have been more complex than that. I'd already tried that before emailing you. Afterwards I did a kpartx and the partitions showed up in /dev but would not mount. Then the /dev/mapper node showed up and I tried /dev/mapper/vda1 and that worked just fine. The big problem is that my test monkey is struggling very hard to handle these new fangled VM's and is just about choking on them (It's about a 2003 motherboard). That means the testing is slow and I have to be very careful to separate out true bugs from what is just very slow hardware by current standards. I have access to remote systems of far higher spec, but I can't reach across the Atlantic to reboot them if things go awry. ;-)
I will pass this on though: during the boot of the virt-rescue, I see this: 1.605763] ------------[ cut here ]------------ [ 1.606763] WARNING: at arch/x86/kernel/apic/apic.c:1318 setup_local_APIC+0x2af/0x3ac() [ 1.609763] Hardware name: Bochs [ 1.611763] Modules linked in: [ 1.620761] Pid: 1, comm: swapper/0 Not tainted 3.2.0-23-lowlatency #31-Ubuntu [ 1.623761] Call Trace: [ 1.636759] [<c10436c2>] warn_slowpath_common+0x72/0xa0 [ 1.640758] [<c1548ae7>] ? setup_local_APIC+0x2af/0x3ac [ 1.643758] [<c1548ae7>] ? setup_local_APIC+0x2af/0x3ac [ 1.645757] [<c1043712>] warn_slowpath_null+0x22/0x30 [ 1.648757] [<c1548ae7>] setup_local_APIC+0x2af/0x3ac [ 1.652756] [<c1786a79>] native_smp_prepare_cpus+0x160/0x1f9 [ 1.654756] [<c177b7e7>] kernel_init+0x61/0x13f [ 1.656756] [<c177b786>] ? start_kernel+0x362/0x362 [ 1.658755] [<c156a37e>] kernel_thread_helper+0x6/0x10 [ 1.719746] ---[ end trace a7919e7f17c0a725 ]--- Not sure why the lowlatency kernel name showed up; I'm not booted into that one, although it does exist in the /boot of the test machine.
On Mon, Apr 16, 2012 at 01:36:03PM +0100, Dale Amon wrote:
I will pass this on though: during the boot of the virt-rescue, I see this:
1.605763] ------------[ cut here ]------------ [ 1.606763] WARNING: at arch/x86/kernel/apic/apic.c:1318 setup_local_APIC+0x2af/0x3ac() [ 1.609763] Hardware name: Bochs [ 1.611763] Modules linked in: [ 1.620761] Pid: 1, comm: swapper/0 Not tainted 3.2.0-23-lowlatency #31-Ubuntu [ 1.623761] Call Trace: [ 1.636759] [<c10436c2>] warn_slowpath_common+0x72/0xa0 [ 1.640758] [<c1548ae7>] ? setup_local_APIC+0x2af/0x3ac [ 1.643758] [<c1548ae7>] ? setup_local_APIC+0x2af/0x3ac [ 1.645757] [<c1043712>] warn_slowpath_null+0x22/0x30 [ 1.648757] [<c1548ae7>] setup_local_APIC+0x2af/0x3ac [ 1.652756] [<c1786a79>] native_smp_prepare_cpus+0x160/0x1f9 [ 1.654756] [<c177b7e7>] kernel_init+0x61/0x13f [ 1.656756] [<c177b786>] ? start_kernel+0x362/0x362 [ 1.658755] [<c156a37e>] kernel_thread_helper+0x6/0x10 [ 1.719746] ---[ end trace a7919e7f17c0a725 ]---
Does this stop it from booting, or is it just a warning? I see plenty of these, particularly when running experimental kernels. FWIW on my Ubuntu 12.04 VM: $ guestfish -N fs exit $ virt-rescue -a test1.img Could not access KVM kernel module: No such file or directory failed to initialize KVM: No such file or directory Back to tcg accelerator. [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Linux version 3.2.0-23-generic (buildd@crested) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu4) ) #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 (Ubuntu 3.2.0-23.36-generic 3.2.14) [ 0.000000] Command line: panic=1 console=ttyS0 udevtimeout=300 no_timer_check acpi=off printk.time=1 cgroup_disable=memory selinux=0 TERM=xterm guestfs_rescue=1 [ 0.000000] KERNEL supported cpus: [ 0.000000] Intel GenuineIntel [ 0.000000] AMD AuthenticAMD [ 0.000000] Centaur CentaurHauls [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: 0000000000000000 - 000000000009bc00 (usable) [ 0.000000] BIOS-e820: 000000000009bc00 - 00000000000a0000 (reserved) [ 0.000000] BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved) [ 0.000000] BIOS-e820: 0000000000100000 - 000000001f3fd000 (usable) [ 0.000000] BIOS-e820: 000000001f3fd000 - 000000001f400000 (reserved) [ 0.000000] BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved) [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] DMI 2.4 present. [ 0.000000] No AGP bridge found [ 0.000000] last_pfn = 0x1f3fd max_arch_pfn = 0x400000000 [ 0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106 [ 0.000000] found SMP MP-table at [ffff8800000fdaf0] fdaf0 [ 0.000000] init_memory_mapping: 0000000000000000-000000001f3fd000 [ 0.000000] RAMDISK: 1f2e9000 - 1f3f0000 [ 0.000000] No NUMA configuration found [ 0.000000] Faking a node at 0000000000000000-000000001f3fd000 [ 0.000000] Initmem setup node 0 0000000000000000-000000001f3fd000 [ 0.000000] NODE_DATA [000000001f3f5000 - 000000001f3f9fff] [ 0.000000] Zone PFN ranges: [ 0.000000] DMA 0x00000010 -> 0x00001000 [ 0.000000] DMA32 0x00001000 -> 0x00100000 [ 0.000000] Normal empty [ 0.000000] Movable zone start PFN for each node [ 0.000000] early_node_map[2] active PFN ranges [ 0.000000] 0: 0x00000010 -> 0x0000009b [ 0.000000] 0: 0x00000100 -> 0x0001f3fd [ 0.000000] SFI: Simple Firmware Interface v0.81 http://simplefirmware.org [ 0.000000] Intel MultiProcessor Specification v1.4 [ 0.000000] MPTABLE: OEM ID: BOCHSCPU [ 0.000000] MPTABLE: Product ID: 0.1 [ 0.000000] MPTABLE: APIC at: 0xFEE00000 [ 0.000000] Processor #0 (Bootup-CPU) [ 0.000000] IOAPIC[0]: apic_id 1, version 17, address 0xfec00000, GSI 0-23 [ 0.000000] Processors: 1 [ 0.000000] SMP: Allowing 1 CPUs, 0 hotplug CPUs [ 0.000000] PM: Registered nosave memory: 000000000009b000 - 000000000009c000 [ 0.000000] PM: Registered nosave memory: 000000000009c000 - 00000000000a0000 [ 0.000000] PM: Registered nosave memory: 00000000000a0000 - 00000000000f0000 [ 0.000000] PM: Registered nosave memory: 00000000000f0000 - 0000000000100000 [ 0.000000] Allocating PCI resources starting at 1f400000 (gap: 1f400000:e0bc0000) [ 0.000000] Booting paravirtualized kernel on bare hardware [ 0.000000] setup_percpu: NR_CPUS:256 nr_cpumask_bits:256 nr_cpu_ids:1 nr_node_ids:1 [ 0.000000] PERCPU: Embedded 28 pages/cpu @ffff88001f000000 s83072 r8192 d23424 u2097152 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 125875 [ 0.000000] Policy zone: DMA32 [ 0.000000] Kernel command line: panic=1 console=ttyS0 udevtimeout=300 no_timer_check acpi=off printk.time=1 cgroup_disable=memory selinux=0 TERM=xterm guestfs_rescue=1 [ 0.000000] Disabling memory control group subsystem [ 0.000000] PID hash table entries: 2048 (order: 2, 16384 bytes) [ 0.000000] Checking aperture... [ 0.000000] No AGP bridge found [ 0.000000] Memory: 486364k/511988k available (6566k kernel code, 468k absent, 25156k reserved, 6637k data, 920k init) [ 0.000000] SLUB: Genslabs=15, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 0.534994] audit: initializing netlink sockeodule: ideapad-laptop.ko: No such device febootstrap: internal insmod virtio_mmio.ko febootstrap: internal insmod virtio_balloon.ko febootstrap: internal insmod virtio-rng.ko febootstrap: internal insmod virtio_console.ko febootstrap: internal insmod ext2.ko febootstrap: picked /sys/block/vdb/dev as root device febootstrap: creating /dev/root as block special 253:16 febootstrap: mounting new root on /root febootstrap: chroot /proc/uptime: No such file or directory Starting /init script ... rm: cannot remove `/proc': Is a directory mkdir: cannot create directory `/proc': File exists rm: cannot remove `/sys': Is a directory mkdir: cannot create directory `/sys': File exists [ 1.527613] Switching to clocksource tsc cannot open /dev/null FATAL: Module pci:v00008086d00001237sv00001AF4sd00001100bc06sc00i00 not found. FATAL: Module pci:v00008086d00007000sv00001AF4sd00001100bc06sc01i00 not found. FATAL: Module platform:Fixed not found. insmod /lib/modules/3.2.0-23-generic/kernel/drivers/i2c/busses/i2c-piix4.ko [ 2.546072] piix4_smbus 0000:00:01.3: SMBus Host Controller at 0xb100, revision 0 WARNING: Not loading blacklisted module snd_pcsp WARNING: Not loading blacklisted module pcspkr FATAL: Module platform:pcspkr not found. insmod /lib/modules/3.2.0-23-generic/kernel/drivers/input/serio/serio_raw.ko insmod /lib/modules/3.2.0-23-generic/kernel/drivers/input/mouse/psmouse.ko WARNING: Not loading blacklisted module evbug insmod /lib/modules/3.2.0-23-generic/kernel/drivers/macintosh/mac_hid.ko [ 3.231744] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input1 FATAL: Module dmi:bvnBochs:bvrBochs:bd01/01/2007:svnBochs:pnBochs:pvr:cvnBochs:ct1:cvr: not found. SIOCSIFADDR: No such device eth0: ERROR while getting interface flags: No such device SIOCADDRT: No such process Reading all physical volumes. This may take a while... No volume groups found No volume groups found ------------------------------------------------------------ Welcome to virt-rescue, the libguestfs rescue shell. Note: The contents of / are the rescue appliance. You have to mount the guest's partitions under /sysroot before you can examine them. bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell groups: cannot find name for group ID 0 I have no name!@(none):/# fdisk -l /dev/vda Disk /dev/vda: 104 MB, 104857600 bytes 189 heads, 49 sectors/track, 22 cylinders, total 204800 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0008b5ec Device Boot Start End Blocks Id System /dev/vda1 128 204672 102272+ 83 Linux I have no name!@(none):/# mount /dev/vda1 /sysroot I have no name!@(none):/# touch /sysroot/hello I have no name!@(none):/# exit exit virt-rescue: Syncing the disk now before exiting ... [ 74.610677] Restarting system. [ 74.611101] machine restart [ several GPFs during shutdown omitted ] $ guestfish -a test1.img -m /dev/vda1 ll / total 17 drwxr-xr-x 3 0 0 1024 Apr 16 17:00 . drwxr-xr-x 21 1000 1000 4096 Apr 16 17:01 .. -rw-r--r-- 1 0 0 0 Apr 16 17:00 hello drwx------ 2 0 0 12288 Apr 16 16:59 lost+found ---------------------------------------------------------------------- I don't know why it cannot set the prompt. I filed a BZ about it: https://bugzilla.redhat.com/show_bug.cgi?id=812970 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
No, it goes through to the 'prompt'. Thanks for the example. It shows that a whole bunch of things I was worrying about are normal behavior for whatever reason. I was particularly wondering about those messages about the pseudo file system mount points that are also in your output.
Did you get any feedback from the Ubuntu guy? It would be really great to be able to do this from the regular update. Also... what change do you think this SEABIOS fix will work with older releases? It strikes me that since its an emulated BIOS it should not care that much about which kernel the host machine is running. It that is true, it would be a big win for me as most of the machines that matter are 'locked down' due to being critical systems. There is no way on Earth any of them are going to upgrade to Precise before sometime in the middle of the summer when there is a big open maintenance window.
On Mon, Apr 16, 2012 at 09:05:58PM +0100, Dale Amon wrote:
Did you get any feedback from the Ubuntu guy? It would be really great to be able to do this from the regular update.
Not at the moment.
Also... what change do you think this SEABIOS fix will work with older releases? It strikes me that since its an emulated BIOS it should not care that much about which kernel the host machine is running.
It apparently doesn't affect the earlier releases of Ubuntu, or not so far as I have seen. The BIOS doesn't affect the running of Linux, but it can affect the initial location of PCI BARs which is enough to break assumptions made by the Linux virtio driver. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
participants (2)
-
Dale Amon -
Richard W.M. Jones