public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Fiona Ebner <f.ebner@proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 05/15] move helper for iscsi initiator name to helpers module and improve name
Date: Tue, 24 Jun 2025 11:48:02 +0200 (CEST)	[thread overview]
Message-ID: <1716504058.7102.1750758482468@webmail.proxmox.com> (raw)
In-Reply-To: <20250623154433.449277-6-f.ebner@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


  reply	other threads:[~2025-06-24  9:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 15:44 [pve-devel] [PATCH-SERIES qemu-server 00/15] preparation for blockdev, part two Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 01/15] fix #5985: qmp client: increase timeout for {device, netdev, object}_{add, del} commands Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 02/15] qmp client: add default timeouts for more blockdev commands Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 03/15] helpers: add missing includes Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 04/15] helpers: fix perlcritic warning about variables named $a and $b Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 05/15] move helper for iscsi initiator name to helpers module and improve name Fiona Ebner
2025-06-24  9:48   ` Fabian Grünbichler [this message]
2025-06-24 10:05     ` Fiona Ebner
2025-06-24 10:10       ` Fabian Grünbichler
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 06/15] introduce QemuImage module Fiona Ebner
2025-06-25 12:54   ` Daniel Kral
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 07/15] introduce OVMF module Fiona Ebner
2025-06-24 10:23   ` Fabian Grünbichler
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 08/15] blockdev: re-use cache setting from child node Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 09/15] blockdev: add workaround for issue #3229 Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 10/15] blockdev: add support for 'size' option Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 11/15] ovmf: add support for using blockdev Fiona Ebner
2025-06-24  8:38   ` Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [PATCH qemu-server 12/15] cfg2cmd: ovmf: support print_ovmf_commandline() returning machine flags Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [RFC qemu-server 13/15] print drive device: don't reference any drive for 'none' starting with machine version 10.0 Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [RFC qemu-server 14/15] blockdev: add support for NBD paths Fiona Ebner
2025-06-23 15:44 ` [pve-devel] [RFC qemu-server 15/15] command line: switch to blockdev starting with machine version 10.0 Fiona Ebner
2025-06-24 13:53   ` DERUMIER, Alexandre via pve-devel
2025-06-24 14:34     ` Fiona Ebner
2025-06-24 14:41       ` DERUMIER, Alexandre via pve-devel
2025-06-25 11:31       ` DERUMIER, Alexandre via pve-devel
     [not found]       ` <f3d01b2976480800cfa294cf888534aebadec067.camel@groupe-cyllene.com>
2025-06-25 15:42         ` Fiona Ebner
2025-06-24  9:40 ` [pve-devel] [PATCH-SERIES qemu-server 00/15] preparation for blockdev, part two DERUMIER, Alexandre via pve-devel
2025-06-24  9:59   ` Fiona Ebner
2025-06-24 11:25     ` DERUMIER, Alexandre via pve-devel
2025-06-24 11:44 ` [pve-devel] partially-applied: " Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1716504058.7102.1750758482468@webmail.proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal