[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] Supporting btrfs subvolumes during inspection



I'd like to think about what calling code would look like.  I think
there are two separate issues, which should be treated as separate
things.

(1) guestfs_inspect_os: What to return from inspect_os, given that
multiple roots may exist on a single device.

(2) guestfs_get_filesystems/mountpoints: How to return the list of
devices and mountpoints.

So treating them as separate issues ...

----------------------------------------

(1) guestfs_inspect_os: What to return from inspect_os, given that
multiple roots may exist on a single device.

I think we should treat the "root" strings as opaque.  It doesn't
matter (except see below) what we return from inspect_os as long as
the same thing is recognized as a parameter by the other calls.

There is an exception, which is code that I've written for Windows
which assumes root == C: device, ie. it does:

  roots = g.inspect_os ();
  if #roots > 1 then die;
  root = roots[0];
  g.mount (root, "/");

To not break the API we really need to keep returning plain device
names for all existing (non-btrfs) OSes.

But since that code would break anyway when presented with a btrfs OS,
we can extend the root string for those.  We don't need a flag or a
change to the API types.

----------------------------------------

(2) guestfs_get_filesystems/mountpoints: How to return the list of
devices and mountpoints.

Existing code looks like this:

 my @roots = $g->inspect_os ();
 for my $root (@roots) {
     my %mps = $g->inspect_get_mountpoints ($root);
     my @mps = sort { length $a <=> length $b } (keys %mps);
     for my $mp (@mps) {
         $g->mount_ro ($mps{$mp}, $mp);
     # ...

http://libguestfs.org/guestfs-perl.3.html#example-2:-inspect-a-virtual-machine-disk-image

If we modify get_mountpoints or even add a new get_mountpoints2 call,
then we push a bunch of complexity up to the user.  The mount code has
to look like:

     for ($mp, $subvol) (@mps) {
         if (!$subvol) {
             $g->mount_ro ($mps{$mp}, $mp);
         } elsif ($g->vfs_type ($mp) eq "btrfs") {
             $g->mount_options ("subvol=$subvol", $mps{$mp}, $mp);
         } elsif ($g->vfs_type ($mp) eq "zfs") {
             $g->mount_options ("something=$subvol", $mps{$mp}, $mp);
         } else {
             die "sorry we don't know how to mount this"
         }
     }

and that's not very nice.

However changing mount to understand more complex strings containing
subvolumes is also not great, and potentially impacts the whole API
(after all, *any* call which might refer to a filesystem such as
vfs_type, would have to be modified).

So I don't know about (2) yet.  Something to keep thinking about.

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]