[Libguestfs] Standalone guestfs

Richard W.M. Jones rjones at redhat.com
Sat Jun 1 19:54:15 UTC 2013


On Sat, Jun 01, 2013 at 02:27:50PM +0000, Gabriel de Perthuis wrote:
> Hello,
> As I understand it guestfs appliances normally work as servers
> and run high-level commands from some external channel.

This is the normal architecture when you're using libguestfs to access
a VM or disk image:

  http://libguestfs.org/guestfs.3.html#architecture

> But it might be possible to bundle a guestfish script to run
> commands from and do away with the external system. 
> That would make it useful on non-virtualised systems.

It's worth noting you can edit any device, including host devices
directly.  For example on my laptop:

** NB: you REALLY NEED to use --ro here unless you know exactly
** what you are doing...

  $ LIBGUESTFS_BACKEND=direct guestfish --ro -a /dev/sda -i
  Enter key or passphrase ("/dev/sda2"): xxx
  
  Welcome to guestfish, the guest filesystem shell for
  editing virtual machine filesystems and disk images.
  
  Type: 'help' for help on commands
        'man' to read the manual
        'quit' to quit the shell
  
  Operating system: Fedora release 18 (Spherical Cow)
  /dev/fedora/root mounted on /
  /dev/sda1 mounted on /boot
  /dev/fedora/home mounted on /home
  
  ><fs> list-filesystems 
  /dev/sda1: ext4
  /dev/fedora/archlinux20121201x64: unknown
  /dev/fedora/f18x64: unknown
  /dev/fedora/f20rawhidex32: unknown
  /dev/fedora/f20rawhidex64: unknown
  /dev/fedora/home: ext4
  /dev/fedora/root: ext4
  /dev/fedora/swap: swap
  /dev/fedora/ubuntu1210: unknown
  /dev/fedora/ubuntu1304: unknown
  /dev/fedora/win7x32dynamic-a: unknown
  /dev/fedora/win7x32dynamic-b: unknown
  /dev/fedora/win7x32dynamic-c: unknown
  /dev/fedora/windows2012: unknown

It's also possible to get libguestfs to connect to an arbitrary
socket, so-called 'libguestfs live'.  That could include a guestfsd
daemon running on the local host.  Run the daemon and set
LIBGUESTFS_BACKEND=unix:/path/to/some/socket

  http://libguestfs.org/guestfs.3.html#backend
  https://rwmj.wordpress.com/2011/07/07/how-does-libguestfs-live-work/#content

It would also be possible to run qemu-nbd or sshd on a physical
machine and access it using libguestfs (>= 1.22) from another machine.
Indeed this is a possible architecture under discussion for the new
version of virt-v2v.

Hope that gives you some ideas.  If you have a specific use scenario
you are interested in, then please let us know.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list