]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
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>
4 years agobump version to 6.1-5
Thomas Lamprecht [Thu, 30 Jan 2020 09:30:22 +0000 (10:30 +0100)]
bump version to 6.1-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agohotplug_pending: make 'ssd' option non-hotpluggable
Oguz Bektas [Thu, 16 Jan 2020 15:06:34 +0000 (16:06 +0100)]
hotplug_pending: make 'ssd' option non-hotpluggable

from hotplug_pending we go into 'vmconfig_update_disk', where we check the
hotpluggability of options.

add 'ssd' there as a non-hotpluggable option (since we'd have to unplug/plug to
change the drive type)

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoAdd CPUConfig file and migrate some helpers
Stefan Reiter [Thu, 16 Jan 2020 15:40:48 +0000 (16:40 +0100)]
Add CPUConfig file and migrate some helpers

The package will be used for custom CPU models as a SectionConfig, hence
the name. For now we simply move some CPU related helper functions and
declarations over from QemuServer to reduce clutter there.

Exports are to avoid changing all call sites, functions have useful
names on their own.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoUse 'volname' instead of 'volid' for 'qemu_img_format'
Fabian Ebner [Mon, 20 Jan 2020 13:00:44 +0000 (14:00 +0100)]
Use 'volname' instead of 'volid' for 'qemu_img_format'

As 'qemu_img_format' just matches a regex, this doesn't make much of
a difference, but AFAICT all other calls of 'qemu_img_format' use 'volname'.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agoFix 2070: vm_start: for a migrating VM, use current format of disk if possible
Fabian Ebner [Mon, 20 Jan 2020 13:00:43 +0000 (14:00 +0100)]
Fix 2070: vm_start: for a migrating VM, use current format of disk if possible

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agovmconfig_apply_pending: remove redundant write/load config calls
Oguz Bektas [Wed, 15 Jan 2020 13:48:59 +0000 (14:48 +0100)]
vmconfig_apply_pending: remove redundant write/load config calls

since we handle errors gracefully now, we don't need to write & save
config every time we change a setting.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoqm start: document timeout default
Thomas Lamprecht [Wed, 15 Jan 2020 16:40:12 +0000 (17:40 +0100)]
qm start: document timeout default

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoadd timeout parameter to vm_start api endpoint
Tim Marx [Tue, 14 Jan 2020 13:30:37 +0000 (14:30 +0100)]
add timeout parameter to vm_start api endpoint

Signed-off-by: Tim Marx <t.marx@proxmox.com>
4 years agoadd new helper to calculate timeout based on vm config
Tim Marx [Tue, 14 Jan 2020 13:30:36 +0000 (14:30 +0100)]
add new helper to calculate timeout based on vm config

Signed-off-by: Tim Marx <t.marx@proxmox.com>
4 years agoFixup CPU flag query to not use get_basic_machine_info
Stefan Reiter [Wed, 15 Jan 2020 14:36:54 +0000 (15:36 +0100)]
Fixup CPU flag query to not use get_basic_machine_info

get_basic_machine_info was removed by commit 045749f2fc.

Use get_host_arch to get the default machine type instead, and
optionally allow to specify architecture as parameter.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoapi: vm clone: unlink zombie target config at end of error cleanup
Thomas Lamprecht [Wed, 15 Jan 2020 07:12:22 +0000 (08:12 +0100)]
api: vm clone: unlink zombie target config at end of error cleanup

This is the guarantee that this call operates on it's created config.
A VMID cannot be reused afterall. So only remove the guarantee at the
last step, just before throwing up the error message about the clone
failure.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: vm clone: remove cloned FW conf in error cleanup path
Thomas Lamprecht [Wed, 15 Jan 2020 07:06:14 +0000 (08:06 +0100)]
api: vm clone: remove cloned FW conf in error cleanup path

We clone the source VM firewall config before forking the "realcmd"
worker, but did not mind cleaning it up again if the clone failed
somewhere in the worker.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi/qemu: remove some empty newlines and code cleanup
Thomas Lamprecht [Wed, 15 Jan 2020 07:02:06 +0000 (08:02 +0100)]
api/qemu: remove some empty newlines and code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoAdd QEMU CPU flag querying helpers
Stefan Reiter [Thu, 21 Nov 2019 14:53:42 +0000 (15:53 +0100)]
Add QEMU CPU flag querying helpers

* query_understood_cpu_flags returns all flags that QEMU/KVM knows about
* query_supported_cpu_flags returns all flags that QEMU/KVM can use on
  this particular host.

To get supported flags, a temporary VM is started with QEMU, so we can
issue the "query-cpu-model-expansion" QMP command. This is how libvirt
queries supported flags for its "host-passthrough" CPU type.
query_supported_cpu_flags is thus rather slow and shouldn't be called
unnecessarily.

Note that KVM and TCG accelerators provide different expansions for the
"host" CPU type, so we need to query both.

Currently only supports x86_64, because QEMU-aarch64 doesn't provide the
necessary querying functions.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agovmconfig_apply_pending: add error handling
Oguz Bektas [Tue, 7 Jan 2020 15:55:18 +0000 (16:55 +0100)]
vmconfig_apply_pending: add error handling

wrap around code which can possibly fail in evals to handle them
gracefully, and log errors.

note: this results in a change of behavior in the API. since errors
are handled gracefully instead of "die"ing, when there is a pending
change which cannot be applied for some reason, it will get logged in
the tasklog but the vm will continue booting regardless. the
non-applied change will stay in the pending section of the
configuration.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoRemove unused 'sharedvm' variable
Fabian Ebner [Thu, 9 Jan 2020 09:23:07 +0000 (10:23 +0100)]
Remove unused 'sharedvm' variable

AFAICT this one hasn't been in use since commit
'4530494bf9f3d45c4a405c53ef3688e641f6bd8e'

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agohotplug_pending: remove redundant write/load config calls
Oguz Bektas [Fri, 13 Dec 2019 11:41:51 +0000 (12:41 +0100)]
hotplug_pending: remove redundant write/load config calls

instead of writing the config after every change, we can do it once for
all the changes in the end to avoid redundant i/o.

we also don't need to load_config after writing fastplug changes.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agobump version to 6.1-4
Thomas Lamprecht [Mon, 16 Dec 2019 15:03:30 +0000 (16:03 +0100)]
bump version to 6.1-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi/restore: do not trigger autostart task from locked context
Thomas Lamprecht [Mon, 16 Dec 2019 14:56:46 +0000 (15:56 +0100)]
api/restore: do not trigger autostart task from locked context

Do the same as for the "create" case, only trigger the "start after
create/restore" task after the locked "realcmd" was done. Else, the
start can never succeed, it also acquires a lock, but restore only
release it once outside of realcmd.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agogrammar fix: s/does not exists/does not exist/g
Thomas Lamprecht [Fri, 13 Dec 2019 11:11:58 +0000 (12:11 +0100)]
grammar fix: s/does not exists/does not exist/g

bump versioned build-dependency, as qemu-server has tests checking
for errors, and we fixed an grammar error in pve-storage, so we need
the newer version to ensure our test go through

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: simplify log callback
Thomas Lamprecht [Thu, 12 Dec 2019 12:38:55 +0000 (13:38 +0100)]
followup: simplify log callback

run_command only passes defined and chomped strings to the callback,
so no need to do that twice.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2493: show QEMU errors in migration log
Stefan Reiter [Mon, 9 Dec 2019 15:14:09 +0000 (16:14 +0100)]
fix #2493: show QEMU errors in migration log

QEMU usually only prints warnings and errors and stays silent otherwise,
so it makes sense to just log all of it's output.

Prefix it with '[<target_hostname>]' to indicate that the output is
coming from the remote node, so users know where to search for the
error.

Side effect is that the 'VM start' task created by the migration will
now show the "QEMU:" prefix, but it's still very readable IMHO.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agohide long commandline on vm_start/migrate failure
Stefan Reiter [Mon, 9 Dec 2019 15:14:08 +0000 (16:14 +0100)]
hide long commandline on vm_start/migrate failure

By default run_command prints the entire commandline executed when an
error occurs, but QEMU and our migrate command are not only
uninteresting to the user[*] but also annoyingly long. Hide them and only
print the exit code.

[*] Especially our migrate command, since it can't be manually executed
anyway. QEMU's commandline *might* contain something interesting, but is
so long that it's tricky to parse anyway, any a user can always call 'qm
showcmd --pretty'.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoupdate disk size before local disk migration
Stefan Reiter [Mon, 9 Dec 2019 13:08:09 +0000 (14:08 +0100)]
update disk size before local disk migration

Split out 'update_disksize' from the renamed 'update_disk_config' to
allow code reuse in QemuMigrate.

Remove dots after messages to keep style consistent for migration log.

After updating in sync_disks (phase1) of migration, write out updated
config. This means that even if migration fails or is aborted in later
stages, we keep the fixed config - this is not an issue, as it would
have been fixed on the next attempt anyway, and it can't hurt to have
the correct size instead of a wrong one either way.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agomove vmstate check to check_vm_modify_config_perm
Dominik Csapak [Mon, 9 Dec 2019 14:27:00 +0000 (15:27 +0100)]
move vmstate check to check_vm_modify_config_perm

so that it gets checked before the special case of removing the vmstate

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agosuspend to disk: check more permissions
Dominik Csapak [Mon, 9 Dec 2019 14:26:59 +0000 (15:26 +0100)]
suspend to disk: check more permissions

only VM.PowerMgmt is not enough, since we allocate space on a storage,
so we need VM.Config.Disk on the vm and Datastore.AllocateSpace on the storage

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agorefactor finding of vmstate storage
Dominik Csapak [Mon, 9 Dec 2019 14:26:58 +0000 (15:26 +0100)]
refactor finding of vmstate storage

we need that on another place, so refactor in its own sub

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agofix wrong punctuation in error msg
Stefan Reiter [Mon, 9 Dec 2019 15:14:07 +0000 (16:14 +0100)]
fix wrong punctuation in error msg

...leading to ugly line info being printed.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocfg2cmd: allow to test for expected error messages
Thomas Lamprecht [Tue, 10 Dec 2019 10:07:00 +0000 (11:07 +0100)]
cfg2cmd: allow to test for expected error messages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoqemu-server: make nodename mock-able for tests
Thomas Lamprecht [Tue, 10 Dec 2019 10:05:39 +0000 (11:05 +0100)]
qemu-server: make nodename mock-able for tests

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: improve error message for outdated QEMU version
Thomas Lamprecht [Tue, 10 Dec 2019 10:06:17 +0000 (11:06 +0100)]
followup: improve error message for outdated QEMU version

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocheck if QEMU version is recent enough for machine type
Stefan Reiter [Mon, 9 Dec 2019 15:14:10 +0000 (16:14 +0100)]
check if QEMU version is recent enough for machine type

...and show the user a more meaningful error otherwise.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agobump version to 6.1-3
Thomas Lamprecht [Mon, 9 Dec 2019 09:34:43 +0000 (10:34 +0100)]
bump version to 6.1-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoremove $vmid param from print_drive
Stefan Reiter [Thu, 5 Dec 2019 15:11:01 +0000 (16:11 +0100)]
remove $vmid param from print_drive

It isn't used in the sub, but suggest it is needed. No users outside
qemu-server found.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocfg2cmd: test runs_at_least_qemu_version and version_cmp explicitly
Stefan Reiter [Wed, 4 Dec 2019 12:15:51 +0000 (13:15 +0100)]
cfg2cmd: test runs_at_least_qemu_version and version_cmp explicitly

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocfg2cmd: minor cleanup
Stefan Reiter [Wed, 4 Dec 2019 12:15:50 +0000 (13:15 +0100)]
cfg2cmd: minor cleanup

We never shipped a 4.1.0 QEMU, so it makes more sense to test as 4.1.1

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agofollowup: minor cleanup/error message spelling
Thomas Lamprecht [Mon, 9 Dec 2019 10:29:26 +0000 (11:29 +0100)]
followup: minor cleanup/error message spelling

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2510: hostpci: always check if device exists
Dominik Csapak [Mon, 9 Dec 2019 09:10:04 +0000 (10:10 +0100)]
fix #2510: hostpci: always check if device exists

if the user set a device as hostpci with the 'shorthand' syntax:

hostpciX: 00:12

we ignored it on starting and showcmd and continued.
Since the user explicitly wanted to passthrough a device, we now check
if there is actually a device with that id

for explicitly configured devices (00:12.1), we did not check if it exists,
but the kvm call failed with a non-obvious error message

now we always call 'lspci' from SysFSTools to check if it actually exists,
and fail if not. With this, we can drop the workaround for adding
'0000' if no domain was given, since lspci does it already for us

this fixes #2510, an issue with using mediated devices where the users did not have
the domain in the config, since we forgot to add the default domain there

the only issue with this patch is that it changes the behaviour of
'showcmd' slightly, as in now, we die if the device was explicitly
given, but did not exists (we showed the commandline, now we fail)

this also slightly changes the commandline for qemu (adding always
the domain), which is not a problem since we cannot live migrate
or snapshot such vms, but we have to adapt the tests

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agocfg2cmd test: add tests for multifunction devices
Dominik Csapak [Mon, 9 Dec 2019 09:10:03 +0000 (10:10 +0100)]
cfg2cmd test: add tests for multifunction devices

by mocking the lspci call

the mocked lspci code is basically the same as the real one,
only difference is the source of the devices and
there is no verbose flag

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoRevert "fix #2478: record python3-minimal as build dependency"
Thomas Lamprecht [Mon, 9 Dec 2019 09:32:46 +0000 (10:32 +0100)]
Revert "fix #2478: record python3-minimal as build dependency"

This reverts commit 951b1783cdd328990b46b47a60a457e5acc33cb0.

4 years agofix #2469: fix qemu-img convert src_format detection
Thomas Lamprecht [Mon, 9 Dec 2019 09:31:33 +0000 (10:31 +0100)]
fix #2469: fix qemu-img convert src_format detection

This reverts commit c5151cb8bb5f919c9e621065224c3d455b60f833 which is
a revert of the wrongly done revert of
commit e2414e73ce75893a143dc32cf6a4e58159cc25ff.

4 years agocreate_efidisk: poll the real size after volume creation
Thomas Lamprecht [Wed, 4 Dec 2019 17:40:31 +0000 (18:40 +0100)]
create_efidisk: poll the real size after volume creation

some storage backends have bigger granularity than the default 128k
size from the EFIVARS template file, so we actually need to poll the
real created disk size, as it will be used to create the target
volume for local storage migration on running VMs, if it's to small
the target will be to small and migration will fail.

Just a fix for newly created EFIDISKS, for others we need to rescan
the size after we've got the migrate lock and write the updated info
out, so that the target node has the correct one (protected from
migrate lock).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorefactor storage whitelist in sync_disks to regex
Thomas Lamprecht [Wed, 4 Dec 2019 17:40:03 +0000 (18:40 +0100)]
refactor storage whitelist in sync_disks to regex

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.1-2
Thomas Lamprecht [Sat, 30 Nov 2019 17:38:50 +0000 (18:38 +0100)]
bump version to 6.1-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: allow to clear vmstate actively
Thomas Lamprecht [Sat, 30 Nov 2019 17:17:17 +0000 (18:17 +0100)]
api: allow to clear vmstate actively

Sometimes, a user wants to remove the 'suspended' state without
resuming the vm from that state. Since the vm is locked with
'suspended', this was not possible without help from root@pam

This patch allows to delete the vmstate and the suspended lock and
related config entries with it. The user still has to have the right
priviliges and the vm cannot be 'protected' for this to work

Inspired-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoimplement removal of vmstate via api
Dominik Csapak [Fri, 29 Nov 2019 10:06:48 +0000 (11:06 +0100)]
implement removal of vmstate via api

we did not actually delete the state if we deleted the 'vmstate' config,
leaving stray vmstates on the disks

actually implement the removal, requiring 'VM.Config.Disk' and
'VM.PowerMgmt' privs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agodelete suspended lock when we have no vmstate
Dominik Csapak [Fri, 29 Nov 2019 10:06:47 +0000 (11:06 +0100)]
delete suspended lock when we have no vmstate

if a user removed the vmstate from the config for whatever reason,
a vmstart did not remove the 'suspended' lock
so always delete it and delete the vmstate only if it really was there

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agologging vmstate into Resume/Start Task
Dominik Csapak [Fri, 29 Nov 2019 10:06:46 +0000 (11:06 +0100)]
logging vmstate into Resume/Start Task

so that the user knows what got loaded as vmstate

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agomigrate phase 3 cleanup: add error into error propagation message
Thomas Lamprecht [Sat, 30 Nov 2019 16:27:14 +0000 (17:27 +0100)]
migrate phase 3 cleanup: add error into error propagation message

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomon_cmd: add explicit return
Thomas Lamprecht [Sat, 30 Nov 2019 16:24:55 +0000 (17:24 +0100)]
mon_cmd: add explicit return

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