Commit Graph

3444 Commits

Author SHA1 Message Date
Thomas Lamprecht
7a6c664fb2 bump version to 8.3.7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-02-04 17:12:28 +01:00
Fiona Ebner
48333b4d6a qmp helpers: device add/del: use HMP interface
Fixes device hotplug in combination with QEMU 9.2.

QEMU commit be93fd5372 ("qdev-monitor: avoid QemuOpts in QMP device_add")
notes:

> This patch changes the behavior of QMP device_add but not HMP
> device_add. QMP clients that sent incorrectly typed device_add QMP
> commands no longer work. This is a breaking change but clients should be
> using the correct types already.

The qemu_deviceadd() helper does not have the required type
information right now, so switch to using HMP, which still behaves the
same when passing a device commandline string. QEMU commit be93fd5372
fixes passing in complex properties via JSON, but the qemu_deviceadd()
helper never uses any such, as it already only received a string (and
naively split it up).

Use HMP for 'device_del' too, simply to keep the qemu_deviceadd() and
qemu_devicedel() helpers consistent.

Switching back to QMP using the correct types in the JSON can still be
done later. Unfortunately, 'qmp-query-schema' does not provide
device-specific types, so another way is needed.

A timeout of 25 seconds is used rather then relying on the low default
like before, since device plug operations require actions by the guest
kernel and might require IO. Device plug is often an interactive
operation, so a too high timeout could lead to bad UX. For now stay a
few seconds under the default timeout of 30 seconds of our web UI's
API request handler. Should specific devices need a higher timeout, it
can still be increased further for them in the future.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
 [TL: reduce timeout from 30s to 25s to ensure sync API requests
      (without a task worker) do not run into the frontend timeout]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-02-04 17:07:19 +01:00
Fiona Ebner
0fc03fc18d api: fix ova live import by using correct format for source image
Commit c8ed1ac2 ("api: create disks: live import: use format from
storage layer") broke live import from an OVA containing a disk,
because a combined format like 'ova+vmdk' was used for the live-import
disk mapping, leading to failure:

> invalid format 'ova+vmdk' for 'scsi0' mapping

There was also an informational message about the confusion earlier:

> file_size_info: '/mnt/pve/dir/images/135/vm-135-disk-0.vmdk': \
> falling back to 'raw' from unknown format 'ova+vmdk

Fixes: c8ed1ac2 ("api: create disks: live import: use format from storage layer")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-20 18:49:41 +01:00
Fabian Grünbichler
9ebec81f01 bump version to 8.3.6
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-01-20 14:46:45 +01:00
Fiona Ebner
ae1da616a7 api: create/update vm: avoid printing empty machine string
While no problem is known with having an empty machine string in the
configuration and it was already possible setting an empty machine
manually via 'qm set', the behavior changed because of commit 919e69d0
("machine: add check_and_pin_machine_string() helper") and there is
potential for problematic edge cases. Restore the previous behavior.

Pinning is also required when there is no given machine type, so the
call to check_and_pin_machine_string() should stay unconditional.

For update, pinning was recently added by commit 7a9570f3 ("api:
update vm config: pin machine version when switching to windows os
type"), so bring that in-line with the behavior for create too.

Another idea would've been to just return the default machine in
check_and_pin_machine_string(), but that would also be a change in
behavior. In particular, the default depends on the arch, so an empty
machine type will pick the default machine for the currently
configured arch even when the arch is later changed.

Reported-by: Daniel Herzig <d.herzig@proxmox.com>
Fixes: 919e69d0 ("machine: add check_and_pin_machine_string() helper")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-20 14:43:07 +01:00
Fabian Grünbichler
b41549af09 bump version to 8.3.5
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-01-20 11:22:29 +01:00
Fiona Ebner
74139e72b0 drive: commandline info: re-use drive_id variable in error message
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2025-01-20 11:20:55 +01:00
Fiona Ebner
098d94739b print drive commandline: code cleanup
Drop unused $volname variable and in-line single-use $volid variable.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2025-01-20 11:20:55 +01:00
Fiona Ebner
b9677ce1ee CD-ROM change: re-use get_path_and_format() helper
While the path for changing a CD-ROM medium was already consistent
with the path for an already inserted CD-ROM at VM start, i.e. the one
from print_drive_commandline_full(), this makes that fact more
explicit. While at it, make sure the format is also consistent with
how it is determined in print_drive_commandline_full(). Do the same
for cloud-init drives, which often are in non-raw format.

Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2025-01-20 11:20:55 +01:00
Fiona Ebner
edaf48cf55 drive: add get_path_and_format() helper
To allow re-using it for CD-ROM hotplug.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2025-01-20 11:20:55 +01:00
Fiona Ebner
9f95aa78c7 move get_drive_id() helper to drive module
No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2025-01-20 11:20:55 +01:00
Fiona Ebner
caddaa62c7 move CD-ROM related helpers to drive module
This was the only user of List::Util, so move that too.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
2025-01-20 11:20:55 +01:00
Thomas Lamprecht
d55f7ced32 bump version to 8.3.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-17 19:34:47 +01:00
Fiona Ebner
93c7a7a57b machine: code cleanup: avoid superfluous augmented assignment operator
Suggested by perlcritic.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
c5d4b11f3e machine: rename machine_version() function to is_machine_version_at_least()
The old name does not make it clear what exactly the function does.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
55b277d224 machine: log informational line when pinning machine version for Windows guest
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
7a9570f33e api: update vm config: pin machine version when switching to windows os type
During virtual machine creation, the machine version is pinned when
the guest OS is Windows. The same should be done when the guest OS
type is newly set to Windows for consistency.

NOTE RFC

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
919e69d0d3 machine: add check_and_pin_machine_string() helper
Extract the logic for guest OS-type dependent machine version pinning
into a dedicated helper, so it can be re-used.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
455e12636f machine: fallback to creation QEMU version for windows starting with 9.1
Starting from QEMU creation version 9.1, pin to the creation version
instead. Support for machine version 5.1 is expected to drop with QEMU
11.1 and it would still be good to handle Windows VMs that do not have
explicit machine version for whatever reason. For example, explicitly
setting the machine without a version on the CLI/API after creation is
one way to end up with such a machine.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
8c4f436b3c move meta information handling to its own module
Like this, it can be used by modules that cannot depend on
QemuServer.pm without creating a cyclic dependency.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
db528966c9 move get_vm_machine() function to machine module
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
5c8407b0dc move windows_get_pinned_machine_version() function to machine module
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
85d47ae2fe move get_installed_machine_version() helper to machine module
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
8532a50890 machine: add default_machine_for_arch() helper
There are already other places where 'aarch64' and 'x86_64' are
checked to be the only valid architectures, for example, the
get_command_for_arch() helper, so the new error scenario for an
unknown arch should not cause any regressions.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
82dff842f0 move get_vm_arch() helper to helpers module
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
1715febd33 move kvm_user_version() function to helpers module
Add an export, since the function is rather commonly used (in
particular inlined in function calls, where prefixing with the module
name would hurt readability) and there won't be much potential for
confusion name-wise.

This was the only user of stat(), so remove the File::stat include.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
0050aa8735 move get_command_for_arch() helper to helpers module
Cannot use the is_native_arch() helper inside the function anymore,
to avoid a cyclic dependency between the 'CPUConfig' and 'Helpers'
modules, inline it.

While at it, improve the variable name for the mapping.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Fiona Ebner
1cb9f2cb89 machine: drop unused parameter from assert_valid_machine_property() helper
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-01-17 19:24:02 +01:00
Daniel Kral
3aa377c9fe api: create disks: also convert tpmstate and efidisk to base image for templates
The commit 37a1f42a introduced a conversion step for newly allocated
volume disks to base volumes for VM templates. This wrongly excluded
efidisk and tmpstate volumes from this conversion, even though those
should be converted to base volumes too.

Therefore, include efidisks and tpmstate volumes to be converted to base
volumes when newly allocating them.

Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Fixes: 37a1f42a ("fix #5301: convert added volume disks to base images for templates")
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2025-01-13 16:29:36 +01:00
Daniel Kral
6b2091da7f vmstatus: make memory description consistent with pve-container
Fixes a small typo and uses the same wording as used in pve-container's
description of the `mem` property.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-12-18 16:41:23 +01:00
Dominik Csapak
f6c7916749 api: migration preconditions: add more return type information
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-12-18 13:43:59 +01:00
Dominik Csapak
1b0df64e87 vmstatus: document more return types
namely 'cpu' and 'mem'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-12-17 14:21:42 +01:00
Fabio Fantoni via pve-devel
03614a8992 fix vm shutdown when agent conf is enabled but is not running in the vm
Checking only vm configuration for choose the shutdown method causes it
to always fail, after reaching the timeout, if the qemu agent option in
the vm configuration is enabled but the agent is not installed and
active in the guest.
As I seen in the windows vm the agent also crashes in some cases, so
shutdown don't fail only if qemu guest agent is not installed or not
started.

Added check that agent is active when choosing agent shutdown method to
avoid certain shutdown failure in those cases.

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
[FE: do not set flag to suppress warning when agent is not running]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-17 13:50:20 +01:00
Thomas Lamprecht
fa7e48662c bump version to 8.3.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-12-15 14:26:36 +01:00
Fabian Grünbichler
9ed5a3371b create_disks: disallow adding of non-raw tpmstate0 volumes
when creating new ones, we already force raw as format, but adding existing
volumes as tpmstate0 had no such checks.

Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-12 11:37:59 +01:00
Fabian Grünbichler
4182c3da78 swtpm: drop unused $volname variable
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-12 10:47:44 +01:00
Fabian Grünbichler
1fe55a9f6c swtpm: check that format of tpmstate volume is raw
since swtpm currently doesn't support anything else, and might overwrite a file
using qcow2 or vmdk format by accident..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-12 10:47:42 +01:00
Fabian Grünbichler
f43a41bec0 api: clone: always do a full clone of tpmstate volumes
since there is no reliable way to check whether a linked clone would end up
being something other than a raw file, and the volumes are tiny anyway.

otherwise on directory storages, the following sequence of events could happen:
- linked clone using raw file as base and qcow2 as overlay
- swtpm_setup interprets qcow2 file as raw
- swtpm_setup fails to find TPM state and overwrites it with a new one
- file is now no longer a linked clone, but a raw file with a qcow2 extension
- move disk and migration fail because of the format mismatch

the downside is that storages that actually support raw linked clones (ZFS,
RBD, LVM-thin) now use more space for fully cloned TPM state volumes...

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-12 10:47:41 +01:00
Fabian Grünbichler
45fedd4729 fix #5980: importdisk: fix spurious warning
if not target disk is given, it makes no sense to check that it is valid.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-09 19:46:03 +01:00
Fabian Grünbichler
4b6051485e api: fix another non-ascii comment
replace a UTF-8 en-dash with a regular hyphen.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-09 11:56:46 +01:00
Fabian Grünbichler
0f8d3e0e34 bump version to 8.3.2
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-12-09 10:16:07 +01:00
Fiona Ebner
034768882f remove dead qemu_img_format() helper
All callers have been switched to get the format from the storage
layer using checked_volume_format() and friends.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
1f961e51a8 resolve destination disk format helper: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
9cefe5d7bf drive mirror: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
2d62759f6c backup: parse backup hints: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper. Failure is
not critical, because this is just the hint for what format the
restored target image should be allocated with, so fallback to 'raw'.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
dfdb1656f6 migration: remote phase one: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
55975bd9db backup: prepare: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
d45102708f cloud-init: commit disk: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
0da8f110e8 migration: get nbd disks helper: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00
Fiona Ebner
d6e76d1b60 cfg2cmd: ovmf drive: use volume format from storage layer
Avoid using the extension based qemu_img_format() helper.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-12-09 09:07:17 +01:00