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 81F8B716AD for ; Thu, 8 Apr 2021 12:33:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 465D019F74 for ; Thu, 8 Apr 2021 12:33:22 +0200 (CEST) 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 A144419F4A for ; Thu, 8 Apr 2021 12:33:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 61F0C45A11 for ; Thu, 8 Apr 2021 12:33:20 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 8 Apr 2021 12:33:13 +0200 Message-Id: <20210408103316.7619-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210408103316.7619-1-f.ebner@proxmox.com> References: <20210408103316.7619-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.007 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. [qemuserver.pm] Subject: [pve-devel] [POC qemu-server 3/6] draft of upgrade_qemu function 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: Thu, 08 Apr 2021 10:33:52 -0000 Signed-off-by: Fabian Ebner --- PVE/QemuServer.pm | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 983fb2f..fa2aad9 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -7729,4 +7729,54 @@ sub vmstate_size { return $mem_size*2 + $driver_state_size; } +# TODO ensure that qmeventd is happy with what we do +sub upgrade_qemu { + my ($vmid, $conf, $param) = @_; + + my $storecfg = PVE::Storage::config(); + my $forcemachine = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf); + + # TODO is it worth setting a lock in the config? + + my $size = vmstate_size($conf); + + my $ramfs = "/run/pve/${vmid}_ramfs"; + my $statefile = "${ramfs}/state"; + + mkpath($ramfs); + + run_command(['mount', '-t', 'ramfs', 'ramfs', $ramfs]); + run_command(['truncate', '-s', "${size}M", $statefile]); + + eval { + eval { + set_migration_caps($vmid, 1); #TODO needed here? + mon_cmd($vmid, "savevm-start", statefile => $statefile); + savevm_monitor($vmid); + }; + if (my $err = $@) { + eval { mon_cmd($vmid, "savevm-end"); }; + warn $@ if $@; + die $err; + } + + mon_cmd($vmid, "quit"); + + my $start_params = { + statefile => $statefile, + forcemachine => $forcemachine, + }; + + # TODO forcecpu, spice ticket? + vm_start_nolock($storecfg, $vmid, $conf, $start_params, {}); + + # TODO save state to disk if there's an error with start? + }; + my $err = $@; + + run_command(['umount', $ramfs]); + + die $err if $err; +} + 1; -- 2.20.1