public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] migrate: silence 'Use of uninitialized value' warning
Date: Mon, 19 May 2025 16:43:57 +0200	[thread overview]
Message-ID: <20250519144357.3515197-1-d.csapak@proxmox.com> (raw)

If no vfio device is present during migration, and the transferred
(main) memory did not change between loop cycles, we get a warning:

 Use of uninitialized value $last_vfio_transferred in string ne

To silence that, check if the transferred vfio value is defined before,
and always write a defined value to $last_vfio_transferred.

This was noticed by a forum user:
https://forum.proxmox.com/threads/166161/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/QemuMigrate.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index b7bf2aa3..f72a9d33 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -1321,9 +1321,12 @@ sub phase2 {
 	    last;
 	}
 
-	if ($memstat->{transferred} ne $last_mem_transferred ||
-	    $stat->{vfio}->{transferred} ne $last_vfio_transferred
-	) {
+	if (
+	    $memstat->{transferred} ne $last_mem_transferred
+	    || (defined($stat->{vfio}->{transferred})
+		&& $stat->{vfio}->{transferred} ne $last_vfio_transferred)
+	)
+	{
 	    my $trans = $memstat->{transferred} || 0;
 	    my $vfio_transferred = $stat->{vfio}->{transferred} || 0;
 	    my $rem = $memstat->{remaining} || 0;
@@ -1389,7 +1392,7 @@ sub phase2 {
 	}
 
 	$last_mem_transferred = $memstat->{transferred};
-	$last_vfio_transferred = $stat->{vfio}->{transferred};
+	$last_vfio_transferred = $stat->{vfio}->{transferred} // 0;
     }
 
     if ($self->{storage_migration}) {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2025-05-19 14:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-19 14:43 Dominik Csapak [this message]
2025-05-20 13:14 ` [pve-devel] [PATCH qemu-server] migrate: code cleanup: factor out variables for transferred memory and vfio Fiona Ebner
2025-05-21 13:39   ` Dominik Csapak
2025-05-21 14:37 ` [pve-devel] applied: [PATCH qemu-server] migrate: silence 'Use of uninitialized value' warning Fiona Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250519144357.3515197-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal