public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [POC qemu-server 4/6] draft of qemuupgrade API call
Date: Thu,  8 Apr 2021 12:33:14 +0200	[thread overview]
Message-ID: <20210408103316.7619-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210408103316.7619-1-f.ebner@proxmox.com>

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Qemu.pm | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c56b609..f20cd76 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -836,6 +836,7 @@ __PACKAGE__->register_method({
 	    { subdir => 'spiceproxy' },
 	    { subdir => 'sendkey' },
 	    { subdir => 'firewall' },
+	    { subdir => 'upgradeqemu' },
 	    ];
 
 	return $res;
@@ -4395,4 +4396,63 @@ __PACKAGE__->register_method({
 	return PVE::QemuServer::Cloudinit::dump_cloudinit_config($conf, $param->{vmid}, $param->{type});
     }});
 
+__PACKAGE__->register_method({
+    name => 'upgrade_qemu',
+    path => '{vmid}/upgradeqemu',
+    method => 'POST',
+    protected => 1,
+    proxyto => 'node',
+    description => "Upgrade the running QEMU version of the VM to the currently installed one.",
+    permissions => {
+	check => ['perm', '/vms/{vmid}', [ 'VM.PowerMgmt' ]],
+    },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    vmid => get_standard_option('pve-vmid',
+		{ completion => \&PVE::QemuServer::complete_vmid }),
+	},
+    },
+    returns => {
+	type => 'string',
+	description => "the task ID.",
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+	my $authuser = $rpcenv->get_user();
+
+	my $node = extract_param($param, 'node');
+	my $vmid = extract_param($param, 'vmid');
+
+	my $check_and_load_config = sub {
+	    PVE::QemuConfig::assert_config_exists_on_node($vmid, $node);
+	    PVE::QemuServer::Helpers::vm_running_locally($vmid) or die "VM is not running\n";
+
+	    # TODO check if running version is actually outdated
+
+	    my $conf = PVE::QemuConfig->load_config($vmid);
+	    PVE::QemuConfig->check_lock($conf);
+
+	    return $conf;
+	};
+
+	$check_and_load_config->();
+
+	# TODO ensure HA is happy with what we do
+
+	my $realcmd = sub {
+	    my $conf = $check_and_load_config->();
+	    PVE::QemuServer::upgrade_qemu($vmid, $conf);
+	};
+
+	my $worker = sub {
+	    return PVE::QemuConfig->lock_config($vmid, $realcmd);
+	};
+
+	return $rpcenv->fork_worker('qemuupgrade', $vmid, $authuser, $worker);
+    }});
+
 1;
-- 
2.20.1





  parent reply	other threads:[~2021-04-08 10:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 10:33 [pve-devel] [POC qemu-server] fix 3303: allow "live" upgrade of qemu version Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 1/6] create vmstate_size helper Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 2/6] create savevm_monitor helper Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 3/6] draft of upgrade_qemu function Fabian Ebner
2021-04-08 10:33 ` Fabian Ebner [this message]
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 5/6] add timing for testing Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 6/6] add usleep parameter to savevm_monitor Fabian Ebner
2021-04-08 16:44 ` [pve-devel] [POC qemu-server] fix 3303: allow "live" upgrade of qemu version Thomas Lamprecht
2021-06-23 17:56   ` Laurent GUERBY

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=20210408103316.7619-5-f.ebner@proxmox.com \
    --to=f.ebner@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