Exit with an error if we would overwrite an existing libvirt domain.
Fixes RHBZ#617110
---
lib/Sys/VirtV2V/Connection/LibVirt.pm | 4 ++++
lib/Sys/VirtV2V/Target/LibVirt.pm | 31 ++++++++++++++++++++++++++++++-
lib/Sys/VirtV2V/Target/RHEV.pm | 11 +++++++++++
3 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/lib/Sys/VirtV2V/Connection/LibVirt.pm
b/lib/Sys/VirtV2V/Connection/LibVirt.pm
index b83a10d..51331da 100644
--- a/lib/Sys/VirtV2V/Connection/LibVirt.pm
+++ b/lib/Sys/VirtV2V/Connection/LibVirt.pm
@@ -79,6 +79,10 @@ sub new
$self->{uri} = URI->new($uri);
$self->{name} = $name;
+ # Check that the guest doesn't already exist on the target
+ die(user_message(__x("Domain {name} already exists on the target.",
+ name => $name))) if ($target->guest_exists($name));
+
# Parse uri authority for hostname and username
$self->{uri}->authority() =~ /^(?:([^:]*)(?::([^@]*))?@)?(.*)$/
or die(user_message(__x("Unable to parse URI authority: {auth}",
diff --git a/lib/Sys/VirtV2V/Target/LibVirt.pm b/lib/Sys/VirtV2V/Target/LibVirt.pm
index 574590c..279e93d 100644
--- a/lib/Sys/VirtV2V/Target/LibVirt.pm
+++ b/lib/Sys/VirtV2V/Target/LibVirt.pm
@@ -145,8 +145,10 @@ sub close
package Sys::VirtV2V::Target::LibVirt;
-use Sys::VirtV2V::Util qw(user_message);
+use Sys::Virt;
+use Sys::Virt::Error;
+use Sys::VirtV2V::Util qw(user_message);
use Locale::TextDomain 'virt-v2v';
=head1 NAME
@@ -288,6 +290,33 @@ sub get_volume
return Sys::VirtV2V::Target::LibVirt::Vol->_get($self->{pool}, $name);
}
+=item guest_exists(name)
+
+Return 1 if a guest with I<name> already exists, 0 otherwise.
+
+=cut
+
+sub guest_exists
+{
+ my $self = shift;
+ my ($name) = @_;
+
+ eval {
+ $self->{vmm}->get_domain_by_name($name);
+ };
+
+ if ($@) {
+ if ($@->code == Sys::Virt::Error::ERR_NO_DOMAIN) {
+ return 0;
+ }
+
+ die(user_message(__x("Error checking for domain: {error}",
+ error => $@->stringify())));
+ }
+
+ return 1;
+}
+
=item create_guest(dom)
Create the guest in the target
diff --git a/lib/Sys/VirtV2V/Target/RHEV.pm b/lib/Sys/VirtV2V/Target/RHEV.pm
index 574b022..218cf63 100644
--- a/lib/Sys/VirtV2V/Target/RHEV.pm
+++ b/lib/Sys/VirtV2V/Target/RHEV.pm
@@ -618,6 +618,17 @@ sub get_volume
die("Cannot retrieve an existing RHEV storage volume by name");
}
+=item guest_exists(name)
+
+This always returns 0 for a RHEV target.
+
+=cut
+
+sub guest_exists
+{
+ return 0;
+}
+
=item create_guest(dom)
Create the guest in the target
--
1.7.2.3
Show replies by date
BoardName and VendorName are for information only, and will likely contain
incorrect information after conversion. Simply remove them.
Fixes RHBZ#595264
---
lib/Sys/VirtV2V/GuestOS/RedHat.pm | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index 74b9de1..a475db8 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -299,6 +299,14 @@ sub update_display_driver
$g->aug_set($path, $driver);
}
+ # Remove VendorName and BoardName if present
+ foreach my $path
+
($g->aug_match('/files'.$self->{xorg}.'/Device/VendorName'),
+
$g->aug_match('/files'.$self->{xorg}.'/Device/BoardName'))
+ {
+ $g->aug_rm($path);
+ }
+
$g->aug_save();
};
--
1.7.2.3
/etc/sysconfig/kernel contains the default kernel package. Ensure we set
DEFAULTKERNEL to whichever kernel we install.
Fixes RHBZ#609526
---
lib/Sys/VirtV2V/GuestOS/RedHat.pm | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index a475db8..a322a5d 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -654,6 +654,23 @@ sub _install_any
my $g = $self->{g};
+ # If we're updating the kernel, make sure DEFAULTKERNEL is updated in case
+ # the kernel package has changed
+ if (defined($kernel)) {
+ eval {
+ foreach my $path
+
($g->aug_match('/files/etc/sysconfig/kernel/DEFAULTKERNEL/value'))
+ {
+ $g->aug_set($path, $kernel->[0]);
+ }
+
+ $g->aug_save();
+ };
+
+ # Propagate augeas errors
+ augeas_error($g, $@) if ($@);
+ };
+
my $resolv_bak = $g->exists('/etc/resolv.conf');
$g->mv('/etc/resolv.conf', '/etc/resolv.conf.v2vtmp') if
($resolv_bak);
--
1.7.2.3
The master/vms directory in an export storage domain is only created when the
domain is attached to a Data Center, not when it is initialised. Because we
write to this directory last, virt-v2v will only currently fail at the very end
of the conversion process. This patch checks for the existence of this directory
early and reports a useful error to the user.
Fixes RHBZ#601535
---
lib/Sys/VirtV2V/Target/RHEV.pm | 31 +++++++++++++++++++++++++------
1 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/lib/Sys/VirtV2V/Target/RHEV.pm b/lib/Sys/VirtV2V/Target/RHEV.pm
index 218cf63..b865c56 100644
--- a/lib/Sys/VirtV2V/Target/RHEV.pm
+++ b/lib/Sys/VirtV2V/Target/RHEV.pm
@@ -497,24 +497,43 @@ sub new
my $fromchild = $nfs->{fromchild};
while (<$fromchild>) {
if (defined($domainuuid)) {
- die(user_message(__x("{mountdir} contains multiple possible ".
+ die(user_message(__x("{domain_path} contains multiple possible ".
"domains. It may only contain one.",
- mountdir => $mountdir)));
+ domain_path => $domain_path)));
}
chomp;
$domainuuid = $_;
}
-
$nfs->check_exit();
if (!defined($domainuuid)) {
- die(user_message(__x("{mountdir} does not contain an initialised ".
+ die(user_message(__x("{domain_path} does not contain an initialised ".
"storage domain",
- mountdir => $mountdir)));
+ domain_path => $domain_path)));
}
-
$self->{domainuuid} = $domainuuid;
+ # Check that the domain has been attached to a Data Center by checking that
+ # the master/vms directory exists
+ my $vms_rel = $domainuuid.'/master/vms';
+ my $vms_abs = $mountdir.'/'.$vms_rel;
+ $nfs = Sys::VirtV2V::Target::RHEV::NFSHelper->new(sub {
+ if (-d $vms_abs) {
+ print "1\n";
+ } else {
+ print "0\n";
+ }
+ });
+ $fromchild = $nfs->{fromchild};
+ while (<$fromchild>) {
+ chomp;
+ die(user_message(__x("{domain_path} has not been attached to a RHEV ".
+ "data center ({path} does not exist).",
+ domain_path => $domain_path,
+ path => $vms_rel))) if ($_ eq "0");
+ }
+ $nfs->check_exit();
+
return $self;
}
--
1.7.2.3