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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 23EB791837 for ; Wed, 21 Dec 2022 17:51:47 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0B910A78E for ; Wed, 21 Dec 2022 17:51:47 +0100 (CET) Received: from lana.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP for ; Wed, 21 Dec 2022 17:51:46 +0100 (CET) Received: by lana.proxmox.com (Postfix, from userid 10043) id 59F612C2670; Wed, 21 Dec 2022 17:51:46 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Wed, 21 Dec 2022 17:51:10 +0100 Message-Id: <20221221165110.303770-1-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.363 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an 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. [qemu.pm] Subject: [pve-devel] [PATCH qemu-server v3] rollback: Only create start task with --start if VM is not running 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: Wed, 21 Dec 2022 16:51:47 -0000 When rolling back to the snapshot of a VM that includes RAM, the VM gets started by the rollback task anyway, so no additional start task is needed. Previously, when rolling back with the start parameter and the VM snapshot included RAM, a start task was created. That task failed because the VM had already been started by the rollback task. Additionally documented this behaviour in the description of the start parameter Signed-off-by: Stefan Hanreich --- Changes v2 -> v3: Use vm_running_locally() instead of check_running() Improved description Changes v1 -> v2: Do not parse config for checking type of snapshot but rather directly check whether VM is running or not via check_running() PVE/API2/Qemu.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index e2a420f..c87602d 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -5066,7 +5066,8 @@ __PACKAGE__->register_method({ snapname => get_standard_option('pve-snapshot-name'), start => { type => 'boolean', - description => "Whether the VM should get started after rolling back successfully", + description => "Whether the VM should get started after rolling back successfully." + . " (Note: VMs will be automatically started if the snapshot includes RAM.)", optional => 1, default => 0, }, @@ -5093,7 +5094,7 @@ __PACKAGE__->register_method({ PVE::Cluster::log_msg('info', $authuser, "rollback snapshot VM $vmid: $snapname"); PVE::QemuConfig->snapshot_rollback($vmid, $snapname); - if ($param->{start}) { + if ($param->{start} && !PVE::QemuServer::Helpers::vm_running_locally($vmid)) { PVE::API2::Qemu->vm_start({ vmid => $vmid, node => $node }); } }; -- 2.30.2