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 EEA4E62626 for ; Fri, 11 Feb 2022 14:02:00 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DD9AC29728 for ; Fri, 11 Feb 2022 14:01:30 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS id B27212971C for ; Fri, 11 Feb 2022 14:01:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4F86A46DF0 for ; Fri, 11 Feb 2022 14:01:29 +0100 (CET) Message-ID: <0b8626f8-df25-05a6-3db3-698591688eab@proxmox.com> Date: Fri, 11 Feb 2022 14:01:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: pve-devel@lists.proxmox.com, =?UTF-8?Q?Fabian_Gr=c3=bcnbichler?= References: <20220209130750.902245-1-f.gruenbichler@proxmox.com> <20220209130750.902245-15-f.gruenbichler@proxmox.com> From: Fabian Ebner In-Reply-To: <20220209130750.902245-15-f.gruenbichler@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.136 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 NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH v5 qemu-server 07/11] mtunnel: add API endpoints 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: Fri, 11 Feb 2022 13:02:01 -0000 Am 09.02.22 um 14:07 schrieb Fabian Grünbichler: > + PVE::Cluster::check_cfs_quorum(); > + > + my $socket_addr = "/run/qemu-server/$vmid.mtunnel"; Nit: since there is another variable with the same name inside $realcmd below, and this one is not used until the end, it could be moved further down. > + > + my $lock = 'create'; > + eval { PVE::QemuConfig->create_and_lock_config($vmid, 0, $lock); }; > + > + raise_param_exc({ vmid => "unable to create empty VM config - $@"}) > + if $@; > + > + my $realcmd = sub { ----8<---- > + 'config' => sub { > + my ($params) = @_; > + ----8<---- > + # not handled by update_vm_api > + my $vmgenid = delete $new_conf->{vmgenid}; > + my $meta = delete $new_conf->{meta}; > + > + $new_conf->{vmid} = $state->{vmid}; > + $new_conf->{node} = $node; > + > + PVE::QemuConfig->remove_lock($state->{vmid}, 'create'); > + > + eval { > + $update_vm_api->($new_conf, 1); > + }; > + if (my $err = $@) { > + # revert to locked previous config > + my $conf = PVE::QemuConfig->load_config($state->{vmid}); > + $conf->{lock} = 'create'; > + PVE::QemuConfig->write_config($state->{vmid}, $conf); > + > + die $err; > + } > + > + my $conf = PVE::QemuConfig->load_config($state->{vmid}); > + $conf->{lock} = 'migrate'; > + $conf->{vmgenid} = $vmgenid if $vmgenid; > + $conf->{meta} = $meta if $meta; Nit: shouldn't matter for these two, but 'if defined(...)' feels safer > + PVE::QemuConfig->write_config($state->{vmid}, $conf); > + > + $state->{lock} = 'migrate'; > + > + return; > + }, ----8<---- > + 'resume' => sub { > + if (PVE::QemuServer::check_running($state->{vmid}, 1)) { Nit: use PVE::QemuServer::Helpers::vm_running_locally instead, as the comment above PVE::QemuServer::check_running suggests > + PVE::QemuServer::vm_resume($state->{vmid}, 1, 1); > + } else { > + die "VM $state->{vmid} not running\n"; > + } > + return; > + },