]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
3 years agocreate_disks: fix uninitialized warning
Fabian Grünbichler [Tue, 2 Jun 2020 08:46:26 +0000 (10:46 +0200)]
create_disks: fix uninitialized warning

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agofix #2748: make order of interfaces consistent
Mira Limbeck [Thu, 28 May 2020 14:48:36 +0000 (16:48 +0200)]
fix #2748: make order of interfaces consistent

As perl hashes have random order, sort them before iterating through.
This makes the output of 'qm cloudinit dump <vmid> network' consistent
between calls if the config has not changed.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
3 years agobump version to 6.2-2
Thomas Lamprecht [Fri, 8 May 2020 11:00:26 +0000 (13:00 +0200)]
bump version to 6.2-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofix #2697: map netdev_add options to correct json types
Dominik Csapak [Tue, 21 Apr 2020 14:01:11 +0000 (16:01 +0200)]
fix #2697: map netdev_add options to correct json types

netdev_add is now a proper qmp command, which means that it verifies
the parameter types properly

instead of sending strings, we now have to choose the correct
types for the parameters

bool for vhost
and uint64 for queues

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agobump version to 6.2-1
Thomas Lamprecht [Thu, 7 May 2020 19:51:05 +0000 (21:51 +0200)]
bump version to 6.2-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqmrestore: fix restore from STDIN
Fabian Grünbichler [Thu, 7 May 2020 07:15:33 +0000 (09:15 +0200)]
qmrestore: fix restore from STDIN

the special case was dropped when moving this to pve-storage.

fixes commit c6d517835abfe345c31cd889b557529d334dcf04

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.1-20
Thomas Lamprecht [Wed, 6 May 2020 15:17:03 +0000 (17:17 +0200)]
bump version to 6.1-20

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: allow listing custom and default CPU models
Stefan Reiter [Mon, 4 May 2020 10:58:39 +0000 (12:58 +0200)]
api: allow listing custom and default CPU models

More API calls will follow for this path, for now add the 'index' call to
list all custom and default CPU models.

Any user can list the default CPU models, as these are public anyway, but
custom models are restricted to users with Sys.Audit on /nodes.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agoapi: check Sys.Audit permissions when setting a custom CPU model
Stefan Reiter [Mon, 4 May 2020 10:58:38 +0000 (12:58 +0200)]
api: check Sys.Audit permissions when setting a custom CPU model

Explicitly allows changing other properties than the cputype, even if
the currently set cputype is not accessible by the user. This way, an
administrator can assign a custom CPU type to a VM for a less privileged
user without breaking edit functionality for them.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agovzdump: use new 'pbs' option
Fabian Grünbichler [Wed, 6 May 2020 08:57:53 +0000 (10:57 +0200)]
vzdump: use new 'pbs' option

instead of storage config to determine whether we are in 'PBS mode'

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agomigrate: cleanup forwarding code
Fabian Grünbichler [Tue, 5 May 2020 11:07:24 +0000 (13:07 +0200)]
migrate: cleanup forwarding code

fixing the following two issues:
- the legacy code path was never converted to the new fork_tunnel
signature (which probably means that nothing triggers it in practice
anymore?)
- the NBD Unix socket got forwarded multiple times if more than one disk
was migrated via NBD (this is harmless, but wrong)

for the second issue I opted to keep the code compatible with the
possibility that Qemu starts supporting multiple NBD servers in the
future (and the target node could thus return multiple UNIX socket
paths). currently we can only start one NBD server on one socket, and
each drive-mirror simply starts a new connection over that single
socket.

I took the liberty of renaming the variables/keys since I found
'tunnel_addr' and 'sock_addr' rather confusing.

Reviewed-By: Mira Limbeck <m.limbeck@proxmox.com>
Tested-By: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agocfg2cmd: set audiodev parameter only on qemu >= 4.2
Aaron Lauterer [Wed, 6 May 2020 12:51:54 +0000 (14:51 +0200)]
cfg2cmd: set audiodev parameter only on qemu >= 4.2

fixes commit 940e2a3a06b3ea47aae144519e2aaa881a80e437

QEMU 4.1 will fail to start a guest with an audio device set with:
> Property '.audiodev' not found

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agorng: die when trying to pass through disconnected hwrng
Stefan Reiter [Tue, 5 May 2020 14:53:12 +0000 (16:53 +0200)]
rng: die when trying to pass through disconnected hwrng

If /dev/hwrng exists, but no actual generator is connected (or it is
disabled on the host), QEMU will happily start the VM but crash as soon
as the guest accesses the VirtIO RNG device.

To prevent this unfortunate behaviour, check if a useable hwrng is
connected to the host before allowing the VM to be started.

While at it, clean up config_to_command by moving new and existing rng
source checks to a seperate sub.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agovzdump: fix template backup to stdout
Fabian Grünbichler [Wed, 6 May 2020 09:56:33 +0000 (11:56 +0200)]
vzdump: fix template backup to stdout

redirecting to the saved STDOUT in case of a template backup or a VM
without any disks failed because of the erroneous '=':

Backup of VM 123123 failed - command '/usr/bin/vma create -v -c [...]' failed:
Bad filehandle: =5 at /usr/share/perl/5.28/IPC/Open3.pm line 58.

https://forum.proxmox.com/threads/vzdump-to-stdout.69364

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agocfg2cmd: fix uninitialized value warning on OVMF w/o efidisk
Stefan Reiter [Wed, 6 May 2020 12:17:52 +0000 (14:17 +0200)]
cfg2cmd: fix uninitialized value warning on OVMF w/o efidisk

It's possible to have a VM with OVMF but without an efidisk, so don't
call parse_drive on a potential undef value.

Partial revert of 818c3b8d91 ("cfg2cmd: ovmf: code cleanup")

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agobump version to 6.1-18
Fabian Grünbichler [Tue, 5 May 2020 09:22:24 +0000 (11:22 +0200)]
bump version to 6.1-18

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agod/control: depend on new libpve-guest-common-perl
Fabian Grünbichler [Tue, 5 May 2020 09:20:07 +0000 (11:20 +0200)]
d/control: depend on new libpve-guest-common-perl

with lock_config_shared

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoclone: use new config_lock_shared
Fabian Grünbichler [Tue, 5 May 2020 08:27:23 +0000 (10:27 +0200)]
clone: use new config_lock_shared

and move the lock call and decision logic closer together

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agobump version to 6.1-18
Thomas Lamprecht [Mon, 4 May 2020 15:36:49 +0000 (17:36 +0200)]
bump version to 6.1-18

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoRevert "resize_vm: request new size from storage after resizing"
Fabian Ebner [Wed, 4 Mar 2020 09:51:12 +0000 (10:51 +0100)]
Revert "resize_vm: request new size from storage after resizing"

This reverts commit b5490d8a98e5e7328eb4cebb0ae0b60e6d406c38.

When resizing a volume of a running VM, a qmp block_resize command
is issued. This is non-blocking, so the size on the storage immediately
after issuing the command might still be the old one.

This is part of the issue reported in bug #2621.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agomigrate: skip rescan for efidisk and shared volumes
Dominik Csapak [Thu, 30 Apr 2020 10:44:48 +0000 (12:44 +0200)]
migrate: skip rescan for efidisk and shared volumes

we really only want to rescan the disk size of the disks we actually
need, and that are only the local disks (for which we have to allocate
the correct size on the target)

also we want to always skip the efidisk, since we get the wanted
size after the loop, and this produced a confusing log line
(for details why we do not want the 'real' size,
see commit 818ce80ec1a89c4abee61145c858b9323180e31b)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agomigrate: don't accidentally take NBD code paths
Fabian Grünbichler [Thu, 30 Apr 2020 07:35:29 +0000 (09:35 +0200)]
migrate: don't accidentally take NBD code paths

by avoiding auto-vivification of $self->{online_local_volumes} via
iteration. most code paths don't care whether it's undef or a reference
to an empty list, but this caused the (already) fixed bug of calling
nbd_stop without having started an NBD server in the first place.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoapi/destroy: repeat early checks after lock
Fabian Grünbichler [Mon, 27 Apr 2020 08:24:26 +0000 (10:24 +0200)]
api/destroy: repeat early checks after lock

to protect against concurrent changes

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoQemuServer: drop unused imported locking functions
Fabian Grünbichler [Mon, 27 Apr 2020 08:24:23 +0000 (10:24 +0200)]
QemuServer: drop unused imported locking functions

lock_file is used by PVE::QemuServer::Memory, but it does properly 'use
PVE::Tools ...' itself so we can drop them in the main module.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agovzdump: assemble: fix skipping all pending and snapshot config entries
Thomas Lamprecht [Mon, 4 May 2020 15:29:09 +0000 (17:29 +0200)]
vzdump: assemble: fix skipping all pending and snapshot config entries

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.1-17
Fabian Grünbichler [Mon, 4 May 2020 12:12:21 +0000 (14:12 +0200)]
bump version to 6.1-17

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agod/control: bump build-depend on pve-storage
Fabian Grünbichler [Mon, 4 May 2020 12:09:36 +0000 (14:09 +0200)]
d/control: bump build-depend on pve-storage

with refactored archive/compressor info and RE

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agoFix #2124: Add support for zstd
Alwin Antreich [Tue, 28 Apr 2020 13:58:14 +0000 (15:58 +0200)]
Fix #2124: Add support for zstd

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
3 years agorestore: replace archive format/compression
Alwin Antreich [Tue, 28 Apr 2020 13:58:12 +0000 (15:58 +0200)]
restore: replace archive format/compression

regex to reduce the code duplication, as archive_info and
decompressor_info provides the same information as well.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
3 years agobackup: never try to freeze in stop mode backup
Thomas Lamprecht [Sun, 3 May 2020 09:13:36 +0000 (11:13 +0200)]
backup: never try to freeze in stop mode backup

VM was can be true for stop mode backup, we cannot check the "is VM
currently running" as that doesn't tells us anything (could be the
backup process), so check the mode also..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years ago_do_vm_stop: only warn if QMP command failed but VM is actually stopped
Thomas Lamprecht [Sun, 3 May 2020 09:12:54 +0000 (11:12 +0200)]
_do_vm_stop: only warn if QMP command failed but VM is actually stopped

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.1-16
Thomas Lamprecht [Wed, 29 Apr 2020 14:23:26 +0000 (16:23 +0200)]
bump version to 6.1-16

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoqm nbdstop: cope graceful with errors
Thomas Lamprecht [Wed, 29 Apr 2020 14:19:41 +0000 (16:19 +0200)]
qm nbdstop: cope graceful with errors

as the nbd server could have been stopped by something else.
Further, it makes no sense to die and mark the migration thus as
failed, just because of a NBD server stop issue.

At this point the migration hand off to the target was done already,
so normally we're good, if it fails we have other (followup) problems
anyway.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomigrate: only stop NBD if we got a NBD url from the target
Thomas Lamprecht [Wed, 29 Apr 2020 14:18:55 +0000 (16:18 +0200)]
migrate: only stop NBD if we got a NBD url from the target

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agocleanup: get rid of unnecessary closures
Fabian Ebner [Wed, 29 Apr 2020 11:34:08 +0000 (13:34 +0200)]
cleanup: get rid of unnecessary closures

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agobump version to 6.1-15
Thomas Lamprecht [Wed, 29 Apr 2020 11:37:40 +0000 (13:37 +0200)]
bump version to 6.1-15

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoInclude vmstate and unused volumes in foreach_volid
Fabian Ebner [Thu, 16 Apr 2020 12:54:43 +0000 (14:54 +0200)]
Include vmstate and unused volumes in foreach_volid

and refactor the test_volid closure. Like this get_replicatable_volumes doesn't
need a separate loop for unused volumes anymore. For get_vm_volumes, which is used
for activation/deactivation of volumes at migration and deactivation in vm_stop_cleanup,
includes those volumes now. For migration it's an improvement, because those volumes
might need to be migrated and for vm_stop_cleanup it shouldn't hurt. The last user
of foreach_volid is check_vm_disks_local used by migrate_vm_precondition,
where information about the additional volumes doesn't hurt either.

Note that replicate is (still) set by default, so the behavior for
get_replicatable_volumes for unused volumes should not change.

Hibernation vmstate files are now also included and recognized as 'is_vmstate'.
The 'size' attribute will not be overwritten by subsequent iterations for the
same volid anymore (a volid may appear both in the config and in snapshots),
so the size from the current config is now preferred.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agoFix test_volid call for vmstate and fix check for snapshots on migration
Fabian Ebner [Thu, 16 Apr 2020 12:54:42 +0000 (14:54 +0200)]
Fix test_volid call for vmstate and fix check for snapshots on migration

by excluding vmstate. It is referenced by snapshots, but
is not a volume containing a snapshot.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
3 years agorestore: small code cleanup for parse_backup_hints
Thomas Lamprecht [Wed, 29 Apr 2020 09:05:19 +0000 (11:05 +0200)]
restore: small code cleanup for parse_backup_hints

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agorestore: use correct storage for format check for cloudinit drives
Dominik Csapak [Tue, 28 Apr 2020 12:52:29 +0000 (14:52 +0200)]
restore: use correct storage for format check for cloudinit drives

when a backup includes a cloudinit disk on a non-existent storage,
the restore fails with 'storage' does not exist

this happens because we want to get the format of the disk, by
checking the source storage

we fix this by using the target storage first and only the source as
fallback

this will still fail if neither storage exists
(which is ok, since we cannot restore then anyway)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoimportovf: die with error when disk file is missing
Dominik Csapak [Thu, 23 Apr 2020 10:46:49 +0000 (12:46 +0200)]
importovf: die with error when disk file is missing

Also add missing '\n' at the end of error messages

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoimportovf: fix import of ovfs without default namespaces
Dominik Csapak [Thu, 23 Apr 2020 10:46:48 +0000 (12:46 +0200)]
importovf: fix import of ovfs without default namespaces

Some OVF files to not declare 'rasd' as a default namespace (in the
top level Envelope element), but inline in each element (e.g.
<rasd:HostResource xmlns:rasd="foo">...</rasd:HostResource>)

This trips up our relative findvalue with
> XPath error : Undefined namespace prefix

To avoid this, search in the global XPathContext (where we register
those namespaces ourselves) and pass the item_node as context
parameter.

This works then for both cases

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agotest: add test for OVF with missing default rasd namespace
Dominik Csapak [Thu, 23 Apr 2020 10:46:47 +0000 (12:46 +0200)]
test: add test for OVF with missing default rasd namespace

sometimes vendors do not put the 'rasd' namespaces in the top level
Envelope, but in every 'rasd' element this adds a test for this

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agotest: print more info when OVF parsing fails
Dominik Csapak [Thu, 23 Apr 2020 10:46:46 +0000 (12:46 +0200)]
test: print more info when OVF parsing fails

When one of the ovf tests fails to parse at all, we just get the
'die' message of the failing component, but not which file actually
failed to parse.

To get better output, convert the parsing also to a test and ok() and
fail() respectively and then printing the error.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoapi/resume: make nocheck root-only
Fabian Grünbichler [Mon, 27 Apr 2020 07:19:13 +0000 (09:19 +0200)]
api/resume: make nocheck root-only

this is only used for migration via 'qm mtunnel', regular users should
never need to resume a VM that does not logically belong to the node it
is running on

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigrate: simplify replicated_volume loop
Fabian Grünbichler [Mon, 20 Apr 2020 09:24:05 +0000 (11:24 +0200)]
migrate: simplify replicated_volume loop

(no change compared to previous iteration except for readability)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoFix live migration with replicated unused volumes
Fabian Ebner [Mon, 20 Apr 2020 08:31:55 +0000 (10:31 +0200)]
Fix live migration with replicated unused volumes

by counting only local volumes that will be live-migrated via qemu_drive_mirror,
i.e. those listed in $self->{online_local_volumes}.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agomigrate: workaround issues with format switch on storage live migration
Thomas Lamprecht [Fri, 17 Apr 2020 13:27:38 +0000 (15:27 +0200)]
migrate: workaround issues with format switch on storage live migration

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocfg2cmd: factor out audio device generation
Thomas Lamprecht [Fri, 17 Apr 2020 13:20:05 +0000 (15:20 +0200)]
cfg2cmd: factor out audio device generation

and version guard it with 4.0 machines, just do be sure

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocfg2cmd: Add the audiodev property to audio devs
Aaron Lauterer [Mon, 16 Mar 2020 10:02:38 +0000 (11:02 +0100)]
cfg2cmd: Add the audiodev property to audio devs

With Qemu 4.2 a new `audiodev` property was introduced [0] to explicitly
specify the backend to be used for the audio device. This is accompanied
with a warning that the fallback to the default audio backend is
deprecated.

[0] https://wiki.qemu.org/ChangeLog/4.2#Audio

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
4 years agocfg2cmd: ovmf: code cleanup
Thomas Lamprecht [Wed, 15 Apr 2020 16:30:53 +0000 (18:30 +0200)]
cfg2cmd: ovmf: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.1-14
Fabian Grünbichler [Thu, 9 Apr 2020 06:58:37 +0000 (08:58 +0200)]
bump version to 6.1-14

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agod/control: depend on updated guest-common/pve-storage
Fabian Grünbichler [Thu, 9 Apr 2020 06:54:42 +0000 (08:54 +0200)]
d/control: depend on updated guest-common/pve-storage

pve-storage: new storage_migrate with allow_rename
guest-common: update_volume_ids

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agosync_disks: log output of storage_migrate
Fabian Ebner [Wed, 8 Apr 2020 09:25:12 +0000 (11:25 +0200)]
sync_disks: log output of storage_migrate

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agosync_disks: be more verbose if storage_migrate fails
Fabian Ebner [Wed, 8 Apr 2020 09:25:11 +0000 (11:25 +0200)]
sync_disks: be more verbose if storage_migrate fails

If storage_migrate dies, the error message might not include the
volume ID or the target storage ID, but those might be good to know.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agosync_disks: use allow_rename to avoid collisions on the target storage
Fabian Ebner [Wed, 8 Apr 2020 09:25:10 +0000 (11:25 +0200)]
sync_disks: use allow_rename to avoid collisions on the target storage

This makes it possible to migrate a VM with volumes store1:vm-123-disk-0
store2:vm-123-disk-0 to some targetstorage. Also prevents migration failure
when there is an orphaned disk with the same volid on the target.

To avoid confusion, the name should not change for 'vmstate'-volumes.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoUpdate volume IDs in one go
Fabian Ebner [Wed, 8 Apr 2020 09:25:09 +0000 (11:25 +0200)]
Update volume IDs in one go

Use 'update_volume_ids' for the live-migrated disks as well.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoAllow specifying targetstorage for offline migration
Fabian Ebner [Wed, 8 Apr 2020 09:25:08 +0000 (11:25 +0200)]
Allow specifying targetstorage for offline migration

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoTake note of changes to the volume IDs when migrating and update the config
Fabian Ebner [Wed, 8 Apr 2020 09:25:07 +0000 (11:25 +0200)]
Take note of changes to the volume IDs when migrating and update the config

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoAllow parsing vmstate entries
Fabian Ebner [Wed, 8 Apr 2020 09:25:06 +0000 (11:25 +0200)]
Allow parsing vmstate entries

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoUse new storage_migrate interface
Fabian Ebner [Wed, 8 Apr 2020 09:25:01 +0000 (11:25 +0200)]
Use new storage_migrate interface

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoSwitch to using foreach_volume instead of foreach_drive
Fabian Ebner [Wed, 8 Apr 2020 09:24:56 +0000 (11:24 +0200)]
Switch to using foreach_volume instead of foreach_drive

It was necessary to move foreach_volid back to QemuServer.pm

In VZDump/QemuServer.pm and QemuMigrate.pm the dependency on
QemuConfig.pm was already there, just the explicit "use" was missing.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agobump version to 6.1-13
Thomas Lamprecht [Wed, 8 Apr 2020 15:13:42 +0000 (17:13 +0200)]
bump version to 6.1-13

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoconfig_to_command: indentation, whitspace and newline fixes
Thomas Lamprecht [Wed, 8 Apr 2020 15:44:16 +0000 (17:44 +0200)]
config_to_command: indentation, whitspace and newline fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoIgnore version checks when using QEMU -rc releases
Stefan Reiter [Wed, 8 Apr 2020 15:11:07 +0000 (17:11 +0200)]
Ignore version checks when using QEMU -rc releases

Upstream marks these as having a micro-version of >=90, unfortunately the
machine versions are bumped earlier so testing them is made unnecessarily
difficult, since the version checking code would abort on migrations etc...

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
[ Thomas: do so refactor ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: bump versioned to libpve-common-perl
Thomas Lamprecht [Wed, 8 Apr 2020 15:13:08 +0000 (17:13 +0200)]
d/control: bump versioned to libpve-common-perl

mainly for the new idmap and storage map format

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocpu config: add upcoming EPYC-Rome CPU type
Thomas Lamprecht [Wed, 8 Apr 2020 15:06:50 +0000 (17:06 +0200)]
cpu config: add upcoming EPYC-Rome CPU type

will be included with QEMU 5.0

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoconfig: harmonize bridge pattern
Fabian Grünbichler [Wed, 8 Apr 2020 12:02:47 +0000 (14:02 +0200)]
config: harmonize bridge pattern

so that pve-container and qemu-server use the same one, in preparation
for moving it to JSONSchema and having a bridgepair format.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agocfg2cmd: add test cases for custom CPU models
Stefan Reiter [Tue, 7 Apr 2020 13:56:20 +0000 (15:56 +0200)]
cfg2cmd: add test cases for custom CPU models

Requires a mock CPU-model config, which is given as a raw string to also
test parsing capabilities. Also tests defaulting behaviour.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-By: Fabian Ebner <f.ebner@proxmox.com>
Tested-By: Fabian Ebner <f.ebner@proxmox.com>
4 years agofix #2318: allow phys-bits CPU setting
Stefan Reiter [Tue, 7 Apr 2020 13:56:19 +0000 (15:56 +0200)]
fix #2318: allow phys-bits CPU setting

Can be specified for a particular VM or via a custom CPU model (VM takes
precedence).

QEMU's default limit only allows up to 1TB of RAM per VM. Increasing the
physical address bits available to a VM can fix this.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoRework get_cpu_options and allow custom CPU models
Stefan Reiter [Tue, 7 Apr 2020 13:56:18 +0000 (15:56 +0200)]
Rework get_cpu_options and allow custom CPU models

If a cputype is custom (check via prefix), try to load options from the
custom CPU model config, and set values accordingly.

While at it, extract currently hardcoded values into seperate sub and add
reasonings.

Since the new flag resolving outputs flags in sorted order for
consistency, adapt the test cases to not break. Only the order is
changed, not which flags are present.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-By: Fabian Ebner <f.ebner@proxmox.com>
Tested-By: Fabian Ebner <f.ebner@proxmox.com>
4 years agoAdd helpers to better structure CPU option handling
Stefan Reiter [Tue, 7 Apr 2020 13:56:17 +0000 (15:56 +0200)]
Add helpers to better structure CPU option handling

To avoid hardcoding even more CPU-flag related things for custom CPU
models, introduce a dynamic approach to resolving flags.

resolve_cpu_flags takes a list of hashes (as documented in the
comment) and resolves them to a valid "-cpu" argument without
duplicates. This also helps by providing a reason why specific CPU flags
have been added, and thus allows for useful warning messages should a
flag be overwritten by another.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-By: Fabian Ebner <f.ebner@proxmox.com>
Tested-By: Fabian Ebner <f.ebner@proxmox.com>
4 years agoInclude "-cpu" parameter with snapshots/suspend
Stefan Reiter [Tue, 7 Apr 2020 13:56:16 +0000 (15:56 +0200)]
Include "-cpu" parameter with snapshots/suspend

Just like with live-migration, custom CPU models might change after a
snapshot has been taken (or a VM suspended), which would lead to a
different QEMU invocation on rollback/resume.

Save the "-cpu" argument as a new "runningcpu" option into the VM conf
akin to "runningmachine" and use as override during rollback/resume.

No functional change with non-custom CPU types intended.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoInclude "-cpu" parameter with live-migration
Stefan Reiter [Tue, 7 Apr 2020 13:56:15 +0000 (15:56 +0200)]
Include "-cpu" parameter with live-migration

This is required to support custom CPU models, since the
"cpu-models.conf" file is not versioned, and can be changed while a VM
using a custom model is running. Changing the file in such a state can
lead to a different "-cpu" argument on the receiving side.

This patch fixes this by passing the entire "-cpu" option (extracted
from /proc/.../cmdline) as a "qm start" parameter. Note that this is
only done if the VM to migrate is using a custom model (which we can
check just fine, since the <vmid>.conf *is* versioned with pending
changes), thus not breaking any live-migration directionality.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agomap_storage: check for definedness not perl-truthiness
Thomas Lamprecht [Tue, 7 Apr 2020 15:25:35 +0000 (17:25 +0200)]
map_storage: check for definedness not perl-truthiness

as else it would reject possible a valid set value

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: s/targetstorage map/storage map/ for parameter exceptions
Thomas Lamprecht [Tue, 7 Apr 2020 15:20:23 +0000 (17:20 +0200)]
followup: s/targetstorage map/storage map/ for parameter exceptions

to reduce duplicated info in the error slightly

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: refactor loop to use perls values
Thomas Lamprecht [Tue, 7 Apr 2020 15:15:28 +0000 (17:15 +0200)]
followup: refactor loop to use perls values

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovm_start: collect and return migration info
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:36 +0000 (13:41 +0200)]
vm_start: collect and return migration info

in addition to printing it. preparation for remote cluster migration,
where we want to return this in a structured fashion over the migration
tunnel instead of parsing stdout via SSH.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agovm_start: split NBD disk allocation further
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:35 +0000 (13:41 +0200)]
vm_start: split NBD disk allocation further

into one sub that retrieves the local disks, and the actual NBD
allocation. that way, remote incoming migration can just call the NBD
allocation with a custom list of volume names/storages/..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigrate: check storage permissions and content type
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:34 +0000 (13:41 +0200)]
migrate: check storage permissions and content type

both where previously missing. the existing 'check_storage_access'
helper is not applicable here since it operates on a full set of VM
config options, not just storage IDs.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigrate: allow arbitrary source->target storage maps
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:33 +0000 (13:41 +0200)]
migrate: allow arbitrary source->target storage maps

the syntax is backwards compatible, providing a single storage ID or '1'
works like before. the new helper ensures consistent behaviour at all
call sites.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigration: fix downtime limit auto-increase
Stefan Reiter [Thu, 2 Apr 2020 13:20:07 +0000 (15:20 +0200)]
migration: fix downtime limit auto-increase

485449e37 ("qmp: use migrate-set-parameters in favor of deprecated options")
changed the initial "migrate_set_downtime" QMP call to the more recent
"migrate-set-parameters", but forgot to do so for the auto-increase code
further below.

Since the units of the two calls don't match, this would have caused the
auto-increase to increase the limit to absurd levels as soon as it kicked
in (ms treated as s).

Update the second call to the new version as well, and while at it remove
the unnecessary "defined()" check for $migrate_downtime, which is always
initialized from the defaults anyway.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agorestore: parse volid with $noerr
Fabian Grünbichler [Thu, 2 Apr 2020 13:12:37 +0000 (15:12 +0200)]
restore: parse volid with $noerr

otherwise VMA files passed in as paths instead of as volids don't
work anymore.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agovm_start: split out NBD disk allocation
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:32 +0000 (13:41 +0200)]
vm_start: split out NBD disk allocation

as preparation of targetstorage mapping and remote migration. this also
removes re-using of the $local_volumes hash in the original code.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agovm_start: split out lock + initial checks
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:31 +0000 (13:41 +0200)]
vm_start: split out lock + initial checks

to start breaking up vm_start before extending parts for new migration
features like storage and network mapping.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agovm_start: condense signature
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:30 +0000 (13:41 +0200)]
vm_start: condense signature

as preparation for refactoring it further. remote migration will add
another 1-2 parameters, and it is already unwieldly enough as it is.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigrate: improve cleanup_remotedisks
Fabian Grünbichler [Mon, 30 Mar 2020 11:41:29 +0000 (13:41 +0200)]
migrate: improve cleanup_remotedisks

to also handle cases where disk allocation failed in the remote
vm_start, and we only have a bitmap but no target drive information.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agorescan: fix call to foreach_volume
Fabian Grünbichler [Wed, 1 Apr 2020 11:02:59 +0000 (13:02 +0200)]
rescan: fix call to foreach_volume

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agobump version to 6.1-12
Fabian Grünbichler [Mon, 30 Mar 2020 07:32:53 +0000 (09:32 +0200)]
bump version to 6.1-12

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoupdate_disk_config: use config volume iterators instead of loops
Fabian Ebner [Thu, 26 Mar 2020 08:09:37 +0000 (09:09 +0100)]
update_disk_config: use config volume iterators instead of loops

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoImplement volume-related helpers and use new foreach_volume
Fabian Ebner [Thu, 26 Mar 2020 08:09:36 +0000 (09:09 +0100)]
Implement volume-related helpers and use new foreach_volume

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agofix efidisks on storages with minimum sizes bigger than OVMF_VARS.fd
Dominik Csapak [Wed, 12 Feb 2020 12:31:06 +0000 (13:31 +0100)]
fix efidisks on storages with minimum sizes bigger than OVMF_VARS.fd

on storages where the minimum size of images is bigger than the real
OVMF_VARS.fd file, they get padded to their minimum size

when using such an image, qemu maps it fully to the vm, but the efi
does not find the vars region and creates a file on the first efi
partition it finds

this breaks some settings in the ovmf, such as resolution

to fix this, we have to specify the size for the pflash, so that
qemu only maps the first n bytes in the vm (this only works for
raw files, not for qcow2)

we also have to use the correct size when converting between storages
in 'clone_disk' (used for move disk and cloning vms) and when
live migrating to different storages

when we now expect that the source image is always correctly used/created
(e.g. raw with size=x in pflash argument) then we always create the
target correctly

when encountering users which have a non-valid image (e.g. a efidisk
moved from zfs to qcow2 before this patch), we have to tell them to
recreate the efidisk and the settings on it

we have to version_guard it to 4.1+pve2 (since we haven't bumped yet
since the change to pve2)

also add 2 tests, one for the old version and one for the new

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-by: Stefan Reiter <s.reiter@proxmox.com>
[ Thomas: rebased to master ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomigration with targetstorage: check if target storage supports images
Fabian Ebner [Thu, 26 Mar 2020 08:09:32 +0000 (09:09 +0100)]
migration with targetstorage: check if target storage supports images

This makes sure that live migration also respects content types.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agomigrate sync disks: split long line
Thomas Lamprecht [Fri, 27 Mar 2020 09:17:28 +0000 (10:17 +0100)]
migrate sync disks: split long line

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomigrate sync_disks: use own variable for often referenced storage config
Thomas Lamprecht [Fri, 27 Mar 2020 09:12:04 +0000 (10:12 +0100)]
migrate sync_disks: use own variable for often referenced storage config

also fix two places where we used $self->{vmid} even if $vmid was in
scope (and the same).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomigrate: cleanup disk/bitmaps if 'qm start' failed
Fabian Grünbichler [Thu, 26 Mar 2020 14:42:59 +0000 (15:42 +0100)]
migrate: cleanup disk/bitmaps if 'qm start' failed

since bitmaps are set early on, and 'qm start' potentially has allocated
the disks but still failed. we can only clean up what we know about
anyway, so the disk part is still only best effort.

also use replicated_volumes instead of bitmap existence to check for
replicated volumes, since 'qm start' on an old node that does not
understand replicated volumes might have allocated a new volume that we
DO want to clean up, and not skip.

also cleanup disks after stopping target VM, otherwise we might end up
in a situation where the target VM is still running and using the disks,
thus blocking the disk cleanup.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigrate: fix auto-vivification in cleanup_bitmaps
Fabian Grünbichler [Thu, 26 Mar 2020 14:42:58 +0000 (15:42 +0100)]
migrate: fix auto-vivification in cleanup_bitmaps

this does not currently trigger since nothing uses $self->{target_drive}
afterwards.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agomigrate: fix replication false-positives
Fabian Grünbichler [Thu, 26 Mar 2020 14:42:57 +0000 (15:42 +0100)]
migrate: fix replication false-positives

by only checking for replicatable volumes when a replication job is
defined, and passing only actually replicated volumes to the target node
via STDIN, and back via STDOUT.

otherwise this can pick up theoretically replicatable, but not actually
replicated volumes and treat them wrong.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoCPUConfig: fix module load when pmxcfs is unavailable
Fabian Grünbichler [Thu, 26 Mar 2020 08:02:05 +0000 (09:02 +0100)]
CPUConfig: fix module load when pmxcfs is unavailable

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agobump version to 6.1-11
Thomas Lamprecht [Thu, 26 Mar 2020 08:00:48 +0000 (09:00 +0100)]
bump version to 6.1-11

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