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. _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel