[Libguestfs] [PATCH 4/4] Sys::Guestfs::Lib::open_guest: Add interface parameter.
Richard W.M. Jones
rjones at redhat.com
Fri Feb 12 12:46:25 UTC 2010
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From c03b7e4d756597f30415260a84a3caee3d9d6bde Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Fri, 12 Feb 2010 12:13:40 +0000
Subject: [PATCH 4/4] Sys::Guestfs::Lib::open_guest: Add interface parameter.
This allows you to override the default QEMU block device emulation.
---
perl/lib/Sys/Guestfs/Lib.pm | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index c9a3237..e17728d 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -117,6 +117,10 @@ disk image, then C<$conn> and C<$dom> will be C<undef>.
If the C<Sys::Virt> module is not available, then libvirt is bypassed,
and this function can only open disk images.
+The optional C<interface> parameter can be used to open devices with
+C<add_drive{,_ro}_with_if>. See
+L<Sys::Guestfs/guestfs_add_drive_with_if> for more details.
+
=cut
sub open_guest
@@ -127,6 +131,7 @@ sub open_guest
my $rw = $params{rw};
my $address = $params{address};
+ my $interface = $params{interface};
my @images = ();
if (ref ($first) eq "ARRAY") {
@@ -203,9 +208,17 @@ sub open_guest
my $g = Sys::Guestfs->new ();
foreach (@images) {
if ($rw) {
- $g->add_drive ($_);
+ if ($interface) {
+ $g->add_drive_with_if ($_, $interface);
+ } else {
+ $g->add_drive ($_);
+ }
} else {
- $g->add_drive_ro ($_);
+ if ($interface) {
+ $g->add_drive_ro_with_if ($_, $interface);
+ } else {
+ $g->add_drive_ro ($_);
+ }
}
}
--
1.6.5.2
More information about the Libguestfs
mailing list