[Libguestfs] --rbd volume access--

Richard W.M. Jones rjones at redhat.com
Fri Mar 14 07:59:16 UTC 2014


On Fri, Mar 14, 2014 at 12:47:08PM +0500, Shumaila Naeem wrote:
> Also i can't use the newest version of libguestfs as im on a production
> system and i could not use the newest version due to some limitations.

You can use the new version without installing it.  However you would
need to be able to install a compiler and other dependencies, which
may not be possible on a production system.

> Also the new version is not available in repo.
> 
> 
> 
> Im getting antother problem :
> 
> while running these commands im getting error :
> guestfish -- add /dev/null : config -set
> drive.hd0.file=rbd:ssd-clonetest-rule5/ubuntu-12.04--1.raw.img : run :
> inspect-os
> /dev/ubuntu-1204-vg/root
> [root at EQkvm0101 ~]# guestfish -- add /dev/null : config -set
> drive.hd0.file=rbd:ssd-clonetest-rule5/ubuntu-12.04--1.raw.img :
>  inspect-get-distro /dev/ubuntu-1204-vg/root
> libguestfs: error: no inspection data: call guestfs_inspect_os first

You have to call inspect-os, and pass the returned value back to
inspect-get-distro.  This is (to say the least) awkward in guestfish,
but much easier if you use a real programming language (libguestfs has
many language bindings, see http://libguestfs.org).  Also you are
missing a call to 'run'.

Here's how you could do it in Perl:

------------------------------------------------------------
#!/usr/bin/perl -w

use strict;
use Sys::Guestfs;

my $g = Sys::Guestfs->new ();
$g->add_drive_opts ("/dev/null", readonly => 1);
# RHEL 6 hack for adding Ceph drives:
$g->config ("-set",
            "drive.hd0.file=rbd:ssd-clonetest-rule5/ubuntu-12.04--1.raw.img");
$g->launch ();

my @roots = $g->inspect_os ();
if (@roots == 0) {
    die "no operating systems found";
}
my $root = $roots[0];
my $distro = $g->inspect_get_distro ($root);
print "distro = $distro\n";
------------------------------------------------------------

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)




More information about the Libguestfs mailing list