Tag Archives: appliance

a-fedora-appliance updated for supermin 5

a-fedora-appliance is a supermin demonstration Fedora appliance.

I have scratch-built a Fedora RPM here which is just a 235K download but contains (by magic!) a fully bootable Fedora appliance. After installing the RPM in Fedora 20, do the following to boot the virtual machine:

# boot-a-fedora-appliance

Screenshot - 310314 - 22:54:03

Note that the scratch build will only last in Koji for a few days. After that you’ll have to follow the README file included in the source.

Leave a comment

Filed under Uncategorized

Problems compiling libguestfs? Try the libguestfs binary appliance

The libguestfs binary “fixed” appliance [README] is a copy of the Fedora appliance, adapted so you can just download it and use it directly with libguestfs.

Just download libguestfs ≥ 1.17.10 (or from git), compile without the usual appliance:

./configure --disable-appliance --disable-daemon
sudo make install

Set your path to point to wherever you unpacked the appliance:

export LIBGUESTFS_PATH=/usr/local/lib/libguestfs/appliance

and then run libguestfs and the virt tools in the usual way.


Filed under Uncategorized

Tip: Creating throwaway appliances with febootstrap

This is an update to a previous posting, but using the new febootstrap 3.x cross-distro toolchain to make building supermin appliances even simpler.

Firstly we create a supermin appliance containing a few packages and their dependencies. Note that I’m not minimizing this appliance so it’s a bit bigger (3.1MB!) than the ones we would generate in reality:

$ mkdir supermin.d
$ febootstrap --names 'bash' 'coreutils' -o supermin.d
febootstrap: warning: some host files are unreadable by non-root
febootstrap: warning: get your distro to fix these files:
$ ls -lh supermin.d/
total 3.1M
-rw-rw-r--. 1 rjones rjones 2.7M Dec 10 18:23 base.img
-rw-rw-r--. 1 rjones rjones 462K Dec 10 18:23 hostfiles

The purpose of these two files is explained in the febootstrap documentation.

This won’t boot without a /init script, and we can easily provide one:

$ cat init
#!/bin/bash -
echo Welcome to my world
bash -i
$ chmod +x init
$ echo init | cpio -o -H newc --quiet > supermin.d/init.img

The 3 files in supermin.d/ are a supermin appliance, and could be packaged up in a Fedora, Debian or Ubuntu package.

When you actually want to come and launch this appliance, you use febootstrap-supermin-helper to reconstruct the appliance:

$ febootstrap-supermin-helper -f ext2 supermin.d x86_64 \
    kernel initrd root

(Note that “kernel”, “initrd” and “root” are output files in that command)

You’d usually arrange for those files to be cached, since febootstrap-supermin-helper takes a few seconds to run (8 seconds on my laptop) and by caching it you can get reconstruction time down to a fraction of a second.

Now to boot, run qemu or qemu-kvm like this:

$ qemu-kvm -kernel kernel -initrd initrd -hda root

After a few seconds you’ll get to the shell:


Filed under Uncategorized

Building libguestfs from source with the binary appliance

Inspired by this comment and reply I wrote a short tutorial which explains how to build libguestfs from source, but using the binary appliance that we ship.

http://libguestfs.org/download/binaries/REUSING-THE-APPLIANCE.txt Dead link. A better link is: http://libguestfs.org/guestfs-building.1.html#using-a-prebuilt-binary-appliance

This is essentially a very easy way to build libguestfs if it hasn’t been ported to your Linux distro, or if you have to rely on some appliance builder which is frequently not working.

1 Comment

Filed under Uncategorized

Tip: Run test scripts in guestfish

In guestfish ≥ 1.3.5 you can run arbitrary test scripts using the debug backdoor (if it is enabled in your build, which it is in all Fedora builds). This is a good way to use the libguestfs appliance for your own tests or experiments. You can already do this using virt-rescue, but this gives you a way to script it.

For example, here we use the mke2fs “-T” option as an experiment:

$ guestfish
><fs> sparse /tmp/test.img 100M
><fs> run
><fs> part-disk /dev/sda mbr
><fs> debug-upload -<<EOF /tmp/script.sh 0755
#!/bin/sh -
/sbin/mke2fs -T news /dev/${sd}a1
><fs> debug sh "/tmp/script.sh"
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
25600 inodes, 25599 blocks
1279 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=29360128
1 block group
32768 blocks per group, 32768 fragments per group
25600 inodes per group

Note that two environment variables are made available to “debug sh” scripts:

  • root is the path to where filesystems are mounted in the appliance, eg. “/sysroot”
  • sd is the prefix for block devices, usually expanding to either “sd”, “hd” or “vd” depending on the block device driver and appliance kernel in use

None of this is portable or stable. We can change the “debug” interface at any time, and it might be disabled in particular builds on libguestfs. You should add commands that you need to the libguestfs API — it’s easy!

Leave a comment

Filed under Uncategorized

libguestfs launch times

Indulge me while a make a “note to self” about efforts to reduce the time taken by guestfs_launch which boots up the libguestfs appliance.

Time (s) Operation
2s Create supermin appliance: This has crept up over time from originally taking about 1/5th of a second to around 2s. Needs attention. Fixed see this note about cpio blocksize and update below.
2-3s qemu startup: The time is mainly spent reading in the large -kernel and particularly -initrd files specified on the command line. The released qemu code is quite rubbish, but luckily kraxel beat me to fixing the problem with this patch.
3s BIOS waits for keypress: As discussed yesterday, I’ve posted a patch. In the meantime the qemu devs have abandoned the old bochs BIOS for SeaBIOS, which I haven’t tested yet,
3s Kernel boot time: Not very many easy wins here, since the kernel is already pretty efficient. We could try to remove some busy waits and sleeps — for example the kernel waits ¼s for the serial ports, which we don’t use.
1-2s Userspace boot time: This is mainly time spent on udev and partition detection. I have never really understood why the kernel needs to pause so long on partition detection. Not much easy meat here, but improving the speed of udev in itself would be worthwhile.

I spotted a nice tool for turning strace output into timelines.

Update — bash globbing

Having solved the cpio problem, the largest bottleneck in creating the supermin appliance becomes globbing.

It’s probably not a well-known fact, but if you do:

ls *.c *.h

then bash reads the directory twice. It treats the two globs on the command line as completely separate entities. This is not so bad for a few globs, but when we make the supermin appliance we need to do over 120 globs, which takes bash about 0.8s to complete, contributing about 10% to the overall launch time. Bash is literally reading the same directory over and over again, 50 or more times.

At the moment it’s not obvious to me how to solve this.


Filed under Uncategorized

Quick win

I got the libguestfs launch time down from 12 seconds to 9 seconds today, 25% faster!

It turns out that the appliance’s BIOS was waiting for 3 seconds for someone to hit [F12] on the imaginary keyboard. A simple patch to bochs BIOS fixes that … This patch benefits everyone using Fedora and virtualization, since all boot times will be reduced by 3 seconds.

This is only the start of the optimizations. I’m pretty certain we can get it down to a 4 or 5 second launch time.


Filed under Uncategorized