public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Alexandre Derumier via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Subject: [pve-devel] [PATCH qemu-server 4/6] migration: refresh remote disk size before resume
Date: Mon, 26 Aug 2024 13:00:27 +0200	[thread overview]
Message-ID: <mailman.408.1724670047.302.pve-devel@lists.proxmox.com> (raw)
In-Reply-To: <20240826110030.1744732-1-alexandre.derumier@groupe-cyllene.com>

[-- Attachment #1: Type: message/rfc822, Size: 6305 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 4/6] migration: refresh remote disk size before resume
Date: Mon, 26 Aug 2024 13:00:27 +0200
Message-ID: <20240826110030.1744732-10-alexandre.derumier@groupe-cyllene.com>

A blockextend occur on source just before the switch.

we want to be sure that lvm size on target is correctly refreshed,

or we could have io-error is the vm is writing to non available
sectors

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 PVE/CLI/qm.pm                         | 26 ++++++++++++++++++++++++++
 PVE/QemuMigrate.pm                    | 13 +++++++++++++
 test/MigrationTest/QemuMigrateMock.pm |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 1410ad5..6e258f3 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -553,6 +553,30 @@ __PACKAGE__->register_method ({
 	return;
     }});
 
+__PACKAGE__->register_method ({
+    name => 'refresh',
+    path => 'refresh',
+    method => 'POST',
+    description => "Force storage volume size cache refresh.",
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
+	},
+    },
+    returns => { type => 'null'},
+    code => sub {
+	my ($param) = @_;
+
+	my $vmid = extract_param($param, 'vmid');
+	my $conf = PVE::QemuConfig->load_config($vmid);
+	my $storecfg = PVE::Storage::config();
+	my $vols = PVE::QemuServer::get_vm_volumes($conf);
+	PVE::Storage::refresh_volumes($storecfg, $vols);
+
+	return;
+    }});
+
 __PACKAGE__->register_method ({
     name => 'importdisk',
     path => 'importdisk',
@@ -1192,6 +1216,7 @@ our $cmddef = {
     'move-disk' => { alias => 'disk move' },
     move_disk => { alias => 'disk move' },
     rescan => { alias => 'disk rescan' },
+    refresh => { alias => 'disk refresh' },
     resize => { alias => 'disk resize' },
     unlink => { alias => 'disk unlink' },
 
@@ -1202,6 +1227,7 @@ our $cmddef = {
 	resize => [ "PVE::API2::Qemu", 'resize_vm', ['vmid', 'disk', 'size'], { %node } ],
 	unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid'], { %node } ],
 	blockextend => [ __PACKAGE__, 'blockextend', ['vmid', 'disk'], { %node }],
+	refresh => [ __PACKAGE__, 'refresh', ['vmid']],
     },
 
     monitor  => [ __PACKAGE__, 'monitor', ['vmid']],
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index bdcc2e5..9ae9ea1 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -1503,6 +1503,19 @@ sub phase3_cleanup {
 	PVE::QemuServer::del_nets_bridge_fdb($conf, $vmid);
 
 	if (!$self->{vm_was_paused}) {
+
+	    # refresh remote volumes size if extend have occured
+            my $cmd = [@{$self->{rem_ssh}}, 'qm', 'disk', 'refresh', $vmid];
+	    my $logf = sub {
+		my $line = shift;
+		$self->log('err', $line);
+	    };
+	    eval { PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => $logf); };
+	    if (my $err = $@) {
+		$self->log('err', $err);
+		$self->{errors} = 1;
+	    }
+
 	    # config moved and nbd server stopped - now we can resume vm on target
 	    if ($tunnel && $tunnel->{version} && $tunnel->{version} >= 1) {
 		my $cmd = $tunnel->{version} == 1 ? "resume $vmid" : "resume";
diff --git a/test/MigrationTest/QemuMigrateMock.pm b/test/MigrationTest/QemuMigrateMock.pm
index 1efabe2..0057868 100644
--- a/test/MigrationTest/QemuMigrateMock.pm
+++ b/test/MigrationTest/QemuMigrateMock.pm
@@ -306,6 +306,8 @@ $MigrationTest::Shared::tools_module->mock(
 			return 0;
 		    } elsif ($cmd eq 'resume') {
 			return 0;
+		    } elsif ($cmd eq 'disk') {
+			return 0;
 		    } elsif ($cmd eq 'unlock') {
 			my $vmid = shift @{$cmd_tail};;
 			die "unlocking wrong vmid: $vmid\n" if $vmid ne $test_vmid;
-- 
2.39.2



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

  parent reply	other threads:[~2024-08-26 11:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240826110030.1744732-1-alexandre.derumier@groupe-cyllene.com>
2024-08-26 11:00 ` [pve-devel] [PATCH pve-storage 1/5] add lvmqcow2 plugin Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH qemu-server 1/6] lvmqcow2: set disk write threshold Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH pve-manager 1/1] pvestatd: lvmqcow2 : extend disk on io-error Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH qemu-server 2/6] qm cli: add blockextend Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH pve-storage 2/5] vdisk_alloc: add underlay_size option Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH pve-storage 3/5] add volume_underlay_resize Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH qemu-server 3/6] qmevent: call qm disk blockextend when write_threshold event is received Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH pve-storage 4/5] add refresh volume Alexandre Derumier via pve-devel
2024-08-26 11:00 ` Alexandre Derumier via pve-devel [this message]
2024-08-26 11:00 ` [pve-devel] [PATCH pve-storage 5/5] add volume_underlay_shrink Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH qemu-server 5/6] qemu_img_format: lvmqcow2 is a path_storage Alexandre Derumier via pve-devel
2024-08-26 11:00 ` [pve-devel] [PATCH qemu-server 6/6] clone: allocate && shrink lvmcow2 underlay Alexandre Derumier via pve-devel

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=mailman.408.1724670047.302.pve-devel@lists.proxmox.com \
    --to=pve-devel@lists.proxmox.com \
    --cc=alexandre.derumier@groupe-cyllene.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