[pve-devel] [PATCH qemu-server 4/5] phase2 : add livemigrate_storage
Alexandre Derumier
aderumier at odiso.com
Thu Apr 25 09:22:52 CEST 2019
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuMigrate.pm | 46 +++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 7a701a9..b38bf5c 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -549,30 +549,13 @@ sub phase2 {
my ($raddr, $rport, $ruri, $spice_port, $spice_ticket) = find_remote_ports($self, $vmid, $cmd);
start_remote_tunnel($self, $nodename, $migration_type, $raddr, $rport, $ruri);
+
+ livemigrate_storage($self, $vmid);
my $start = time();
my $opt_bwlimit = $self->{opts}->{bwlimit};
- if (defined($self->{online_local_volumes})) {
- $self->{storage_migration} = 1;
- $self->{storage_migration_jobs} = {};
- $self->log('info', "starting storage migration");
-
- die "The number of local disks does not match between the source and the destination.\n"
- if (scalar(keys %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}});
- foreach my $drive (keys %{$self->{target_drive}}){
- my $target = $self->{target_drive}->{$drive};
- my $nbd_uri = $target->{nbd_uri};
- my $source_sid = PVE::Storage::Plugin::parse_volume_id($conf->{$drive});
- my $target_sid = PVE::Storage::Plugin::parse_volume_id($target->{volid});
- my $bwlimit = PVE::Storage::get_bandwidth_limit('migrate', [$source_sid, $target_sid], $opt_bwlimit);
-
- $self->log('info', "$drive: start migration to $nbd_uri");
- PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1, undef, $bwlimit);
- }
- }
-
$self->log('info', "starting online/live migration on $ruri");
$self->{livemigration} = 1;
@@ -1102,4 +1085,29 @@ sub start_remote_tunnel {
}
}
+sub livemigrate_storage {
+ my ($self, $vmid) = @_;
+
+ my $conf = $self->{vmconf};
+
+ if (defined($self->{online_local_volumes})) {
+ $self->{storage_migration} = 1;
+ $self->{storage_migration_jobs} = {};
+ $self->log('info', "starting storage migration");
+
+ die "The number of local disks does not match between the source and the destination.\n"
+ if (scalar(keys %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}});
+ foreach my $drive (keys %{$self->{target_drive}}){
+ my $target = $self->{target_drive}->{$drive};
+ my $nbd_uri = $target->{nbd_uri};
+ my $source_sid = PVE::Storage::Plugin::parse_volume_id($conf->{$drive});
+ my $target_sid = PVE::Storage::Plugin::parse_volume_id($target->{volid});
+ my $bwlimit = PVE::Storage::get_bandwidth_limit('migrate', [$source_sid, $target_sid], $self->{opts}->{bwlimit});
+
+ $self->log('info', "$drive: start migration to $nbd_uri");
+ PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1, undef, $bwlimit);
+ }
+ }
+}
+
1;
--
2.11.0
More information about the pve-devel
mailing list