From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
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 2826C606E4
 for <pve-devel@lists.proxmox.com>; Thu,  3 Dec 2020 10:28:01 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 0F4B2259B7
 for <pve-devel@lists.proxmox.com>; Thu,  3 Dec 2020 10:28:01 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (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 id 423AE259AD
 for <pve-devel@lists.proxmox.com>; Thu,  3 Dec 2020 10:27:59 +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 EAB0E44BDE
 for <pve-devel@lists.proxmox.com>; Thu,  3 Dec 2020 10:27:58 +0100 (CET)
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Dominik Csapak <d.csapak@proxmox.com>
References: <20201203084309.24838-1-d.csapak@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
Message-ID: <eb5115dc-d63d-b03b-16ec-36c3651d4127@proxmox.com>
Date: Thu, 3 Dec 2020 10:27:58 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101
 Thunderbird/84.0
MIME-Version: 1.0
In-Reply-To: <20201203084309.24838-1-d.csapak@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.074 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.001 Looks like a legit reply (A)
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 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]
Subject: Re: [pve-devel] [PATCH qemu-server] fix backpu/restore with
 ipv6/ports for pbs
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>
X-List-Received-Date: Thu, 03 Dec 2020 09:28:01 -0000

On 03.12.20 09:43, Dominik Csapak wrote:
> by copying the 'get_server_with_port' from PVE::Storage::PBSPlugin
> here and using it for generating the server
>=20
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> ideally we would make the get_server_with_port sub in pve-storage
> public and use it here (like we do e.g. in container with
> 'run_raw_client_cmd') or even push that stuff into

we actually want to remove all run_raw_client_cmd usage, because it has n=
o
checks and is pretty raw - a clean interface would be much nicer..



> PVE::PBSClient module in comment to reuse that here and in pve-storage
>=20
> but to avoid the dependency bumps and fix it fast, this
> should be enough for now
>=20

I know I said to try to avoid the need for dependency bumps if possible, =
so
this one is one me.

>  PVE/QemuServer.pm        | 14 +++++++++++++-
>  PVE/VZDump/QemuServer.pm |  3 ++-
>  2 files changed, 15 insertions(+), 2 deletions(-)
>=20
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 4989938..7170230 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -6050,6 +6050,18 @@ sub rescan {
>      }
>  }
> =20
> +sub pbs_get_server_with_port {
> +    my ($scfg) =3D @_;
> +
> +    my $server =3D $scfg->{server};
> +    $server =3D "[$server]" if $server =3D~ /^$IPV6RE$/;
> +
> +    if (my $port =3D $scfg->{port}) {
> +	$server .=3D ":$port" if $port !=3D 8007;
> +    }
> +    return $server;
> +}
> +
>  sub restore_proxmox_backup_archive {
>      my ($archive, $vmid, $user, $options) =3D @_;
> =20
> @@ -6058,7 +6070,7 @@ sub restore_proxmox_backup_archive {
>      my ($storeid, $volname) =3D PVE::Storage::parse_volume_id($archive=
);
>      my $scfg =3D PVE::Storage::storage_config($storecfg, $storeid);
> =20
> -    my $server =3D $scfg->{server};
> +    my $server =3D pbs_get_server_with_port($scfg);
>      my $datastore =3D $scfg->{datastore};
>      my $username =3D $scfg->{username} // 'root@pam';
>      my $fingerprint =3D $scfg->{fingerprint};

a few lines below, just out of context we see the sole use for all this e=
xtracting:

my $repo =3D "$username\@$server:$datastore";

So how about adding a get_repo sub to storage, or the PBSClient in pve-co=
mmon
(if we have a documented datastructure like scfg to get the info sanely f=
rom).

> diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
> index 5003676..57436e6 100644
> --- a/PVE/VZDump/QemuServer.pm
> +++ b/PVE/VZDump/QemuServer.pm
> @@ -473,7 +473,8 @@ sub archive_pbs {
> =20
>      my $starttime =3D time();
> =20
> -    my $server =3D $scfg->{server};
> +    my $server =3D PVE::QemuServer::pbs_get_server_with_port($scfg);
> +
>      my $datastore =3D $scfg->{datastore};
>      my $username =3D $scfg->{username} // 'root@pam';
>      my $fingerprint =3D $scfg->{fingerprint};
>=20