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 C503D9382E for ; Thu, 5 Jan 2023 13:47:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ABA793016 for ; Thu, 5 Jan 2023 13:47:54 +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 for ; Thu, 5 Jan 2023 13:47:53 +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 7A26C450E1; Thu, 5 Jan 2023 13:47:53 +0100 (CET) Message-ID: Date: Thu, 5 Jan 2023 13:47:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 From: Fiona Ebner To: "DERUMIER, Alexandre" , "pve-devel@lists.proxmox.com" , "aderumier@odiso.com" References: <20221209192726.1499142-1-aderumier@odiso.com> <20221209192726.1499142-3-aderumier@odiso.com> <6f19de848609331e0be425355a354089f1ef5614.camel@groupe-cyllene.com> Content-Language: en-US In-Reply-To: <6f19de848609331e0be425355a354089f1ef5614.camel@groupe-cyllene.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.494 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 -2.939 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 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, test.pl, server.pm, helpers.pm] Subject: Re: [pve-devel] [PATCH qemu-server 02/10] add memory parser 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, 05 Jan 2023 12:47:54 -0000 Am 02.01.23 um 11:50 schrieb DERUMIER, Alexandre: > Hi Fiona, > > > I'm beginning to rework the patch serie > > If it's ok for you, I'll split it in differents patch series, 1 to add > the parser, 1 for maxmem and 1 for virtio. > > About this comment: > > Le vendredi 16 décembre 2022 à 14:38 +0100, Fiona Ebner a écrit : >>> diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm >>> index e91f906..9115d50 100644 >>> --- a/PVE/QemuServer/Helpers.pm >>> +++ b/PVE/QemuServer/Helpers.pm >>> @@ -143,8 +143,7 @@ sub version_cmp { >>>   } >>>   >>>   sub config_aware_timeout { >>> -    my ($config, $is_suspended) = @_; >>> -    my $memory = $config->{memory}; >>> +    my ($config, $memory, $is_suspended) = @_; >> >> Why do you add this? Also, when you adapt the callers, you only pass >> in >> $config->{memory} which is already part of $config. > > When I try to > > use PVE::QemuServer::Memory qw(get_current_memory); > > in the Helpers.pm, to parse the $conf->{memory}, > > I'm getting errors in tests: > > # error does not match expected error: 'Undefined subroutine > &PVE::QemuServer::windows_version called at ../PVE/QemuServer.pm line > 3562. > > That's why I'm parsing the memory in QemuServer and send it as param > config_aware_timeout. > I suspect it's because PVE::QemuServer::Memory does a use PVE::QemuServer; resulting in a circular include and that seems to break the export? The same error also shows up if I do use PVE::QemuServer; in PVE::QemuServer::Helpers directly. But it's strange, because your series turns PVE::QemuServer::Memory into an exporter and PVE::QemuServer uses it, and there it doesn't break. But I guess we just got lucky there :/ I tried to track it down and it seems to be because run_config2command_tests.pl does a use PVE::QMPClient; which in turn does a use PVE::QemuServer::Helpers; It seems the "early" include of Helpers invalidates the later one with qw(). A small reproducer is: febner@pve7-dev ~/playground (git)-[master] % cat Helpers.pm package Helpers; use strict; use warnings; use Server; use base qw(Exporter); our @EXPORT_OK = qw(foo); sub foo { print "foo\n"; } 1; febner@pve7-dev ~/playground (git)-[master] % cat Server.pm package Server; use strict; use warnings; use Helpers qw(foo); sub bar { foo(); } 1; febner@pve7-dev ~/playground (git)-[master] % cat test.pl #!/usr/bin/perl use strict; use warnings; use lib qw(.); #use Helpers; use Server; Server::bar(); febner@pve7-dev ~/playground (git)-[master] % ./test.pl foo febner@pve7-dev ~/playground (git)-[master] % vi test.pl febner@pve7-dev ~/playground (git)-[master] % cat test.pl #!/usr/bin/perl use strict; use warnings; use lib qw(.); use Helpers; use Server; Server::bar(); febner@pve7-dev ~/playground (git)-[master] % ./test.pl Undefined subroutine &Server::foo called at Server.pm line 9. > > Do you known a better way to do it ? > I guess we should avoid circular use statements whenever possible, so the current way can be fine.