]> git.proxmox.com Git - qemu-server.git/commitdiff
migration: split out config_update_local_disksizes from scan_local_volumes
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 29 Jan 2021 15:11:34 +0000 (16:11 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 18 Apr 2021 16:30:41 +0000 (18:30 +0200)
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/QemuMigrate.pm

index d0295f87a5fe8d2e7679801610a6de9ab8bfab4d..455581cf8827428e14652a210adfd6497afb56d2 100644 (file)
@@ -587,28 +587,6 @@ sub scan_local_volumes {
               'PVE::QemuConfig', $self->{replication_jobcfg}, $start_time, $start_time, $logfunc);
        }
 
-       # sizes in config have to be accurate for remote node to correctly
-       # allocate disks
-       PVE::QemuConfig->foreach_volume($conf, sub {
-           my ($key, $drive) = @_;
-           return if $key eq 'efidisk0'; # skip efidisk, will be handled later
-
-           my $volid = $drive->{file};
-           return if !defined($local_volumes->{$volid}); # only update sizes for local volumes
-
-           my ($updated, $msg) = PVE::QemuServer::Drive::update_disksize($drive, $local_volumes->{$volid}->{size});
-           if (defined($updated)) {
-               $conf->{$key} = PVE::QemuServer::print_drive($updated);
-               $self->log('info', "drive '$key': $msg");
-           }
-       });
-
-       # we want to set the efidisk size in the config to the size of the
-       # real OVMF_VARS.fd image, else we can create a too big image, which does not work
-       if (defined($conf->{efidisk0})) {
-           PVE::QemuServer::update_efidisk_size($conf);
-       }
-
        foreach my $volid (sort keys %$local_volumes) {
            my $ref = $local_volumes->{$volid}->{ref};
            if ($self->{running} && $ref eq 'config') {
@@ -628,6 +606,33 @@ sub scan_local_volumes {
     die "Problem found while scanning volumes - $@" if $@;
 }
 
+sub config_update_local_disksizes {
+    my ($self) = @_;
+
+    my $conf = $self->{vmconf};
+    my $local_volumes = $self->{local_volumes};
+
+    PVE::QemuConfig->foreach_volume($conf, sub {
+       my ($key, $drive) = @_;
+       return if $key eq 'efidisk0'; # skip efidisk, will be handled later
+
+       my $volid = $drive->{file};
+       return if !defined($local_volumes->{$volid}); # only update sizes for local volumes
+
+       my ($updated, $msg) = PVE::QemuServer::Drive::update_disksize($drive, $local_volumes->{$volid}->{size});
+       if (defined($updated)) {
+           $conf->{$key} = PVE::QemuServer::print_drive($updated);
+           $self->log('info', "drive '$key': $msg");
+       }
+    });
+
+    # we want to set the efidisk size in the config to the size of the
+    # real OVMF_VARS.fd image, else we can create a too big image, which does not work
+    if (defined($conf->{efidisk0})) {
+       PVE::QemuServer::update_efidisk_size($conf);
+    }
+}
+
 sub filter_local_volumes {
     my ($self, $migration_mode) = @_;
 
@@ -732,9 +737,11 @@ sub phase1 {
     $conf->{lock} = 'migrate';
     PVE::QemuConfig->write_config($vmid, $conf);
 
-    # scan_local_volumes fixes disk sizes to match their actual size, write changes so
-    # target allocates correct volumes
     $self->scan_local_volumes($vmid);
+
+    # fix disk sizes to match their actual size and write changes,
+    # so that the target allocates the correct volumes
+    $self->config_update_local_disksizes();
     PVE::QemuConfig->write_config($vmid, $conf);
 
     $self->sync_offline_local_volumes();