+} else {
+ while (@domains) {
+ my $n = 0; # number of disks added so far
+ my @request = ();
+ while (@domains) {
+ my $c = @{$domains[0]->{disks}};
+ if ($c > $max_disks) {
+ warn __x("virt-df: ignoring {name}, it has too many disks ({c} > {max})",
+ name => $domains[0]->{name},
+ c => $c, max => $max_disks);
+ next;
+ }
+ last if $n + $c > $max_disks;
+ $n += $c;
+ push @request, shift (@domains);
+ }
+ multi_df (@request);
+ }
+}
+
+sub multi_df
+{
+ local $_;
+ eval {
+ my $g = Sys::Guestfs->new ();
+
+ my ($d, $disk);
+
+ foreach $d (@_) {
+ foreach $disk (@{$d->{disks}}) {
+ $g->add_drive_ro ($disk);
+ }
+ }
+
+ $g->launch ();
+ my $has_lvm2 = feature_available ($g, "lvm2");
+
+ my @devices = $g->list_devices ();
+ my @partitions = $g->list_partitions ();
+
+ my $n = 0;
+ foreach $d (@_) {
+ my $name = $d->{name};
+ my $nr_disks = @{$d->{disks}};
+
+ # Filter LVM to only the devices applying to the original domain.
+ my @devs = @devices[$n .. $n+$nr_disks-1];
+ $g->lvm_set_filter (\@devs) if $has_lvm2;
+
+ # Find which whole devices (RHBZ#590167), partitions and LVs
+ # contain mountable filesystems. Stat those which are
+ # mountable, and ignore the others.
+ foreach (@devs) {
+ try_df ($name, $g, $_, canonical_dev ($_, $n));
+ }
+ foreach (filter_partitions (\@devs, @partitions)) {
+ try_df ($name, $g, $_, canonical_dev ($_, $n));
+ }
+ if ($has_lvm2) {
+ foreach ($g->lvs ()) {
+ try_df ($name, $g, $_);
+ }
+ }
+
+ $n += $nr_disks;
+ }
+ };
+ warn if $@;
+}