[pve-devel] [PATCH qemu-server 2/2] fix #2315: api: have resize endpoint spawn a worker task

Fiona Ebner f.ebner at proxmox.com
Tue May 30 15:52:04 CEST 2023


Similar to the corresponding endpoint for containers. Because disks
are involved, this can be a longer running operation, as is also
indicated by the 60 seconds timeout used in qemu_block_resize() which
is called by this endpoint.

This is a breaking API change.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

I just went with calling the task 'resize' too like for containers.
Should I rather use a different name, to be able to distinguish them?

 PVE/API2/Qemu.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index a80eefc9..84fc1fdb 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -4680,7 +4680,10 @@ __PACKAGE__->register_method({
 	    },
 	},
     },
-    returns => { type => 'null'},
+    returns => {
+	type => 'string',
+	description => "the task ID.",
+    },
     code => sub {
         my ($param) = @_;
 
@@ -4764,8 +4767,11 @@ __PACKAGE__->register_method({
 	    PVE::QemuConfig->write_config($vmid, $conf);
 	};
 
-        PVE::QemuConfig->lock_config($vmid, $updatefn);
-        return;
+	my $worker = sub {
+	    PVE::QemuConfig->lock_config($vmid, $updatefn);
+	};
+
+	return $rpcenv->fork_worker('resize', $vmid, $authuser, $worker);
     }});
 
 __PACKAGE__->register_method({
-- 
2.39.2






More information about the pve-devel mailing list