]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
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>
4 years agovzdump: fix up PBS plugin
Thomas Lamprecht [Thu, 26 Mar 2020 07:49:16 +0000 (08:49 +0100)]
vzdump: fix up PBS plugin

fixes commit 0b2f574b4ccd68ba7c1ebf1927beeff33cca179d

enforce_vm_running_for_backup is now witout return value, for the PBS
I forgot to remove an now outdated call to handle_vm_powerstate, drop
that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoVerify VM-specific CPU configs seperately
Stefan Reiter [Wed, 12 Feb 2020 15:11:23 +0000 (16:11 +0100)]
Verify VM-specific CPU configs seperately

$cpu_fmt is being reused for custom CPUs as well as VM-specific CPU
settings. The "pve-vm-cpu-conf" format is introduced to verify a config
specifically for use as VM-specific settings.

"pve-cpu-conf" is registered for use in custom CPU API calls (where no
additional checks are required).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoAdapt CPUConfig to handle custom models
Stefan Reiter [Wed, 12 Feb 2020 15:11:22 +0000 (16:11 +0100)]
Adapt CPUConfig to handle custom models

Turn CPUConfig into a SectionConfig with parsing/writing support for
custom CPU models. IO is handled using cfs.

Namespacing will be provided using "custom-" prefix for custom model
names (in VM config only, cpu-models.conf will contain unprefixed
names).

Includes two overrides to avoid writing redundant information to the
config file, additionally get_custom_model is used to retrieve a custom
model configuration by name.

Resolve custom names in print_cpu_device when a custom cpu is passed.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agobump version to 6.1-10
Thomas Lamprecht [Wed, 25 Mar 2020 14:16:29 +0000 (15:16 +0100)]
bump version to 6.1-10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoFix calls to get_replicateable_volumes
Fabian Ebner [Wed, 25 Mar 2020 12:18:25 +0000 (13:18 +0100)]
Fix calls to get_replicateable_volumes

There is a need to set $noerr, because otherwise migration for a
VM with a non-replicatable volume fails with:
missing replicate feature on volume 'myfs:107/vm-107-disk-2.raw'

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agobump version to 6.1-9
Thomas Lamprecht [Wed, 25 Mar 2020 09:07:23 +0000 (10:07 +0100)]
bump version to 6.1-9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoqemu migrate: sort and split module usage
Thomas Lamprecht [Wed, 25 Mar 2020 09:05:58 +0000 (10:05 +0100)]
qemu migrate: sort and split module usage

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoadd basic version check for live-migration with replicated disks
Thomas Lamprecht [Wed, 25 Mar 2020 09:02:29 +0000 (10:02 +0100)]
add basic version check for live-migration with replicated disks

as we need at least pve-qemu in 4.2 for this to work, the target side
is implicitly checked with "to old version" check for migrate or the
mirror will fail anyway.

Just use the simple "qemu binary version check", as we could stil
live migrate an older snapshot with older machine versions if both
sides have a recent enough qemu.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomigrate: add live-migration of replicated disks
Fabian Grünbichler [Tue, 17 Mar 2020 07:55:27 +0000 (08:55 +0100)]
migrate: add live-migration of replicated disks

with incremental drive-mirror and dirty-bitmap tracking.

1.) get replicated disks that are currently referenced by running VM
2.) add a block-dirty-bitmap to each of them
3.) replicate ALL replicated disks
4.) pass bitmaps from 2) to drive-mirror for disks from 1)
5.) skip replicated disks when cleaning up volumes on either source or
target

added error handling is just removing the bitmaps if an error occurs at
any point after 2, except when the handover to the target node has
already happened, since the bitmaps are cleaned up together with the
source VM in that case.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agomigrate: add replication info to disk overview
Fabian Grünbichler [Tue, 17 Mar 2020 07:55:26 +0000 (08:55 +0100)]
migrate: add replication info to disk overview

to make migration logs a bit easier to grasp with a quick glance.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agodrive-mirror: add support for incremental sync
Fabian Grünbichler [Tue, 17 Mar 2020 07:55:25 +0000 (08:55 +0100)]
drive-mirror: add support for incremental sync

by re-using a dirty bitmap that represents changes since the divergence
of source and target volume. requires a qemu that supports incremental
drive-mirroring, and will die otherwise.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoAdd unused description to drivedesc_hash
Fabian Ebner [Tue, 17 Mar 2020 12:28:09 +0000 (13:28 +0100)]
Add unused description to drivedesc_hash

Moved code so that initialization of drivedesc_hash stays a single block.
Avoid auto-vivication in parse_drive.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoversion_guard: early out when major/minor version is high enough
Stefan Reiter [Thu, 19 Mar 2020 10:03:13 +0000 (11:03 +0100)]
version_guard: early out when major/minor version is high enough

E.g.: If a feature requires 4.1+pveN and we're using machine version 4.2
we don't need to increase the pve version to N (4.2+pve0 is enough).

We check this by doing a min_version call against a non-existant higher
pve-version for the major/minor tuple we want to test for, which can
only work if the major/minor alone is high enough.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agobump version to 6.1-8
Thomas Lamprecht [Fri, 20 Mar 2020 10:12:26 +0000 (11:12 +0100)]
bump version to 6.1-8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomigrate phase3: add to comment why a blockjob cancel is OK here
Thomas Lamprecht [Fri, 20 Mar 2020 10:08:20 +0000 (11:08 +0100)]
migrate phase3: add to comment why a blockjob cancel is OK here

Clarify why a cancel is actually not really canceling here, because
we're already finished with storage migration and the block jobs are
all in ready state and we (source) are going to stop soon to hand
over to target.

> Note that if you issue 'block-job-cancel' after 'drive-mirror' has
> indicated (via the event BLOCK_JOB_READY) that the source and
> destination are synchronized, then the event triggered by this
> command changes to BLOCK_JOB_COMPLETED, to indicate that the
> mirroring has ended and the destination now has a point-in-time
> copy tied to the time of the cancellation
-- qapi/block-core.json (QEMU 4.2)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorevert spice_ticket prefix change in 7827de4
Mira Limbeck [Fri, 20 Mar 2020 09:18:23 +0000 (10:18 +0100)]
revert spice_ticket prefix change in 7827de4

The change to the prefixed version broke migration from new to old
qemu-server version. This reverts the change and adds a TODO comment for
7.0 to change it to the prefixed version then.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agoDie on misaligned memory for hotplugging
Stefan Reiter [Wed, 18 Mar 2020 15:18:45 +0000 (16:18 +0100)]
Die on misaligned memory for hotplugging

...instead of booting with an invalid config once and then silently
changing the memory size for consequent VM starts.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Tested-by: Alwin Antreich <a.antreich@proxmox.com>
4 years agoDisable memory hotplugging for custom NUMA topologies
Stefan Reiter [Wed, 18 Mar 2020 15:18:44 +0000 (16:18 +0100)]
Disable memory hotplugging for custom NUMA topologies

This cannot work, since we adjust the 'memory' property of the VM config
on hotplugging, but then the user-defined NUMA topology won't match for
the next start attempt.

Check needs to happen here, since it otherwise fails early with "total
memory for NUMA nodes must be equal to vm static memory".

With this change the error message reflects what is actually happening
and doesn't allow VMs with exactly 1GB of RAM either.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Tested-by: Alwin Antreich <a.antreich@proxmox.com>
4 years agovzdump archive_vma: move getting QMPClient nearer to using sites
Thomas Lamprecht [Thu, 19 Mar 2020 17:48:41 +0000 (18:48 +0100)]
vzdump archive_vma: move getting QMPClient nearer to using sites

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: indentation and code cleanup
Thomas Lamprecht [Thu, 19 Mar 2020 17:46:49 +0000 (18:46 +0100)]
vzdump: indentation and code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: factor out VM powerstate handling and qmp backup cancel
Thomas Lamprecht [Thu, 19 Mar 2020 17:41:43 +0000 (18:41 +0100)]
vzdump: factor out VM powerstate handling and qmp backup cancel

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: factor out QGA FS freeze/thaw
Thomas Lamprecht [Thu, 19 Mar 2020 17:37:20 +0000 (18:37 +0100)]
vzdump: factor out QGA FS freeze/thaw

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: factor out fork_compressor_pipe
Thomas Lamprecht [Thu, 19 Mar 2020 17:34:31 +0000 (18:34 +0100)]
vzdump: factor out fork_compressor_pipe

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: factor out _get_task_devlist
Thomas Lamprecht [Thu, 19 Mar 2020 17:32:00 +0000 (18:32 +0100)]
vzdump: factor out _get_task_devlist

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: refactor and cleanup code in query_backup_status_loop
Thomas Lamprecht [Thu, 19 Mar 2020 16:15:45 +0000 (17:15 +0100)]
vzdump: refactor and cleanup code in query_backup_status_loop

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: use QemuConfig directly to set/unset locks
Thomas Lamprecht [Thu, 19 Mar 2020 14:58:41 +0000 (15:58 +0100)]
vzdump: use QemuConfig directly to set/unset locks

no need to fork/exec a process for that..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: code cleanup
Thomas Lamprecht [Thu, 19 Mar 2020 14:58:13 +0000 (15:58 +0100)]
vzdump: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump prepare: refactor and code cleanup
Thomas Lamprecht [Thu, 19 Mar 2020 10:48:19 +0000 (11:48 +0100)]
vzdump prepare: refactor and code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovm_start: drop redundant if
Fabian Grünbichler [Wed, 18 Mar 2020 09:08:54 +0000 (10:08 +0100)]
vm_start: drop redundant if

since both if and else branch contain identical code

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agodrive_mirror: rename variables and values
Fabian Grünbichler [Wed, 18 Mar 2020 07:21:29 +0000 (08:21 +0100)]
drive_mirror: rename variables and values

and add some more details to comments.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoadd unix socket support for NBD storage migration
Mira Limbeck [Tue, 17 Mar 2020 19:56:12 +0000 (20:56 +0100)]
add unix socket support for NBD storage migration

The reuse of the tunnel, which we're opening to communicate with the target
node and to forward the unix socket for the state migration, for the NBD unix
socket requires adding support for an array of sockets to forward, not just a
single one. We also have to change the $sock_addr variable to an array
for the cleanup of the socket file as SSH does not remove the file.

To communicate to the target node the support of unix sockets for NBD
storage migration, we're specifying an nbd_protocol_version which is set
to 1. This version is then passed to the target node via STDIN. Because
we don't want to be dependent on the order of arguments being passed
via STDIN, we also prefix the spice ticket with 'spice_ticket: '. The
target side handles both the spice ticket and the nbd protocol version
with a fallback for old source nodes passing the spice ticket without a
prefix.
All arguments are line based and require a newline in between.

When the NBD server on the target node is started with a unix socket, we
get a different line containing all the information required to start
the drive-mirror. This contains the unix socket path used on the target node
which we require for forwarding and cleanup.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agoparse nbd_protocol_version if available
Mira Limbeck [Tue, 17 Mar 2020 19:56:11 +0000 (20:56 +0100)]
parse nbd_protocol_version if available

For secure live migration with local disks via NBD over a unix socket,
we have to somehow communicate from the source node to the target node
if it supports it. This is because there can only be one NBD server with
exactly one socket bound.

The source node passes that information via STDIN. Support for
'spice_ticket: (...)' is added in addition to 'nbd_protocol_version:
<version>'. As old source nodes send the spice ticket without a prefix,
we still have to have a fallback for this case. New information should
always be passed via a prefix that is matched, otherwise it will be
recognized as spice ticket.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agoadd NBD server unix socket support in vm_start
Mira Limbeck [Tue, 17 Mar 2020 19:56:10 +0000 (20:56 +0100)]
add NBD server unix socket support in vm_start

As the NBD server spawned by qemu can only listen on a single socket,
we're dependent on a version being passed to vm_start that indicates
which protocol can be used, TCP or Unix, by the source node.

The change in socket type (TCP to Unix) comes with a different URI. For
unix sockets it has the form: 'nbd:unix:<path/to/socket>:exportname=<device>'.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agoadd qemu_drive_mirror_monitor completion modes
Mira Limbeck [Tue, 17 Mar 2020 19:56:09 +0000 (20:56 +0100)]
add qemu_drive_mirror_monitor completion modes

With Qemu 4.2 we encountered a problem with unix sockets and SSH socket
forwarding for drive-mirror. It seems the socket gets reopened again and
again after it closes for some reason. This can be worked around by
specifying 'block-job-cancel' instead of 'block-job-complete' when we're
not interested in swapping the disks again from NBD to their original
protocol. This is always the case when we use drive-mirror for live
migrating a VM.

qemu_drive_mirror is used for migration and for clone_disk. All in all
we have 3 cases to handle. Either the 'skip' case which skips the
completion of the job. The 'wait' case which was the default before and
still is when $completion is undefined. And the new 'wait_noswap' case
which is used for the live migration.
If 'wait_noswap' is specified, we issue a 'block-job-cancel' once the block
job is in 'ready' state. This completes the block job without swapping the
disks.

clone_disk always uses 'block-job-cancel' via the qemu_blockjobs_cancel
sub.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agoChange format for unused drives
Fabian Ebner [Thu, 12 Mar 2020 10:19:12 +0000 (11:19 +0100)]
Change format for unused drives

and make it match with what parse_drive does. Even though the 'real' format
was pve-volume-id, callers already expected that parse_drive returns a hash
with a valid 'file' key (e.g. PVE/API2/Qemu.pm:1147ff).

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Reviewed-By: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agofix #2580: api/delete: drop VM from HA resources if purge is set
Thomas Lamprecht [Thu, 12 Mar 2020 12:31:41 +0000 (13:31 +0100)]
fix #2580: api/delete: drop VM from HA resources if purge is set

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: bump versioned dependency for libpve-guest-common-perl (>= 3.0-5)
Thomas Lamprecht [Thu, 12 Mar 2020 10:11:58 +0000 (11:11 +0100)]
d/control: bump versioned dependency for libpve-guest-common-perl (>= 3.0-5)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoarchive_pbs: call backup_cancel only when job is really started
Dietmar Maurer [Wed, 11 Mar 2020 06:55:58 +0000 (07:55 +0100)]
archive_pbs: call backup_cancel only when job is really started

4 years agoarchive_vma: call backup_cancel only when job is really started
Dietmar Maurer [Wed, 11 Mar 2020 06:55:57 +0000 (07:55 +0100)]
archive_vma: call backup_cancel only when job is really started

4 years agoPVE/QemuServer.pm - proxmox backup server restore: use new pbs-restore binary
Dietmar Maurer [Wed, 11 Mar 2020 06:55:56 +0000 (07:55 +0100)]
PVE/QemuServer.pm - proxmox backup server restore: use new pbs-restore binary

This is much faster than using a pipe with qemu-img.

4 years agocleanup backup code: share code between restore_vma_archive and restore_proxmox_backu...
Dietmar Maurer [Wed, 11 Mar 2020 06:55:55 +0000 (07:55 +0100)]
cleanup backup code: share code between restore_vma_archive and restore_proxmox_backup_archive

4 years agoimplement restore from proxmox backup storage
Dietmar Maurer [Wed, 11 Mar 2020 06:55:54 +0000 (07:55 +0100)]
implement restore from proxmox backup storage

4 years agoadd support for proxmox backup
Dietmar Maurer [Wed, 11 Mar 2020 06:55:53 +0000 (07:55 +0100)]
add support for proxmox backup

4 years agoAppend newline to all QGA commands
Kamil Trzcinski [Mon, 9 Mar 2020 13:32:44 +0000 (14:32 +0100)]
Append newline to all QGA commands

Since the MacOS Mojave Apple ships AppleQEMUGuestAgent by default.
However, it does not fully adhere to QGA specs as they do expect each
command to be newline delimited.

This makes each command to be newline delimited which is harmless for
all other systems (Windows, Linux), but enable guest agent by default
without any changes on OSX.

Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agosdn: use sdn tap_create|plug
Alexandre Derumier [Mon, 9 Mar 2020 09:24:21 +0000 (10:24 +0100)]
sdn: use sdn tap_create|plug

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocloudinit: make genisoimage only output errors
Thomas Lamprecht [Tue, 10 Mar 2020 13:47:03 +0000 (14:47 +0100)]
cloudinit: make genisoimage only output errors

avoids a genisoimage output like:
> Total translation table size: 0
> Total rockridge attributes bytes: 417
> Total directory bytes: 0
> Path table size(bytes): 10
> Max brk space used 0
> 178 extents written (0 MB)

on every VM start.

Rather than that useless output, tell genisoimage to be quiet, which
still prints errors but nothing else. Additionally print a short
single line about that we're to create the cloud-init iso.

Reformat while at it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: bump versioned dependency for libpve-guest-common-perl (>= 3.0-4)
Thomas Lamprecht [Tue, 10 Mar 2020 13:28:26 +0000 (14:28 +0100)]
d/control: bump versioned dependency for libpve-guest-common-perl (>= 3.0-4)

for the moved definedness-safe comparison methods

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: do not import unused methods
Thomas Lamprecht [Tue, 10 Mar 2020 13:26:29 +0000 (14:26 +0100)]
followup: do not import unused methods

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoQemuServer: use helper functions from GuestHelpers
Oguz Bektas [Wed, 19 Feb 2020 16:07:56 +0000 (17:07 +0100)]
QemuServer: use helper functions from GuestHelpers

removes safe_string_ne and safe_num_ne code which is now shared in
GuestHelpers. also change all the calls to use the shared definitions.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agobump version to 6.1-7
Thomas Lamprecht [Mon, 9 Mar 2020 18:12:20 +0000 (19:12 +0100)]
bump version to 6.1-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoConsistently use format determined in 'PVE::Storage::foreach_volid'
Fabian Ebner [Mon, 9 Mar 2020 12:24:51 +0000 (13:24 +0100)]
Consistently use format determined in 'PVE::Storage::foreach_volid'

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
LGTM-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agosync_disks: Always set 'snapshots' for qcow2 and vmdk volumes
Fabian Ebner [Mon, 9 Mar 2020 12:24:50 +0000 (13:24 +0100)]
sync_disks: Always set 'snapshots' for qcow2 and vmdk volumes

This fixes an issue when migrating a VM with an unused volume with format
qcow2 or vmdk. Since 'snapshots' wasn't set, storage_migrate wanted to
export/import with format raw+size instead. Therefore it used (instead of
just 'dd') 'qemu-img convert', which fails when its output leaves through
a pipe. Upon importing, a second error is present, because the format from
the volume ID doesn't match the format of the stream and there is no
conversion yet.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
LGTM-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoupdate_disksize: small code cleanup
Thomas Lamprecht [Sat, 7 Mar 2020 17:34:21 +0000 (18:34 +0100)]
update_disksize: small code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoAlso update disk size if there was no old size
Fabian Ebner [Mon, 2 Mar 2020 10:33:48 +0000 (11:33 +0100)]
Also update disk size if there was no old size

If for whatever reason there is no size in the property string
of a drive, 'qm rescan' would do nothing for that drive and
live migration would also fail.

Also adds a check to avoid potential auto-vivification of volid_hash->{$volid}

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoUse MAX_UNUSED_DISKS from Drive.pm to avoid duplication
Fabian Ebner [Mon, 2 Mar 2020 10:33:46 +0000 (11:33 +0100)]
Use MAX_UNUSED_DISKS from Drive.pm to avoid duplication

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoRename disksize to bootdisk_size and print_drive_full to print_drive_commandline_full
Fabian Ebner [Mon, 2 Mar 2020 10:33:45 +0000 (11:33 +0100)]
Rename disksize to bootdisk_size and print_drive_full to print_drive_commandline_full

to avoid confusion with print_drive

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoCreate Drive.pm and move drive-related code there
Fabian Ebner [Mon, 2 Mar 2020 10:33:44 +0000 (11:33 +0100)]
Create Drive.pm and move drive-related code there

The initialization for the drive keys in $confdesc is changed
to be a single for-loop iterating over the keys of $drivedesc_hash and
the initialization of the unusedN keys is move to directly below it.

To avoid the need to change all the call sites, functions with more than
a few callers are exported from the submodule and imported into QemuServer.pm.

For callers of the now imported functions within QemuServer.pm, the prefix
PVE::QemuServer is dropped, because it is unnecessary and now even confusing.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoUse parse_drive for EFI disk
Fabian Ebner [Mon, 2 Mar 2020 10:33:43 +0000 (11:33 +0100)]
Use parse_drive for EFI disk

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoReplace drivename_hash with drivedesc_hash
Fabian Ebner [Mon, 2 Mar 2020 10:33:42 +0000 (11:33 +0100)]
Replace drivename_hash with drivedesc_hash

which contains the full descriptions of the drives, and
make parse_drive not depend on $confdesc anymore.
In preparation to moving drive-related code to its own module.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agofix #2264: add virtio-rng device
Stefan Reiter [Thu, 20 Feb 2020 17:10:44 +0000 (18:10 +0100)]
fix #2264: add virtio-rng device

Allow a user to add a virtio-rng-pci (an emulated hardware random
number generator) to a VM with the rng0 setting. The setting is
version_guard()-ed.

Limit the selection of entropy source to one of three:
/dev/urandom (preferred): Non-blocking kernel entropy source
/dev/random: Blocking kernel source
/dev/hwrng: Hardware RNG on the host for passthrough

QEMU itself defaults to /dev/urandom (or the equivalent getrandom()
call) if no source file is given, but I don't fully trust that
behaviour to stay constant, considering the documentation [0] already
disagrees with the code [1], so let's always specify the file ourselves.

/dev/urandom is preferred, since it prevents host entropy starvation.
The quality of randomness is still good enough to emulate a hwrng, since
a) it's still seeded from the kernel's true entropy pool periodically
and b) it's mixed with true entropy in the guest as well.

Additionally, all sources about entropy predicition attacks I could find
mention that to predict /dev/urandom results, /dev/random has to be
accessed or manipulated in one way or the other - this is not possible
from a VM however, as the entropy we're talking about comes from the
*hosts* blocking pool.

More about the entropy and security implications of the non-blocking
interface in [2] and [3].

Note further that only one /dev/hwrng exists at any given time, if
multiple RNGs are available, only the one selected in
'/sys/devices/virtual/misc/hw_random/rng_current' will feed the file.
Selecting this is left as an exercise to the user, if at all required.

We limit the available entropy to 1 KiB/s by default, but allow the user
to override this. Interesting to note is that the limiter does not work
linearly, i.e. max_bytes=1024/period=1000 means that up to 1 KiB of data
becomes available on a 1000 millisecond timer, not that 1 KiB is
streamed to the guest over the course of one second - hence the
configurable period.

The default used here is the same as given in the QEMU documentation [0]
and has been verified to affect entropy availability in a guest by
measuring /dev/random throughput. 1 KiB/s is enough to avoid any
early-boot entropy shortages, and already has a significant impact on
/dev/random availability in the guest.

[0] https://wiki.qemu.org/Features/VirtIORNG
[1] https://git.qemu.org/?p=qemu.git;a=blob;f=crypto/random-platform.c;h=f92f96987d7d262047c7604b169a7fdf11236107;hb=HEAD
[2] https://lwn.net/Articles/261804/
[3] https://lwn.net/Articles/808575/

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocpu models: add missing comma
Thomas Lamprecht [Fri, 6 Mar 2020 16:55:46 +0000 (17:55 +0100)]
cpu models: add missing comma

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocpu models: qemu 4.2 : add skylake, icelake, cascadelake notsx
Alexandre Derumier [Thu, 5 Mar 2020 15:15:12 +0000 (16:15 +0100)]
cpu models: qemu 4.2 : add skylake, icelake, cascadelake notsx

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
4 years agocpu models : add icelake-{server|client}
Alexandre Derumier [Thu, 5 Mar 2020 15:15:11 +0000 (16:15 +0100)]
cpu models : add icelake-{server|client}

exist since 2018
https://git.qemu.org/?p=qemu.git;a=commit;h=8a11c62da9146dd89aee98947e6bd831e65a970d

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
4 years agoQGA exec: note limits explicit in CLI and API
Thomas Lamprecht [Fri, 6 Mar 2020 16:56:21 +0000 (17:56 +0100)]
QGA exec: note limits explicit in CLI and API

The http-server has a 64KB payload limit for post requests, so note
that explicit even if it's a theoretical maximum as the reamainig
params also need some space in the request

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2612: allow input-data in guest exec and make command optional
Stefan Reiter [Thu, 27 Feb 2020 10:47:41 +0000 (11:47 +0100)]
fix #2612: allow input-data in guest exec and make command optional

'input-data' can be used to pass arbitrary data to a guest when running
an agent command with 'guest-exec'. Most guest-agent implementations
treat this as STDIN to the command given by "path"/"arg", but some go as
far as relying solely on this parameter, and even fail if "path" or
"arg" are set (e.g. Mikrotik Cloud Hosted Router) - thus "command" needs
to be made optional.

Via the API, an arbitrary string can be passed, on the command line ('qm
guest exec'), an additional '--pass-stdin' flag allows to forward STDIN
of the qm process to 'input-data', with a size limitation of 1 MiB to
not overwhelm QMP.

Without 'input-data' (API) or '--pass-stdin' (CLI) behaviour is unchanged.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agofix #2611: use correct operation in get_bandwidth_limit
Stefan Reiter [Tue, 25 Feb 2020 15:32:01 +0000 (16:32 +0100)]
fix #2611: use correct operation in get_bandwidth_limit

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoprint_drive: Use $skip to avoid the need to copy the hash
Fabian Ebner [Mon, 24 Feb 2020 12:43:53 +0000 (13:43 +0100)]
print_drive: Use $skip to avoid the need to copy the hash

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoAlign size to 1 KiB bytes before doing 'qmp block_resize'
Fabian Ebner [Wed, 19 Feb 2020 10:31:30 +0000 (11:31 +0100)]
Align size to 1 KiB bytes before doing 'qmp block_resize'

1. Avoids the error
"VM 111 qmp command 'block_resize' failed - The new size must be a multiple of 512"
for qcow2 disks.
2. Because volume_import expects disk sizes to be a multiple of 1 KiB.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agovzdump: exclude efidisks from backups of non-OVMF machines
Stefan Reiter [Mon, 17 Feb 2020 09:34:16 +0000 (10:34 +0100)]
vzdump: exclude efidisks from backups of non-OVMF machines

Machines running with SeaBIOS don't have the efidisk attached, so QEMU
cannot back it up and fails with "unknown drive".

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoSimplify QEMU version check and require 3.0+
Stefan Reiter [Wed, 12 Feb 2020 10:10:56 +0000 (11:10 +0100)]
Simplify QEMU version check and require 3.0+

Some of the recent QMP changes require at least 2.8.0, but since the
oldest version we officially package for 6.x is 4.0.0 anyway, checking
for at least 3.0 should not break anyone's setup.

Note that this does not affect machine version checks, only the
installed QEMU binary version.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoversion_guard scsi drive count
Stefan Reiter [Mon, 10 Feb 2020 15:05:36 +0000 (16:05 +0100)]
version_guard scsi drive count

Live-migrating a VM with more than 14 SCSI disks to a node that doesn't
support it yet is broken. Use a bumped pve-version to represent that and
give the user a nice error message instead.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoUse 'QEMU version' -> '+pve-version' mapping for machine types
Stefan Reiter [Mon, 10 Feb 2020 15:05:35 +0000 (16:05 +0100)]
Use 'QEMU version' -> '+pve-version' mapping for machine types

The previously introduced approach can fail for pinned versions when a
new QEMU release is introduced. The saner approach is to use a mapping
that gives one pve-version for each QEMU release.

Fortunately, the old system has not been bumped yet, so we can still
change it without too much effort.

QEMU versions without a mapping are assumed to be pve0, 4.1 is mapped to
pve1 since thats what we had as our default previously.

Pinned machine versions (i.e. pc-i440fx-4.1) are always assumed to be
pve0, for specific pve-versions they'd have to be pinned as well (i.e.
pc-i440fx-4.1+pve1).

The new logic also makes the pve-version dynamic, and starts VMs with
the lowest possible 'feature-level', i.e. if a feature is only available
with 4.1+pve2, but the VM isn't using it, we still start it with
4.1+pve0.

We die if we don't support a version that is requested from us. This
allows us to use the pve-version as live-migration blocks (i.e. bumping
the version and then live-migrating a VM which uses the new feature (so
is running with the bumped version) to an outdated node will present the
user with a helpful error message and fail instead of silently modifying
the config and only failing *after* the migration).

$version_guard is introduced in config_to_command to use for features
that need to check pve-version, it automatically handles selecting the
newest necessary pve-version for the VM.

Tests have to be adjusted, since all of them now resolve to pve0 instead
of pve1. EXPECT_ERROR matching is changed to use 'eq' instead of regex
to allow special characters in error messages.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agobump version to 6.1-6
Thomas Lamprecht [Mon, 10 Feb 2020 05:40:45 +0000 (06:40 +0100)]
bump version to 6.1-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoresize_vm: request new size from storage after resizing
Fabian Ebner [Mon, 13 Jan 2020 10:47:43 +0000 (11:47 +0100)]
resize_vm: request new size from storage after resizing

Because of alignment and rounding in the storage backend, the effective
size might not match the 'newsize' parameter we passed along.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoqmp: use query-cpus-fast for hotplug
Stefan Reiter [Thu, 6 Feb 2020 09:53:55 +0000 (10:53 +0100)]
qmp: use query-cpus-fast for hotplug

query-cpus has been deprecated since 2.12.0 [0] in favor of
query-cpus-fast, which no longer incurs a guest performance penalty on
the guest. The returned information is the same as far as our use case
is concerned.

[0] https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoqmp: use migrate-set-parameters in favor of deprecated options
Stefan Reiter [Thu, 6 Feb 2020 09:53:54 +0000 (10:53 +0100)]
qmp: use migrate-set-parameters in favor of deprecated options

migrate_set_downtime, migrate_set_speed and migrate-set-cachesize have
all been deprecated since 2.8 or 2.11 [0]. They still work, but no
reason not to use the correct version.

Note that the downtime-limit parameter switched from seconds to
milliseconds, so convert to that. Slightly improve log output with units
while at it.

[0] https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoqmp: use 'id' parameter instead of 'device'
Stefan Reiter [Thu, 6 Feb 2020 09:53:53 +0000 (10:53 +0100)]
qmp: use 'id' parameter instead of 'device'

'device' is deprecated since 2.8 in favor of 'id' [0], but since we
always consistently set the id on our drives anyway we can substitute it
easily.

[0] see files qapi/block.json and qapi/block-core.json in QEMU source
code, the online documentation doesn't mention it AFAICT

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoqmp: use 'blockdev-change-medium' instead of generic 'change'
Stefan Reiter [Thu, 6 Feb 2020 09:53:52 +0000 (10:53 +0100)]
qmp: use 'blockdev-change-medium' instead of generic 'change'

...and cleanup surrounding code a bit.

'change' is deprecated, and according to the qapi definition in QEMU it
is 'strongly recommended' to avoid using it.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoRemove unused $force parameter
Stefan Reiter [Thu, 6 Feb 2020 09:53:51 +0000 (10:53 +0100)]
Remove unused $force parameter

The fixme got it right :)

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agomigrate: re-order lines to improve readability
Fabian Grünbichler [Wed, 5 Feb 2020 08:43:09 +0000 (09:43 +0100)]
migrate: re-order lines to improve readability

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoExtract volume ID before calling 'parse_volume_id'
Fabian Ebner [Wed, 29 Jan 2020 13:30:09 +0000 (14:30 +0100)]
Extract volume ID before calling 'parse_volume_id'

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agorename 'volid' to 'drivestr' where it's not only a volume ID
Fabian Ebner [Wed, 29 Jan 2020 13:30:08 +0000 (14:30 +0100)]
rename 'volid' to 'drivestr' where it's not only a volume ID

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoFix description for vm_config and change description for vm_pending
Fabian Ebner [Tue, 4 Feb 2020 08:41:00 +0000 (09:41 +0100)]
Fix description for vm_config and change description for vm_pending

The description for vm_config was out of date and from the description
for vm_pending it was hard to tell what the difference to vm_config was.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agofixup: re-add target check
Fabian Grünbichler [Wed, 5 Feb 2020 07:35:14 +0000 (08:35 +0100)]
fixup: re-add target check

that accidentally got dropped while re-factoring previous commit

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agofix #2578: check if $target is provided in clone
Oguz Bektas [Mon, 3 Feb 2020 15:23:55 +0000 (16:23 +0100)]
fix #2578: check if $target is provided in clone

regression introduced with commit a85ff91b

previously we set $target to undef if it's localnode or localhost, then
we check if node exists.

with regression commit, behaviour changes as we do the node check in
else, but $target may be undef. this causes an error:

    no such cluster node ''

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
improved readability

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agofix #2566: increase scsi limit to 31
Dominik Csapak [Fri, 31 Jan 2020 14:41:22 +0000 (15:41 +0100)]
fix #2566: increase scsi limit to 31

to achieve this we have to add 3 new scsihw addresses since lsi
controllers can only hold 7 scsi drives

we go up to 31, since this is the limit for virtio-scsi-single devices
we have reserved (we can increase this in the future)

to make it more future proof, we add a new pci bridge under pci
bridge 1, so we have to adapt the bridge adding code (we did not
need this for q35 previously)

impact on live migration:
since on older versions of qemu-server we do not have those config
settings, there is no problem from old -> new

new->old is not supported anyway and this breaks so that
the vm crashes and loses the configs for scsi15-30
(same behaviour as e.g. with audio0 and migration from new->old)

tested with 31 scsi disk on
i440fx + virtio-scsi
i440fx + lsi
q35 + virtio-scsi
q35 + lsi
with ovmf + seabios

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agomove the vmgenid device after readconfig on q35
Dominik Csapak [Fri, 31 Jan 2020 14:41:21 +0000 (15:41 +0100)]
move the vmgenid device after readconfig on q35

and adapt the tests

this does not impact live migration, since the order here does not
change the device layout

we want this to consistently have the readconfig first

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoallow reading snapshot config for VM.Audit
Dominik Csapak [Fri, 31 Jan 2020 10:40:37 +0000 (11:40 +0100)]
allow reading snapshot config for VM.Audit

VM.Audit can see the current config and the list of snapshots
already, so there is no real reason to disallow
the config of snapshots

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>