VMware and multiple vmdk files
by Thierry Thelliez
With VMWare (server), you can pre-allocate your image in several vmdk
files. But I have not bee able to mount that in guestfs.
On file (e.g. guest.vmdk) is a text file pointing to all the other
files (e.g. guest-f001.vmdk, guest-f002.vmdk,...).
I tried the following scenarios without success:
1- just adding the base vmdk: add_drive guest.vmdk
2- adding all the files:
add_drive guest-f001.vmdk
add_drive guest-f002.vmdk
...
It works if I merge all the files with vmware-vdiskmanager
(something like: vmware-vdiskmanager -r guest.vmdk -t 0 guest-new.vmdk)
Can I use guestfs without merging all the files in one image?
Thanks,
Thierry
14 years, 6 months
[PATCH 1/2] Rely on new augeas lens for modules.conf and conf.modules
by Matthew Booth
Latest augeas includes a lens for /etc/modules.conf. If this new lens is
present, the code to force the Modprobe lens to try to match /etc/modules.conf
as well results in /etc/modules.conf not being parsed at all. This results in
modprobe_aliases in virt-inspector output being empty.
This change is equivalent to change cfd28d1140393667913689b7b9bcf21c8bfe592c
from virt-v2v.
An effect of this change is that the Modules_conf augeas lens is now required
for correct operation on guests which use /etc/modules.conf.
Fixes RHBZ#596776
---
perl/lib/Sys/Guestfs/Lib.pm | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 2c5c837..128f7c9 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1820,13 +1820,6 @@ sub _find_modprobe_aliases
# Initialise augeas
$g->aug_init("/", 16);
- # Register additional paths to the Modprobe lens
- $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/modules.conf");
- $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/conf.modules");
-
- # Make augeas reload
- $g->aug_load();
-
my %modprobe_aliases;
for my $pattern qw(/files/etc/conf.modules/alias
--
1.7.0.1
14 years, 7 months
[PATCH] RHEV: Only mark the first disk as bootable
by Matthew Booth
RHEV will fail to start a guest with more than one VirtIO disk marked as
bootable. The previous behaviour of V2V simply marked all disks as bootable,
intending to follow the behaviour of libvirt's qemu driver. However, libvirt's
qemu driver actually only marks the first disk specified in the domain XML
(which may or may not be Xda) as bootable. This change updates the RHEV output
to follow this.
Fixes RHBZ#595619
---
lib/Sys/VirtV2V/Target/RHEV.pm | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/Sys/VirtV2V/Target/RHEV.pm b/lib/Sys/VirtV2V/Target/RHEV.pm
index c35379d..231fe5c 100644
--- a/lib/Sys/VirtV2V/Target/RHEV.pm
+++ b/lib/Sys/VirtV2V/Target/RHEV.pm
@@ -874,8 +874,9 @@ sub _disks
$diske->setAttribute('ovf:format', 'http://en.wikipedia.org/wiki/Byte');
# IDE = 0, SCSI = 1, VirtIO = 2
$diske->setAttribute('ovf:disk-interface', $bus eq 'virtio' ? 2 : 0);
- # The libvirt QEMU driver marks all disks as bootable
- $diske->setAttribute('ovf:boot', 'True');
+ # The libvirt QEMU driver marks the first disk (in document order) as
+ # bootable
+ $diske->setAttribute('ovf:boot', $driveno == 1 ? 'True' : 'False');
# Add disk to VirtualHardware
my $item = $ovf->createElement('Item');
--
1.7.0.1
14 years, 7 months
[PATCH] Remove Windows 7 viostor from config
by Matthew Booth
Windows 7 (version 6.1) doesn't require a different driver to Windows 2008
(version 6.0), Windows Vista (version 6.0) or Windows 2008 R2 (version 6.1).
They're all version 6, so we can just match on that.
---
v2v/virt-v2v.conf | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/v2v/virt-v2v.conf b/v2v/virt-v2v.conf
index 9fbb1cc..c3dfd30 100644
--- a/v2v/virt-v2v.conf
+++ b/v2v/virt-v2v.conf
@@ -153,12 +153,6 @@
<app os='windows' major='6' arch='x86_64' name='viostor'>
<path>windows/2008/x86_64/viostor.sys</path>
</app>
- <app os='windows' major='6' minor='1' arch='i386' name='viostor'>
- <path>windows/7/i386/viostor.sys</path>
- </app>
- <app os='windows' major='6' minor='1' arch='x86_64' name='viostor'>
- <path>windows/7/x86_64/viostor.sys</path>
- </app>
<!-- RHSrvAny is compiled as a 32 bit app even on 64 bit Windows -->
<app os='windows' name='rhsrvany'>
<path>windows/rhsrvany.exe</path>
--
1.7.0.1
14 years, 7 months
[PATCH] Windows: Display an error containing all missing when any are missing
by Matthew Booth
Fixes RHBZ#596238
---
lib/Sys/VirtV2V/Converter/Windows.pm | 57 +++++++++++++++------------------
1 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/lib/Sys/VirtV2V/Converter/Windows.pm b/lib/Sys/VirtV2V/Converter/Windows.pm
index 8de2bcd..e55d0f3 100644
--- a/lib/Sys/VirtV2V/Converter/Windows.pm
+++ b/lib/Sys/VirtV2V/Converter/Windows.pm
@@ -181,9 +181,8 @@ sub _preconvert
eval { $g->mkdir ("/temp"); };
eval { $g->mkdir ("/temp/v2v"); };
- _upload_viostor ($g, $tmpdir, $desc, $devices, $config);
+ _upload_files ($g, $tmpdir, $desc, $devices, $config);
_add_viostor_to_registry ($g, $tmpdir, $desc, $devices, $config);
- _upload_service ($g, $tmpdir, $desc, $devices, $config);
_add_service_to_registry ($g, $tmpdir, $desc, $devices, $config);
}
@@ -343,7 +342,7 @@ sub _add_service_to_registry
$g->upload ($tmpdir . "/system", $system_filename);
}
-sub _upload_viostor
+sub _upload_files
{
my $g = shift;
my $tmpdir = shift;
@@ -351,39 +350,35 @@ sub _upload_viostor
my $devices = shift;
my $config = shift;
- my $driverpath = "/windows/system32/drivers";
- $driverpath = $g->case_sensitive_path ($driverpath);
+ # Check we have all required files
+ my @missing;
+ my %files;
- my ($app, $depnames) = $config->match_app ($desc, "viostor", $desc->{arch});
- $app = $config->get_transfer_path ($g, $app);
- $g->cp ($app, $driverpath);
-}
+ for my $file ("viostor", "firstboot", "firstbootapp", "rhsrvany") {
+ my ($path) = $config->match_app ($desc, $file, $desc->{arch});
+ my $local = $config->get_transfer_path ($g, $path);
+ push (@missing, $path) unless ($g->exists($local));
-sub _upload_service
-{
- my $g = shift;
- my $tmpdir = shift;
- my $desc = shift;
- my $devices = shift;
- my $config = shift;
-
- my $path = "/temp/v2v";
- $path = $g->case_sensitive_path ($path);
+ $files{$file} = $local;
+ }
- my ($app, $depnames) =
- $config->match_app ($desc, "firstboot", $desc->{arch});
- $app = $config->get_transfer_path ($g, $app);
- $g->cp ($app, $path);
+ # We can't proceed if there are any files missing
+ die(user_message(__x("Installation failed because the following ".
+ "files referenced in the configuration file are ".
+ "required, but missing: {list}",
+ list => join(' ', @missing)))) if (@missing > 0);
- ($app, $depnames) =
- $config->match_app ($desc, "firstbootapp", $desc->{arch});
- $app = $config->get_transfer_path ($g, $app);
- $g->cp ($app, $path);
+ # Copy viostor into place
+ my $driverpath = "/windows/system32/drivers";
+ $driverpath = $g->case_sensitive_path ($driverpath);
+ $g->cp ($files{viostor}, $driverpath);
- ($app, $depnames) =
- $config->match_app ($desc, "rhsrvany", $desc->{arch});
- $app = $config->get_transfer_path ($g, $app);
- $g->cp ($app, $path);
+ # Copy other files into a temp directory
+ my $path = "/temp/v2v";
+ $path = $g->case_sensitive_path ($path);
+ $g->cp ($files{firstboot}, $path);
+ $g->cp ($files{firstbootapp}, $path);
+ $g->cp ($files{rhsrvany}, $path);
}
=back
--
1.7.0.1
14 years, 7 months
[PATCH] Fix error in Converter::Windows when there is no transfer iso
by Matthew Booth
The code for mounting the transfer iso in Converter::Windows didn't do the same
level of error checking as the same code in GuestOS::RedHat. This change moves
the GuestOS code into Config, and updates both GuestOS::RedHat and
Converter::Windows to use Config.
Fixes RHBZ#596091
---
lib/Sys/VirtV2V/Config.pm | 51 ++++++++++++++++++++++++
lib/Sys/VirtV2V/Converter/Windows.pm | 40 ++++---------------
lib/Sys/VirtV2V/GuestOS/RedHat.pm | 72 ++++++---------------------------
3 files changed, 72 insertions(+), 91 deletions(-)
diff --git a/lib/Sys/VirtV2V/Config.pm b/lib/Sys/VirtV2V/Config.pm
index 334adf9..10ef8be 100644
--- a/lib/Sys/VirtV2V/Config.pm
+++ b/lib/Sys/VirtV2V/Config.pm
@@ -203,6 +203,44 @@ sub get_transfer_iso
return $iso_path;
}
+=item get_transfer_path(path)
+
+Return the path to I<path> as accessible by the libguestfs appliance. This
+function will also ensure that the transfer iso is mounted.
+
+=cut
+
+sub get_transfer_path
+{
+ my $self = shift;
+ my ($g, $path) = @_;
+
+ # Check that the transfer iso is mounted
+ if (!exists($self->{transfer_mount})) {
+ # Existing code expects the mount to exist, but handles the case where
+ # files in it don't exist. Therefore we always create the mount point,
+ # but only mount anything on it if there's actually a transfer iso.
+
+ # Create the transfer mount point
+ $self->{transfer_mount} = $g->mkdtemp("/tmp/transferXXXXXX");
+
+ # Only mount the transfer iso if there is one
+ if (defined($self->get_transfer_iso())) {
+ # Find the transfer device
+ my @devices = $g->list_devices();
+ my $transfer = $devices[$#devices];
+
+ $g->mount_ro($transfer, $self->{transfer_mount});
+ $self->{transfer_mounted} = 1;
+
+ # We'll need this to unmount in DESTROY
+ $self->{g} = $g;
+ }
+ }
+
+ return File::Spec->catfile($self->{transfer_mount}, $path);
+}
+
sub _get_search
{
my ($desc, $name, $arch) = @_;
@@ -458,6 +496,19 @@ sub set_default_net_mapping
$self->{default_net_mapping} = [ $name, $type ];
}
+sub DESTROY
+{
+ my $self = shift;
+
+ my $g = $self->{g};
+
+ # Remove the transfer mount point if it was used
+ $g->umount($self->{transfer_mount})
+ if(defined($self->{transfer_mounted}));
+ $g->rmdir($self->{transfer_mount})
+ if(defined($self->{transfer_mount}));
+}
+
=back
=head1 COPYRIGHT
diff --git a/lib/Sys/VirtV2V/Converter/Windows.pm b/lib/Sys/VirtV2V/Converter/Windows.pm
index 4ea2caa..8de2bcd 100644
--- a/lib/Sys/VirtV2V/Converter/Windows.pm
+++ b/lib/Sys/VirtV2V/Converter/Windows.pm
@@ -181,21 +181,10 @@ sub _preconvert
eval { $g->mkdir ("/temp"); };
eval { $g->mkdir ("/temp/v2v"); };
- # Find the transfer device
- my @devices = $g->list_devices();
- my $transfer = $devices[$#devices];
-
- my $transfer_mount = $g->mkdtemp ("/temp/transferXXXXXX");
- $g->mount_ro ($transfer, $transfer_mount);
-
- _upload_viostor ($g, $tmpdir, $desc, $devices, $config,
- $transfer_mount);
- _add_viostor_to_registry ($g, $tmpdir, $desc, $devices, $config,
- $transfer_mount);
- _upload_service ($g, $tmpdir, $desc, $devices, $config,
- $transfer_mount);
- _add_service_to_registry ($g, $tmpdir, $desc, $devices, $config,
- $transfer_mount);
+ _upload_viostor ($g, $tmpdir, $desc, $devices, $config);
+ _add_viostor_to_registry ($g, $tmpdir, $desc, $devices, $config);
+ _upload_service ($g, $tmpdir, $desc, $devices, $config);
+ _add_service_to_registry ($g, $tmpdir, $desc, $devices, $config);
}
# See http://rwmj.wordpress.com/2010/04/30/tip-install-a-device-driver-in-a-win...
@@ -206,7 +195,6 @@ sub _add_viostor_to_registry
my $desc = shift;
my $devices = shift;
my $config = shift;
- my $transfer_mount = shift;
# Locate and download the system registry.
my $system_filename;
@@ -305,7 +293,6 @@ sub _add_service_to_registry
my $desc = shift;
my $devices = shift;
my $config = shift;
- my $transfer_mount = shift;
# Locate and download the system registry.
my $system_filename;
@@ -363,13 +350,12 @@ sub _upload_viostor
my $desc = shift;
my $devices = shift;
my $config = shift;
- my $transfer_mount = shift;
my $driverpath = "/windows/system32/drivers";
$driverpath = $g->case_sensitive_path ($driverpath);
my ($app, $depnames) = $config->match_app ($desc, "viostor", $desc->{arch});
- $app = _transfer_path ($transfer_mount, $app);
+ $app = $config->get_transfer_path ($g, $app);
$g->cp ($app, $driverpath);
}
@@ -380,36 +366,26 @@ sub _upload_service
my $desc = shift;
my $devices = shift;
my $config = shift;
- my $transfer_mount = shift;
my $path = "/temp/v2v";
$path = $g->case_sensitive_path ($path);
my ($app, $depnames) =
$config->match_app ($desc, "firstboot", $desc->{arch});
- $app = _transfer_path ($transfer_mount, $app);
+ $app = $config->get_transfer_path ($g, $app);
$g->cp ($app, $path);
($app, $depnames) =
$config->match_app ($desc, "firstbootapp", $desc->{arch});
- $app = _transfer_path ($transfer_mount, $app);
+ $app = $config->get_transfer_path ($g, $app);
$g->cp ($app, $path);
($app, $depnames) =
$config->match_app ($desc, "rhsrvany", $desc->{arch});
- $app = _transfer_path ($transfer_mount, $app);
+ $app = $config->get_transfer_path ($g, $app);
$g->cp ($app, $path);
}
-# Get full, local path of a file on the transfer mount
-sub _transfer_path
-{
- my $transfer_mount = shift;
- my $path = shift;
-
- return File::Spec->catfile ($transfer_mount, $path);
-}
-
=back
=head1 COPYRIGHT
diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index c46cbbe..1709733 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -889,7 +889,9 @@ sub _install_config
}
my @missing;
- if (defined($kernel) && !$g->exists($self->_transfer_path($kernel))) {
+ if (defined($kernel) &&
+ !$g->exists($self->{config}->get_transfer_path($g, $kernel)))
+ {
push(@missing, $kernel);
}
@@ -1167,7 +1169,7 @@ sub _get_nevra
my $g = $self->{g};
- $rpm = $self->_transfer_path($rpm);
+ $rpm = $self->{config}->get_transfer_path($g, $rpm);
# Get NEVRA for the rpm to be installed
my $nevra = $g->command(['rpm', '-qp', '--qf',
@@ -1292,7 +1294,8 @@ sub _get_deppaths
foreach my $app (@apps) {
my ($path, $deps) = $config->match_app($desc, $app, $arch);
- my $exists = $self->{g}->exists($self->_transfer_path($path));
+ my $g = $self->{g};
+ my $exists = $g->exists($self->{config}->get_transfer_path($g, $path));
if (!$exists) {
push(@$missing, $path);
@@ -1319,7 +1322,10 @@ sub _get_deppaths
};
if (defined($path)) {
- if (!$self->{g}->exists($self->_transfer_path($path))) {
+ my $g = $self->{g};
+
+ if (!$g->exists($self->{config}->get_transfer_path($g, $path)))
+ {
push(@$missing, $path);
foreach my $deppath ($self->_get_deppaths($missing,
@@ -1482,10 +1488,11 @@ sub _install_rpms
# Nothing to do if we got an empty set
return if(scalar(@rpms) == 0);
+ my $g = $self->{g};
+
# All paths are relative to the transfer mount. Need to make them absolute.
- @rpms = map { $_ = $self->_transfer_path($_) } @rpms;
+ @rpms = map { $_ = $self->{config}->get_transfer_path($g, $_) } @rpms;
- my $g = $self->{g};
$g->command(['rpm', $upgrade == 1 ? '-U' : '-i', @rpms]);
# Reload augeas in case the rpm installation changed anything
@@ -1496,46 +1503,6 @@ sub _install_rpms
$self->_augeas_error($@) if($@);
}
-# Get full, local path of a file on the transfer mount
-sub _transfer_path
-{
- my $self = shift;
-
- my ($path) = @_;
-
- $self->_ensure_transfer_mounted();
-
- return File::Spec->catfile($self->{transfer_mount}, $path);
-}
-
-# Ensure that the transfer device is mounted. If not, mount it.
-sub _ensure_transfer_mounted
-{
- my $self = shift;
-
- # Return immediately if it's already mounted
- return if(exists($self->{transfer_mount}));
-
- my $g = $self->{g};
-
- # Code in this file expects the mount to exist, but handles the case where
- # files in it don't exist. Therefore we always create the mount point, but
- # only mount anything on it if there's actually a transfer iso.
-
- # Create the transfer mount point
- $self->{transfer_mount} = $g->mkdtemp("/tmp/transferXXXXXX");
-
- # Only mount the transfer iso if there is one
- if (defined($self->{config}->get_transfer_iso())) {
- # Find the transfer device
- my @devices = $g->list_devices();
- my $transfer = $devices[$#devices];
-
- $g->mount_ro($transfer, $self->{transfer_mount});
- $self->{transfer_mounted} = 1;
- }
-}
-
=item remap_block_devices(devices, virtio)
See BACKEND INTERFACE in L<Sys::VirtV2V::GuestOS> for details.
@@ -1830,19 +1797,6 @@ sub supports_virtio
return 1;
}
-sub DESTROY
-{
- my $self = shift;
-
- my $g = $self->{g};
-
- # Remove the transfer mount point if it was used
- $g->umount($self->{transfer_mount})
- if(defined($self->{transfer_mounted}));
- $g->rmdir($self->{transfer_mount})
- if(defined($self->{transfer_mount}));
-}
-
=back
=head1 COPYRIGHT
--
1.7.0.1
14 years, 7 months