From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id BB3EB1FF16F
	for <inbox@lore.proxmox.com>; Tue, 24 Jun 2025 11:47:34 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 14598325FB;
	Tue, 24 Jun 2025 11:48:07 +0200 (CEST)
Date: Tue, 24 Jun 2025 11:48:02 +0200 (CEST)
From: =?UTF-8?Q?Fabian_Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <1716504058.7102.1750758482468@webmail.proxmox.com>
In-Reply-To: <20250623154433.449277-6-f.ebner@proxmox.com>
References: <20250623154433.449277-1-f.ebner@proxmox.com>
 <20250623154433.449277-6-f.ebner@proxmox.com>
MIME-Version: 1.0
X-Priority: 3
Importance: Normal
X-Mailer: Open-Xchange Mailer v7.10.6-Rev78
X-Originating-Client: open-xchange-appsuite
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.043 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 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. [helpers.pm, proxmox.com, qemuserver.pm]
Subject: Re: [pve-devel] [PATCH qemu-server 05/15] move helper for iscsi
 initiator name to helpers module and improve name
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>


> Fiona Ebner <f.ebner@proxmox.com> hat am 23.06.2025 17:44 CEST geschrieben:
> 
>  
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  src/PVE/QemuServer.pm                  | 21 ++++-----------------
>  src/PVE/QemuServer/Helpers.pm          | 15 +++++++++++++++
>  src/test/run_config2command_tests.pl   |  2 +-
>  src/test/run_qemu_img_convert_tests.pl |  2 +-
>  4 files changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
> index 71376edc..b67fe832 100644
> --- a/src/PVE/QemuServer.pm
> +++ b/src/PVE/QemuServer.pm
> @@ -51,7 +51,8 @@ use PVE::Tools
>  use PVE::QMPClient;
>  use PVE::QemuConfig;
>  use PVE::QemuConfig::NoWrite;
> -use PVE::QemuServer::Helpers qw(config_aware_timeout min_version kvm_user_version windows_version);
> +use PVE::QemuServer::Helpers
> +    qw(config_aware_timeout get_iscsi_initiator_name min_version kvm_user_version windows_version);
>  use PVE::QemuServer::Cloudinit;
>  use PVE::QemuServer::CGroup;
>  use PVE::QemuServer::CPUConfig
> @@ -1506,20 +1507,6 @@ sub print_drivedevice_full {
>      return $device;
>  }
>  
> -sub get_initiator_name {
> -    my $initiator;
> -
> -    my $fh = IO::File->new('/etc/iscsi/initiatorname.iscsi') || return;
> -    while (defined(my $line = <$fh>)) {
> -        next if $line !~ m/^\s*InitiatorName\s*=\s*([\.\-:\w]+)/;
> -        $initiator = $1;
> -        last;
> -    }
> -    $fh->close();
> -
> -    return $initiator;
> -}
> -
>  sub print_drive_commandline_full {
>      my ($storecfg, $vmid, $drive, $live_restore_name) = @_;
>  
> @@ -4010,7 +3997,7 @@ sub config_to_command {
>      my $scsihw = defined($conf->{scsihw}) ? $conf->{scsihw} : $defaults->{scsihw};
>  
>      # Add iscsi initiator name if available
> -    if (my $initiator = get_initiator_name()) {
> +    if (my $initiator = get_iscsi_initiator_name()) {
>          push @$devices, '-iscsi', "initiator-name=$initiator";
>      }
>  
> @@ -8357,7 +8344,7 @@ sub convert_iscsi_path {
>          my $target = $2;
>          my $lun = $3;
>  
> -        my $initiator_name = get_initiator_name();
> +        my $initiator_name = get_iscsi_initiator_name();
> 
>          return "file.driver=iscsi,file.transport=tcp,file.initiator-name=$initiator_name,"
>              . "file.portal=$portal,file.target=$target,file.lun=$lun,driver=raw";
> diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
> index 9ec989f7..3e444839 100644
> --- a/src/PVE/QemuServer/Helpers.pm
> +++ b/src/PVE/QemuServer/Helpers.pm
> @@ -16,6 +16,7 @@ use base 'Exporter';
>  our @EXPORT_OK = qw(
>      min_version
>      config_aware_timeout
> +    get_iscsi_initiator_name
>      kvm_user_version
>      parse_number_sets
>      windows_version
> @@ -296,4 +297,18 @@ sub needs_extraction {
>      return $vtype eq 'import' && $fmt =~ m/^ova\+(.*)$/;
>  }
>  
> +sub get_iscsi_initiator_name {
> +    my $initiator;
> +
> +    my $fh = IO::File->new('/etc/iscsi/initiatorname.iscsi') || return;
> +    while (defined(my $line = <$fh>)) {
> +        next if $line !~ m/^\s*InitiatorName\s*=\s*([\.\-:\w]+)/;
> +        $initiator = $1;
> +        last;
> +    }
> +    $fh->close();
> +
> +    return $initiator;
> +}
> +
>  1;
> diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2command_tests.pl
> index 9f4ecabf..52fedd7b 100755
> --- a/src/test/run_config2command_tests.pl
> +++ b/src/test/run_config2command_tests.pl
> @@ -248,7 +248,7 @@ $qemu_server_module->mock(
>      get_host_arch => sub() {
>          return $current_test->{host_arch} // 'x86_64';
>      },
> -    get_initiator_name => sub {
> +    get_iscsi_initiator_name => sub {
>          return 'iqn.1993-08.org.debian:01:aabbccddeeff';
>      },

hmm, this works "by accident"

>      cleanup_pci_devices => {
> diff --git a/src/test/run_qemu_img_convert_tests.pl b/src/test/run_qemu_img_convert_tests.pl
> index 55144994..86eb53be 100755
> --- a/src/test/run_qemu_img_convert_tests.pl
> +++ b/src/test/run_qemu_img_convert_tests.pl
> @@ -504,7 +504,7 @@ $qemu_server_module->mock(
>      run_command => sub {
>          $command = shift;
>      },
> -    get_initiator_name => sub {
> +    get_iscsi_initiator_name => sub {

same here - should we move it to mock Helpers already in this patch?

>          return "foobar";
>      },
>  );
> -- 
> 2.47.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel