]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
2 months agosupport live-import for 'import-from' disk options on create
Wolfgang Bumiller [Wed, 14 Feb 2024 08:29:58 +0000 (09:29 +0100)]
support live-import for 'import-from' disk options on create

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 months agogeneralize live restore code
Wolfgang Bumiller [Tue, 13 Feb 2024 15:16:50 +0000 (16:16 +0100)]
generalize live restore code

instead of a "pbs-backing" parameter we now have a
"live-restore-backing" parameter containing the `-blockdev` arg and
its name, which also means we print the blockdev earlier

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 months agod/changelog: drop import-from fix entry, regression got never out
Thomas Lamprecht [Mon, 11 Mar 2024 09:40:22 +0000 (10:40 +0100)]
d/changelog: drop import-from fix entry, regression got never out

The fix is for a regression that never made it into a bumped package,
so no need to mention it in the changelog.

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agoconfig: update network: code-style & readability improvements
Thomas Lamprecht [Sun, 10 Mar 2024 17:27:09 +0000 (18:27 +0100)]
config: update network: code-style & readability improvements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agoconfig: apply pending: code-style & readability improvements
Thomas Lamprecht [Sun, 10 Mar 2024 17:26:52 +0000 (18:26 +0100)]
config: apply pending: code-style & readability improvements

among other things, avoid one indentation level by returning early
from the eval.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agoconfig: pending network: avoid undef-warning on old/new comparison
Thomas Lamprecht [Sun, 10 Mar 2024 17:12:21 +0000 (18:12 +0100)]
config: pending network: avoid undef-warning on old/new comparison

A network device of a VM does not necessarily has to be connected to
an actual bridge, so when a new pending value is set we need to use
the undef-safe compare helpers when checking if there was a change
between old and new value, as otherwise one gets ugly "use of
uninitialized value in string ne" warnings.

Link: https://forum.proxmox.com/threads/143072/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agoadd missing import
Wolfgang Bumiller [Wed, 14 Feb 2024 10:18:26 +0000 (11:18 +0100)]
add missing import

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 months agobump version to 8.1.0
Thomas Lamprecht [Fri, 8 Mar 2024 14:00:38 +0000 (15:00 +0100)]
bump version to 8.1.0

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agocpu config: implement is_native_arch locally for now
Thomas Lamprecht [Fri, 8 Mar 2024 14:06:25 +0000 (15:06 +0100)]
cpu config: implement is_native_arch locally for now

could be a better fit in PVE::Tools, like proposed by Filip, but OTOH.
Tools is already crowded as is, so wait if we need it on more places
outside of qemu-server.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agoQMP client: sort commands with 10 minutes timeout alphabetically
Fiona Ebner [Fri, 9 Feb 2024 12:14:27 +0000 (13:14 +0100)]
QMP client: sort commands with 10 minutes timeout alphabetically

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2 months agoQMP client: add missing use statement for UNIX Sockets module
Fiona Ebner [Fri, 9 Feb 2024 12:14:26 +0000 (13:14 +0100)]
QMP client: add missing use statement for UNIX Sockets module

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2 months agoQMP client: remove unnecessary question mark from comment
Fiona Ebner [Fri, 9 Feb 2024 12:14:25 +0000 (13:14 +0100)]
QMP client: remove unnecessary question mark from comment

There might've been a question back when it got first added in commit
9d689077 ("use long timeouts for snapshot monitor command"). But
nowadays, the value is well-established. Changing it would affect
quite a few operations, so that should not be done without good
reason and is likely better done for the specific operation.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2 months agoQMP client: increase default timeout for drive-mirror to 10 minutes
Fiona Ebner [Fri, 9 Feb 2024 12:14:24 +0000 (13:14 +0100)]
QMP client: increase default timeout for drive-mirror to 10 minutes

like for other block operations.

Reported in the community forum:
https://forum.proxmox.com/threads/141238/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2 months agocpu config: Unify the default value for 'kvm'
Filip Schauer [Wed, 21 Feb 2024 14:33:16 +0000 (15:33 +0100)]
cpu config: Unify the default value for 'kvm'

Make the default value for 'kvm' consistent, taking into account
whether the VM will run on the same CPU architecture as the host.

This would be a breaking change to CPU hotplug for VMs with a
different CPU architecture running on an x86_64 host, as in this case
the default CPU type for CPU hotplug changes from 'kvm64' to 'qemu64'.
However, CPU hotplug of non x86_64 architectures is not supported
anyway, so this is not a breaking change after all.

It should be noted that this change does alter the CPU hotplug
behaviour when emulating an x86_64 CPU on a non-x86_64 host. This is
however not officially supported in Proxmox VE.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2 months agoMove is_native from PVE::QemuServer to PVE::Tools
Filip Schauer [Wed, 21 Feb 2024 14:33:15 +0000 (15:33 +0100)]
Move is_native from PVE::QemuServer to PVE::Tools

Move is_native from PVE::QemuServer to PVE::Tools and rename it to
is_native_arch to be more descriptive.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2 months agoprevent starting a 32-bit VM using a 64-bit OVMF BIOS
Filip Schauer [Wed, 21 Feb 2024 14:33:14 +0000 (15:33 +0100)]
prevent starting a 32-bit VM using a 64-bit OVMF BIOS

Instead of starting a VM with a 32-bit CPU type and a 64-bit OVMF image,
throw an error before starting the VM telling the user that OVMF is not
supported on 32-bit CPU types.

To obtain a list of 32-bit CPU types, refer to the builtin_x86_defs in
target/i386/cpu.c of QEMU. Exclude any entries that have the long mode
feature (CPUID_EXT2_LM).

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2 months agocpu config: add helper to get the default CPU type
Filip Schauer [Wed, 21 Feb 2024 14:33:13 +0000 (15:33 +0100)]
cpu config: add helper to get the default CPU type

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2 months agomediated device pass-through: fix race condition on VM reboot
Dominik Csapak [Thu, 7 Mar 2024 09:33:37 +0000 (10:33 +0100)]
mediated device pass-through: fix race condition on VM reboot

When rebooting a VM from PVE (via CLI/API), the reboot code is called
under a guest lock, which creates a reboot request, shuts down the VM
and then calls the regular cleanup code, which includes the mdev
cleanup.

In parallel, the qmeventd observes that the VM process has gone, and
starts 'qm cleanup' which is (among other tasks) also starts the VM
again if a reboot from the PVE side is pending.
The qmeventd synchronizes this through a lock on the guest, with a
default timeout of 10 seconds.

Since we currently also always wait 10 seconds for the NVIDIA driver
to clean up the mdev, this creates a race condition for the cleanup
lock. IOW., when the call to `qm cleanup` starts before we started to
sleep for 10 seconds, it will not be able to acquire its lock and not
start the vm again.

To avoid the race condition in practice, do two things:
* increase the timeout in `qm cleanup` to 60 seconds.
  Technically this still might run into a timeout, as we can configure
  up to 16 mediated devices with each delaying 10 seconds in the worst
  case, but realistically most users won't configure more than two or
  three of them, if even that.

* change the hard-coded `sleep 10` to a loop sleeping for 1 second
  each before checking the state again. This shortens the timeout when
  the NVIDIA driver did not require the full 10s to finish the
  clean-up.

Further, add a bit of logging, so one can properly see in the task log
what is happening at which point in time.

Fixes: 49c51a60 (pci: workaround nvidia driver issue on mdev cleanup)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
 [ TL: change warn to print, reword commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agoapi: clone vm: comment and style clean-up deactivation error-handling
Thomas Lamprecht [Fri, 8 Mar 2024 12:49:03 +0000 (13:49 +0100)]
api: clone vm: comment and style clean-up deactivation error-handling

Make the post-if check for the target not already running more
prominent by using a full if block.

Also comment on why we ignore the error here, while the commit
changing that explained it well, this is one of the things that might
be better of with a in-code comment (as doing the deactivation is
described as important here, so one might wonder why the code
continues if that fails)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agofix #1734: clone VM: if deactivation fails demote error to warning
Hannes Duerr [Wed, 6 Mar 2024 14:08:34 +0000 (15:08 +0100)]
fix #1734: clone VM: if deactivation fails demote error to warning

When a template with disks on LVM is cloned to another node, the
volumes are first activated, then cloned and deactivated again after
cloning.

However, if clones of this template are now created in parallel to
other nodes, it can happen that one of the tasks can no longer
deactivate the logical volume because it is still in use.  The reason
for this is that we use a shared lock.
Since the failed deactivation does not necessarily have consequences,
we downgrade the error to a warning, which means that the clone tasks
will continue to be completed successfully.

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
3 months agoapi: fix using import-from with SCSI disks
Fiona Ebner [Wed, 31 Jan 2024 10:53:59 +0000 (11:53 +0100)]
api: fix using import-from with SCSI disks

by fixing the SCSI feature compatibility check helper. The helper is
also called for disks using import-from, so it has to use the extended
schema when parsing the drive.

Fixes: d1feab4a ("fix #4957: add vendor and product information passthrough for SCSI-Disks")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
3 months agofix #4085: properly activate cicustom storage(s)
Fabian Grünbichler [Thu, 25 Jan 2024 12:33:12 +0000 (13:33 +0100)]
fix #4085: properly activate cicustom storage(s)

PVE::Storage::path() neither activates the storage of the passed-in volume, nor
does it ensure that the returned value is actually a file or block device, so
this actually fixes two issues. PVE::Storage::abs_filesystem_path() actually
takes care of both, while still calling path() under the hood (since $volid
here is always a proper volid, unless we change the cicustom schema at some
point in the future).

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 months agomigration: secure and use source volume names for deactivation
Hannes Duerr [Tue, 19 Dec 2023 14:03:05 +0000 (15:03 +0100)]
migration: secure and use source volume names for deactivation

During migration, the volume names may change if the name is already in
use at the target location. We therefore want to save the original names
so that we can deactivate the original volumes afterwards.

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
3 months agodrive: product/vendor: add comment with rationale for limits
Fiona Ebner [Fri, 26 Jan 2024 10:28:32 +0000 (11:28 +0100)]
drive: product/vendor: add comment with rationale for limits

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
3 months agofix #4957: add vendor and product information passthrough for SCSI-Disks
Hannes Duerr [Wed, 10 Jan 2024 12:45:49 +0000 (13:45 +0100)]
fix #4957: add vendor and product information passthrough for SCSI-Disks

adds vendor and product information for SCSI devices to the json schema
and checks in the VM create/update API call if it is possible to add
these to QEMU as a device option

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
[FE: add missing space to exception message
     use config option for exception e.g. scsi0 rather than 'product'
     style fixes]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
4 months agoqemu_volume_snapshot_delete: drop (now) unused parameter
Fabian Grünbichler [Tue, 9 Jan 2024 09:25:11 +0000 (10:25 +0100)]
qemu_volume_snapshot_delete: drop (now) unused parameter

since we always determine the deviceid, passing in a possibly wrong value makes
no sense and could actually re-introduce bugs.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
4 months agofix #2258: select correct device when removing drive snapshot via QEMU
Fiona Ebner [Wed, 3 Jan 2024 13:41:49 +0000 (14:41 +0100)]
fix #2258: select correct device when removing drive snapshot via QEMU

The QMP command needs to be issued for the device where the disk is
currently attached, not for the device where the disk was attached at
the time the snapshot was taken.

Fixes the following scenario with a disk image for which
do_snapshots_with_qemu() is true (i.e. qcow2 or RBD+krbd=0):
1. Take snapshot while disk image is attached to a given bus+ID.
2. Detach disk image.
3. Attach disk image to a different bus+ID.
4. Remove snapshot.

Previously, this would result in an error like:
> blockdev-snapshot-delete-internal-sync' failed - Cannot find device=drive-scsi1 nor node_name=drive-scsi1

While the $running parameter for volume_snapshot_delete() is planned
to be removed on the next storage plugin APIAGE reset, it currently
causes an immediate return in Storage/Plugin.pm. So passing a truthy
value would prevent removing a snapshot from an unused qcow2 disk that
was still used at the time the snapshot was taken. Thus, and because
some exotic third party plugin might be using it for whatever reason,
it's necessary to keep passing the same value as before.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
4 months agodrive: Create get_scsi_devicetype
Hannes Duerr [Wed, 6 Dec 2023 07:47:44 +0000 (08:47 +0100)]
drive: Create get_scsi_devicetype

Encapsulation of the functionality for determining the scsi device type
in a new function for reusability in QemuServer/Drive.pm

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
4 months agoMove NEW_DISK_RE to QemuServer/Drive.pm
Hannes Duerr [Wed, 6 Dec 2023 07:47:43 +0000 (08:47 +0100)]
Move NEW_DISK_RE to QemuServer/Drive.pm

Prepare for introduction of new helper

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
4 months agoMove path_is_scsi to QemuServer/Drive.pm
Hannes Duerr [Wed, 6 Dec 2023 07:47:42 +0000 (08:47 +0100)]
Move path_is_scsi to QemuServer/Drive.pm

Prepare for introduction of new helper

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
4 months agofix #4501: TCP migration: start vm: move port reservation and usage closer together
Fiona Ebner [Tue, 19 Dec 2023 13:44:59 +0000 (14:44 +0100)]
fix #4501: TCP migration: start vm: move port reservation and usage closer together

Currently, volume activation, PCI reservation and resetting systemd
scope happen in between, so the 5 second expiretime used for port
reservation is not always enough.

It's possible to defer telling QEMU where it should listen for
migration and do so after it has been started via QMP. Therefore, the
port reservation can be moved very close to the actual usage.

Mentioned here for completeness and can still be done as an additional
change later if desired: next_migrate_port could be modified to
optionally return the open socket and it should be possible to pass
the file descriptor directly to QEMU, but that would require accepting
the connection before on the Perl side (otherwise leads to ENOTCONN
107). While it would avoid any races, it's not the most elegant
and the change at hand should be enough in all practical situations.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Acked-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
5 months agocpu config: add QEMU 8.1 cpu models
Alexandre Derumier [Mon, 11 Dec 2023 15:17:02 +0000 (16:17 +0100)]
cpu config: add QEMU 8.1 cpu models

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
[FE: add prefix to commit title, capitalize QEMU]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
5 months agoschema: mention that migration with VNC clipboard is not yet supported
Fiona Ebner [Wed, 29 Nov 2023 09:16:35 +0000 (10:16 +0100)]
schema: mention that migration with VNC clipboard is not yet supported

as this might be surprising to users.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
5 months agomigration: do not allow live-migration with clipboard=vnc
Markus Frank [Fri, 24 Nov 2023 12:32:38 +0000 (13:32 +0100)]
migration: do not allow live-migration with clipboard=vnc

It is not yet supported for QEMU's vdagent device which is used for
the VNC clipboard.

The migration precondition API call will now treat the VNC clipboard
as a local resource. Thus the GUI blocks migration and shows:
"Can't migrate VM with local resources: clipboard=vnc"

QemuMigrate's prepare function will also abort live migration early
when using the VNC clipboard.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
[FE: adapt commit message a bit]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
5 months agobump version to 8.0.10
Thomas Lamprecht [Wed, 22 Nov 2023 13:12:52 +0000 (14:12 +0100)]
bump version to 8.0.10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosdn: pass vmid and hostname to add_dhcp_mapping
Stefan Lendl [Tue, 21 Nov 2023 14:55:56 +0000 (15:55 +0100)]
sdn: pass vmid and hostname to add_dhcp_mapping

if no DHCP mapping was found in IPAM it will request a new IP which
requires these values.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
5 months agobump version to 8.0.9
Wolfgang Bumiller [Tue, 21 Nov 2023 14:47:55 +0000 (15:47 +0100)]
bump version to 8.0.9

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agod/control: recommend libpve-network-perl >= 0.8.3
Wolfgang Bumiller [Tue, 21 Nov 2023 13:52:17 +0000 (14:52 +0100)]
d/control: recommend libpve-network-perl >= 0.8.3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agofixup an sdn call outside the have_sdn guard
Wolfgang Bumiller [Tue, 21 Nov 2023 12:25:51 +0000 (13:25 +0100)]
fixup an sdn call outside the have_sdn guard

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agonic online bridge/vlan change: link disconnect/reconnect
Alexandre Derumier [Fri, 17 Nov 2023 11:40:04 +0000 (12:40 +0100)]
nic online bridge/vlan change: link disconnect/reconnect

We want to notify guest of the change, so it can resubmit dhcp request,
or send gratuitous arp,...

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agonic hotplug: add_dhcp_mapping
Alexandre Derumier [Fri, 17 Nov 2023 11:40:03 +0000 (12:40 +0100)]
nic hotplug: add_dhcp_mapping

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovm_destroy: delete ip from ipam
Alexandre Derumier [Fri, 17 Nov 2023 11:40:02 +0000 (12:40 +0100)]
vm_destroy: delete ip from ipam

Co-Authored-By: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agoapi2: create|restore|clone: add_free_ip
Alexandre Derumier [Fri, 17 Nov 2023 11:40:01 +0000 (12:40 +0100)]
api2: create|restore|clone: add_free_ip

Co-Authored-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovm_start : vm-network-scripts: add_dhcp_reservation
Alexandre Derumier [Fri, 17 Nov 2023 11:40:00 +0000 (12:40 +0100)]
vm_start : vm-network-scripts: add_dhcp_reservation

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovmnic add|remove : add|del ip in ipam
Alexandre Derumier [Fri, 17 Nov 2023 11:39:59 +0000 (12:39 +0100)]
vmnic add|remove : add|del ip in ipam

Co-Authored-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agotests: cfg2cmd: rename vnc-clipboard to lower-case and add description
Thomas Lamprecht [Mon, 20 Nov 2023 15:36:51 +0000 (16:36 +0100)]
tests: cfg2cmd: rename vnc-clipboard to lower-case and add description

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agotests: add cases for clipboard with spice & std display
Markus Frank [Tue, 14 Nov 2023 09:22:53 +0000 (10:22 +0100)]
tests: add cases for clipboard with spice & std display

add one test case for a spice display and one for std

Signed-off-by: Markus Frank <m.frank@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
5 months agoapi: add clipboard variable to return at status/current
Markus Frank [Tue, 14 Nov 2023 09:22:52 +0000 (10:22 +0100)]
api: add clipboard variable to return at status/current

This can be used by noVNC to check if a clipboard is available.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
5 months agoconfig: enable VNC clipboard parameter in vga_fmt
Markus Frank [Tue, 14 Nov 2023 09:22:51 +0000 (10:22 +0100)]
config: enable VNC clipboard parameter in vga_fmt

add option to use the qemu vdagent implementation to enable the VNC
clipboard. When enabled with SPICE the spice-vdagent gets replaced
with the QEMU implementation.

This patch does not solve #1406, but does allow copy and paste with a
running X-session, when spice-vdagent is installed on the guest.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
5 months agod/control: wrap-and-sort -tkn
Thomas Lamprecht [Mon, 20 Nov 2023 15:19:35 +0000 (16:19 +0100)]
d/control: wrap-and-sort -tkn

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agod/control: depend on split-out edk2-firmware packages
Thomas Lamprecht [Mon, 20 Nov 2023 15:19:23 +0000 (16:19 +0100)]
d/control: depend on split-out edk2-firmware packages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agogitignore: sort content
Thomas Lamprecht [Fri, 17 Nov 2023 14:54:24 +0000 (15:54 +0100)]
gitignore: sort content

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agogitignore: add build output and .vscode to ignored files
Stefan Lendl [Fri, 17 Nov 2023 14:20:26 +0000 (15:20 +0100)]
gitignore: add build output and .vscode to ignored files

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
 [ TL: extend subject and use more specific build-dir glob ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agobump version to 8.0.8
Thomas Lamprecht [Sun, 12 Nov 2023 17:54:44 +0000 (18:54 +0100)]
bump version to 8.0.8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agovm start: add warning about deprecated machine version
Fiona Ebner [Fri, 10 Nov 2023 13:24:51 +0000 (14:24 +0100)]
vm start: add warning about deprecated machine version

While there already is a warning from QEMU proper, that one is not
visible as a task warning and it's not straightforward to make it be
one, because QEMU is started inside a run_fork(). It's also more
future-proof to have the detection explicit on our side and the
documentation can be referenced.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agotest: migration: mock get_current_qemu_machine
Fiona Ebner [Fri, 10 Nov 2023 13:24:50 +0000 (14:24 +0100)]
test: migration: mock get_current_qemu_machine

by remembering the 'forcemachine' parameter that's passed along when
starting the target instance.

In preparation to introduce a call to get_current_qemu_machine after
starting a VM to check for machine version deprecation.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agomachine: get current: add flag if current machine is deprecated in list context
Fiona Ebner [Fri, 10 Nov 2023 13:24:49 +0000 (14:24 +0100)]
machine: get current: add flag if current machine is deprecated in list context

Will be used for a warning.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agomachine: get current: return early from loop if possible
Fiona Ebner [Fri, 10 Nov 2023 13:24:48 +0000 (14:24 +0100)]
machine: get current: return early from loop if possible

No point iterating through the rest if we already got the current
machine.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agomachine: get current: make it clear that pve-version only exists for the current...
Fiona Ebner [Fri, 10 Nov 2023 13:24:47 +0000 (14:24 +0100)]
machine: get current: make it clear that pve-version only exists for the current machine

by adding a comment and grouping the code better. See the PVE QEMU
patch "PVE: Allow version code in machine type" for reference. The way
the code was written previously made it look like a bug where
$pve_version might be overwritten multiple times.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agomachine: get current: improve naming and style
Fiona Ebner [Fri, 10 Nov 2023 13:24:46 +0000 (14:24 +0100)]
machine: get current: improve naming and style

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agoadd some comments for legacy 2MB OVMF image builds
Thomas Lamprecht [Sat, 11 Nov 2023 14:09:42 +0000 (15:09 +0100)]
add some comments for legacy 2MB OVMF image builds

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agomigration: add missing eval on nbdstop with tunnel v2
Alexandre Derumier [Fri, 29 Sep 2023 08:28:59 +0000 (10:28 +0200)]
migration: add missing eval on nbdstop with tunnel v2

It was already done in tunnel v1.

Avoid to avoid migration (and keep both source/targetvm locked) if
nbdstop error occur

2023-09-28 16:20:39 ERROR: error - tunnel command '{"cmd":"nbdstop"}' failed - failed to handle 'nbdstop' command - VM 140 qmp command 'nbd-server-stop' failed - got timeout
2023-09-28 16:20:39 ERROR: migration finished with problems (duration 00:01:42)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agonbd-stop: increase timeout to 25s
Alexandre Derumier [Fri, 29 Sep 2023 08:28:58 +0000 (10:28 +0200)]
nbd-stop: increase timeout to 25s

This can seemingly need a bit longer than expected, and better than
erroring out on migration is to wait a bit longer.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agod/control: record break of with older ha-manager
Thomas Lamprecht [Mon, 6 Nov 2023 09:27:36 +0000 (10:27 +0100)]
d/control: record break of with older ha-manager

As the ha-manager accessed rather internal details before that
version, and the memory property changing to a format-string with sub
properties in 7f8c808 ("add memory parser") breaks that access, so
ensure the installed ha-manager is using the newer
get_derived_property method to access that information cleanly.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agoadd|del_bridge_fdb: remove unused firewall param
Alexandre Derumier [Tue, 26 Sep 2023 07:39:39 +0000 (09:39 +0200)]
add|del_bridge_fdb: remove unused firewall param

6 months agocpu hotplug: cannot change feature online
Alexandre Derumier [Tue, 10 Oct 2023 15:37:17 +0000 (17:37 +0200)]
cpu hotplug: cannot change feature online

The vCPUs are passed as devices with specific id only when CPU
hot-plug is enable at cold start.

So, we can't enable/disable allow-hotplug online as then vCPU hotplug
API will thrown errors not finding core id.

Not enforcing this could also lead to migration failure, as the QEMU
command line for the target VM could be made different than the one it
was actually running with, causing a crash of the target as Fiona
observed [0].

[0]: https://lists.proxmox.com/pipermail/pve-devel/2023-October/059434.html

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
 [ TL: Reflowed & expanded commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agovzdump: assemble: improve error messages
Fiona Ebner [Mon, 23 Oct 2023 08:59:08 +0000 (10:59 +0200)]
vzdump: assemble: improve error messages

by including the errno. Might make it clearer what the issue is in
cases like: https://forum.proxmox.com/threads/135261/

Also add the missing newlines, the missing "to" in the second message,
switch to the more common "or die" and avoid line bloat while at it.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agobackup, migrate: fix races with suspended VMs that can wake up
Filip Schauer [Fri, 13 Oct 2023 13:50:06 +0000 (15:50 +0200)]
backup, migrate: fix races with suspended VMs that can wake up

Fix races with ACPI-suspended VMs which could wake up during migration
or during a suspend-mode backup.

Revert prevention, of ACPI-suspended VMs automatically resuming after
migration, introduced by 7ba974a6828d. The commit introduced a
potential problem that causes a suspended VM that wakes up during
migration to remain paused after the migration finishes.

This can be fixed once QEMU preserves the 'suspended' runstate during
migration (current patch on the qemu-devel list [0]) by checking for
the 'suspended' runstate on the target after migration.

Furthermore the commit increased the race window during the
preparation of a suspend-mode backup, when a suspended VM wakes up
between the vm_is_paused check in PVE::VZDump::QemuServer::prepare and
PVE::VZDump::QemuServer::qga_fs_freeze. This causes the code to skip
fs-freeze even if the VM has woken up, potentially leaving the file
system in an inconsistent state.

To prevent this, do not treat the suspended runstate as paused when
migrating or archiving a VM.

[0]: https://lists.nongnu.org/archive/html/qemu-devel/2023-08/msg05260.html

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
 [ TL: massage in Fiona's extra info into commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 months agofix #4522: api: vncproxy: also set environment variable for ticket without websocket
Fiona Ebner [Mon, 16 Oct 2023 13:12:26 +0000 (15:12 +0200)]
fix #4522: api: vncproxy: also set environment variable for ticket without websocket

Since commit 2dc0eb61 ("qm: assume correct VNC setup in 'vncproxy',
disallow passwordless"), 'qm vncproxy' will just fail when the
LC_PVE_TICKET environment variable is not set. Since it is not only
required in combination with websocket, drop that conditional.

For the non-serial case, this was the last remaining effect of the
'websocket' parameter, so update the parameter description.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
6 months agoapi: vncproxy: update description of websocket parameter
Fiona Ebner [Mon, 16 Oct 2023 13:12:25 +0000 (15:12 +0200)]
api: vncproxy: update description of websocket parameter

Since commit 3e7567e0 ("do not use novnc wsproxy"), the websocket
upgrade is done via the HTTP server.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agoapi: reduce overly lengthy comment
Thomas Lamprecht [Tue, 10 Oct 2023 10:57:00 +0000 (12:57 +0200)]
api: reduce overly lengthy comment

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 months agoFix ACPI-suspended VMs resuming after migration
Filip Schauer [Mon, 9 Oct 2023 13:25:19 +0000 (15:25 +0200)]
Fix ACPI-suspended VMs resuming after migration

Add checks for "suspended" and "prelaunch" runstates when checking
whether a VM is paused.

This fixes the following issues:
* ACPI-suspended VMs automatically resuming after migration
* Shutdown and reboot commands timing out instead of failing
  immediately on suspended VMs

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
7 months agovm start: set higher timeout if using PCI passthrough
Friedrich Weber [Fri, 6 Oct 2023 12:15:33 +0000 (14:15 +0200)]
vm start: set higher timeout if using PCI passthrough

The default VM startup timeout is `max(30, VM memory in GiB)` seconds.
Multiple reports in the forum [0] [1] and the bug tracker [2] suggest
this is too short when using PCI passthrough with a large amount of VM
memory, since QEMU needs to map the whole memory during startup (see
comment #2 in [2]). As a result, VM startup fails with "got timeout".

To work around this, set a larger default timeout if at least one PCI
device is passed through. The question remains how to choose an
appropriate timeout. Users reported the following startup times:

ref | RAM | time  | ratio (s/GiB)
---------------------------------
[1] | 60G |  135s |  2.25
[1] | 70G |  157s |  2.24
[1] | 80G |  277s |  3.46
[2] | 65G |  213s |  3.28
[2] | 96G | >290s | >3.02

The data does not really indicate any simple (e.g. linear)
relationship between RAM and startup time (even data from the same
source). However, to keep the heuristic simple, assume linear growth
and multiply the default timeout by 4 if at least one `hostpci[n]`
option is present, obtaining `4 * max(30, VM memory in GiB)`. This
covers all cases above, and should still leave some headroom.

[0]: https://forum.proxmox.com/threads/83765/post-552071
[1]: https://forum.proxmox.com/threads/126398/post-592826
[2]: https://bugzilla.proxmox.com/show_bug.cgi?id=3502

Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
7 months agoadd memory parser
Alexandre Derumier [Mon, 4 Sep 2023 11:39:49 +0000 (13:39 +0200)]
add memory parser

In preparation to add more properties to the memory configuration like
maximum hotpluggable memory and whether virtio-mem devices should be
used.

This also allows to get rid of the cyclic include of PVE::QemuServer
in the memory module.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
[FE: also convert new usage in get_derived_property
     remove cyclic include of PVE::QemuServer
     add commit message]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agointroduce QMPHelpers module
Fiona Ebner [Mon, 4 Sep 2023 11:39:48 +0000 (13:39 +0200)]
introduce QMPHelpers module

moving qemu_{device,object}{add,del} helpers there for now.

In preparation to remove the cyclic include of PVE::QemuServer in the
memory module and generally for better modularity in the future.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agomemory: replace deprecated check_running() call
Fiona Ebner [Mon, 4 Sep 2023 11:39:47 +0000 (13:39 +0200)]
memory: replace deprecated check_running() call

PVE::QemuServer::check_running() does both
PVE::QemuConfig::assert_config_exists_on_node()
PVE::QemuServer::Helpers::vm_running_locally()

The former one isn't needed here when doing hotplug, because the API
already assert that the VM config exists. It also would introduce a
new cyclic dependency between PVE::QemuServer::Memory <->
PVE::QemuConfig with the proposed virtio-mem patch set.

In preparation to remove the cyclic include of PVE::QemuServer in the
memory module.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agomove NUMA-related code into memory module
Fiona Ebner [Mon, 4 Sep 2023 11:39:46 +0000 (13:39 +0200)]
move NUMA-related code into memory module

which is the only user of the parse_numa() helper. While at it, avoid
the duplication of MAX_NUMA.

In preparation to remove the cyclic include of PVE::QemuServer in the
memory module.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agomove parse_number_sets() helper to helpers module
Fiona Ebner [Mon, 4 Sep 2023 11:39:45 +0000 (13:39 +0200)]
move parse_number_sets() helper to helpers module

In preparation to move parse_numa() to the memory module.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agorestore vma: inline one timeout variable and move other closer to usage
Fiona Ebner [Tue, 12 Sep 2023 09:16:17 +0000 (11:16 +0200)]
restore vma: inline one timeout variable and move other closer to usage

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agorestore vma: add comment describing timeout
Fiona Ebner [Tue, 12 Sep 2023 09:16:16 +0000 (11:16 +0200)]
restore vma: add comment describing timeout

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
7 months agofix #2816: restore: remove timeout when allocating disks
Fiona Ebner [Tue, 12 Sep 2023 09:16:15 +0000 (11:16 +0200)]
fix #2816: restore: remove timeout when allocating disks

10 minutes is not long enough when disks are large and/or network
storages are used when preallocation is not disabled. The default is
metadata preallocation for qcow2, so there are still reports of the
issue [0][1]. If allocation really does not finish like the comment
describing the timeout feared, just let the user cancel it.

Also note that when restoring a PBS backup, there is no timeout for
disk allocation, and there don't seem to be any user complaints yet.

The 5 second timeout for receiving the config from vma is kept,
because certain corruptions in the VMA header can lead to the
operation hanging there.

There is no need for the $tmp variable before setting back the old
timeout, because that is at least one second, so we'll always be able
to set the $oldtimeout variable to undef in time in practice.
Currently, there shouldn't even be an outer timeout in the first
place, because the only call path leading to here is via the create
API (also used by qmrestore), both of which don't set a timeout.

[0]: https://forum.proxmox.com/threads/126825/
[1]: https://forum.proxmox.com/threads/128093/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
8 months agodrive: Fix typo in description of efitype
Filip Schauer [Tue, 5 Sep 2023 08:42:31 +0000 (10:42 +0200)]
drive: Fix typo in description of efitype

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
8 months agomemory: use static_memory in foreach_dimm
Alexandre Derumier [Mon, 19 Jun 2023 07:28:34 +0000 (09:28 +0200)]
memory: use static_memory in foreach_dimm

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 months agobump version to 8.0.7
Fiona Ebner [Mon, 21 Aug 2023 09:53:38 +0000 (11:53 +0200)]
bump version to 8.0.7

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
8 months agotests: use valid machine types for snapshot tests
Markus Frank [Wed, 18 Jan 2023 13:57:56 +0000 (14:57 +0100)]
tests: use valid machine types for snapshot tests

In preparation to turn the 'machine' parameter into a property string.

parse_property_string checks for the regex, therefore the test-cases
with 'somemachine' and 'someothermachine' would fail.

To avoid that, replace 'somemachine' and 'someothermachine' with 'q35'
and 'pc' with sed:

sed -i 's/somemachine/q35/g'
sed -i 's/someothermachine/pc/g'

Signed-off-by: Markus Frank <m.frank@proxmox.com>
[FE: improve wording in commit message]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agofix #3963: Skip TPM startup for template VMs
Filip Schauer [Thu, 10 Aug 2023 09:20:36 +0000 (11:20 +0200)]
fix #3963: Skip TPM startup for template VMs

Skip the software TPM startup when starting a template VM for performing
a backup. This fixes an error that occurs when the TPM state disk is
write-protected.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
9 months agocfg2cmd: netdev: fix value for tx_queue_size
Fiona Ebner [Thu, 27 Jul 2023 09:10:01 +0000 (11:10 +0200)]
cfg2cmd: netdev: fix value for tx_queue_size

Quoting from QEMU commit 4271f40383 ("virtio-net: correctly report
maximum tx_queue_size value"):

> Maximum value for tx_queue_size depends on the backend type.
> 1024 for vDPA/vhost-user, 256 for all the others.

> So the parameter is silently ignored and ethtool reports a different
> value than the one provided by the user.

Indeed, for a non-vDPA/vhost-user netdev, the guest will see TX: 256
instead of the specified 1024 here. With the mentioned QEMU commit (in
master and will be part of 8.1), using 1024 will be a hard error:

> Invalid tx_queue_size (= 1024), must be a power of 2 between 256 and 256

Since neither vhost-user, nor vhost-vdpa netdev types are exposed by
Proxmox VE, just changing the limit to the correct 256 should be fine.
No obvious issue during live-migration found.

Fixes: 620d6b32 ("virtio-net: increase defaults rx|tx-queue-size to 1024")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agomigration: alloc nbd disks: fix fall-back for remote live migration
Fiona Ebner [Mon, 17 Jul 2023 14:00:20 +0000 (16:00 +0200)]
migration: alloc nbd disks: fix fall-back for remote live migration

While the comment sated
>    # order of precedence, filtered by whether storage supports it:
>    # 1. explicit requested format
>    # 2. format of current volume
>    # 3. default format of storage

the code did not fall back to the default format in the case of remote
migration, because the format was already set and the code used
> $format //= $defFormat;

This made remote migration from dir with qcow2 to e.g. LVM-thin fail.

Move extracting the format from the volume name to the call side for
local migration. This allows the logic here to be much simpler.

Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agomigration: alloc nbd disks: base format hint off source storage
Fiona Ebner [Mon, 17 Jul 2023 14:00:19 +0000 (16:00 +0200)]
migration: alloc nbd disks: base format hint off source storage

Previously, qemu_img_format() was called with the target storage's
$scfg and the source storage's volume name.

This mismatch should only be relevant for certain special kinds of
storage plugins:
- no path, but does support an additional QEMU image format besides
  'raw', in short NPAF.
- no path, volume name can match QEMU_FORMAT_RE, in short NPVM.

Note that all integrated plugins are neither NPAF nor NPVM.

Note that for NPAF plugins, qemu_img_format() already always returns
'raw' because there is no path. It's a bit unlikely such a plugin
exists, because there were no bug reports about qemu_img_format()
misbehaving there yet.

Let's go through the cases:
- If source and target storage both have or don't have a path,
  qemu_img_format($scfg, $volname) returns the same for both $scfg's.
- If source storage has a path, but target storage does not, the
  format hint was previously 'raw', but can only be more correct now
  (being what the source image actually is):
  - For non-NPAF targets, since we know there is no path, it follows
    that 'raw' is the only supported QEMU image format.
  - For NPAF targets, the format will be preserved now (if actually
    supported).
- If source storage does not have a path, but target storage does, the
  format hint will be 'raw' now.
  - For non-NPVM sources, QEMU_FORMAT_RE didn't match when
    qemu_img_format() was called with the target storage's $scfg, so
    the hint also was 'raw' before this commit.
  - For NPVM sources, qemu_img_format() might've guessed a format from
    the source volume name when called with the target's $scfg before
    this commit. If the target storage supports the previously guessed
    format, it was preserved before this commit, but will not be
    anymore. In theory, the guess might've also been wrong, and in
    this case, this commit avoids the wrong guess.

To summarize, there is only one edge case with an exotic kind of third
party storage plugin where format preservation would be lost and in
another edge case, format preservation is gained.

In preparation to simplify the format fallback logic implementation.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agofix: api: fix permission check for cloudinit drive update
Friedrich Weber [Mon, 13 Mar 2023 12:56:25 +0000 (13:56 +0100)]
fix: api: fix permission check for cloudinit drive update

Trying to regenerate a cloudinit drive as a non-root user via the API
currently throws a Perl error, as reported in the forum [1]. This is
due to a type mismatch in the permission check, where a string is
passed but an array is expected.

[1] https://forum.proxmox.com/threads/regenerate-cloudinit-by-put-api-return-500.124099/

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
9 months agocloudinit: allow non-root users to set ciupgrade option
Friedrich Weber [Mon, 24 Jul 2023 11:33:48 +0000 (13:33 +0200)]
cloudinit: allow non-root users to set ciupgrade option

The new ciupgrade option was missing in $cloudinitoptions in
PVE::API2::Qemu, so $check_vm_modify_config_perm defaulted to
requiring root@pam for modifying the option. To fix this, add
ciupgrade to $cloudinitoptions. This also fixes an issue where
ciupgrade was missing in the output of `qm cloudinit pending`,
as it also relies on $cloudinitoptions.

This issue was originally reported in the forum [0].

Also add a comment to avoid similar issues when adding new options in
the future.

[0]: https://forum.proxmox.com/threads/131043/

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
9 months agofix #4620: cfg2cmd: drive device: correctly handle IDE for q35
Fiona Ebner [Thu, 20 Jul 2023 09:45:02 +0000 (11:45 +0200)]
fix #4620: cfg2cmd: drive device: correctly handle IDE for q35

Only unit 0 for IDE is supported with machine type q35. Currently,
QEMU will fail startup with machine type q35 with an error like
> Can't create IDE unit 1, bus supports only 1 units
when ide1 or ide3 is configured.

Make sure to keep backwards compat form migration by leaving ide0 and
ide2 fixed. Since starting with ide1 or ide3 never worked, they can be
moved to a controller with a higher ID without issue.

Reported in the community forum:
https://forum.proxmox.com/threads/124615/post-543127
https://forum.proxmox.com/threads/130815/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agotest: add tests with multiple IDE CD-ROM drives
Fiona Ebner [Thu, 20 Jul 2023 09:45:01 +0000 (11:45 +0200)]
test: add tests with multiple IDE CD-ROM drives

None of the configured test storages support the content type iso
right now, just add it to cifs-store.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agoupdate_vm_api: properly wrap arguments
Fabian Grünbichler [Wed, 19 Jul 2023 10:22:04 +0000 (12:22 +0200)]
update_vm_api: properly wrap arguments

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
9 months agoapi: update: also check access for currently configured bridge
Fiona Ebner [Mon, 17 Jul 2023 07:15:18 +0000 (09:15 +0200)]
api: update: also check access for currently configured bridge

Relevant when modifying or removing an existing network device.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agoqmeventd: VMID from PID: avoid goto
Fiona Ebner [Mon, 10 Jul 2023 08:53:02 +0000 (10:53 +0200)]
qmeventd: VMID from PID: avoid goto

If strtol() returns an errno, make sure not to print the error message
twice after the refactoring.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agoqmeventd: VMID from PID: don't fail immediately when encountering unexpected entry
Fiona Ebner [Mon, 10 Jul 2023 08:53:01 +0000 (10:53 +0200)]
qmeventd: VMID from PID: don't fail immediately when encountering unexpected entry

While such entries shuoldn't exist in practice without manually
messing around, it's not hard to imagine, and there's still a good
chance the actual VMID can still be found.

It's still unexpected to encounter such entries so keep the log line.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agoqmeventd: further improve getting VMID from PID
Fiona Ebner [Mon, 10 Jul 2023 08:53:00 +0000 (10:53 +0200)]
qmeventd: further improve getting VMID from PID

by also expecting the ".scope" part and trying the next entry if it is
not present instead of immediately failing.

It's still unexpected to encounter such entries, so keep the log line.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agoqmeventd: improve getting VMID from PID in presence of legacy cgroup entries
Fiona Ebner [Mon, 10 Jul 2023 08:52:59 +0000 (10:52 +0200)]
qmeventd: improve getting VMID from PID in presence of legacy cgroup entries

On a hybrid cgroup system, the /proc/<PID>/cgroup file looks like

> 13:pids:/qemu.slice/110.scope
> 12:perf_event:/
> 11:devices:/qemu.slice
> 10:misc:/
> 9:hugetlb:/
> 8:freezer:/
> 7:cpu,cpuacct:/qemu.slice/110.scope
> 6:memory:/qemu.slice/110.scope
> 5:rdma:/
> 4:cpuset:/
> 3:blkio:/qemu.slice
> 2:net_cls,net_prio:/
> 1:name=systemd:/qemu.slice/110.scope
> 0::/qemu.slice/110.scope

but the order doesn't seem to be deterministic, so it can happen that
an entry like '11:devices:/qemu.slice' is the first to match the
'/qemu.slice' part, which previously made the code expect to find the
VMID.

To improve detection, as a first step, match the trailing slash too.

Reported in the community forum:
https://forum.proxmox.com/threads/129320/post-571654

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
10 months agovzdump: pbs: factor out getting and checking encryption keys
Thomas Lamprecht [Thu, 6 Jul 2023 15:42:11 +0000 (17:42 +0200)]
vzdump: pbs: factor out getting and checking encryption keys

factor the common checks for disk-less and "normal" backups out into
its own helper, avoiding code duplication and ensuring that the
messages and checks stay in sync.

The use sites for key and master key are a bit clearer, as it all
just depends on them being defined or not.

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