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 681F98A0C9 for ; Mon, 1 Aug 2022 15:03:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5ECB930111 for ; Mon, 1 Aug 2022 15:02:35 +0200 (CEST) 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 for ; Mon, 1 Aug 2022 15:02:33 +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 65A8240F96 for ; Mon, 1 Aug 2022 15:02:33 +0200 (CEST) Date: Mon, 01 Aug 2022 15:02:26 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220719114639.3035048-1-d.csapak@proxmox.com> <20220719114639.3035048-10-d.csapak@proxmox.com> In-Reply-To: <<<20220719114639.3035048-10-d.csapak@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1659358021.77apmy6k6v.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.160 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 Subject: Re: [pve-devel] [PATCH qemu-server 5/7] PVE/QemuServer: extend 'check_local_resources' for mapped resources 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: Mon, 01 Aug 2022 13:03:05 -0000 On July 19, 2022 1:46 pm, Dominik Csapak wrote: > by adding them to their own list, saving the nodes where > they are not allowed, and return those on 'wantarray' so this seems to be the main place where we benefit from a cluster-wide=20 HW map - but it could just as well be a loop over the node specific=20 config files, possibly after reducing the node list via means of=20 storages.. and, for the call in migrate where we know the target node already we=20 could pass it here to reduce the amount of work we have to do ;) >=20 > Signed-off-by: Dominik Csapak > --- > PVE/QemuServer.pm | 36 ++++++++++++++++++++++++++++++++++-- > 1 file changed, 34 insertions(+), 2 deletions(-) >=20 > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index a6ca80d..ea7e213 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -2617,6 +2617,21 @@ sub check_local_resources { > my ($conf, $noerr) =3D @_; > =20 > my @loc_res =3D (); > + my $mapped_res =3D []; > + > + my $nodelist =3D PVE::Cluster::get_nodelist(); > + my $hw_map =3D PVE::HardwareMap::config(); > + > + my $not_allowed_nodes =3D { map { $_ =3D> [] } @$nodelist }; > + > + my $add_not_allowed_nodes =3D sub { > + my ($type, $key, $id) =3D @_; > + for my $node (@$nodelist) { > + if (!defined($id) || !defined($hw_map->{$type}->{$id}->{$node})) { > + push @{$not_allowed_nodes->{$node}}, $key; > + } > + } > + }; > =20 > push @loc_res, "hostusb" if $conf->{hostusb}; # old syntax > push @loc_res, "hostpci" if $conf->{hostpci}; # old syntax > @@ -2624,7 +2639,24 @@ sub check_local_resources { > push @loc_res, "ivshmem" if $conf->{ivshmem}; > =20 > foreach my $k (keys %$conf) { > - next if $k =3D~ m/^usb/ && ($conf->{$k} =3D~ m/^spice(?![^,])/); > + if ($k =3D~ m/^usb/) { > + my $entry =3D parse_property_string($usb_fmt, $conf->{$k}); > + my $usb =3D PVE::QemuServer::USB::parse_usb_device($entry->{host}); > + next if $usb->{spice}; > + if ($usb->{mapped}) { > + $add_not_allowed_nodes->('usb', $k, $entry->{host}); > + push @$mapped_res, $k; > + next; > + } > + } > + if ($k =3D~ m/^hostpci/) { > + my $entry =3D parse_property_string('pve-qm-hostpci', $conf->{$k}); > + if ($entry->{host} !~ m/:/) { > + $add_not_allowed_nodes->('pci', $k, $entry->{host}); > + push @$mapped_res, $k; > + next; > + } > + } > # sockets are safe: they will recreated be on the target side post-migr= ate > next if $k =3D~ m/^serial/ && ($conf->{$k} eq 'socket'); > push @loc_res, $k if $k =3D~ m/^(usb|hostpci|serial|parallel)\d+$/; > @@ -2632,7 +2664,7 @@ sub check_local_resources { > =20 > die "VM uses local resources\n" if scalar @loc_res && !$noerr; > =20 > - return \@loc_res; > + return wantarray ? (\@loc_res, $mapped_res, $not_allowed_nodes) : \@= loc_res; > } > =20 > # check if used storages are available on all nodes (use by migrate) > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20