]> git.proxmox.com Git - pve-storage.git/log
pve-storage.git
17 months agozfs: list images: code cleanup
Fiona Ebner [Tue, 20 Dec 2022 13:16:38 +0000 (14:16 +0100)]
zfs: list images: code cleanup

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
17 months agozfs: list images: don't use cache
Fiona Ebner [Tue, 20 Dec 2022 13:16:37 +0000 (14:16 +0100)]
zfs: list images: don't use cache

There is no caller using $cache and the same $storeid multiple times,
so there is no need to keep the cache.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
17 months agozfs: list: only cache and list images for requested storage/pool
Fiona Ebner [Tue, 20 Dec 2022 13:16:36 +0000 (14:16 +0100)]
zfs: list: only cache and list images for requested storage/pool

The plugin for remote ZFS storages currently also uses the same
list_images() as the plugin for local ZFS storages. There is only
one cache which does not remember the target host where the
information originated.

This is problematic for rescan in qemu-server:
1. Via list_images() and zfs_list_zvol(), ZFSPlugin.pm's zfs_request()
   is executed for a remote ZFS.
2. $cache->{zfs} is set to the result of scanning the images there.
3. Another list_images() for a local ZFS storage happens and uses the
   cache with the wrong information.

The only two operations using the cache currently are
1. Disk rescan in qemu-server which is affected by the issue. It is
   done as part of (or as a) long-running operations.
2. prepare_local_job for pvesr, but the non-local ZFS plugin doesn't
   support replication, so it cannot trigger there. The cache only
   helps if there is a replicated guest with volumes on different
   ZFS storages, but otherwise it will be less efficient than no
   cache or querying every storage by itself.

Fix the issue by making the cache $storeid-specific, which effectively
makes the cache superfluous, because there is no caller using the same
$storeid multiple times. As argued above, this should not really hurt
the callers described above much and actually improves performance for
all other callers.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
17 months agodisk manage: pass full NVMe device path to smartctl
Fiona Ebner [Mon, 12 Dec 2022 12:33:09 +0000 (13:33 +0100)]
disk manage: pass full NVMe device path to smartctl

This essentially reverts commit c9bd3d2 ("fix #1123: modify NVME
device path for SMART support").

The man page for smartctl states
> Use the forms "/dev/nvme[0-9]" (broadcast namespace) or
> "/dev/nvme[0-9]n[1-9]" (specific  namespace 1-9) for NVMe devices.
so it should be fine to pass the path with the specific namespace to
smartctl.

But that text was already present in the man page of version 6.5,
which is the version the commit c9bd3d2 talks about. It might be that
it was necessary to drop the specific namespace for the version
backported from Stretch to Jessie (the bug report mentions that that
version was used[0]), but it's not quite clear.

With current versions, passing in the path with the specific namespace
did work as expected[1], even on a device with multiple namespaces set
up tested locally. In PBS, the path queried via
udev::Device::from_syspath("/sys/block/{name}") is passed to smartctl
and that also included the specific namespace on the systems I tested
with a short script.

So pass the full path to make things a little bit simpler and to avoid
potential future issues like bug #2020[2].

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=1123#c3
[1]: https://forum.proxmox.com/threads/113962/post-493185
[2]: https://bugzilla.proxmox.com/show_bug.cgi?id=2020

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
17 months agoRevert "Fix #2020: use /sys to map nvmeXnY to nvmeX"
Fiona Ebner [Mon, 28 Nov 2022 11:29:49 +0000 (12:29 +0100)]
Revert "Fix #2020: use /sys to map nvmeXnY to nvmeX"

This reverts commit c3442aa5546b029a524928d10c7ecabe0024c137.

Nowadays, relying on 'readlink /sys/block/nvmeXnY/device' won't always
lead to the correct device, as reported in the community forum[0],
where it results in '../../nvme-subsys0' and there's no matching entry
under '/dev/'.

Since Linux kernel 5.4, in particular commit 733e4b69d508 ("nvme:
Assign subsys instance from first ctrl"), the problematic situation
from bug #2020 shouldn't happen anymore.

Stated more clearly by the commit's author here[1]:
> Indeed, that commit will make the naming a bit more sane and will
> definitely prevent mistaken identity. It is still possible to
> observe controllers with instances that don't match their
> namespaces, but it is impossible to get a namespace instance that
> matches a non-owning controller.

The only other user of get_sysdir_info() doesn't use the 'device'
entry, so reverting that part is fine too.

[0] https://forum.proxmox.com/threads/113962/
[1] https://github.com/linux-nvme/nvme-cli/issues/510#issuecomment-552508647

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>

17 months agobump version to 7.3-1
Thomas Lamprecht [Thu, 24 Nov 2022 07:26:55 +0000 (08:26 +0100)]
bump version to 7.3-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17 months agoget bandwidth limit: improve detecting if storages are involved
Fiona Ebner [Wed, 23 Nov 2022 11:40:25 +0000 (12:40 +0100)]
get bandwidth limit: improve detecting if storages are involved

Previously, calling with e.g. $storage_list = [undef] would lead to an
early return of $override and not consider the limit from
datacenter.cfg.

Refactoring the bandwidth limit handling for migration introduced
calls such as described above, which broke applying the limit from
datacenter.cfg for VM RAM/state migration.

Reported in the community forum:
https://forum.proxmox.com/threads/37920/post-513005

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
17 months agotest: bwlimit: fix test description
Fiona Ebner [Wed, 23 Nov 2022 11:40:24 +0000 (12:40 +0100)]
test: bwlimit: fix test description

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
18 months agobump version to 7.2-12
Thomas Lamprecht [Thu, 17 Nov 2022 18:12:38 +0000 (19:12 +0100)]
bump version to 7.2-12

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agodisk manage: fix dereferencing draid config
Thomas Lamprecht [Thu, 17 Nov 2022 18:08:50 +0000 (19:08 +0100)]
disk manage: fix dereferencing draid config

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agobump version to 7.2-11
Thomas Lamprecht [Thu, 17 Nov 2022 16:51:13 +0000 (17:51 +0100)]
bump version to 7.2-11

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agoapi: FileRestore: make use of file-restores and guis timeout mechanism
Dominik Csapak [Thu, 10 Nov 2022 10:36:33 +0000 (11:36 +0100)]
api: FileRestore: make use of file-restores and guis timeout mechanism

file-restore has a 'timeout' parameter and if that is exceeded, returns
an error with the http code 503 Service Unavailable

When the web ui encounters such an error, it retries the listing a few
times before giving up.

To make use of these, add the 'timeout' parameter to the new
'extraParams' of 'file_restore_list'.

25 seconds are chosen because it's under pveproxy 30s limit, with a bit
of overhead to spare for the rest of the api call, like json decoding,
forking, access control checks, etc.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoapi: FileRestore: decode and return proper error of file-restore listing
Dominik Csapak [Thu, 10 Nov 2022 10:36:32 +0000 (11:36 +0100)]
api: FileRestore: decode and return proper error of file-restore listing

since commit
ba690c40 ("file-restore: remove 'json-error' parameter from list_files")

in proxmox-backup, the file-restore binary will return the error as json
when called with '--output-format json' (which we do in PVE::PBSClient)

here, we assume that 'file-restore' will fail in that case, and we try
to use the return value as an array ref which fails, and the user never
sees the real error message.

To fix that, check the ref type of the return value and act accordingly

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoapi: storage: fix indentation in free volume
Thomas Lamprecht [Fri, 11 Nov 2022 12:49:08 +0000 (13:49 +0100)]
api: storage: fix indentation in free volume

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agodisk manage: draid: style clean ups
Thomas Lamprecht [Fri, 11 Nov 2022 08:23:49 +0000 (09:23 +0100)]
disk manage: draid: style clean ups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agodisk manage: move "draid-config set only on draid level" assertion
Thomas Lamprecht [Fri, 11 Nov 2022 08:22:19 +0000 (09:22 +0100)]
disk manage: move "draid-config set only on draid level" assertion

so that there is a better code locality and also we avoid forgetting
to adapt the check for each specific draid-config parameter if a new
one gets added or an existing one changed.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agofix #3967: enable ZFS dRAID creation via API
Stefan Hrdlicka [Thu, 10 Nov 2022 13:24:48 +0000 (14:24 +0100)]
fix #3967: enable ZFS dRAID creation via API

It is possible to set the number of spares and the size of
data stripes via draidspares & dreaddata parameters.

Signed-off-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>

18 months agozfs diskmanage: code/indentation cleanup in get_pool_data
Thomas Lamprecht [Fri, 11 Nov 2022 07:01:14 +0000 (08:01 +0100)]
zfs diskmanage: code/indentation cleanup in get_pool_data

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agopbs: prune: avoid getting all snapshots for group assembly if fixed anyway
Thomas Lamprecht [Mon, 7 Nov 2022 14:55:37 +0000 (15:55 +0100)]
pbs: prune: avoid getting all snapshots for group assembly if fixed anyway

If both type and vmid is defined we don't need to list the current
snapshots, we simply can derive the single backup group from that and
let the PBS client handle the rest.

Should be a not so small speedup for most setups using PBS backup and
pruning configured on PVE side, as vzdump calls this separately for
every vmid on backup jobs with multiple guests included.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agopbs: wrap getting list volumes for pruning for error context
Thomas Lamprecht [Mon, 7 Nov 2022 14:22:08 +0000 (15:22 +0100)]
pbs: wrap getting list volumes for pruning for error context

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agoapi: pbs: file restore: don't use namespaced parameters
Fabian Ebner [Wed, 20 Jul 2022 10:59:48 +0000 (12:59 +0200)]
api: pbs: file restore: don't use namespaced parameters

Instead, rely on PBSClient to set namespace according to the initial
configuration.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
18 months agobump common dependency to 7.2-4
Wolfgang Bumiller [Fri, 4 Nov 2022 13:13:58 +0000 (14:13 +0100)]
bump common dependency to 7.2-4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
19 months agobump version to 7.2-10
Thomas Lamprecht [Thu, 29 Sep 2022 12:33:18 +0000 (14:33 +0200)]
bump version to 7.2-10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months ago(remote) export: check and untaint format
Fabian Grünbichler [Wed, 28 Sep 2022 12:50:59 +0000 (14:50 +0200)]
(remote) export: check and untaint format

this format comes from the remote cluster, so it might not be supported
on the source side - checking whether it's known (as additional
safeguard) and untainting (to avoid open3 failure) is required.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
 [ T: squashed in canonical perl array ref access ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoapi: disk SMART: fix details for depreacated return value comment
Thomas Lamprecht [Fri, 23 Sep 2022 09:59:33 +0000 (11:59 +0200)]
api: disk SMART: fix details for depreacated return value comment

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agodisk manage: module wide code/style cleanup
Thomas Lamprecht [Fri, 23 Sep 2022 09:54:41 +0000 (11:54 +0200)]
disk manage: module wide code/style cleanup

fixing some issues reported by perlcritic along the way.

cutting down 70 lines, often with even improving readability.
Tried to recheck and be conservative, so there shouldn't be any
regression, but it's still perl after all...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agofix #4165: disk: SMART: add normalized field
Matthias Heiserer [Thu, 21 Jul 2022 10:45:58 +0000 (12:45 +0200)]
fix #4165: disk: SMART: add normalized field

This makes it consistent with the naming scheme in PBS/GUI.
Keep value for API stability reasons and remove it in the next major version.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.cspak@proxmox.com>
20 months agoapi: remove duplicate variable
Fabian Grünbichler [Tue, 20 Sep 2022 08:50:12 +0000 (10:50 +0200)]
api: remove duplicate variable

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
20 months agobump version to 7.2-9
Fabian Grünbichler [Tue, 20 Sep 2022 07:20:14 +0000 (09:20 +0200)]
bump version to 7.2-9

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
20 months agodisks: allow add_storage for already configured local storage
Aaron Lauterer [Fri, 19 Aug 2022 15:01:21 +0000 (17:01 +0200)]
disks: allow add_storage for already configured local storage

One of the smaller annoyances, especially for less experienced users, is
the fact, that when creating a local storage (ZFS, LVM (thin), dir) in a
cluster, one can only leave the "Add Storage" option enabled the first
time.

On any following node, this option needed to be disabled and the new
node manually added to the list of nodes for that storage.

This patch changes the behavior. If a storage of the same name already
exists, it will verify that necessary parameters match the already
existing one.
Then, if the 'nodes' parameter is set, it adds the current node and
updates the storage config.
In case there is no nodes list, nothing else needs to be done, and the
GUI will stop showing the question mark for the configured, but until
then, not existing local storage.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
20 months agodisks: die if storage name is already in use
Aaron Lauterer [Fri, 19 Aug 2022 15:01:20 +0000 (17:01 +0200)]
disks: die if storage name is already in use

If a storage of that type and name already exists (LVM, zpool, ...) but
we do not have a Proxmox VE Storage config for it, it is possible that
the creation will fail midway due to checks done by the underlying
storage layer itself. This in turn can lead to disks that are already
partitioned. Users would need to clean this up themselves.

By adding checks early on, not only checking against the PVE storage
config, but against the actual storage type itself, we can die early
enough, before we touch any disk.

For ZFS, the logic to gather pool data is moved into its own function to
be called from the index API endpoint and the check in the create
endpoint.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
20 months agodiskmanage: add mounted_paths
Aaron Lauterer [Fri, 19 Aug 2022 15:01:19 +0000 (17:01 +0200)]
diskmanage: add mounted_paths

returns a list of mounted paths with the backing devices

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
20 months agoRBD plugin: librados connect: increase timeout when in worker
Fiona Ebner [Fri, 2 Sep 2022 07:33:07 +0000 (09:33 +0200)]
RBD plugin: librados connect: increase timeout when in worker

The default timeout in PVE/RADOS.pm is 5 seconds, but this is not
always enough for external clusters under load. Workers can and should
take their time to not fail here too quickly.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
20 months agoRBD plugin: librados connect: pass along options
Fiona Ebner [Fri, 2 Sep 2022 07:33:06 +0000 (09:33 +0200)]
RBD plugin: librados connect: pass along options

In preparation to increase the timeout for workers. Both existing
callers of librados_connect() don't currently use the parameter.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
20 months agoRBD plugin: path: conditionalize get_rbd_dev_path() call
Fiona Ebner [Wed, 31 Aug 2022 08:50:54 +0000 (10:50 +0200)]
RBD plugin: path: conditionalize get_rbd_dev_path() call

The return value of get_rbd_dev_path() is only used when $scfg->{krbd}
evaluates to true and the function shouldn't have any side effects
that are needed later, so the call can be avoided otherwise.

This also saves a RADOS connection and command with configurations for
external clusters with krbd disabled.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
21 months agofix #4189: pbs: bump list_volumes timeout to 2mins
Wolfgang Bumiller [Wed, 17 Aug 2022 10:32:37 +0000 (12:32 +0200)]
fix #4189: pbs: bump list_volumes timeout to 2mins

When switching this from calling the external binary to
using the perl api client the timeout got reduced to 7
seconds, which is definitely insufficient for larger stores.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
21 months agobump version to 7.2-8
Fabian Grünbichler [Tue, 16 Aug 2022 11:56:56 +0000 (13:56 +0200)]
bump version to 7.2-8

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agopbs: die if master key is missing
Fabian Grünbichler [Tue, 16 Aug 2022 11:55:43 +0000 (13:55 +0200)]
pbs: die if master key is missing

while the resulting backups are encrypted, they would not be restorable
using the master key (only) if the original PVE system is lost.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agopbs: warn about missing, but config master key
Fabian Grünbichler [Tue, 16 Aug 2022 10:33:54 +0000 (12:33 +0200)]
pbs: warn about missing, but config master key

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agopbs: detect mismatch of encryption settings and key
Fabian Grünbichler [Tue, 16 Aug 2022 10:33:53 +0000 (12:33 +0200)]
pbs: detect mismatch of encryption settings and key

if the key file doesn't exist (anymore), but the storage.cfg references
one, die on commands that should use encryption instead of falling back
to plain-text operations.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
22 months agobump version to 7.2-7
Thomas Lamprecht [Fri, 15 Jul 2022 11:36:39 +0000 (13:36 +0200)]
bump version to 7.2-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
22 months agopbs: fix namespace handling in list_volumes
Fabian Ebner [Fri, 15 Jul 2022 10:47:51 +0000 (12:47 +0200)]
pbs: fix namespace handling in list_volumes

Before af07f67 ("pbs: use vmid parameter in list_snapshots") the
namespace was set via do_raw_client_command, but now it needs to be
set explicitly here.

Fixes: af07f67 ("pbs: use vmid parameter in list_snapshots")
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
22 months agobump version to 7.2-6
Thomas Lamprecht [Thu, 14 Jul 2022 11:47:14 +0000 (13:47 +0200)]
bump version to 7.2-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
22 months agopbs: use vmid parameter in list_snapshots
Wolfgang Bumiller [Thu, 14 Jul 2022 11:24:10 +0000 (13:24 +0200)]
pbs: use vmid parameter in list_snapshots

Particularly for operations such as pruning backups after a
scheduled backups we do not want to list the entire
store.

(pbs_api_connect is moved up unmodified)

Note that the 'snapshots' CLI command only takes a full
group, but the API does allow specifying a backup-id without
a backup-type!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
22 months agoBTRFSPlugin: reuse DirPlugin update/get_volume_attribute
Dominik Csapak [Thu, 2 Jun 2022 08:52:14 +0000 (10:52 +0200)]
BTRFSPlugin: reuse DirPlugin update/get_volume_attribute

this allows setting notes+protected for backups on btrfs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
22 months agoDirPlugin: update_volume_attribute: don't use update_volume_notes
Dominik Csapak [Thu, 2 Jun 2022 08:52:13 +0000 (10:52 +0200)]
DirPlugin: update_volume_attribute: don't use update_volume_notes

by refactoring it into a helper and use that.
With this, we can omit the 'update_volume_notes' in subclasses

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
23 months agobump version to 7.2-5
Wolfgang Bumiller [Wed, 15 Jun 2022 08:54:55 +0000 (10:54 +0200)]
bump version to 7.2-5

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agofixup tests
Wolfgang Bumiller [Wed, 15 Jun 2022 08:49:11 +0000 (10:49 +0200)]
fixup tests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agodiskmanage: only set mounted property for mounted devices
Wolfgang Bumiller [Wed, 15 Jun 2022 08:42:20 +0000 (10:42 +0200)]
diskmanage: only set mounted property for mounted devices

instead of setting an empty string for not mounted devices

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agoAdded a LOG_EXT constant as a counterpart to NOTES_EXT
Daniel Tschlatscher [Tue, 14 Jun 2022 09:00:13 +0000 (11:00 +0200)]
Added a LOG_EXT constant as a counterpart to NOTES_EXT

and refactored usages for .log and .notes with them.
At some parts in the test case code I had to source new variables to
shorten the line length to not exceed the 100 column line limit.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agoSwitched to using log_warn of PVE::RESTEnvironment
Daniel Tschlatscher [Tue, 14 Jun 2022 09:00:12 +0000 (11:00 +0200)]
Switched to using log_warn of PVE::RESTEnvironment

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agoAdapted unlink calls for archive files in case of ENOENT
Daniel Tschlatscher [Tue, 14 Jun 2022 09:00:11 +0000 (11:00 +0200)]
Adapted unlink calls for archive files in case of ENOENT

This improves handling when two archive remove calls are creating a
race condition where one would formerly encounter an error. Now both
finish successfully.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agofix #3972: Remove the .notes file when a backup is deleted
Daniel Tschlatscher [Tue, 14 Jun 2022 09:00:10 +0000 (11:00 +0200)]
fix #3972: Remove the .notes file when a backup is deleted

When a VM or Container backup was deleted, the .notes file was not
removed, therefore, over time the dump folder would get polluted with
notes for backups that no longer existed. As backup names contain a
timestamp and as the notes cannot be reused because of this, I think
it is safe to just delete them just like we do with the .log file.

Furthermore, I sourced the deletion of the log and notes file into a
new function called "archive_auxiliaries_remove". Additionally, the
archive_info object now returns one more field containing the name of
the notes file. The test cases have to be adapted to expect this new
value as the package will not compile otherwise.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agoapi2: disks: add mounted boolean field
Hannes Laimer [Wed, 8 Jun 2022 07:09:59 +0000 (07:09 +0000)]
api2: disks: add mounted boolean field

... and remove '(mounted)' from usage string

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
23 months agorbd: get_rbd_dev_path: return /dev/rbd path only if cluster matches
Aaron Lauterer [Mon, 23 May 2022 10:54:25 +0000 (12:54 +0200)]
rbd: get_rbd_dev_path: return /dev/rbd path only if cluster matches

The changes in cfe46e2d4a97a83f1bbe6ad656e6416399309ba2 git not catch
all situations.
In the case of a guest having 2 disk images with the same name on a pool
with the same name but in two different ceph clusters we still had
issues when starting it. The first disk got mapped as expected. The
second disk did not get mapped because we returned the old $path to
"/dev/rbd/<pool>/<image>" because it already existed from the first
disk.

In the case that only the "old" /dev/rbd path exists and we do not have
the /dev/rbd-pve/<cluster>/... path available, we now check if the
cluster fsid used by that rbd device matches the one we expect. If it
does, then we are in the situation that the image has been mapped before
the new rbd-pve udev rule was introduced. If it does not, then we have
the situation of an ambiguous mapping in /dev/rbd and return the
$pve_path.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agorbd: fix #4060 show data-pool usage when configured
Aaron Lauterer [Wed, 18 May 2022 09:04:54 +0000 (11:04 +0200)]
rbd: fix #4060 show data-pool usage when configured

When a data-pool is configured, use it for status infos. The 'data-pool'
config option is used to mark the erasure coded pool while the 'pool'
will be the replicated pool holding meta data such as the omap.

This means, the 'pool' will only use a small amount of space and people
are interested how much they can store in the erasure coded pool anyway.

Therefore this patch reorders the assignment of the used pool name by
availability of the scfg parameters: data-pool -> pool -> fallback 'rbd'

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agobump version to 7.2-4
Thomas Lamprecht [Fri, 13 May 2022 12:27:28 +0000 (14:27 +0200)]
bump version to 7.2-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorbd: warn if no stats for a pool could be gathered
Stoiko Ivanov [Tue, 3 May 2022 11:31:40 +0000 (13:31 +0200)]
rbd: warn if no stats for a pool could be gathered

happens in case of a mistyped poolname, and the new message should be
more helpful than:
`Use of uninitialized value $free in addition (+) at \
/usr/share/perl5/PVE/Storage/RBDPlugin.pm line 64`

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agorbd: add fallback default poolname 'rbd' to status
Stoiko Ivanov [Tue, 3 May 2022 11:31:39 +0000 (13:31 +0200)]
rbd: add fallback default poolname 'rbd' to status

the fallback to a default pool name of 'rbd' was introduced in:
1440604a4b072b88cc1e4f8bbae4511b50d1d68e
and worked for the status command, because it used the `rados_cmd`
sub.

This fallback was lost with the changes in:
41aacc6cdeea9b0c8007cbfb280acf827932c3d6

leading to confusing errors:
`Use of uninitialized value in string eq at \
/usr/share/perl5/PVE/Storage/RBDPlugin.pm line 633`
(e.g. in the journal from pvestatd)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agod/control: bump versioned dependecy for proxmox-backup-client
Thomas Lamprecht [Fri, 13 May 2022 12:06:42 +0000 (14:06 +0200)]
d/control: bump versioned dependecy for proxmox-backup-client

for the s/backup-ns/ns/ change

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopbs: backup-ns parameter was renamed to ns
Wolfgang Bumiller [Fri, 13 May 2022 11:07:49 +0000 (13:07 +0200)]
pbs: backup-ns parameter was renamed to ns

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump version to 7.2-3
Thomas Lamprecht [Thu, 12 May 2022 12:49:01 +0000 (14:49 +0200)]
bump version to 7.2-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependecy for proxmox-backup-client
Thomas Lamprecht [Thu, 12 May 2022 12:57:00 +0000 (14:57 +0200)]
d/control: bump versioned dependecy for proxmox-backup-client

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependency for pve-common
Thomas Lamprecht [Thu, 12 May 2022 12:45:17 +0000 (14:45 +0200)]
d/control: bump versioned dependency for pve-common

for namespace support

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopbs: namespace support
Wolfgang Bumiller [Thu, 12 May 2022 08:44:53 +0000 (10:44 +0200)]
pbs: namespace support

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump version to 7.2-2
Thomas Lamprecht [Thu, 28 Apr 2022 16:20:02 +0000 (18:20 +0200)]
bump version to 7.2-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorbd: get path: allow fake override of fsid in scfg for some regression tests
Thomas Lamprecht [Thu, 28 Apr 2022 16:17:56 +0000 (18:17 +0200)]
rbd: get path: allow fake override of fsid in scfg for some regression tests

to avoid calls into RADOS connect, that trigger RPCEnv not
initialized breakage in regression tests, but wouldn't really work
otherwise either

in the future the RBD $scfg could actually support this (or similarly
named) property, to safe on storage addition and then avoid frequent
mon commands

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.2-1
Thomas Lamprecht [Thu, 28 Apr 2022 15:38:22 +0000 (17:38 +0200)]
bump version to 7.2-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorbd: unmap volume after rename
Fabian Ebner [Thu, 28 Apr 2022 08:47:18 +0000 (10:47 +0200)]
rbd: unmap volume after rename

When krbd is used, subsequent removal after an an operation
involving a rename could fail with
> librbd::image::PreRemoveRequest: 0x559b7506a470 \
> check_image_watchers: image has watchers - not removing
because the old mapping was still present.

For both operations with a rename, the owning guest should be offline,
but even if it weren't, unmap simply fails when the volume is in-use.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agorbd: drop get_kernel_device_path
Fabian Grünbichler [Wed, 27 Apr 2022 11:03:16 +0000 (13:03 +0200)]
rbd: drop get_kernel_device_path

it only redirected to get_rbd_dev_path with the same signature and both
are private subs..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agorbd: reduce number of stats in likely path
Fabian Grünbichler [Wed, 27 Apr 2022 11:01:42 +0000 (13:01 +0200)]
rbd: reduce number of stats in likely path

the new udev rule is expected to be in place and active, switching the
checks around means 1 instead of 2 stat()s in this rather hot code path.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agorbd: fix #3969: add rbd dev paths with cluster info
Aaron Lauterer [Wed, 13 Apr 2022 09:43:22 +0000 (11:43 +0200)]
rbd: fix #3969: add rbd dev paths with cluster info

By adding our own customized rbd udev rules and ceph-rbdnamer we can
create device paths that include the cluster fsid and avoid any
ambiguity if the same pool and namespace combination is used in
different clusters we connect to.

Additionally to the '/dev/rbd/<pool>/...' paths we now have
'/dev/rbd-pve/<cluster fsid>/<pool>/...' paths.

The other half of the patch makes use of the new device paths in the RBD
plugin.

The new 'get_rbd_dev_path' method the full device path. In case that the
image has been mapped before the rbd-pve udev rule has been installed,
it returns the old path.

The cluster fsid is read from the 'ceph.conf' file in the case of a
hyperconverged setup. In the case of an external Ceph cluster we need to
fetch it via a rados api call.

Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agostorage plugins: en/decode volume notes as UTF-8
Dominik Csapak [Wed, 9 Mar 2022 08:21:28 +0000 (09:21 +0100)]
storage plugins: en/decode volume notes as UTF-8

When writing into the file, explicitly utf8 encode it, and then try
to utf8 decode it on read.

If the notes are not valid utf8, we assume they were iso-8859 encoded
and return as is.

Technically this is a breaking change, since there are iso-8859
comments that would successfully decode as utf8, for example: the
byte sequence "C2 A9" would be "£" in iso, but would decode to "£".

From what i can tell though, this is rather unlikely to happen for
"real world" notes, because the first byte would be in the range of
C0-F7 (which are mostly language dependent characters like "Â") and
the following bytes would have to be in the range of 80-BF, which are
only special characters like "£" (or undefined)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agozfs pool: bump non-worker timeoiut default to 10s
Thomas Lamprecht [Tue, 26 Apr 2022 13:25:38 +0000 (15:25 +0200)]
zfs pool: bump non-worker timeoiut default to 10s

With 30s we got for sync api calls 10s leaves still enough room for
answering and other stuff.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3803: ZFSPoolPlugin: zfs_request: increase minimum timeout in worker
Dominik Csapak [Thu, 23 Dec 2021 12:06:22 +0000 (13:06 +0100)]
fix #3803: ZFSPoolPlugin: zfs_request: increase minimum timeout in worker

Since most zfs operations can take a while (under certain conditions),
increase the minimum timeout for zfs_request in workers to 5 minutes.

We cannot increase the timeouts in synchronous api calls, since they are
hard limited to 30 seconds, but in worker we do not have such limits.

The existing default timeout does not change (60minutes in worker,
5seconds otherwise), but all zfs_requests with a set timeout (<5minutes)
will use the increased 5 minutes in a worker.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoceph config: minor code cleanup & comment
Thomas Lamprecht [Tue, 26 Apr 2022 10:47:54 +0000 (12:47 +0200)]
ceph config: minor code cleanup & comment

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosome code style refcatoring/cleanup
Thomas Lamprecht [Fri, 22 Apr 2022 12:30:01 +0000 (14:30 +0200)]
some code style refcatoring/cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.1-2
Fabian Grünbichler [Wed, 6 Apr 2022 11:30:21 +0000 (13:30 +0200)]
bump version to 7.1-2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agodisks: zfs: code indentation/style improvments
Thomas Lamprecht [Wed, 6 Apr 2022 10:56:43 +0000 (12:56 +0200)]
disks: zfs: code indentation/style improvments

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoplugins: allow limiting the number of protected backups per guest
Fabian Ebner [Tue, 29 Mar 2022 12:53:13 +0000 (14:53 +0200)]
plugins: allow limiting the number of protected backups per guest

The ability to mark backups as protected broke the implicit assumption
in vzdump that remove=1 and current number of backups being the limit
(i.e. sum of all keep options) will result in a backup being removed.

Introduce a new storage property 'max-protected-backups' to limit the
number of protected backups per guest. Use 5 as a default value, as it
should cover most use cases, while still not having too big of a
potential overhead in many scenarios.

For external plugins that do not return the backup subtype in
list_volumes, all protected backups with the same ID will count
towards the limit.

An alternative would be to count the protected backups when pruning.
While that would avoid the need for a new property, it would break the
current semantics of protected backups being ignored for pruning. It
also would be less flexible, e.g. for PBS, it can make sense to have
both keep-all=1 and a limit for the number of protected snapshots on
the PVE side.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoapi: file restore: use check_volume_access to restrict content type
Fabian Ebner [Wed, 30 Mar 2022 10:24:33 +0000 (12:24 +0200)]
api: file restore: use check_volume_access to restrict content type

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agopvesm: extract config: add content type check
Fabian Ebner [Wed, 30 Mar 2022 10:24:32 +0000 (12:24 +0200)]
pvesm: extract config: add content type check

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agocheck volume accesss: add content type parameter
Fabian Ebner [Wed, 30 Mar 2022 10:24:31 +0000 (12:24 +0200)]
check volume accesss: add content type parameter

Adding such a check here avoids the need to parse at the call sites in
some cases.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agocheck volume access: allow for images/rootdir if user has VM.Config.Disk
Fabian Ebner [Wed, 30 Mar 2022 10:24:30 +0000 (12:24 +0200)]
check volume access: allow for images/rootdir if user has VM.Config.Disk

Listing guest images should not require Datastore.Allocate in this
case. In preparation for adding disk import to the GUI.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agocheck volume access: always allow with Datastore.Allocate privilege
Fabian Ebner [Wed, 30 Mar 2022 10:24:29 +0000 (12:24 +0200)]
check volume access: always allow with Datastore.Allocate privilege

Such users are supposed to be administrators of the storage, but
previously, access to backups was not allowed when not also having
VM.Backup.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agopvesm: extract config: check for VM.Backup privilege
Fabian Ebner [Wed, 30 Mar 2022 10:24:28 +0000 (12:24 +0200)]
pvesm: extract config: check for VM.Backup privilege

In preparation to have check_volume_access() always allow access for
users with Datastore.Allocate privilege. As to not automatically give
all such users permission to extract the config too.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agolist volumes: also return backup type for backups
Fabian Ebner [Thu, 16 Dec 2021 12:12:23 +0000 (13:12 +0100)]
list volumes: also return backup type for backups

Otherwise, there is no storage-agnostic way to filter by backup group.

Call it subtype, to not confuse it with content type, and to be able
to re-use it for other content types than backup, if the need ever
arises.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agocifs: check connection: bubble up NT_STATUS_LOGON_FAILURE
Fabian Ebner [Mon, 15 Nov 2021 12:37:56 +0000 (13:37 +0100)]
cifs: check connection: bubble up NT_STATUS_LOGON_FAILURE

in the same manner as NT_STATUS_ACCESS_DENIED. It can be assumed to be
a configuration error, so avoid showing the generic "storage <storeid>
is not online". Reported in the community forum:
https://forum.proxmox.com/threads/storage-is-not-online-cifs.99201/post-428858

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoactivate storage: improve error when check_connection dies
Fabian Ebner [Mon, 15 Nov 2021 12:37:55 +0000 (13:37 +0100)]
activate storage: improve error when check_connection dies

by making sure the storage ID is part of the error. This can happen
for (at least) CIFS, and GlusterFS with local server.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agostorage/plugin: factoring out regex for backup extension re
Lorenz Stechauner [Fri, 22 Oct 2021 12:23:11 +0000 (14:23 +0200)]
storage/plugin: factoring out regex for backup extension re

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
2 years agostorage: rename REs for iso and vztmpl extensions
Lorenz Stechauner [Fri, 22 Oct 2021 12:23:10 +0000 (14:23 +0200)]
storage: rename REs for iso and vztmpl extensions

these changes make it more clear, how many capture groups each
RE inclues.

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
2 years agozfs: volume import: use correct format for renaming
Fabian Ebner [Thu, 3 Mar 2022 12:31:21 +0000 (13:31 +0100)]
zfs: volume import: use correct format for renaming

Previously, the transport format (which currently is always 'zfs') was
passed in, resulting in subvol-disks not to be renamed correctly.

Fixes: a97d3ee ("Introduce allow_rename parameter for pvesm import and storage_migrate")
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agofile_size_info: cast 'size' and 'used' to integer
Mira Limbeck [Fri, 18 Feb 2022 08:58:27 +0000 (09:58 +0100)]
file_size_info: cast 'size' and 'used' to integer

`qemu-img info --output=json` returns the size and used values as integers in
the JSON format, but the regex match converts them to strings.
As we know they only contain digits, we can simply cast them back to integers
after the regex.

The API requires them to be integers.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agofix #3894: cast 'size' and 'used' to integer
Mira Limbeck [Fri, 18 Feb 2022 08:58:26 +0000 (09:58 +0100)]
fix #3894: cast 'size' and 'used' to integer

Perl's automatic conversion can lead to integers being converted to
strings, for example by matching it in a regex.

To make sure we always return an integer in the API call, add an
explicit cast to integer.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoadd volume_import/export_start helpers
Fabian Grünbichler [Wed, 9 Feb 2022 13:07:50 +0000 (14:07 +0100)]
add volume_import/export_start helpers

exposing the two halves of a storage migration for usage across
cluster boundaries.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agostorage_migrate: pull out import/export_prepare
Fabian Grünbichler [Wed, 9 Feb 2022 13:07:49 +0000 (14:07 +0100)]
storage_migrate: pull out import/export_prepare

for re-use with remote migration, where import and export happen on
different clusters connected via a websocket instead of SSH tunnel.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agostorage_migrate_snapshot: skip for btrfs without snapshots
Fabian Grünbichler [Wed, 9 Feb 2022 13:07:48 +0000 (14:07 +0100)]
storage_migrate_snapshot: skip for btrfs without snapshots

this allows migrating from btrfs to other raw+size accepting storages,
provided no snapshots exist.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobump version to 7.1-1
Thomas Lamprecht [Fri, 4 Feb 2022 17:08:09 +0000 (18:08 +0100)]
bump version to 7.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorbd: followup code style cleanups
Thomas Lamprecht [Fri, 4 Feb 2022 17:04:31 +0000 (18:04 +0100)]
rbd: followup code style cleanups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #1816: rbd: add support for erasure coded ec pools
Aaron Lauterer [Fri, 28 Jan 2022 11:22:41 +0000 (12:22 +0100)]
fix #1816: rbd: add support for erasure coded ec pools

The first step is to allocate rbd images correctly.

The metadata objects still need to be stored in a replicated pool, but
by providing the --data-pool parameter on image creation, we can place
the data objects on the erasure coded (EC) pool.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>