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 16911606EC for ; Wed, 16 Feb 2022 13:57:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 129744777 for ; Wed, 16 Feb 2022 13:57:59 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 5EA05476C for ; Wed, 16 Feb 2022 13:57:58 +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 357B146184 for ; Wed, 16 Feb 2022 13:57:58 +0100 (CET) Date: Wed, 16 Feb 2022 13:57:51 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Fabian Ebner , pve-devel@lists.proxmox.com References: <20220209130750.902245-1-f.gruenbichler@proxmox.com> <20220209130750.902245-15-f.gruenbichler@proxmox.com> <0b8626f8-df25-05a6-3db3-698591688eab@proxmox.com> In-Reply-To: <<0b8626f8-df25-05a6-3db3-698591688eab@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1645015881.gu6l40pgef.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.188 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 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: Wed, 16 Feb 2022 12:57:59 -0000 On February 11, 2022 2:01 pm, Fabian Ebner wrote: > Am 09.02.22 um 14:07 schrieb Fabian Gr=C3=BCnbichler: >> + PVE::Cluster::check_cfs_quorum(); >> + >> + my $socket_addr =3D "/run/qemu-server/$vmid.mtunnel"; >=20 > 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. ack >=20 >> + >> + my $lock =3D 'create'; >> + eval { PVE::QemuConfig->create_and_lock_config($vmid, 0, $lock); }; >> + >> + raise_param_exc({ vmid =3D> "unable to create empty VM config - $@"}) >> + if $@; >> + >> + my $realcmd =3D sub { >=20 > ----8<---- >=20 >> + 'config' =3D> sub { >> + my ($params) =3D @_; >> + >=20 > ----8<---- >=20 >> + # not handled by update_vm_api >> + my $vmgenid =3D delete $new_conf->{vmgenid}; >> + my $meta =3D delete $new_conf->{meta}; >> + >> + $new_conf->{vmid} =3D $state->{vmid}; >> + $new_conf->{node} =3D $node; >> + >> + PVE::QemuConfig->remove_lock($state->{vmid}, 'create'); >> + >> + eval { >> + $update_vm_api->($new_conf, 1); >> + }; >> + if (my $err =3D $@) { >> + # revert to locked previous config >> + my $conf =3D PVE::QemuConfig->load_config($state->{vmid}); >> + $conf->{lock} =3D 'create'; >> + PVE::QemuConfig->write_config($state->{vmid}, $conf); >> + >> + die $err; >> + } >> + >> + my $conf =3D PVE::QemuConfig->load_config($state->{vmid}); >> + $conf->{lock} =3D 'migrate'; >> + $conf->{vmgenid} =3D $vmgenid if $vmgenid; >> + $conf->{meta} =3D $meta if $meta; >=20 > Nit: shouldn't matter for these two, but 'if defined(...)' feels safer >=20 >> + PVE::QemuConfig->write_config($state->{vmid}, $conf); >> + >> + $state->{lock} =3D 'migrate'; >> + >> + return; >> + }, >=20 > ----8<---- >=20 >> + 'resume' =3D> sub { >> + if (PVE::QemuServer::check_running($state->{vmid}, 1)) { >=20 > Nit: use PVE::QemuServer::Helpers::vm_running_locally instead, as the > comment above PVE::QemuServer::check_running suggests done. this one might be worthy of a repo-wide cleanup at some point? >=20 >> + PVE::QemuServer::vm_resume($state->{vmid}, 1, 1); >> + } else { >> + die "VM $state->{vmid} not running\n"; >> + } >> + return; >> + }, >=20