Commit Graph

3406 Commits

Author SHA1 Message Date
Wolfgang Bumiller
a38204c14b fix #5528: override cgroup methods to call systemd via dbus
Systemd reapplies its known values on reload, so we cannot simply call
into PVE::CGroup. Call systemd's SetUnitProperties method via dbus
instead.

The hotplug and startup code also calculated different values, as one
operated within systemd's value framework (documented in
systemd.resource-control(5)) and one worked with cgroup values
(distinguishing between cgroup v1 and v2 manually).

This is now unified by overriding `change_cpu_quota()` and
`change_cpu_shares()` via `PVE::QemuServer::CGroup` which now takes
systemd-based values and sends those directly via dbus.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-23 08:05:53 +02:00
Thomas Lamprecht
eff31066f7 bump version to 8.2.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 19:42:22 +02:00
Dominik Csapak
e583e372a2 fix #5574: api: fix permission check for 'spice' usb port
With the last change in the permission check, I accidentally broke the
check for 'spice' host value, since in the if/elsif/else this will fall
through to the else case which was only intended for when neither 'host'
nor 'mapping' was set.

This made 'spice' only settable by root@pam since there we return early.

To fix this, move the spice check into the 'host' branch, but only error
out in case it's not spice.

Fixes: e3971865 (enable cluster mapped USB devices for guests)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-07-22 19:37:37 +02:00
Stefan Hanreich
0565f489ff config: net: avoid duplicate ipam entries on nic update
Updating the NIC of a VM when the following conditions were met:
* VM is turned off
* NIC is on a bridge that uses automatic dhcp
* Leave bridge unchanged

led to duplicate IPAM entries for the same network device.

This is due to the fact that the add_next_free_cidr always ran on
applying pending network changes.

Now we only add a new ipam entry if either:
* the value of the bridge or mac address changed
* the network device has been newly added

This way no duplicate IPAM entries should get created.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-07-22 18:38:05 +02:00
Fiona Ebner
1c5001c2e7 bump version to 8.2.2
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-12 16:27:25 +02:00
Dominik Csapak
a06b779489 stop cleanup: remove unnecessary tpmstate cleanup
tpmstate0 is already included in `get_vm_volumes`, and our only storage
plugin that has unmap_volume implemented is the RBDPlugin, where we call
unmap in `deactivate_volume`. So it's already ummapped by the
`deactivate_volumes` calls above.

For third-party storage plugins, it's natural to expect that
deactivate_volume() would also remove a mapping for the volume just
like RBDPlugin does.

While there is an explicit map_volume() call in start_swtpm(), a
third-party plugin might expect an explicit unmap_volume() call too.
However, the order of calls right now is
1. activate_volume()
2. map_volume()
3. deactivate_volume()
4. unmap_volume()

Which seems like it could cause problems already for third-party
plugins relying on an explicit unmap call.

All that said, it is unlikely that a third-party plugin breaks. If it
really happens, it can be discussed/adapted to the actual needs still.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Acked-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-05 10:35:46 +02:00
Fiona Ebner
3de77f7590 cfg2cmd: split out helper for vga properties
To remove some line bloat from the config_to_command() function.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-04 13:54:02 +02:00
Fiona Ebner
1f71de6713 schema: vga: mention that type 'cirrus' should not be used
[0]: https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
[1]: https://lore.kernel.org/qemu-devel/usd6hvncbao47zklcb5qlpvjcuk7odryu57f45imxienyltlec@2ujm6g2gr2od/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-04 13:54:02 +02:00
Fiona Ebner
c06503872d backup: prepare: remove outdated QEMU version check
In Proxmox VE 8, the oldest supported QEMU version is 8.0, so a check
for version 4.0.1 is not required anymore.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-03 15:08:51 +02:00
Fiona Ebner
d0fb8f8239 migration: handle replication: remove outdated and inaccurate check for QEMU version
In Proxmox VE 8, the oldest supported QEMU version is 8.0, so a
check for version 4.2 is not required anymore. The check was also
wrong, because it checked the installed version and not the currently
running one.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-03 15:08:47 +02:00
Fiona Ebner
e30435dc72 api: fix typo reported by perlcritic
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-03 14:49:12 +02:00
Fiona Ebner
326b668718 api: add missing use statements 2024-07-03 14:48:59 +02:00
Fiona Ebner
eb7613a60f autocomplete: backup: also list archives from PBS storages and without compressor extension
While archives with unknown or undetermined subtype could be shown,
this is only for autocompletion, so users can still specify those
manually if required.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-03 14:33:59 +02:00
Fiona Ebner
8964b466ae fix #5572: avoid warning about uninitialized value when cloning cloudinit disk
Some callers like the move disk API endpoint do not pass an explicit
completion argument. This is not an issue in general, because
qemu_drive_mirror_monitor() defaults to 'complete'. However, there was
a string comparision for the cloudinit case that can trigger a warning
about the value being uninitialized.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-03 14:32:34 +02:00
Fabian Grünbichler
a5586eb452 block job: fix log message
this was a stray search and replace for job -> job_id that should have only
changed variable names..

Fixes: 0ea24bf ("mirror monitor: refactoring/code cleanup")

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-07-02 16:08:19 +02:00
Fiona Ebner
da5a20c7c7 live import: do not auto-dismiss stream job to improve error message and detection
upon failure. Otherwise, the job would disappear too quickly from the
job list and cannot be queried for the actual error anymore.

Relevant part of the error in an actual example:

Before:
> VM 106 qmp command 'blockdev-del' failed - Node 'drive-scsi0-restore' is busy: node is used as backing hd of '#block655'

After:
> block job (stream) error: restore-scsi0: No space left on device (io-status: ok)

Note that previously, it was not even detected that the stream job
failed and the error message is because the subsequent cleanup failed.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-02 16:00:24 +02:00
Fiona Ebner
105d135e5a live restore: do not auto-dismiss stream job to improve error message and detection
upon failure. Otherwise, the job would disappear too quickly from the
job list and cannot be queried for the actual error anymore.

Relevant part of the error in an actual example:

Before:
> VM 112 qmp command 'blockdev-del' failed - Node 'drive-scsi0-pbs' is busy: node is used as backing hd of '#block046'

After:
> block job (stream) error: restore-drive-scsi0: No space left on device (io-status: ok)

Note that previously, it was not even detected that the stream job
failed and the error message is because the subsequent cleanup failed.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-02 16:00:24 +02:00
Fiona Ebner
d000846505 mirror: do not auto-dismiss to allow getting error message from job
upon failure. Otherwise, the job would disappear too quickly from the
job list and cannot be queried for the actual error anymore.

Relevant part of the error in actual examples (note that the fact that
it's a mirror job is already mentioned earlier in the full error, with
"block job (mirror) error:"):

Before:
> 'mirror' has been cancelled
> 'mirror' has been cancelled

After:
> Source and target image have different sizes (io-status: ok)
> No space left on device (io-status: ok)

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-02 16:00:24 +02:00
Fiona Ebner
caded41823 blockjob: anticipate jobs with auto-dismiss=false for better error messages and detection
When auto-dismiss=true (the default), a failed job can disappear very
quickly from the job list and there might not be any chance to see the
error in the result of 'query-block-jobs'. For jobs with $completion
being 'auto', like 'block-stream', it couldn't even be detected that
the job failed.

Jobs with auto-dismiss=false on the other hand, will wait in
'concluded' state until manually dismissed. For those, it will be
possible to query the error if the job failed.

There doesn't seem to be a way to have only failed jobs stay around,
e.g. something like auto-dismiss=on-success.

Planned to be used for the 'drive-mirror' and 'block-stream' jobs
initially.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-02 16:00:24 +02:00
Dominik Csapak
3ab3dd55c4 fix #3352: templates: minimize config when starting templates
templates can only be started in context of a pbs backup, and there we
don't need or want to use most of the config, since they cannot be
started normally anyway.

We minimize the config by copying some specific relevant options (see
the comments for why the options were chosen) and all disk
configurations.

Since we change the qemu commandline for templates, we now have to adapt
the tests involving templates.

Without this, users can get into a situation where the template cannot
be backed up when there are some resources not available (such as cpu
cores, kvm, pci devices, etc.) even if the backup process does not need
them.

This change has some nice side effects, such as we don't need to
allocate the full amount of memory anymore for templates that have a
hostpci device configured, the configured bridges don't have to exist,
etc.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-07-01 10:48:27 +02:00
Dominik Csapak
89ca39266d tests: cfg2cmd: add test for templates with more options
during pbs backups, we need to start templates, so add a test for that.
We already have some tests for templates, but none with hostpci,tpm,
etc.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-07-01 10:48:27 +02:00
Fiona Ebner
242a5c6ed1 api: update vm: prohibit changing version of TPM state
After the TPM state has been created (to be precise, initialized by
swtpm) it is not possible to change the version anymore. Doing so will
lead to failure starting the associated VM. While documented in the
description, it's better to enforce this via API.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-01 10:44:25 +02:00
Fiona Ebner
87084b18dd drive: tpm: fix default version in schema
Since the check in start_swtpm() only checks for an explicitly
configured v2.0 to opt-in to version 2, the actual default is v1.2
and not v2.0 like the schema stated.

Of course, it would be nicer to have the default be v2.0, but changing
the check to use that default would break any TPM state without an
explicitly configured version.

There doesn't seem to be any code beside start_swtpm() accessing the
version.

Fixes: f9dde219 ("fix #3075: add TPM v1.2 and v2.0 support via swtpm")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-01 10:37:48 +02:00
Fiona Ebner
6ee6046ef2 fix #5562: tpm: avoid warning about undefined value when version is not explicitly set
Fixes: f9dde219 ("fix #3075: add TPM v1.2 and v2.0 support via swtpm")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-01 10:37:37 +02:00
Fiona Ebner
581b678320 vma restore: bump timeout for reading header
With high IO pressure, 5 seconds might not be enough, even if the
request is small.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-18 17:48:45 +02:00
Fiona Ebner
4e06882ba5 vma restore: improve timeout error messages
The generic "got timeout" message cannot be associated to a certain
code path and also isn't very user-friendly. Use dedicated messages
for each stage and also suggest why the timeout for reading the header
might have happened, i.e. because it was corrupted.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-18 17:48:45 +02:00
Fiona Ebner
daf64a27b9 fix #5440: hmp helpers: drive{add, del}: increase timeout
The default timeout for HMP commands is 5 seconds.

While it should be rather fast to attach a new drive to QEMU, a busy
system might take longer, so future-proof and increase to 60 seconds.

On the other hand, detaching a drive needs to complete any pending IO
on it, so use the same 10 minutes timeout that's used for
drive-related QMP commands.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-11 13:56:44 +02:00
Fiona Ebner
990e32ff1b cli: qm: increase timeout for monitor commands to 30 seconds
The default timeout is 5 seconds, but some HMP commands (e.g.
disk-related ones) might take longer than that. It's still an
interactive session, so use 30 seconds for now. Should there be any
user-complains about frequent timeouts, it could still be increased
further.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-11 13:56:44 +02:00
Fiona Ebner
3281138ab7 vzdump: increase timeout for attaching drives to 60 seconds
The default timeout for HMP commands is 5 seconds and while it should
be rather fast to attach a new drive to QEMU, a system can be very
busy during backup, so future-proof and increase to 60 seconds.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-11 13:56:44 +02:00
Fiona Ebner
a0541b7149 api: human monitor: increase timeout to 25 seconds
The default timeout is 5 seconds, but some HMP commands (e.g.
disk-related ones) might take longer than that. The API call is
synchronous, so has to complete within 30 seconds, and since there is
no other costly operation, use 25 seconds.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-11 13:56:44 +02:00
Fiona Ebner
4ee69c54f6 monitor: allow passing timeout for a HMP command
Passing the timeout key with an explicit value of undef is fine,
because both the absence of the timeout key and an explicit value of
undef will lead to $timeout being undef in the qmp_cmd() function.

In preparation to increase the timeout for certain (e.g. disk-related)
HMP commands.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-11 13:56:44 +02:00
Fiona Ebner
46e0b1eb62 migration: add missing use statements
There's functions from all of those being used, but without importing
first.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-05-23 10:52:18 +02:00
Fiona Ebner
c799e40fbf suspend: continue cleanup even if savevm-end QMP command fails
The savevm-end command also fails when no snapshot operation was
started before. In particular, this is the case when savevm-start
failed early, because of unmigratable devices.

Avoid potentially leaving an orphaned volume and snasphot-related
configuration keys around by continuing with cleanup instead.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-05-15 19:37:22 +02:00
Thomas Lamprecht
88e18f9c5d d/control: bump versioned dependency for guest-common
To ensure schema is correct for being validated properly.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-05-15 19:26:59 +02:00
Fabian Grünbichler
44da74c5ce remote migration: enable schema validation
by wrapping the properties from the command definition to get an
actual schema definition.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-05-15 19:26:35 +02:00
Fiona Ebner
ce8a5a4b7e schema: fix description of migrate_downtime parameter
Since commit 865ef132 ("implement dynamic migration_downtime") the
migration downtime will be automatically increased when migration
cannot converge at the very end. Update the description to reflect
reality.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-05-03 19:32:45 +02:00
Thomas Lamprecht
54aa98cea5 bump version to 8.2.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 11:49:08 +02:00
Filip Schauer
67dca4238b cpu config: fix get_cpu_bitness always reverting to default cpu type
This fixes the broken prevention of starting a VM with a 32-bit CPU
using a 64-bit OVMF (UEFI) BIOS.

Fixes: 89d5b1c9 ("prevent starting a 32-bit VM using a 64-bit OVMF BIOS")
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
[FE: add Fixes trailer, add prefix to title]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-04-24 11:37:28 +02:00
Thomas Lamprecht
c82cb51590 d/copyright: update years
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 17:18:30 +02:00
Thomas Lamprecht
ed9956cced bump version to 8.2.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 17:10:06 +02:00
Fiona Ebner
81a8c4e5ee qmeventd: also treat 'prelaunch' and 'suspended' states as active
Otherwise, a VM in those states would be terminated after a backup
in handle_qmp_return() with QMP 'quit', which is pretty bad in case
of the 'suspended' state.

Does not change the fact that a VM started in prelaunch mode for
backup is terminated later (that is handled by the Perl code).

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-04-23 16:46:20 +02:00
Thomas Lamprecht
6ba1f1c0c3 os type: add Windows Server 2025 as supported with win11 type
Martin tested the 2025 preview and it worked fine  using the win11 OS
type.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-20 16:19:17 +02:00
Thomas Lamprecht
0089920f42 bump version to 8.1.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-20 12:28:39 +02:00
Thomas Lamprecht
43569a32ae api: create vm: fix missing import for serializing machine type
The machine handling was transformed into a full fledged property
string with a (sub) format, but the single call-site for print_machine
was seemingly not tested, as this could have never worked due to a
missing import of the print_property_string helper.

Fixes: 8082eb8 ("config: define machine schema as property-string")
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-20 12:27:30 +02:00
Thomas Lamprecht
e2c1459968 bump version to 8.1.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-19 20:32:51 +02:00
Thomas Lamprecht
21e3a39e48 d/control: bump versioned pve-firewall dependency
to ensure the is_nftables helper is available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-19 20:11:56 +02:00
Stefan Hanreich
29728dbf83 firewall: add handling for new nft firewall
When the nftables firewall is enabled, we do not need to create
firewall bridges.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [ TL: use a more meaningful variable name and add a comment ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-19 20:09:20 +02:00
Fiona Ebner
4c042b2802 bump version to 8.1.2
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-04-19 16:47:54 +02:00
Fiona Ebner
5d85728282 backup: implement fleecing option
Management for fleecing images is implemented here. If the fleecing
option is set, for each disk (except EFI disk and TPM state) a new
fleecing image is allocated on the configured fleecing storage (same
storage as original disk by default). The disk is attached to QEMU
with the 'size' parameter, because the block node in QEMU has to be
the exact same size and the newly allocated image might be bigger if
the storage has a coarser allocation or rounded up. After backup, the
disks are detached and removed from the storage.

If the storage supports qcow2, use that as the fleecing image format.
This allows saving some space even on storages that do not properly
support discard, like, for example, older versions of NFS.

Since there can be multiple volumes with the same volume name on
different storages, the fleecing image's name cannot be just based on
the original volume's name. The schema vm-ID-fleece-N(.FORMAT) with N
incrementing for each disk is used.

Partially inspired by the existing handling of the TPM state image
during backup.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-04-19 15:47:42 +02:00
Fiona Ebner
36377acfbd backup: disk info: also keep track of size
which will be needed to allocate fleecing images.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-04-19 15:47:42 +02:00