5
0
mirror of git://git.proxmox.com/git/pve-guest-common.git synced 2025-01-08 21:17:52 +03:00
Commit Graph

156 Commits

Author SHA1 Message Date
Fabian Ebner
17b5185b77 vzdump: mailto: use email-or-username-list format
because it is a more complete pattern. Also, 'mailto' was a '-list' format in
PVE 6.2 and earlier, so this also fixes whitespace-related backwards
compatibility. In particular, this fixes creating a backup job in the GUI
without setting an address, which passes along ''.

For example,
> vzdump 153 --mailto " ,,,admin@proxmox.com;;; developer@proxmox.com , ; "
was valid and worked in PVE 6.2.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-02-19 16:29:58 +01:00
Fabian Ebner
7a9b527f54 vzdump: command line: make sure mailto is comma-separated
In addition to relying on shellquote(), it's still nice to avoid printing out
unnecessary whitespaces, especially newlines.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-02-19 16:29:58 +01:00
Fabian Ebner
9e542a4f90 vzdump: command line: refactor handling prune-backups
to re-use a line here and with the next patch.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-02-19 16:29:58 +01:00
Fabian Ebner
533d6e503a vzdump: correctly handle prune-backups option in commandline and cron config
Previously only the hash reference was printed instead of the property string.
It's also necessary to parse the property string when reading the cron config.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-01-26 18:48:27 +01:00
Fabian Ebner
0111ceb9fd vzdump: add explicit reminder for breaking schema change for PVE 7.0
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-01-26 18:45:16 +01:00
Fabian Ebner
5da50f8cf5 vzdump: update exclude-path description
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-11-24 16:30:10 +01:00
Fabian Ebner
f6c5ba3cdb job_status: simplify fixup of jobs for stolen guests
by using switch_replication_job_target_nolock.

If a job is scheduled for removal and the guest was
stolen, it still makes sense to correct the job entry,
which didn't happen previously.

AFAICT, this was the only user of swap_source_target_nolock.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-11-06 15:10:25 +01:00
Fabian Ebner
0c3550c014 create nolock variant for switch_replication_job_target
so that it can be used within job_status

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-11-06 15:09:51 +01:00
Fabian Ebner
158c90bf9a also update sources in switch_replication_job_target
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-11-06 15:07:04 +01:00
Fabian Ebner
6364fd6385 clarify what the source property is used for in a replication job
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-11-06 15:06:52 +01:00
Fabian Ebner
db9eb287d4 job_status: read only after acquiring the lock
to get the current replication config and have the VM list
and state object as recent as possible.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-11-06 15:05:47 +01:00
Thomas Lamprecht
60aeee5fb1 print snapshot tree: reduce indentation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-24 16:57:38 +02:00
Oguz Bektas
295a6359db vzdump: use regex check for 'mailto'
add a new string format to allow local usernames like 'root' but also
limit which characters can be used in the 'mailto' address.

Co-Authored-by: Fabian Gruenbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2020-09-03 10:02:32 +02:00
Thomas Lamprecht
0eec698ff5 move config: add comment about node owning configs
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-08-24 09:45:30 +02:00
Fabian Ebner
659061237c Add move_config_to_node method
allows to mock it when testing and a few lines less duplication
between the migration modules.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-08-24 09:42:50 +02:00
Fabian Ebner
0d9520c415 Add prune-backups option to vzdump parameters
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-08-20 17:39:15 +02:00
Fabian Grünbichler
301b375bab unbreak config_with_pending_array
which lead to current and pending/delete values being returned
separately, and being misinterpreted by the web interface (and probably
other clients as well).

Fixes: daf8fca57a

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-08-05 12:12:44 +02:00
Thomas Lamprecht
07c587d84a followup: add comment to avoid same mistake again
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-11 18:47:53 +02:00
Stoiko Ivanov
dd59a7cac0 fix #2834: skip refs in config_with_pending_array
With the refactoring of config_with_pending_array in
daf8fca57a a few sanity checks on parsed configs
were dropped.

One case where a config value should be skipped, instead of parsed and added
is when the value is not scalar. This is the case for the raw lxc keys
(e.g. lxc.init.cmd, lxc.apparmor.profile) - which get added as array to the
'lxc' key.

This patch reintroduces the skipping of non-scalar values, when parsing the
config but not for the pending values.
From a short look through the commit history the sanity checks were in place
since 2014 (introduced in qemu-server for handling pending configuration
changes), and their removal did not cause any other regressions.
To my knowledge only the raw lxc config keys are parsed into a non-scalar
value.

Tested by adding a 'lxc.init.cmd' key to a container config.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-07-11 18:45:26 +02:00
Aaron Lauterer
a8878e5ef7 Adapt description of get_backup_volumes
as `data` was a bit too generic we now use `volume_config` in the actual
implementations. Thus we should adapt the description as well.

Tab spacing for the other keys has been adapted for easier readabilty.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2020-06-24 11:14:19 +02:00
Thomas Lamprecht
daf8fca57a refactor config_with_pending_array
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-20 17:08:09 +02:00
Thomas Lamprecht
43c899e407 fix config_with_pending_array for falsy current values
one could have a config with:
> acpi: 0

and a pending deletion for that to restore the default 1 value.

The config_with_pending_array method then pushed the key twice, one
in the loop iterating the config itself correctly and once in the
pending delete hash, which is normally only for those options not yet
referenced in the config at all. Here the check was on "truthiness"
not definedness, fix that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-20 17:04:40 +02:00
Fabian Grünbichler
9cdd44001a lock_config: rename lock_config_mode -> lock_config_shared
and pull the actual lock_file_full handling into a helper, to make the
public interface clearer:

lock_config -> standard exclusive lock with 10s timeout
lock_config_full -> exclusive lock with configurable timeout
lock_config_shared -> shared lock with configurable timeout

the latter only has a single user (qemu-server's clone API call)
currently.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
2020-05-05 11:11:57 +02:00
Fabian Grünbichler
990d9675c5 snapshot_delete: check for concurrent modifications at each step
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
2020-05-05 11:11:57 +02:00
Fabian Ebner
c261973c52 snapshot_rollback: make sure newer replication snapshots are deleted
Commit a1dfeff3a8 changed the behavior
for Replication::prepare with last_sync=0, so use last_sync=1 instead.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-05-05 11:11:37 +02:00
Fabian Grünbichler
82a0485717 snapshot_rollback: flock earlier
to protect checks against concurrent modifications

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
2020-05-05 11:11:29 +02:00
Fabian Ebner
97b9ccec08 fix 2682: make sure configuration file is up-to-date for lock_config-variants
See [0] for the details. The call tree for the variants is
lock_config -> lock_config_full -> lock_config_mode
so it is sufficient to adapt lock_config_mode.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=2682

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-05-05 11:11:29 +02:00
Fabian Ebner
093c4c6e09 Avoid duplication by using lock_config_mode
No functional change is intended.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-05-05 11:11:19 +02:00
Alwin Antreich
e8ca21371f Fix: #2124 add zstd support
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
2020-05-04 14:08:16 +02:00
Fabian Ebner
95a9508eba Add update_volume_ids
This function is intened to be used after doing a migration where some
of the volume IDs changed.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-09 09:39:42 +02:00
Fabian Ebner
36cff88657 Use new storage_migrate interface
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-09 09:39:31 +02:00
Thomas Lamprecht
e90f586aab replicaiton: log rate and transport type
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-08 13:27:34 +02:00
Thomas Lamprecht
45b4c97f0f replication: dont declare variable in post-if scope
If a variable is defined and assigned in a conditional statement, it
is not defined behavior in Perl.

For more information about this behaviour see
https://perldoc.perl.org/perlsyn.html#Statement-Modifiers

> NOTE: The behaviour of a my, state, or our modified with a
> statement modifier conditional or loop construct (for example,
> `my $x if ...`) is undefined.
> The value of the my variable may be undef, any previously assigned
> value, or possibly anything else.
> Don't rely on it. Future versions of perl might do something
> different from the version of perl you try it out on. Here be
> dragons."

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-08 13:20:07 +02:00
Fabian Ebner
261d47a451 foreach_volume(_full): generalize and implement function
Introduce a parameter $opts to allow for better control of which
keys/volumes to use for the iteration and ability to reverse the order.
Also, allow extra parameters for the function.

Removes the '__snapshot'-prefix for future use from outside the module.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-27 14:15:22 +01:00
Fabian Ebner
8db0144048 Add foreach_unused_volume
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-27 14:10:02 +01:00
Fabian Ebner
4e6382ab58 Add interfaces for volume-related helpers
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-27 14:10:02 +01:00
Dominik Csapak
b2b16cee39 make GuestHelpers a subclass of Exporter
or else the Exports will not work

found by hotplugging nics with current master from qemu-server
which resulted in a
'undefined subroutine &PVE::QemuServer::safe_string_ne'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-12 11:09:00 +01:00
Thomas Lamprecht
1245ad854c get_backup_volumes: clarifcation and indentation improvements to comment
Aaron clarified that one documented element actually slipped through
and won't be returned.

Also firx the mixed tab/space indentation, for such comments we can
be pretty liberal and I just went with the two spaces per level, as
some part already had that.

Clarify that both array and hash are refs.

[0]: https://pve.proxmox.com/pipermail/pve-devel/2020-March/042070.html

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-10 12:17:03 +01:00
Aaron Lauterer
b2a2affa3f abstractconfig: add prototype for get_backup_volumes
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2020-03-10 12:13:07 +01:00
Thomas Lamprecht
67b3581e64 config: add missing use GuestHelpers module
import the typesafe_ne method when we're at it
2020-03-10 09:48:22 +01:00
Thomas Lamprecht
47d7954c59 config: return early if $opt is not partial fast pluggable
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-10 09:43:56 +01:00
Oguz Bektas
866f5834fd abstractconfig: add partial_fast_plug
allows partial fast plugging of functions as defined in the
$partial_fast_plug_option in qemuserver (and possibly lxc later on)

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2020-03-10 09:00:05 +01:00
Oguz Bektas
24d90d8d10 guesthelpers: move/add safe comparison functions from lxc and qemu
move the safe_string_ne and safe_num_ne functions to guesthelpers to
remove duplicate code.

add the new safe_boolean_ne and typesafe_ne helper functions

also add them in @EXPORT_OK

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2020-03-10 09:00:05 +01:00
Thomas Lamprecht
ab44df53f7 fix some typos
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-02-08 16:03:49 +01:00
Thomas Lamprecht
9420142c33 trivial whitespace fix
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-02-07 16:22:47 +01:00
Thomas Lamprecht
fde98d5e11 config trait: allow to pass lock to create_and_lock_config
allows us to reuse this for clone, where we want to create a "clone"
locked config for the target guest.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-23 11:01:56 +01:00
Thomas Lamprecht
fb73d112aa grammar fix: s/does not exists/does not exist/g
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-13 12:08:06 +01:00
Wolfgang Bumiller
727080edd9 avoid cyclic reference in closure
otherwise this leaks memory

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-19 09:46:46 +01:00
Fabian Grünbichler
0c85474f68 use PVE::SSHInfo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-18 12:01:39 +01:00
Fabian Grünbichler
96c08a9dcd use PVE::DataCenterConfig
to make sure that the corresponding cfs_read_file works() works.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-18 12:01:39 +01:00