Tag Archives: virt-inspector

Inspection in virt-manager

Using a background thread, inspect the virt-manager VMs and (just for a quick example) add the hostname to the user interface. I’m hoping in future that we can do things like changing those boring generic computer icons into operating system logos, displaying disk usage, and lots more.




Filed under Uncategorized

virt-inspector now supports Slackware

# virt-inspector Slackware13x64
<?xml version="1.0"?>
    <product_name>Slackware 13.1.0</product_name>

So now virt-inspector is known to detect: ArchLinux, CentOS, Debian, Fedora, FreeBSD, Gentoo, Linux Mint, Mandriva, Meego, Pardus, Red Hat Enterprise Linux, Scientific Linux, Slackware, Ubuntu, Windows XP through 7.

Leave a comment

Filed under Uncategorized

libguestfs: Live CD inspection

New in libguestfs 1.9.4, you can now run virt-inspector on some types of installer CD and live CD. The output tells you what type of operating system is on the CD:

$ virt-inspector cd.iso
<?xml version="1.0"?>
    <product_name>Windows Server 2003 Enterprise x64 Edition</product_name>
      <mountpoint dev="/dev/sda">/</mountpoint>
      <filesystem dev="/dev/sda">


On IRC someone asked me how long this takes. Here is the time to run the above command on my laptop:

real	0m4.736s
user	0m1.134s
sys	0m2.897s

The use case is in tools like virt-manager where we would like to detect what sort of ISO a user is installing from so that we can set the OS hints correctly. 5 seconds is just about acceptable as long as this happens in the background and doesn’t disturb the UI.

Leave a comment

Filed under Uncategorized

What is guest inspection

[This article expands on what I wrote here.]

I’ve been asked a few times if there is a standard for describing or inspecting virtual machines. Or conversely, should virt-inspector produce Enterprise Standard XML and not the ad-hoc XML that it produces right now?

Consider first what does “operating system version” mean? “Fedora 14” — what does that mean? It could mean a “class” of operating systems, waiting to be installed. Or perhaps it means a particular installed instance, together with all the configuration tweaks made by the administrator? Or perhaps you mean a bare installation before configuration (what the cool kids are now calling “JEOS”).

For a class of operating systems, before installation, what you would like to know includes:

  1. kernel type (“linux”)
  2. operating system name (“Fedora”)
  3. operating system version (“14”)
  4. architecture
  5. install location
  6. how to download and install it
  7. do installed versions need licensing, like Windows Activation or RHN subs?
  8. what preferred devices should we expose to new instances? (eg. does this have drivers for virtio, or should we expose some legacy devices?)
  9. minimum and recommended resources (RAM, disk space etc)

There is no comprehensive store of this data at the moment, although virt-install hard-codes some of it. So does VMware.

An installed instance of an OS is quite different. You’d like to know:

  1. what configuration changes were made?
  2. what applications are installed?
  3. what device drivers does it expect?
  4. what’s the state of critical security fixes?

and more. virt-inspector covers some of this. It also crosses over with inventory management standards like the impenetrable CIM. It also enters configuration management territory, so tools like puppet, kickstart and cfengine are applicable.

A running OS contains even more information beyond what is in the disk image:

  1. how many vCPUs?
  2. how much RAM
  3. what actual devices and resources?

Here we overlap with OVF, libvirt XML and more.

So there you have it: a difficult, multi-faceted, ill-defined problem with no easy answers.

Leave a comment

Filed under Uncategorized

Changes ahead for libguestfs RHEL 6.1 package

I previously said that libguestfs in RHEL 6.1 would be based on the recent upstream 1.6 release.

This plans have had to change slightly. It looks like we’ll rebase to 1.7.16 (a development version).

The reason is simply that to get into the next release of RHEV we had to remove the Perl dependencies on a number of key programs, because the tiny RHEV-H hypervisor [PDF] doesn’t have space to include Perl. Several programs like virt-inspector and virt-df had to be rewritten in C. We could backport all of the changes but they amount to nearly every change since 1.6 anyway.

What I do have to do is to meticulously check each C program precisely matches the old Perl version, in terms of output, command line arguments and so on, so that scripts written against RHEL 6.0 won’t break. But that’s what you pay Red Hat for.

Preview packages will be available here.


Filed under Uncategorized

libguestfs inspection now lists Windows apps

In version ≥ 1.7.8 Windows apps can be listed from virt-inspector:

$ virt-inspector Win7.img
        <name>Mozilla Firefox (3.6.12)</name>
        <display_name>Mozilla Firefox (3.6.12)</display_name>
        <version>3.6.12 (en-GB)</version>
        <install_path>C:\Program Files\Mozilla Firefox</install_path>

or from guestfish:

$ guestfish -a Win7.img --ro -i
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

Operating system: Windows 7 Enterprise
/dev/vda2 mounted on /

><fs> inspect-list-applications /dev/vda2
[0] = {
  app_name: Mozilla Firefox (3.6.12)
  app_display_name: Mozilla Firefox (3.6.12)
  app_epoch: 0
  app_version: 3.6.12 (en-GB)
  app_install_path: C:\Program Files\Mozilla Firefox
  app_publisher: Mozilla
  app_url: http://www.mozilla.com/en-GB/
[1] = {
  app_name: VLC media player
  app_display_name: VLC media player 1.1.5
  app_epoch: 0
  app_version: 1.1.5
  app_install_path: C:\Program Files\VideoLAN\VLC
  app_publisher: VideoLAN
  app_url: http://www.videolan.org/

The same API also works for Fedora, RHEL, Debian and Ubuntu guests, where it lists installed packages instead of “applications”.

Leave a comment

Filed under Uncategorized

Tip: Use Augeas to get the default boot kernel for a VM

Note: This requires libguestfs ≥ 1.5.23

The example below demonstrates a couple of new features of libguestfs 1.5: the core inspection API, and add_drive_opts with optional arguments. Along with the use of Augeas to parse configuration files with ease.

You can use this as a template for getting almost any information from a guest or disk image. Examples include:

  • list the user accounts in the guest
  • what repositories is it configured to use
  • what NTP servers does it connect to
  • what were the boot messages last time it booted
  • list who was logged in recently
#!/usr/bin/perl -w

use Sys::Guestfs;

die "Usage: whichboot.pl linuxdisk.img\n" if @ARGV == 0;

# Add the disk image.
my $g = Sys::Guestfs->new ();
foreach (@ARGV) {
    $g->add_drive_opts ($_, readonly => 1);
$g->launch ();

# Inspect the operating system and mount disks correctly.
my @roots = $g->inspect_os ();
die "no operating system detected, or OS is multi-boot" unless @roots == 1;
my %fses = $g->inspect_get_mountpoints ($roots[0]);
my @fses = sort { length $a <=> length $b } keys %fses;
foreach (@fses) {
    $g->mount_ro ($fses{$_}, $_);

# Use Augeas to parse configuration files.
$g->aug_init ("/", 16);

# Get GRUB default boot option.
my $grub_conf = "//files/boot/grub/menu.lst";
my $default = $g->aug_get ("$grub_conf/default");

# Add 1 because GRUB counts from 0, Augeas counts from 1.

# Get the kernel from GRUB.
my $kernel = $g->aug_get ("$grub_conf/title[$default]/kernel");

print "default boot kernel: $kernel\n"

Leave a comment

Filed under Uncategorized