Matthew Booth
2009-Jul-24 13:59 UTC
[Libguestfs] [PATCH] Make read-only optional in mount_operating_system()
---
perl/lib/Sys/Guestfs/Lib.pm | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 5d48ba8..00a9bdb 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1067,14 +1067,22 @@ sub mount_operating_system
local $_;
my $g = shift;
my $os = shift;
+ my $ro = shift; # Read-only?
+
+ $ro = 1 unless(defined($ro)); # ro defaults to 1 if unspecified
my $mounts = $os->{mounts};
# Have to mount / first. Luckily '/' is early in the ASCII
# character set, so this should be OK.
foreach (sort keys %$mounts) {
- $g->mount_ro ($mounts->{$_}, $_)
- if $_ ne "swap" && $_ ne "none" && ($_
eq '/' || $g->is_dir ($_));
+ if($_ ne "swap" && $_ ne "none" &&
($_ eq '/' || $g->is_dir ($_))) {
+ if($ro) {
+ $g->mount_ro ($mounts->{$_}, $_)
+ } else {
+ $g->mount ($mounts->{$_}, $_)
+ }
+ }
}
}
--
1.6.2.5
Richard W.M. Jones
2009-Jul-24 14:22 UTC
[Libguestfs] [PATCH] Make read-only optional in mount_operating_system()
On Fri, Jul 24, 2009 at 02:59:19PM +0100, Matthew Booth wrote:> --- > perl/lib/Sys/Guestfs/Lib.pm | 12 ++++++++++-- > 1 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm > index 5d48ba8..00a9bdb 100644 > --- a/perl/lib/Sys/Guestfs/Lib.pm > +++ b/perl/lib/Sys/Guestfs/Lib.pm > @@ -1067,14 +1067,22 @@ sub mount_operating_system > local $_; > my $g = shift; > my $os = shift; > + my $ro = shift; # Read-only? > + > + $ro = 1 unless(defined($ro)); # ro defaults to 1 if unspecified > > my $mounts = $os->{mounts}; > > # Have to mount / first. Luckily '/' is early in the ASCII > # character set, so this should be OK. > foreach (sort keys %$mounts) { > - $g->mount_ro ($mounts->{$_}, $_) > - if $_ ne "swap" && $_ ne "none" && ($_ eq '/' || $g->is_dir ($_)); > + if($_ ne "swap" && $_ ne "none" && ($_ eq '/' || $g->is_dir ($_))) { > + if($ro) { > + $g->mount_ro ($mounts->{$_}, $_) > + } else { > + $g->mount ($mounts->{$_}, $_) > + } > + } > } > }So it was ignoring $ro previously? +1. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.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
Reasonably Related Threads
- failure converting Linux ESX guest to KVM hypervisor
- virt-customize fail to inject firstboot script when running it from script.
- Re: Concurrent scanning of same disk
- Re: [PATCH v2 2/3] v2v: allow alternative directories for distributions
- Concurrent scanning of same disk