Commit Graph

1383 Commits

Author SHA1 Message Date
Thomas Lamprecht
d6deb7f6bb move helper to check bridge access out of api
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-08 17:50:50 +02:00
Fiona Ebner
d62bdac593 fast plug options: add migrate_downtime and migrate_speed
for convenience. These options do not influence the QEMU instance
directly, but are only used for migration, so no need to keep them in
pending.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-07 18:37:51 +02:00
Fiona Ebner
f68910a05f fast plug options: order alphabetically
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-07 18:37:51 +02:00
Leo Nunner
efa3355d3b fix #3428: cloudinit: add parameter for upgrade on boot
up until now, we did an automatic upgrade after the first boot in our
standard cloud-init config. This has been requested to be toggleable
several times [1][2]. With this patch, "package_upgrade" is disabled by
default, and needs to be enabled manually, diverging from the previous
behaviour.

[1] https://forum.proxmox.com/threads/how-to-prevent-automatic-apt-upgrade-during-the-first-boot-with-cloud-init.68472/
[2] https://forum.proxmox.com/threads/cloud-init-ohne-package-upgrade.123841/

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
2023-06-07 18:25:46 +02:00
Fiona Ebner
bda7ccb1c9 schema: avoid using deprecated -no-hpet in example for 'args' property
instead use a recent example that served as a workaround in #4625.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 17:35:41 +02:00
Fiona Ebner
17bacc2182 cfg2cmd: replace deprecated no-hpet option with hpet=off machine flag
like the deprecation message printed by QEMU suggests.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 17:35:41 +02:00
Fiona Ebner
0f704640be cfg2cmd: replace deprecated no-acpi option with acpi=off machine flag
like the deprecation message printed by QEMU suggests.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 17:35:41 +02:00
Fiona Ebner
e35eb8766b cfg2cmd: use actual backend names instead of removed tty and paraport aliases
As described in:
https://qemu-project.gitlab.io/qemu/about/removed-features.html#chardev-backend-aliases-tty-and-parport-removed-in-8-0

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 17:35:41 +02:00
Fiona Ebner
2e4357c537 block resize: avoid passing zero size to QMP command
Commit 7246e8f9 ("Set zero $size and continue if volume_resize()
returns false") mentions that this is needed for "some storages with
backing block devices to do online resize" and since this patch came
together [0] with pve-storage commit a4aee43 ("Fix RBD resize with
krbd option enabled."), it's safe to assume that RBD with krbd is
meant. But it should be the same situation for any external plugin
relying on the same behavior.

Other storages backed by block devices like LVM(-thin) and ZFS return
1 and the new size respectively, and the code is older than the above
mentioned commits. So really, the RBD plugin just should have returned
a positive value to be in-line with those and there should be no need
to pass 0 to the block_resize QMP command either.

Actually, it's a hack, because the block_resize QMP command does not
actually do special handling for the value 0. It's just that in the
case of a block device, QEMU won't try to resize it (and not fail for
shrinkage). But the size in the raw driver's BlockDriverState is
temporarily set to 0 (which is not nice), until the sector count is
refreshed, where raw_co_getlength is called, which queries the new
size and sets the size in the raw driver's BlockDriverState again as a
side effect. It's not known to cause any issues, but bdrv_getlength is
a coroutine wrapper starting from QEMU 8.0.0, and it's just better to
avoid setting a completely wrong value even temporarily. Just pass the
actually requested size like is done for LVM(thin) and ZFS.

[0]: https://lists.proxmox.com/pipermail/pve-devel/2017-January/025060.html

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-06 19:42:16 +02:00
Christian Ebner
bb547dcbd6 net: Skip and warn of interfaces without bridge
Handle and warn about network interfaces which are not attached to
any bridge because the user actively removed it from the VM config.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2023-06-06 18:26:27 +02:00
Fiona Ebner
e4263214b8 disable SMM check: always return false for virt machine type
There is no 'smm' flag for the 'virt' machine type.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-05-15 11:09:33 +02:00
Fiona Ebner
efa3aa2496 avoid list context for volume_size_info calls
With the recent pve-storage commit d70d814 ("api: fix get content call response
type for RBD/ZFS/iSCSI volumes"), the volume_size_info call for RBD in
list context is much slower than before (from a quick test, about twice as long
without snapshots, even longer with snapshots and untested, but when using an
external cluster with image not having the fast-diff feature, it should be worse
still) and thus increases the likelihood to run into timeouts here.

None of the callers here actually need the more expensive call, so just
avoid calling in list context.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-03-21 10:37:40 +01:00
Dominik Csapak
49c51a60db pci: workaround nvidia driver issue on mdev cleanup
in some nvidia grid drivers (e.g. 14.4 and 15.x), their kernel module
tries to clean up the mdev device when the vm is shutdown and if it
cannot do that (e.g. becaues we already cleaned it up), their removal
process cancels with an error such that the vgpu does still exist inside
their book-keeping, but can't be used/recreated/freed until a reboot.

since there seems no obvious way to detect if thats the case besides
either parsing dmesg (which is racy), or the nvidia kernel module
version(which i'd rather not do), we simply test the pci device vendor
for nvidia and add a 10s sleep. that should give the driver enough time
to clean up and we will not find the path anymore and skip the cleanup.

This way, it works with both the newer and older versions of the driver
(some of the older drivers are LTS releases, so they're still
supported).

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-03-16 09:08:34 +01:00
Dominik Csapak
c8bd54e9a8 fix #4553: nvidia vgpu: reuse smbios uuid for '-uuid' parameter
instead of using the mdev uuid. The nvidia driver does not actually care
that it's the same as the mdev, and in qemu the uuid parameter
overwrites the smbios1 uuid internally, so we should have been reusing
that in the first place.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-03-16 09:08:27 +01:00
Fiona Ebner
79f5ca393a clone: remove outdated TODO about bandwidth limit
Respecting bandwidth limit for offline clone was implemented by commit
56d16f16 ("fix #4249: make image clone or conversion respect bandwidth
limit"). It's still not respected for EFI disks, but those are small,
so just ignore it.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-24 08:56:28 +01:00
Leo Nunner
56d16f169c fix #4249: make image clone or conversion respect bandwidth limit
Previously, cloning a stopped VM didn't respect bwlimit. Passing the -r
(ratelimit) parameter to qemu-img convert fixes this issue.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
 [ T: reword subject line slightly ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-23 17:09:51 +01:00
Alexandre Derumier
62fdcfd4cf update network dev: MTU is not hot-pluggable
Avoid pretending that a MTU change on a existing network device gets
applied live to a running VM.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
 [ T: reworded and expanded commit message slightly ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-23 16:37:34 +01:00
Christoph Heiss
93e21fd230 vzdump: Add VM QGA option to skip fs-freeze/-thaw on backup
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-02-23 16:34:10 +01:00
Matthias Heiserer
1183c8f1a0 ovmf efi disk: ignore efitype parameter for ARM VMs
Required because there's one single efi for ARM, and the 2m/4m
difference doesn't seem to apply.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
 [ T: move description to format and reword subject ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-23 16:29:57 +01:00
Fiona Ebner
72a5a17610 swtpm: use start time as prefix for logging
to be able to distinguish different invocations.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-23 12:53:25 +01:00
Fiona Ebner
b2e9c4d322 swtpm: enable logging
AFAICT, previously, errors from swtpm would not show up in any logs,
because they were just printed to the stderr of the daemonized
invocation here.

The 'truncate' option is not used, so that the log is not immediately
lost when a new instance is started. This increases the chance that
the relevant errors are still present when requesting the log from a
user.

Log level 1 contains the most relevant errors and seems to be quiet
for working-as-expected invocations. Log level 2 already includes
logging full TPM commands, some of which are 1024 bytes long. Thus,
log level 1 was chosen.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-23 12:53:25 +01:00
Fiona Ebner
cb64a64339 start: make not being able to set polling interval for ballooning non-critical
The guest will be running, so it's misleading to fail the start task
here. Also ensures that we clean up the hibernation state upon resume
even if there is an error here, which did not happen previously[0].

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

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-23 11:42:40 +01:00
Alexandre Derumier
dafb728cb8 memory: remove calls to parse_hotplug_features
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
[FE: style: avoid overly long lines]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-15 14:34:25 +01:00
Fiona Ebner
8fbae1dc8f fix #4525: clone disk: disallow mirror if it might cause problems with io_uring
The target of the drive-mirror operation is opened with (essentially)
the same flags as the source in QEMU, in particular whether io_uring
should be used is inherited.

But io_uring currently causes problems in combination with certain
storage types, sometimes even leading to crashes (LVM with Linux 6.1).
Just disallow live cloning of drives when the source uses io_uring and
the target storage is not ready for it. There is one exception, namely
when source and target storage are the same. In that case, just assume
it will keep working for the target.

Migration does not seem to be affected, because there, the target VM
opens the images with the checked aio setting and then NBD exports of
those are used as the targets for mirroring.

It can be that the default determined for the source is not what's
actually used, because after a drive-mirror to a storage with a
different default, it will still use the default from the old storage.
Unfortunately, aio doesn't seem to be part of the 'query-block' QMP
command's result, so just tolerate this edge case.

The check can be removed if either
1. drive-mirror learns to open the target with a different aio setting
or more ideally
2. there are no more bad storages for io_uring.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-14 10:09:04 +01:00
Fiona Ebner
b7071d6c00 drive commandline: factor out determining direct cache usage into helper
In preparation to re-use it for a check for live disk cloning.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-14 10:09:04 +01:00
Fiona Ebner
eec9f9fe00 drive commandline: factor out checks if io_uring is allowed by default
while getting rid of the double negation.

In preparation to re-use the check for live disk cloning.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-14 10:09:04 +01:00
Fiona Ebner
ea7c3b39b2 hotplug: disk: mark aio as non-hotpluggable
Previously, changing aio would be applied to the configuration, but
the drive would still be using the old setting.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-02-14 10:09:04 +01:00
Alexandre Derumier
39c074fe23 qemu_memory_hotplug: remove unused $opt arg
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-02-03 11:23:47 +01:00
Thomas Lamprecht
ea0bc51427 schema: OS type: note that the l26 type is also compatible with Linux 6.x
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-30 11:02:53 +01:00
Fiona Ebner
252e2624dc schema: memory: be precise that unit is binary prefix
In the web UI, this was fixed years ago by pve-manager commit c11c4a40
("fix #1631: change units to binary prefix").

Quickly checked with the 'query-memory-size-summary' QMP command that
this is actually the case.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-01-24 17:09:52 +01:00
Thomas Lamprecht
eba285f594 cloud init schema: fix indentation and overly long wording
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-19 11:57:06 +01:00
Noel Ullreich
f78c9b6b44 fix #4378: standardized error for ovmf files
The error messages for missing OVMF_CODE and OVMF_VARS files were
inconsistent as well as the error for the missing base var file not
telling you the expected path.

Signed-off-by: Noel Ullreich <n.ullreich@proxmox.com>
2023-01-18 11:03:11 +01:00
Thomas Lamprecht
4044ae1fc3 vm start: fix code style for balloon enabling
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-16 13:46:29 +01:00
Fiona Ebner
83f04be3d5 migration: nbd export: switch away from deprecated QMP command
The 'nbd-server-add' QMP command has been deprecated since QEMU 5.2 in
favor of a more general 'block-export-add'.

When using 'nbd-server-add', QEMU internally converts the parameters
and calls blk_exp_add() which is also used by 'block-export-add'. It
does one more thing, namely calling nbd_export_set_on_eject_blk() to
auto-remove the export from the server when the backing drive goes
away. But that behavior is not needed in our case, stopping the NBD
server removes the exports anyways.

It was checked with a debugger that the parameters to blk_exp_add()
are still the same after this change. Well, the block node names are
autogenerated and not consistent across invocations.

The alternative to using 'query-block' would be specifying a
predictable 'node-name' for our '-drive' commandline. It's not that
difficult for this use case, but in general one needs to be careful
(e.g. it can't be specified for an empty CD drive, but would need to
be set when inserting a CD later). Querying the actual 'node-name'
seemed a bit more future-proof.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-01-13 14:04:39 +01:00
Thomas Lamprecht
c3d151080a cdrom path: code reduction
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-01-13 13:52:39 +01:00
Stefan Sterz
490b730854 cd rom handling: refactor cd rom path helper function
to stop returning results of assignments

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-01-13 13:20:35 +01:00
Stefan Sterz
259470ee41 cd rom handling: return a clearer error when there is no cd rom drive
when a vm is configured to use a physical cd rom drive but there is no
such drive a cryptic "uninitialized value" error is thrown. this is
due to `$path` being undefined in `sub print_drive_commandline_full`.
warn that no cd rom drive is available instead.

note that the error was cosmetic as the vm would start just fine.

forum thread: https://forum.proxmox.com/threads/119592/

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-01-13 13:20:35 +01:00
Stefan Hanreich
30fdf99cff fix #4358: destroy_vm: Ignore 'suspended' lock when destroying VM
Since we can now differentiate between 'suspended' and 'suspending',
it is possible to ignore the 'suspended' lock when destroying a VM.
It shouldn't matter whether the VM is locked because of hibernation
when you want to remove it. Therefore we can safely ignore the lock.
2023-01-11 10:59:32 +01:00
Fiona Ebner
b3a3e92962 fix #4435: devices list: avoid error for undefined value
When $d->{'pci_bridge'}->{devices} is undef, @-dereferencing it will
die with:
> Can't use an undefined value as an ARRAY reference

This can happen (at least) when the VM is in 'prelaunch' state. The
QAPI definition for '@PciBridgeInfo' also declares the 'devices'
member as optional.

Before commit 721624b ("collect device list for nested pci-bridges"),
there was no issue, because $d->{'pci_bridge'}->{devices} was used in
foreach, so auto-vivified if undef.

Fixes: f721624b ("collect device list for nested pci-bridges")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-01-11 10:14:44 +01:00
Fiona Ebner
7bd9abd243 tree-wide: switch to official spelling of QEMU in descriptions/messages
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-12-20 10:26:41 +01:00
Thomas Lamprecht
3d07669cf1 ovmf cmd assembly: rework now that it's in a separate method
We can now do a few things that would be not really possible, or at
least mess with readability when this was still mostly inline
config2command, shaves of quite a few lines of code.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-12-12 11:43:19 +01:00
Thomas Lamprecht
2ceb59d4b1 ovmf cmd assembly: reorder arguments
in preparation of reworking the new separate method for OVMF cmd
assembly, do this in a separate very targeted commit to make it more
clear that the next reworking-commit doesn't messes with our tests at
all.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-12-12 11:41:50 +01:00
Fiona Ebner
b7d80c7905 cfg2cmd: factor out ovmf drives printing
No functional change is intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-12-06 16:56:30 +01:00
Fabian Grünbichler
ad9e347c46 fix #4372: fix vm_resume migration callback
the fix for the recently introduced requirement of loading the VM config while
migrating was incomplete, since the vmlist node value could already be out of
date by the time load_config is called.

extend the fallback behaviour even further, by doing the following sequence:
- try regular load_config (likely case, rename already fully processed)
- if it fails, get node from vmlist, and load_config using that
- it that fails, invalidate the PVE::Cluster cache, retry regular load_config

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-11-30 16:21:39 +01:00
Fabian Grünbichler
a20dc58a1b explain 'nocheck' in more places
was only explained in git history and vm_stop, add comments in other
relevant places to avoid future breakage.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-11-21 13:42:52 +01:00
Fabian Grünbichler
270bfff2e1 vm_resume: fix nocheck/migrate handling
it's not deterministic whether the rename/move of the VM config
triggered on the source side of a migration is already visible on the
target side when vm_resume is executed. check the vmlist for the node
where the config is currently located if $nocheck is set - it is now
needed to add the forwarding DB entries to the bridge.

this fixes an issue on busier or slower clusters, where pmxcfs hasn't
yet processed the rename, and resuming would fail with an error about
the config not existing.

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

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-11-21 13:42:52 +01:00
Thomas Lamprecht
fe62da4f97 fdb: only manage FDB entries for Linux bridges for now
we need to handle OVS setups differently, so for now just ignore it
there (behavior as it was in 7.2)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-20 16:03:45 +01:00
Thomas Lamprecht
f81c9843c3 fdb: pull out bridge variable
no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-20 16:03:17 +01:00
Fabian Grünbichler
eef93bc590 migrate: add remote migration handling
remote migration uses a websocket connection to a task worker running on
the target node instead of commands via SSH to control the migration.
this websocket tunnel is started earlier than the SSH tunnel, and allows
adding UNIX-socket forwarding over additional websocket connections
on-demand.

the main differences to regular intra-cluster migration are:
- source VM config and disks are only removed upon request via --delete
- shared storages are treated like local storages, since we can't
assume they are shared across clusters (with potentical to extend this
by marking storages as shared)
- NBD migrated disks are explicitly pre-allocated on the target node via
tunnel command before starting the target VM instance
- in addition to storages, network bridges and the VMID itself is
transformed via a user defined mapping
- all commands and migration data streams are sent via a WS tunnel proxy
- pending changes and snapshots are discarded on the target side (for
  the time being)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-11-17 15:21:39 +01:00
Fabian Grünbichler
05b2a4ae9c migrate: refactor remote VM/tunnel start
no semantic changes intended, except for:
- no longer passing the main migration UNIX socket to SSH twice for
forwarding
- dropping the 'unix:' prefix in start_remote_tunnel's timeout error message

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-11-17 15:21:39 +01:00