]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
3 years agolive-restore: hold 'create' lock during operation
Stefan Reiter [Wed, 21 Apr 2021 14:25:25 +0000 (16:25 +0200)]
live-restore: hold 'create' lock during operation

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agolive-restore: don't remove VM on error
Stefan Reiter [Wed, 21 Apr 2021 14:25:24 +0000 (16:25 +0200)]
live-restore: don't remove VM on error

Potentially an admin can still recover some data, or wants to inspect
the state.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoqmrestore: add live-restore option
Stefan Reiter [Wed, 21 Apr 2021 14:25:23 +0000 (16:25 +0200)]
qmrestore: add live-restore option

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agodrive: volume in-use check: remove unused closure parameter
Fabian Ebner [Mon, 19 Apr 2021 13:39:50 +0000 (15:39 +0200)]
drive: volume in-use check: remove unused closure parameter

and simplify the calling iteration.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: keep log rate steady if polling gets more frequent
Thomas Lamprecht [Mon, 19 Apr 2021 20:01:05 +0000 (22:01 +0200)]
migration: keep log rate steady if polling gets more frequent

Either we're done in a few seconds anyway, or if the VM dirties lots
of pages we need quite a bit of time, and then it does not help to
output roughly the same status 10 times a second...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigration: rework logging to more humand friendly, less spammy
Thomas Lamprecht [Mon, 19 Apr 2021 19:54:33 +0000 (21:54 +0200)]
migration: rework logging to more humand friendly, less spammy

* use render_bytes where possible, to get quick to read and grasp
  units printed
* xbzrle is only interesting if actually pages/bytes are send using
  it, so only log in that case
* log if VM dirties more than we send
* log current speed we get from QEMU

In general there are less lines logged and huge integers are avoided.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigration: factor out variable + code cleanup
Thomas Lamprecht [Mon, 19 Apr 2021 19:51:21 +0000 (21:51 +0200)]
migration: factor out variable + code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigration: log: s/migration_caps/migration capabilities/
Thomas Lamprecht [Mon, 19 Apr 2021 19:48:31 +0000 (21:48 +0200)]
migration: log: s/migration_caps/migration capabilities/

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigration: do not set default speed limit
Thomas Lamprecht [Mon, 19 Apr 2021 19:46:49 +0000 (21:46 +0200)]
migration: do not set default speed limit

the claim that QEMU limits this to 32M otherwise is bogus, at least
with any current QEMU version..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigration: refactor and tidy-up code
Thomas Lamprecht [Mon, 19 Apr 2021 12:56:12 +0000 (14:56 +0200)]
migration: refactor and tidy-up code

Use an early die so that the rest can loose an indentation level for
the actual migration status reporting code

Extract common used members of the stat hash for shorter code.

use `git show -w --word-diff=color --word-diff-regex='\w+'` for
getting a better view of actual changes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigration: move finishing block jobs to phase2 for better/uniform error handling
Fabian Ebner [Fri, 29 Jan 2021 15:11:43 +0000 (16:11 +0100)]
migration: move finishing block jobs to phase2 for better/uniform error handling

avoids the possibility to die during phase3_cleanup and instead of needing to
duplicate the cleanup ourselves, benefit from phase2_cleanup doing so.

The duplicate cleanup was also very incomplete: it didn't stop the remote kvm
process (leading to 'VM already running' when trying to migrate again
afterwards), but it removed its disks, and it didn't unlock the config, didn't
close the tunnel and didn't cancel the block-dirty bitmaps.

Since migrate_cancel should do nothing after the (non-storage) migrate process
has completed, even that cleanup step is fine here.

Since phase3 is empty at the moment, the order of operations is still the same.

Also add a test, that would complain about finish_tunnel not being called before
this patch. That test also checks that local disks are not already removed
before finishing the block jobs.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: split out replication from scan_local_volumes
Fabian Ebner [Fri, 29 Jan 2021 15:11:42 +0000 (16:11 +0100)]
migration: split out replication from scan_local_volumes

and avoid one loop over the config, by extending foreach_volid to include the
drivename.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: keep track of replicated volumes via local_volumes
Fabian Ebner [Fri, 29 Jan 2021 15:11:41 +0000 (16:11 +0100)]
migration: keep track of replicated volumes via local_volumes

by extending filter_local_volumes.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: use storage_migration for checks instead of online_local_volumes
Fabian Ebner [Fri, 29 Jan 2021 15:11:40 +0000 (16:11 +0100)]
migration: use storage_migration for checks instead of online_local_volumes

Like this we don't need to worry about auto-vivifaction.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: cleanup_remotedisks: simplify and include more disks
Fabian Ebner [Fri, 29 Jan 2021 15:11:39 +0000 (16:11 +0100)]
migration: cleanup_remotedisks: simplify and include more disks

Namely, those migrated with storage_migrate by using the information from
volume_map. Call cleanup_remotedisks in phase1_cleanup as well, because that's
where we end if sync_offline_local_volumes fails, and some disks might already
have been transfered successfully. Note that the local disks are still here, so
this is fine.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: simplify removal of local volumes and get rid of self->{volumes}
Fabian Ebner [Fri, 29 Jan 2021 15:11:38 +0000 (16:11 +0100)]
migration: simplify removal of local volumes and get rid of self->{volumes}

This also changes the behavior to remove the local copies of offline migrated
volumes only after the migration has finished successfully (this is relevant
for mixed settings, e.g. online migration with unused/vmstate disks).

local_volumes contains both, the volumes previously in $self->{volumes}
and the volumes in $self->{online_local_volumes}, and hence is the place
to look for which volumes we need to remove. Of course, replicated
volumes still need to be skipped.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: add nbd migrated volumes to volume_map earlier
Fabian Ebner [Fri, 29 Jan 2021 15:11:37 +0000 (16:11 +0100)]
migration: add nbd migrated volumes to volume_map earlier

and avoid a little bit of duplication by creating a helper

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: save targetstorage and bwlimit in local_volumes hash and re-use information
Fabian Ebner [Fri, 29 Jan 2021 15:11:36 +0000 (16:11 +0100)]
migration: save targetstorage and bwlimit in local_volumes hash and re-use information

It is enough to call get_bandwith_limit once for each source_storage.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: fix calculation of bandwith limit for non-disk migration
Fabian Ebner [Fri, 29 Jan 2021 15:11:35 +0000 (16:11 +0100)]
migration: fix calculation of bandwith limit for non-disk migration

The case with:
1. no generic 'migration' limit from the storage plugin
2. a migrate_speed limit in the VM config
was broken. It would assign 0 to migrate_speed when picking the minimum value
and then default to the default value. Fix it by checking if bwlimit is 0
before picking the minimum.

Also, make it a bit more readable by avoiding the trick of //-assigning bwlimit
before the units match up and relying on getting back the original bwlimit value
as the minimum. Instead, only ||-assign after the units match up and don't rely
on other things.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: split out config_update_local_disksizes from scan_local_volumes
Fabian Ebner [Fri, 29 Jan 2021 15:11:34 +0000 (16:11 +0100)]
migration: split out config_update_local_disksizes from scan_local_volumes

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: avoid re-scanning all volumes
Fabian Ebner [Fri, 29 Jan 2021 15:11:33 +0000 (16:11 +0100)]
migration: avoid re-scanning all volumes

by using the information obtained in the first scan. This
also makes sure we only scan local storages.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigration: split sync_disks into two functions
Fabian Ebner [Fri, 29 Jan 2021 15:11:32 +0000 (16:11 +0100)]
migration: split sync_disks into two functions

by making local_volumes class-accessible. One functions is for scanning all local
volumes and one is for actually syncing offline volumes via storage_migrate. The
exception is replicated volumes, this still happens during the scan for now.

Also introduce a filter_local_volumes helper, to makes life easier.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agotest: migration: add parse_volume_id calls
Fabian Ebner [Fri, 29 Jan 2021 15:11:31 +0000 (16:11 +0100)]
test: migration: add parse_volume_id calls

so it fails when something bad comes in.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agorestore: update config: remove unused parameter
Fabian Ebner [Thu, 18 Mar 2021 09:44:50 +0000 (10:44 +0100)]
restore: update config: remove unused parameter

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agotest: add tests for restoring config
Fabian Ebner [Thu, 18 Mar 2021 09:44:49 +0000 (10:44 +0100)]
test: add tests for restoring config

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agod/control: bump pve-storage dependency for new vdisk param
Thomas Lamprecht [Sun, 18 Apr 2021 16:04:29 +0000 (18:04 +0200)]
d/control: bump pve-storage dependency for new vdisk param

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofilter by content type when using vdisk_list
Fabian Ebner [Mon, 22 Mar 2021 14:32:43 +0000 (15:32 +0100)]
filter by content type when using vdisk_list

except for migration, where it would be subtly backwards-incompatible. Since
there is a scan_volids call for migration, we can't default to filtering in
scan_volids just yet.

Also allows to get rid of the existing filtering hack in rescan().

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agocfg2cmd: fix +pveN machine types with pxe
Stefan Reiter [Wed, 31 Mar 2021 14:39:23 +0000 (16:39 +0200)]
cfg2cmd: fix +pveN machine types with pxe

Pinned machine versions like "pc-i440fx-4.2+pve2.pxe" would otherwise
get a second "+pve0" suffix, which is incorrect.

Also deal with non-pve pinned versions correctly, i.e.
"pc-i440fx-5.2.pxe" becomes "pc-i440fx-5.2+pve0.pxe".

Handle .pxe suffixes in Machine.pm as well, and add two test cases.

Co-developed-by: Luca Berneking <luca@berneking.net>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agodrive: volume in-use check: fix fallback path comparison
Fabian Ebner [Thu, 15 Apr 2021 10:10:57 +0000 (12:10 +0200)]
drive: volume in-use check: fix fallback path comparison

When checking whether a volume is still referenced by a snapshot, the volid
itself is first checked. When the volid is different, we fall back to comparing
the path.

As the first value to be compared is a volume's path, the second value better be
a volume's path too, and not a snapshot's path.

See also 77019edfe0c190c949cdc0b0e3b4ad2ca37313b3 for historical context.

The error that led me here:
* had a VM with ZFS over iSCSI storage with an exsiting snapshot
* add new unused drive
* try to remove the unsued drive
* fails, because ZFS (not Pool!) Plugin does not support snapshot paths.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agobump version to 6.3-11
Thomas Lamprecht [Thu, 15 Apr 2021 16:32:10 +0000 (18:32 +0200)]
bump version to 6.3-11

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agodrive mirror: stop logging progress for a disk after it got ready
Thomas Lamprecht [Thu, 15 Apr 2021 15:52:52 +0000 (17:52 +0200)]
drive mirror: stop logging progress for a disk after it got ready

If, why ever, got "not-ready" again we'd log again the next round.

Improves the behavior for multiple disks, especially on migration
where we mirrored the local disks one by one, but kept reporting on
prev. ones.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoimage convert: use human-readable units in progress report
Thomas Lamprecht [Thu, 15 Apr 2021 15:51:01 +0000 (17:51 +0200)]
image convert: use human-readable units in progress report

similar to what driver mirror monitor was changed too

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoindentation line-length cleanup
Thomas Lamprecht [Thu, 15 Apr 2021 15:50:13 +0000 (17:50 +0200)]
indentation line-length cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agorestore PBS: use actual PVE::QemuConfig interface for destroying a config on error
Thomas Lamprecht [Tue, 6 Apr 2021 17:43:44 +0000 (19:43 +0200)]
restore PBS: use actual PVE::QemuConfig interface for destroying a config on error

avoid further spaghettification of our code base...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agopbs_live_restore: code cleanup, avoid prefixin local package
Thomas Lamprecht [Tue, 6 Apr 2021 17:43:03 +0000 (19:43 +0200)]
pbs_live_restore: code cleanup, avoid prefixin local package

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomirror monitor: rework periodic status reporting
Thomas Lamprecht [Tue, 6 Apr 2021 17:39:41 +0000 (19:39 +0200)]
mirror monitor: rework periodic status reporting

orient on the backup output which got reworked for PVE 6.2/6.3

Avoid overwhelming the user with redundant information, and use human
readable units.

before:
> restore-drive-scsi5: transferred: 167772160 bytes remaining: 8422162432 bytes total: 8589934592 bytes progression: 1.95 % busy: 1 ready: 0

after:
> restore-drive-scsi0: transferred 720.0 MiB of 32.0 GiB (2.20%) in 12s

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agolive restore: slightly more status output
Thomas Lamprecht [Tue, 6 Apr 2021 17:38:53 +0000 (19:38 +0200)]
live restore: slightly more status output

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomirror monitor: avoid overlong hash access, use intermediate variable
Thomas Lamprecht [Tue, 6 Apr 2021 15:46:19 +0000 (17:46 +0200)]
mirror monitor: avoid overlong hash access, use intermediate variable

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomirror monitor: refactoring/code cleanup
Thomas Lamprecht [Tue, 6 Apr 2021 14:59:14 +0000 (16:59 +0200)]
mirror monitor: refactoring/code cleanup

mostly s/\$job/$job_id/ and s/foreach/for/ + sort.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agolive restore: start/delete blockdev jobs in deterministic order
Thomas Lamprecht [Tue, 6 Apr 2021 14:51:04 +0000 (16:51 +0200)]
live restore: start/delete blockdev jobs in deterministic order

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: restore: better error messages
Thomas Lamprecht [Tue, 6 Apr 2021 08:15:20 +0000 (10:15 +0200)]
api: restore: better error messages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: restore: start and live-restore do not conflict
Thomas Lamprecht [Tue, 6 Apr 2021 08:12:47 +0000 (10:12 +0200)]
api: restore: start and live-restore do not conflict

if live-restore is set then the VM is actually started before, so we
can just skip it..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoprint drive: prefix drive-ID on errors
Thomas Lamprecht [Tue, 6 Apr 2021 08:12:08 +0000 (10:12 +0200)]
print drive: prefix drive-ID on errors

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agolive-restore: register qmeventd handle
Stefan Reiter [Wed, 3 Mar 2021 09:56:11 +0000 (10:56 +0100)]
live-restore: register qmeventd handle

Similar to backups, prevent QEMU from being killed by qmeventd during
the live-restore, so a guest can shut itself down without aborting the
restore operation.

Note that the 'close' is only to be explicit, the handle will also be
closed in case an operation errors (i.e. when the 'eval' is left).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoextract register_qmeventd_handle to QemuServer.pm
Stefan Reiter [Wed, 3 Mar 2021 09:56:10 +0000 (10:56 +0100)]
extract register_qmeventd_handle to QemuServer.pm

...to be reused by live-restore.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoenable live-restore for PBS
Stefan Reiter [Wed, 3 Mar 2021 09:56:09 +0000 (10:56 +0100)]
enable live-restore for PBS

Enables live-restore functionality using the 'alloc-track' QEMU driver.
This allows starting a VM immediately when restoring from a PBS
snapshot. The snapshot is mounted into the VM, so it can boot from that,
while guest reads and a 'block-stream' job handle the restore in the
background.

If an error occurs, the VM is deleted and all data written during the
restore is lost.

The VM remains locked during the restore, which automatically prohibits
any modifications to the config while restoring. Some modifications
might potentially be safe, however, this is experimental enough that I
believe this would cause more bad stuff(tm) than actually satisfy any
use cases.

Pool handling is slightly adjusted so the VM can be added to the pool
before the restore starts.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agocfg2cmd: allow PBS snapshots as backing files for drives
Stefan Reiter [Wed, 3 Mar 2021 09:56:08 +0000 (10:56 +0100)]
cfg2cmd: allow PBS snapshots as backing files for drives

Uses the custom 'alloc-track' filter node to redirect writes to the
original drives target, while unwritten blocks will be read from the
specified PBS snapshot.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agomake qemu_drive_mirror_monitor more generic
Stefan Reiter [Wed, 3 Mar 2021 09:56:07 +0000 (10:56 +0100)]
make qemu_drive_mirror_monitor more generic

...so it works with other block jobs as well. Intended use case is
block-stream, which also requires a new "auto" (wait only) completion
mode, since it finishes automatically anyway.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agobump version to 6.3-10
Thomas Lamprecht [Tue, 30 Mar 2021 16:41:03 +0000 (18:41 +0200)]
bump version to 6.3-10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoschema: mention special syntax for allocating a new volume
Fabian Ebner [Tue, 2 Mar 2021 12:02:04 +0000 (13:02 +0100)]
schema: mention special syntax for allocating a new volume

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agofix #2670: cloudinit enable SLAAC
Mira Limbeck [Mon, 29 Mar 2021 12:07:15 +0000 (14:07 +0200)]
fix #2670: cloudinit enable SLAAC

cloud-init's SLAAC option was disabled in 2018 because there was no
support for it. Now that cloud-init 19.4 or newer versions are more
widespread, we can finally reenable it.

Also include minimum required cloud-init version for SLAAC support in
format description.

Tested on Ubuntu 20.04 (ci 20.4), CentOS 8 (ci 19.4), Debian 10 (ci
20.2).

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
3 years agofix #3314: IPv6 requires type 'static6'
Mira Limbeck [Mon, 29 Mar 2021 12:07:14 +0000 (14:07 +0200)]
fix #3314: IPv6 requires type 'static6'

A fix was also provided in bugzilla by user wsapplegate:
https://bugzilla.proxmox.com/show_bug.cgi?id=3314

Tested on Ubuntu 20.04, CentOS 8 and Debian 10.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
3 years agoincrease timeout for QMP block_resize
Stefan Reiter [Tue, 30 Mar 2021 15:59:52 +0000 (17:59 +0200)]
increase timeout for QMP block_resize

In testing this usually completes almost immediately, but in theory this
is a storage/IO operation and as such can take a bit to finish. It's
certainly not unthinkable that it might take longer than the default *3
seconds* we've given it so far. Make it a minute.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agobump version to 6.3-9
Thomas Lamprecht [Fri, 26 Mar 2021 08:47:34 +0000 (09:47 +0100)]
bump version to 6.3-9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agovzdump: improve error logging for query-proxmox-support
Stefan Reiter [Wed, 17 Mar 2021 10:19:35 +0000 (11:19 +0100)]
vzdump: improve error logging for query-proxmox-support

Only show "not supported by QEMU version" message if we determine that
to be the actual cause, just print the error otherwise.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoapi: migrate: fix variable name
Fabian Ebner [Tue, 23 Mar 2021 09:15:23 +0000 (10:15 +0100)]
api: migrate: fix variable name

Commit abff03211f28018ce193911173afa39ba1a6ff24 switched to iterating over the
values instead of the keys, but didn't update the variable name. Use target_sid,
because target is already in use for the target node.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agosnapshot: set migration caps before savevm-start
Stefan Reiter [Tue, 16 Mar 2021 16:30:23 +0000 (17:30 +0100)]
snapshot: set migration caps before savevm-start

A "savevm" call (both our async variant and the upstream sync one) use
migration code internally. As such, they both expect migration
capabilities to be set.

This is usually not a problem, as the default set of capabilities is ok,
however, it leads to differing snapshot settings if one does a snapshot
after a machine has been live-migrated (as the capabilities will persist
from that), which could potentially lead to discrepencies in snapshots
(currently it seems to be fine, but it still makes sense to set them to
safeguard against future changes).

Note that we do set the "dirty-bitmaps" capability now (if
query-proxmox-support reports true), which has three effects:

1) PBS dirty-bitmaps are preserved in snapshots, enabling
   fast-incremental backups to work after rollback (as long as no newer
   backups exist), including for hibernate/resume
2) snapshots taken from now on, with a QEMU version supporting bitmap
   migration, *might* lead to incompatibility of these snapshots with
   QEMU versions that don't know about bitmaps at all (i.e. < 5.0 IIRC?)
   - forward compatibility is still given, and all other capabilities we
   set go back to very old versions
3) since we now explicitly disable bitmap saving if the version doesn't
   report support, we avoid crashes even with not-updated QEMU versions

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agorestore vma: fix applying storage-specific bandwidth limit
Fabian Ebner [Mon, 15 Mar 2021 11:57:27 +0000 (12:57 +0100)]
restore vma: fix applying storage-specific bandwidth limit

At this stage, there are no keys in %storage_limits to iterate over. The
refactoring in commit 9f3d73bc353c79f84498122b779764184f504005 broke the logic
by accident.

Also explicitly set zero if there is no limit to avoid repeating the
get_bandwith_limit call for the same storage. When accessing the value later,
zero is already correctly handled as 'no limit'.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agobump version to 6.3-8
Thomas Lamprecht [Fri, 12 Mar 2021 09:01:16 +0000 (10:01 +0100)]
bump version to 6.3-8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoimprove windows VM version pinning on VM creation
Thomas Lamprecht [Fri, 12 Mar 2021 08:58:12 +0000 (09:58 +0100)]
improve windows VM version pinning on VM creation

unify code paths to ensure more consistent behavior, especially on
future changes.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqm status: sort hash keys on verbose output
Thomas Lamprecht [Thu, 11 Mar 2021 14:04:26 +0000 (15:04 +0100)]
qm status: sort hash keys on verbose output

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.3-7
Thomas Lamprecht [Tue, 9 Mar 2021 07:21:50 +0000 (08:21 +0100)]
bump version to 6.3-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agorestore: write new config to variable first
Fabian Ebner [Mon, 8 Mar 2021 12:26:57 +0000 (13:26 +0100)]
restore: write new config to variable first

and use file_set_contents to really commit it afterwards. Mostly done as a
preparation for the later patch for sanitizing the config on restore, but
shouldn't hurt by itself either.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agovzdump: increase PBS 'backup' QMP call timeout
Stefan Reiter [Mon, 8 Mar 2021 15:32:30 +0000 (16:32 +0100)]
vzdump: increase PBS 'backup' QMP call timeout

Commit "a941bbd0 client: raise HTTP_TIMEOUT to 120s" in proxmox-backup
did the same, however, we would now still fail after 60 seconds since
the QMP call would time out.

Increase the timeout here to the same +5 seconds to give some time to
receive a response, so if the HTTP call in proxmox-backup times out, we
can still get a useful error message instead of timing out the QMP call
too.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agobump version to 6.3-6
Thomas Lamprecht [Fri, 5 Mar 2021 20:43:05 +0000 (21:43 +0100)]
bump version to 6.3-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: create_vm: check serial and usb permissions
Fabian Ebner [Fri, 5 Mar 2021 10:29:20 +0000 (11:29 +0100)]
api: create_vm: check serial and usb permissions

The existing check_vm_modify_config_perm doesn't do so anymore, but
the check only got re-added to the modify/delete paths. See commits
165be267ebff3f614cc6b56bbb594ef4d456a4e9 and
e30f75c571a6a678f8f1f3dfb2dee1b622b49185 for context.

In the future, it might make sense to generalise the
check_vm_modify_config_perm and have it not only take keys, but both
new and old values, and use that generalised function everywhere.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoalways pin windows VMs to a machine version by default
Thomas Lamprecht [Fri, 5 Mar 2021 19:46:28 +0000 (20:46 +0100)]
always pin windows VMs to a machine version by default

A fix for violating a important standard for booting[0] in recently
packaged QEMU 5.2 surfaced some issues with Windows based VMs in our
forum[1], which seem to be quite sensitive for such changes (it seems
they derive lots of their device assignment from ACPI).
User visible effects are loss of any network configuration due to
windows thinking it was swapped with a new one, and starts with a
fresh config - this is mostly problematic for setups with static
address assignment.

There may be lots of other, more subtle, effects and the PVE admin is
also not always the VM admin, so we really need to avoid such
negative effects. Do this by pinning the version of any windows based
VMs to either the minimum of (5.1, kvm-version) for existing VMs or
the kvm-version at time of VM creation for new ones.

There are patches in pve-manager for user to be able to change the
pinned version themself in the webinterface, so this can now also get
adapted more easily if there surface any other issues (with new or
old version) in the future.

0: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
1: https://forum.proxmox.com/threads/warning-latest-patch-just-broke-all-my-windows-vms-6-3-4-patch-inside.84915/page-2#post-373331

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoostype schema: win10 is valid for win 2019 server too
Thomas Lamprecht [Fri, 5 Mar 2021 19:45:19 +0000 (20:45 +0100)]
ostype schema: win10 is valid for win 2019 server too

the webinterface shows it like this since quite a while already.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agocan_run_pve_machine_version: PVE version can really be optional
Thomas Lamprecht [Fri, 5 Mar 2021 17:49:06 +0000 (18:49 +0100)]
can_run_pve_machine_version: PVE version can really be optional

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: machine list: parse as JSON
Thomas Lamprecht [Fri, 5 Mar 2021 15:33:08 +0000 (16:33 +0100)]
api: machine list: parse as JSON

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: add Machine module to query machine types
Stefan Reiter [Thu, 4 Mar 2021 12:52:05 +0000 (13:52 +0100)]
api: add Machine module to query machine types

The file is provided by pve-qemu-kvm.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agofix #3301: status: add currently running machine and QEMU version to full status
Fabian Ebner [Mon, 1 Mar 2021 15:53:26 +0000 (16:53 +0100)]
fix #3301: status: add currently running machine and QEMU version to full status

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Reviewed-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agomachine: split out helper for handling query-machines qmp command result
Fabian Ebner [Mon, 1 Mar 2021 15:53:25 +0000 (16:53 +0100)]
machine: split out helper for handling query-machines qmp command result

to be re-used in the vmstatus() call.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Reviewed-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoconfig: parse: also warn about invalid lines
Fabian Ebner [Wed, 3 Mar 2021 11:01:26 +0000 (12:01 +0100)]
config: parse: also warn about invalid lines

as we already do for containers.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agofix #3324: clone disk: use larger blocksize for EFI disk
Fabian Ebner [Mon, 1 Mar 2021 12:02:23 +0000 (13:02 +0100)]
fix #3324: clone disk: use larger blocksize for EFI disk

Moving to Ceph is very slow when bs=1. Instead, use a larger block size in
combination with the (currently) PVE-specific osize option to specify the
desired output size.

Suggested-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agosnapshot-test: mock query-savevm better
Stefan Reiter [Thu, 18 Feb 2021 13:52:34 +0000 (14:52 +0100)]
snapshot-test: mock query-savevm better

Otherwise the new printing functions produce warnings about undefined
numbers. These stats are guaranteed to be returned by real QEMU, so mock
them with some sensible values.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoAPI: update_vm_api: check for CDROM on disk delete
Aaron Lauterer [Fri, 12 Feb 2021 15:57:50 +0000 (16:57 +0100)]
API: update_vm_api: check for CDROM on disk delete

Since CDRoms and disks share the same config keys, we need to check if
it actually is a CDRom and then check the permissions accordingly.

Otherwise it is possible for someone without VM.Config.CDROM
permissions, but with VM.Config.Disk permissions to remove a CD drive
while being unable to create a CDRom drive.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
3 years agoqmeventd: fix more early broken lines
Thomas Lamprecht [Fri, 12 Feb 2021 08:52:06 +0000 (09:52 +0100)]
qmeventd: fix more early broken lines

increases readabillity, and up to 100 cc is just fine

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.3-5
Thomas Lamprecht [Thu, 11 Feb 2021 17:05:24 +0000 (18:05 +0100)]
bump version to 6.3-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmeventd: fix linker flags order
Thomas Lamprecht [Thu, 11 Feb 2021 17:02:18 +0000 (18:02 +0100)]
qmeventd: fix linker flags order

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmeventd: allow up to 100 columns per line
Thomas Lamprecht [Thu, 11 Feb 2021 16:21:23 +0000 (17:21 +0100)]
qmeventd: allow up to 100 columns per line

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmeventd: catch calloc error
Thomas Lamprecht [Thu, 11 Feb 2021 15:48:51 +0000 (16:48 +0100)]
qmeventd: catch calloc error

even if close to impossible to happen, NULL dereferences are never
nice..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmeventd: rework description, mention s.reiter as author
Thomas Lamprecht [Thu, 11 Feb 2021 15:03:31 +0000 (16:03 +0100)]
qmeventd: rework description, mention s.reiter as author

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmeventd: change license to AGPLv3 update copyright
Thomas Lamprecht [Thu, 11 Feb 2021 15:01:19 +0000 (16:01 +0100)]
qmeventd: change license to AGPLv3 update copyright

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmeventd: explicitly close() pidfds
Stefan Reiter [Tue, 9 Feb 2021 15:24:07 +0000 (16:24 +0100)]
qmeventd: explicitly close() pidfds

In most circumstances a pidfd gets closed automatically once the child
dies, and that *should* be guaranteed by us calling SIGKILL - however,
it seems that sometimes that doesn't happen, leading to leaked file
descriptors[0].

Also add a small note to verbose mode showing when the late-cleanup
actually happens, helped during debug.

[0] https://forum.proxmox.com/threads/cannot-shutdown-vm.83911/

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agosnapshot: clear up log messages
Thomas Lamprecht [Thu, 11 Feb 2021 13:06:02 +0000 (14:06 +0100)]
snapshot: clear up log messages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agosnapshot: reduce logging rate after one minute
Thomas Lamprecht [Thu, 11 Feb 2021 13:05:20 +0000 (14:05 +0100)]
snapshot: reduce logging rate after one minute

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agosnapshot: log storage where VM state is saved too
Thomas Lamprecht [Thu, 11 Feb 2021 13:04:19 +0000 (14:04 +0100)]
snapshot: log storage where VM state is saved too

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agosavevm: show information about drives during snapshot
Stefan Reiter [Mon, 8 Feb 2021 11:15:11 +0000 (12:15 +0100)]
savevm: show information about drives during snapshot

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agosavevm: periodically print progress
Stefan Reiter [Mon, 8 Feb 2021 11:15:10 +0000 (12:15 +0100)]
savevm: periodically print progress

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agod/control: bump versioned dependency of libpve-common-perl to 6.3-3
Thomas Lamprecht [Mon, 8 Feb 2021 15:35:19 +0000 (16:35 +0100)]
d/control: bump versioned dependency of libpve-common-perl to 6.3-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agovzdump: use renderers from Tools instead of duplicating code
Stefan Reiter [Mon, 8 Feb 2021 11:15:09 +0000 (12:15 +0100)]
vzdump: use renderers from Tools instead of duplicating code

...taking card not to lose the custom precision for byte conversion.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agotest: migrate: correctly mock storage module
Fabian Ebner [Mon, 8 Feb 2021 14:26:03 +0000 (15:26 +0100)]
test: migrate: correctly mock storage module

by fixing a typo. Since cfs_read_file within the storage module was not mocked,
the tests could fail on some setups. Now that get_bandwidth_limit is mocked,
cfs_read_file is not called anymore, but still mock it too for good measure and
to make it more future-proof.

Reported-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agocloudinit: remove pending delete on online regenerate image
Alexandre Derumier [Sat, 6 Feb 2021 13:39:54 +0000 (14:39 +0100)]
cloudinit: remove pending delete on online regenerate image

currently only pending changes are applied when we regenerate
image on a running vm, but not the pending delete.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
3 years agocloudinit: add opennebula config format
Alexandre Derumier [Sat, 6 Feb 2021 13:01:29 +0000 (14:01 +0100)]
cloudinit: add opennebula config format

This is an alternative format for cloudinit use by opennebula,
https://cloudinit.readthedocs.io/en/latest/topics/datasources/opennebula.html

but it can be also used by opennebula context scripts

https://github.com/OpenNebula/addon-context-linux
https://github.com/OpenNebula/addon-context-windows

This context scripts are simple udev trigger/bash scripts
and allow live configuration changes.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
3 years agobump version to 6.3-4
Thomas Lamprecht [Thu, 28 Jan 2021 16:46:09 +0000 (17:46 +0100)]
bump version to 6.3-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoanchor CPU flag regex to avoid arbitrary flag suffixes
Stefan Reiter [Mon, 18 Jan 2021 13:07:52 +0000 (14:07 +0100)]
anchor CPU flag regex to avoid arbitrary flag suffixes

Previously one could specify a CPU flag like 'pcidfoobar' and it would
be accepted, even though we attempt to filter VM-only flags for
security. AFAICT none of the flags we allow can be turned into any
others just by appending text, but better safe than sorry.

Reported-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agofix #2788: do not resume vms after backup if they were paused before
Dominik Csapak [Wed, 20 Jan 2021 12:32:04 +0000 (13:32 +0100)]
fix #2788: do not resume vms after backup if they were paused before

by checking if the vm is paused at the beginning and skipping the
resume now we also skip the qga freeze/thaw (which cannot work if the
vm is paused)

moved the 'vm_is_paused' sub from the api to PVE/QemuServer.pm so it
is available everywhere we need it.

since a suspend backup would pause the vm anyway, we can skip that
step also

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agoapi: destroy VM: fixup parameter description language
Thomas Lamprecht [Tue, 26 Jan 2021 17:40:20 +0000 (18:40 +0100)]
api: destroy VM: fixup parameter description language

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agostyle fix: missing trailing comma
Thomas Lamprecht [Mon, 25 Jan 2021 15:24:52 +0000 (16:24 +0100)]
style fix: missing trailing comma

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>