5
0
mirror of git://git.proxmox.com/git/pve-guest-common.git synced 2024-12-25 23:21:36 +03:00
Commit Graph

96 Commits

Author SHA1 Message Date
Oguz Bektas
810ee08809 abstractconfig: add pending changes related helpers
use a better naming scheme for methods from qemuserver:

split_flagged_list -> parse_pending_delete
join_flagged_list -> print_pending_delete
vmconfig_delete_pending_option -> add_to_pending_delete
vmconfig_undelete_pending_option -> remove_from_pending_delete
vmconfig_cleanup_pending -> cleanup_pending

parse_pending_delete now has a better representation of the force value,
which is encoded in a perl hash i.e. $conf->{$opt}->{force} = 1 or 0
depending on if the string in config has '!' or not.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-18 09:28:34 +02:00
Thomas Lamprecht
1aa76f2f0b base guest config: add common destroy_config implementation
copied over from pve-containers implementation with the same name.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 08:47:33 +02:00
Christian Ebner
8c3af92574 fix #1291: implement remove_vmid_from_backup_jobs
remove_vmid_from_backup_jobs updates the vzdump.cron backup jobs,
excluding the given vmid.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-18 07:47:23 +02:00
Christian Ebner
e2a0a93be0 vzdump: move registration of vzdump.cron from manager to guest-common to avoid cyclic dependency
The registration of the vzdump.cron file was handled in pve-manager.
By moving the relevant code to pve-guest-common, cyclic dependencies
for cfs registration are avoided.
This makes this patch of guest-common a build dependency for the other
packages touched in this patch series.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-10-18 07:47:23 +02:00
Thomas Lamprecht
5ee5f8873e followup: rename to print_snapshot_tree, add comment and rename $res param
This was taken from a CLI helper, there $res is a common parameter
name which denotes that it's the res from the API call the CLI
command bases on. But here that makes no sense and is not really
telling about what the value(s) of $res could be. Further explain
that with a comment.

As this also prints uncoditionally to STDOUT let's say so through the
method name.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-01 17:20:27 +02:00
Oguz Bektas
725dcadba3 reformat code for snapshot tree into GuestHelpers
qm/pct listsnapshot lack feature parity w.r.t. showing snapshots in a
tree ordered by the date. by moving this code into GuestHelpers, it can
be shared.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-01 17:15:04 +02:00
Christian Ebner
1daaf2ea3f implement remove_vmid_jobs for ReplicationConfig
Allows to remove replication jobs from the config based on the vmid.

Preparations for #1291 fix

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 16:36:34 +02:00
Wolfgang Link
3cdcfff633 increase max reading replication state file size.
In this file, the error of a failed job will also be stored.
The default 32768 bytes are not very much.

This file is on the local filesystem so there is no filesystem
size restrictions like in /etc/pve.
2019-04-17 07:26:53 +00:00
Thomas Lamprecht
1c9da8ac5b follouwp: saner exception handling
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-02-01 10:10:48 +01:00
Dominik Csapak
3acb4e7463 add check/exec_hookscript to GuestHelpers
check_hookscript will be used for the container/vm api to check if the
hookscript volume id is correct

exec_hookscript can be called to execute a hookscript

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-01 10:10:48 +01:00
Wolfgang Bumiller
90fba9cdf3 replace complete_snapshot_name with snapshot_list
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-01-03 10:22:26 +01:00
Thomas Lamprecht
b3b0025bd6 fix deprecated unescaped left brace in regex
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-12-14 14:06:08 +01:00
Rhonda D'Vine
eb50bb6141 Bash completion helper for snapshot name
This is the bash completion helper function for completing the snapshot
name.  This is used both in qemu-server and pve-container.

This patch is the base for the patches in qemu-server and pve-container.

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>
2018-11-14 11:55:08 +01:00
Dominik Csapak
3fa4ce4516 add snapshot rollback hook and remove qemu machine code
instead move the QEMU machine logic inside qemu-server package with
the help of the new snapshot rollback hook

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-09-17 15:21:22 +02:00
Thomas Lamprecht
cbbb06a5ae add create_and_lock_config
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-12 09:45:40 +02:00
Wolfgang Bumiller
24691c2141 cleanup: ReplicationConfig: be specific about write_config
Since it doesn't write but returns the text to be written,
let's be specific about the fact that we're returning a
value.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-05-14 13:51:26 +02:00
Wolfgang Link
7319c02cfd Add lock to pervent lost update. 2018-05-09 15:10:30 +02:00
Wolfgang Link
7bbb0cd6a9 Swap source and target in replication config, if VM was stolen. 2018-05-09 15:10:30 +02:00
Wolfgang Link
286a9ab991 Add function: swap source and target in replication config 2018-05-09 15:10:30 +02:00
Wolfgang Link
d5b277dc99 Get snapshots when no state is available.
With this patch we can restore the state of a state less job.
It may happen that there are more replication snapshots,
because no job state is known can not delete any snapshot.
Existing multiple replication-snapshot happens
when a node fails in middel of a replication
and then the VM is moved to another node.
That's why we have to test if we have a common base on both nodes.
Given this, we take this as a replica state.
After we have a state again, the rest of the snapshots can be deleted on the next run.
2018-05-09 15:10:30 +02:00
Wolfgang Link
a1dfeff3a8 Delete replication snapshots only if last_sync is not 0.
If last_sync is 0, the VM configuration has been stolen
(either manually or by HA restoration).
Under this condition, the replication snapshot should not be deleted.
This snapshot is used to restore replication state.
If the last_snap is greater than 0 and does not match the snap name
it must be a remnant of an earlier sync and should be deleted.
2018-05-09 15:10:30 +02:00
Wolfgang Link
4ea5167ef0 Add config parameter 'source'.
This parameter is useful for restoring the replication status.
It is also corrected if it is missing or wrong.
2018-05-09 15:10:30 +02:00
Wolfgang Link
d869a19c9e Cleanup for stateless jobs.
If a VM configuration has been manually moved or recovered by HA,
there is no status on this new node.
In this case, the replication snapshots still exist on the remote side.
It must be possible to remove a job without status,
otherwise, a new replication job on the same remote node will fail
and the disks will have to be manually removed.
When searching through the sorted_volumes generated from the VMID.conf,
we can be sure that every disk will be removed in the event
of a complete job removal on the remote side.

In the end, the remote_prepare_local_job calls on the remote side a prepare.
2018-05-09 15:10:30 +02:00
Dietmar Maurer
edd61f2b3a Replication.pm: code cleanup 2018-04-16 10:52:24 +02:00
Dietmar Maurer
c1797f7a4d PVE/Replication.pm: fix error message 2018-04-16 10:48:49 +02:00
Wolfgang Link
ce22af0895 fix #1694: make failure of snapshot removal non-fatal
In certain high-load scenarios ANY ZFS operation can block,
including registering an (async) destroy.
Since ZFS operations are implemented via ioctl's,
killing the user space process
does not affect the waiting kernel thread processing the ioctl.

Once "zfs destroy" has been called, killing it does not say anything
about whether the destroy operation will be aborted or not.
Since running into a timeout effectively means killing it,
we don't know whether the snapshot exists afterwards or not.
We also don't know how long it takes for ZFS to catch up on pending ioctls.

Given the above problem, we must to not die on errors when deleting a no
longer needed snapshot fails (under a timeout) after an otherwise
successful replication. Since we retry on the next run anyway, this is
not problematic.

The snapshot deletion error will be logged in the replication log
and the syslog/journal.
2018-04-16 10:40:48 +02:00
Thomas Lamprecht
c8a71da5ce vzdump: add common log sub-method
Add a general log method here which supports to pass on the "log to
syslog too" functionality and makes it more clear what each
parameter of logerr and logginfo means.

Further, we can now also log wlith a 'warn' level, which can be
useful to notice an backup user of a possible problem which isn't a
error per se, but may need the users attention.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-12-15 12:11:22 +01:00
Thomas Lamprecht
8044127d7d vzdump: allow all defined log levels
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-12-15 12:11:22 +01:00
Wolfgang Link
ac02a68e07 Remove noerr form replication.
We will handle this errors in the API and decide what to do.

Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-12-13 14:51:34 +01:00
Wolfgang Bumiller
81228d280f replication: purge states: verify the vmlist
Instead of clearing out the local state if the last
cfs_update failed.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-10-17 14:00:39 +02:00
Wolfgang Link
aa0d516fc5 Add logfunc in storage_migration.
This will redirect export and import output to the correct log, instead of paring it into the syslog.
2017-10-16 15:00:57 +02:00
Thomas Lamprecht
047ee481a6 VZDump/Plugin: avoid cyclic dependency
pve-guest-common is above qemu-server, pve-container and thus also
pve-manager in the package hierarchy.
The latter hosts PVE::VZDump, so using it here adds a cyclic
dependency between pve-manager and pve-guest-common.

Move the log method to the base plugin class and inline the
run_command function directly do the plugins cmd method.

pve-manager's PVE::VZDump may use this plugins static log function
then instead of its own copy.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-21 09:48:08 +02:00
Thomas Lamprecht
71dd5d907b AbstractMigrate: remove unused obsolete variables 2017-09-20 12:39:11 +02:00
Thomas Lamprecht
ee966a3f7a AbstractMigrate: do not overwrite global signal handlers
perls 'local' must be either used in front of each $SIG{...}
assignments or they must be put in a list, else it affects only the
first variable and the rest are *not* in local context.

This may cause weird behaviour where daemons seemingly do not get
terminating signals delivered correctly and thus may not shutdown
gracefully anymore.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-07 10:32:08 +02:00
Alwin Antreich
4c3144eaa6 Fix #1480: die if snapshot name is not found before set_lock is used
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
2017-09-01 09:06:24 +02:00
Wolfgang Bumiller
d91bac5053 replication: we must call storage_migrate with with_snapshots true 2017-07-03 11:58:41 +02:00
Thomas Lamprecht
23ca78cd25 replication job_status: add get_disabled parameter
allows the API/frontend to get the disabled jobs easier

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-06-29 10:42:19 +02:00
Dietmar Maurer
b3ed460ed0 Revert "Add guest type at find_local_replication_job"
This reverts commit 914b6647a4.

No longer required.
2017-06-29 07:27:16 +02:00
Dietmar Maurer
6358ffe1cb PVE::Replication - do not use $jobcfg->{vmtype} 2017-06-29 07:26:51 +02:00
Wolfgang Link
914b6647a4 Add guest type at find_local_replication_job
We need this at migration time.
2017-06-28 14:29:45 +02:00
Dietmar Maurer
40bcf6526b fix previous commit 2017-06-28 12:05:18 +02:00
Dietmar Maurer
22ce136731 replication: improve schedule_job_now
do no not modify anything if there is no state
2017-06-28 12:01:50 +02:00
Wolfgang Bumiller
b90dc712c5 replication: add schedule_job_now helper 2017-06-28 11:54:11 +02:00
Wolfgang Bumiller
621b955fb8 replication: sort time stamps numerically 2017-06-28 09:52:17 +02:00
Dietmar Maurer
1b82f17117 replication: pass $noerr to run_replication_nolock 2017-06-28 07:54:11 +02:00
Wolfgang Link
14849765e5 Add new function delete_guest_states. 2017-06-27 12:51:44 +02:00
Wolfgang Bumiller
fd844180a7 replication: don't sync to offline targets on error states
There's no point in trying to replicate to a target node
which is offline. Note that if we're not already in an
error state we do still give it a try in order for this to
get logged as an error at least once.
2017-06-27 12:13:24 +02:00
Wolfgang Bumiller
3385399339 replication: keep retrying every 30 minutes in error state
Otherwise we never get out of it.
2017-06-27 12:13:24 +02:00
Dietmar Maurer
92a243e986 PVE::ReplicationState - cleanup job state on job removal
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2017-06-27 11:53:28 +02:00
Dietmar Maurer
44972014b2 PVE::ReplicationState::purge_old_states - new helper 2017-06-27 10:15:01 +02:00