From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BA45E6C2F9 for ; Fri, 29 Jan 2021 16:11:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E40B61127C for ; Fri, 29 Jan 2021 16:11:50 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D7D0D1120D for ; Fri, 29 Jan 2021 16:11:47 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A0D22441C0 for ; Fri, 29 Jan 2021 16:11:47 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 29 Jan 2021 16:11:37 +0100 Message-Id: <20210129151143.10014-8-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210129151143.10014-1-f.ebner@proxmox.com> References: <20210129151143.10014-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.004 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemumigrate.pm] Subject: [pve-devel] [PATCH v2 qemu-server 07/13] migration: add nbd migrated volumes to volume_map earlier X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2021 15:11:51 -0000 and avoid a little bit of duplication by creating a helper Signed-off-by: Fabian Ebner --- No changes from v1 PVE/QemuMigrate.pm | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index db68371..b10638a 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -846,6 +846,22 @@ sub phase2 { } } + my $handle_storage_migration_listens = sub { + my ($drive_key, $drivestr, $nbd_uri) = @_; + + $self->{stopnbd} = 1; + $self->{target_drive}->{$drive_key}->{drivestr} = $drivestr; + $self->{target_drive}->{$drive_key}->{nbd_uri} = $nbd_uri; + + my $source_drive = PVE::QemuServer::parse_drive($drive_key, $conf->{$drive_key}); + my $target_drive = PVE::QemuServer::parse_drive($drive_key, $drivestr); + my $source_volid = $source_drive->{file}; + my $target_volid = $target_drive->{file}; + + $self->{volume_map}->{$source_volid} = $target_volid; + $self->log('info', "volume '$source_volid' is '$target_volid' on the target\n"); + }; + my $target_replicated_volumes = {}; # Note: We try to keep $spice_ticket secret (do not pass via command line parameter) @@ -877,9 +893,7 @@ sub phase2 { my $targetdrive = $3; $targetdrive =~ s/drive-//g; - $self->{stopnbd} = 1; - $self->{target_drive}->{$targetdrive}->{drivestr} = $drivestr; - $self->{target_drive}->{$targetdrive}->{nbd_uri} = $nbd_uri; + $handle_storage_migration_listens->($targetdrive, $drivestr, $nbd_uri); } elsif ($line =~ m!^storage migration listens on nbd:unix:(/run/qemu-server/(\d+)_nbd\.migrate):exportname=(\S+) volume:(\S+)$!) { my $drivestr = $4; die "Destination UNIX socket's VMID does not match source VMID" if $vmid ne $2; @@ -888,9 +902,7 @@ sub phase2 { my $targetdrive = $3; $targetdrive =~ s/drive-//g; - $self->{stopnbd} = 1; - $self->{target_drive}->{$targetdrive}->{drivestr} = $drivestr; - $self->{target_drive}->{$targetdrive}->{nbd_uri} = $nbd_uri; + $handle_storage_migration_listens->($targetdrive, $drivestr, $nbd_uri); $unix_socket_info->{$nbd_unix_addr} = 1; } elsif ($line =~ m/^re-using replicated volume: (\S+) - (.*)$/) { my $drive = $1; @@ -929,19 +941,13 @@ sub phase2 { my $nbd_uri = $target->{nbd_uri}; my $source_drive = PVE::QemuServer::parse_drive($drive, $conf->{$drive}); - my $target_drive = PVE::QemuServer::parse_drive($drive, $target->{drivestr}); - my $source_volid = $source_drive->{file}; - my $target_volid = $target_drive->{file}; my $bwlimit = $local_volumes->{$source_volid}->{bwlimit}; my $bitmap = $target->{bitmap}; $self->log('info', "$drive: start migration to $nbd_uri"); PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 'skip', undef, $bwlimit, $bitmap); - - $self->{volume_map}->{$source_volid} = $target_volid; - $self->log('info', "volume '$source_volid' is '$target_volid' on the target\n"); } } -- 2.20.1