Commit Graph

2769 Commits

Author SHA1 Message Date
Thomas Lamprecht
c21013ac58 bump version to 7.0-17
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-21 11:58:18 +02:00
Thomas Lamprecht
5a08fb9c8b config properties: refactor skipping internal options to declarative
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-21 08:23:11 +02:00
Thomas Lamprecht
3d0ee5d41c tests: fixup simple1-template.conf.cmd
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-20 18:18:31 +02:00
Thomas Lamprecht
3326ae19de code and indentation cleanups
fix the classic indentation error on `additionalProperties` in the
main QEMU API

drop some not so useful empty lines to avoid making rather huge
methods even bigger (more intimidating, less on screen to grasp the
full picture).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-20 17:31:45 +02:00
Thomas Lamprecht
fa3b3ce067 config2cmd: code cleanup and indentation reduction
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-20 15:39:20 +02:00
Thomas Lamprecht
483ceeabef indentation and fixes
with some style/tw thrown in-between

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-20 12:56:59 +02:00
Thomas Lamprecht
8d88a59433 fix overly long/short lines and typos
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-20 08:24:08 +02:00
Stefan Reiter
179b9f1ba5 ostype: support Windows 11/Server 2022
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-10-18 09:53:44 +02:00
Thomas Lamprecht
2c29655663 Revert "config_aware_timeout: add 5s if TPM is configured"
This reverts commit d4e1e1f862.

It's bogus, the VM start timeout is only starting to tick after we
started the TPM already...
2021-10-18 09:47:42 +02:00
Thomas Lamprecht
d4e1e1f862 config_aware_timeout: add 5s if TPM is configured
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-18 09:43:46 +02:00
Thomas Lamprecht
90c41bac8f swtmp: die early in startup check
no point in waiting another 50 ms if we know that we'd die already
anyway..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-18 09:43:46 +02:00
Thomas Lamprecht
6bbcd71f94 code style: readability cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-18 09:43:46 +02:00
Stefan Reiter
f85951dc82 swtpm: wait for pidfile
swtpm may take a little bit to daemonize, so the pidfile might not be
available right after run_command. Causes an ugly warning about using an
undefined value in a match, so wait up to 5s for it to appear.

Note that in testing this loop only ever got to the first or second
iteration, so I believe the timeout duration should be more than enough.

Also add a missing 'usleep' import, 'usleep' was used before but never
imported, apparently the other case never got triggered...

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-10-18 09:43:46 +02:00
Stefan Reiter
9d83932d7c snapshot: fix tpmstate with rbd
QEMU doesn't know about the tpmstate, so 'do_snapshots_with_qemu' should
never return true in that case. Note that inconsistencies related to
snapshot timing do not matter much, as the actual TPM data is exported
together with other device state by QEMU anyway.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-10-18 09:43:45 +02:00
Thomas Lamprecht
212220a4fa vm_start: better name systemd scope property variable
`properties` is a bit ambiguous and as we have scope and start
runtime properties in the same scope it's good to avoid that
ambiguity.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-18 09:43:45 +02:00
Thomas Lamprecht
c077cc166e cloudinit: opennebula: refactor to reduce code bloat
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Thomas Lamprecht
2eee6748a0 cloudinit: better use of string variable interpolation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Thomas Lamprecht
d01de38cb6 pci: prepare: improve no-IOMMU error message
give some context

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Dominik Csapak
1fb1822ec9 fix #3258: block vm start when pci device is already in use
on vm start, we reserve all pciids that we use, and
remove the reservation again in vm_stop_cleanup

first with only a time-based reservation but after the vm is started,
we reserve again but with the pid.

for this, we have to move the start_timeout calculation above the
hostpci handling.

also moved the pci initialization out of the conf parsing loop
so that we can reserve all ids before we actually touch any of them

while touching the lines, fix the indentation

this way, when a vm starts with a pci device that is already configured
for a different running vm, will not be started and the user gets
the error that the device is already in use

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Thomas Lamprecht
a01593676c pci reservation: rework helpers style and readability wise
both style and readability are naturally subjective to a certain
degree...

Also, this patch mixes a bit much into one thing, but splitting that
up would mean lots of work I just wanted to avoid, sorry about that.

Among other things:

- avoid a level of indentation in the reserve loop
- rename pciids to reservation_list where it was a better fit
- make reserve set either pid or time to avoid suggesting that we
  save both
- rename parameters to requested/dropped IDs for easier understanding
  what's going on in the code
- avoid old_pid/pid, use running_pid and reserver_pid instead to
  clarify what they actually mean
- drop useless returns to avoid suggesting the return value has any
  use and save some lnes
- use a hash slice to delete all dropped IDs at once, shorter and
  faster
- use 5 second timeout for reservation, this does nothing intensive
  nor does it wait for anything, so the critical section should be
  really short, 5s is really long enough for a wait..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Thomas Lamprecht
bda0ebff2d pci reservation: move lock/reservation file into /run/qemu-server
lck needs to die, the days of any 8.3 file naming schemes are long
gone (in the server space that is ;)

/var/run is /run so use the shorter, and while /var/lock is a OK
place for the locks we try to keep lock and lock-object together
nowadays. The qemu-server sub-directory avoids overly cluttering the
already crowded top-level /run dir

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 18:17:34 +02:00
Thomas Lamprecht
cda95d5223 pci reservation: encode locklessness of parsers in name
to avoid that they're misused

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 14:44:50 +02:00
Dominik Csapak
3bfee796f4 pci: add helpers to (un)reserve pciids for a vm
saves a list of pciid <-> vmid mappings in /var/run
that we can check when we start a vm

if we're not given a pid but a timeout, we save the time when the
reservation will run out (current time + timeout + 5s) since each
vm start (until we can save the pid) varies from config to config

reserve_pci_usage and remove_pci_reservation always expect a list of ids
so that we can update the reservation for a vm all at once

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-10-11 09:07:52 +02:00
Thomas Lamprecht
71cb8e0f87 pci related code cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-11 08:39:28 +02:00
Thomas Lamprecht
e2b42bee6d pci: use local helper to generated generate_mdev_uuid
avoid (API) leaking qemu-server specific stuff into pve-common

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-11 08:38:28 +02:00
Thomas Lamprecht
82712fcd3c pci: prepare_pci_device: fixup parameter name
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-11 08:37:35 +02:00
Dominik Csapak
acd4b77745 pci: refactor pci device preparation
makes the vm start a bit less crowded

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-10-08 06:27:19 +02:00
Thomas Lamprecht
96a3f51f8d bump version to 7.0-16
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 20:22:22 +02:00
Thomas Lamprecht
39c55c8f6e tests: cfg2cmd: add 4MB-EFI-secboot and TPM test
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 20:20:51 +02:00
Thomas Lamprecht
a064e5117f efi: use vendor-agonstic "pre-enrolled-keys" + description fix
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 18:35:25 +02:00
Thomas Lamprecht
6881de41a4 d/control: bump versioned dependency on pve-edk2-firmware 3.20210831-1
to ensure the newer OVMF 4MB builds with secureboot/SMM-enforcement
are available.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 18:09:48 +02:00
Stefan Reiter
b5099b4f6c ovmf: support secure boot with 4m and 4m-ms efidisk types
Provide support for secure boot by using the new "4m" and "4m-ms"
variants of the OVMF code/vars templates. This is specified on the
efidisk via the 'efitype' and 'ms-keys' parameters.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-10-05 18:04:03 +02:00
Dominik Csapak
a4d5b84c9c pci: to not capture first group in PCIRE
we do not need this group, but want to use the regex where we have
multiple groups, so make it a non-capture group

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-10-05 16:14:42 +02:00
Thomas Lamprecht
759dd88a38 bump version to 7.0-15
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 07:25:22 +02:00
Thomas Lamprecht
6b8c4311bf d/control: add dependency for swtpm and swtpm-tools
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 07:09:24 +02:00
Thomas Lamprecht
16b7bc2659 d/control: wrap-and-sort -tkn
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 07:08:32 +02:00
Thomas Lamprecht
132683274a start: warn about terminating the swtpm instance
if only to notice the user about the PID if the termination fails

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 07:05:42 +02:00
Thomas Lamprecht
2b9ee9441a trivial: indentation/formatting fixup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 07:05:07 +02:00
Stefan Reiter
f9dde219f2 fix #3075: add TPM v1.2 and v2.0 support via swtpm
Starts an instance of swtpm per VM in it's systemd scope, it will
terminate by itself if the VM exits, or be terminated manually if
startup fails.

Before first use, a TPM state is created via swtpm_setup. State is
stored in a 'tpmstate0' volume, treated much the same way as an efidisk.

It is migrated 'offline', the important part here is the creation of the
target volume, the actual data transfer happens via the QEMU device
state migration process.

Move-disk can only work offline, as the disk is not registered with
QEMU, so 'drive-mirror' wouldn't work. swtpm itself has no method of
moving a backing storage at runtime.

For backups, a bit of a workaround is necessary (this may later be
replaced by NBD support in swtpm): During the backup, we attach the
backing file of the TPM as a read-only drive to QEMU, so our backup
code can detect it as a block device and back it up as such, while
ensuring consistency with the rest of disk state ("snapshot" semantic).

The name for the ephemeral drive is specifically chosen as
'drive-tpmstate0-backup', diverging from our usual naming scheme with
the '-backup' suffix, to avoid it ever being treated as a regular drive
from the rest of the stack in case it gets left over after a backup for
some reason (shouldn't happen).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-10-05 06:51:02 +02:00
Fabian Grünbichler
d2ceac56b5 api: template: invert lock and fork
like for other API calls, repeat the cheap checks done for early abort
before forking and without locks after forking and obtaining the lock,
and only hold the flock in the forked worker instead of across the fork.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2021-10-04 09:46:57 +02:00
Fabian Grünbichler
b297918ce2 api: return UPID in template call
as reported on the forum, this is currently missing, making status
queries via the API impossible:

https://forum.proxmox.com/threads/create-vm-via-api-interface.95942/#post-416084

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2021-10-04 09:46:52 +02:00
Fabian Grünbichler
3e07c6d54b vm_destroy: remove pending volumes as well
if a volume is only referenced in the pending section of a config it was
previously not removed when removing the VM, unless the non-default
'remove unreferenced disks' option was enabled.

keeping track of volume IDs which we attempt to remove gets rid of false
warnings in case a volume is referenced both in the config and the
pending section, or multiple times in the config for other reasons.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-09-30 17:37:27 +02:00
Thomas Lamprecht
243af50d49 bump version to 7.0-14
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-22 09:32:25 +02:00
Thomas Lamprecht
f8830c4d6e migrate: code style, use up to 100cc if it helps to reduce line-bloat
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-22 09:26:18 +02:00
Thomas Lamprecht
95b3583b5e migrate: simplify code and add comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-22 09:25:53 +02:00
Fabian Ebner
d213ba299d migrate: use correct target storage id for checks
The '--targetstorage' parameter does not apply to shared storages.

Example for a problem solved with the enabled check: Given a VM with
images only on a shared storage 'storeA', not available on the target
node (i.e. restricted by the nodes property). Then using
'--targetstorage storeB' would make offline migration suddenly
"work", but of course the disks would not be accessible and then
trying to migrate back would fail...

Example for a problem solved with the content type check: if a
VM had a shared ISO image, and there was a '--targetstorage storeA'
option, availablity of the 'iso' content type is checked for
'storeA', which is wrong as the ISO would not be moved to that
storage.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-09-22 08:57:35 +02:00
Thomas Lamprecht
a8d0fec3c2 whitespace/indentation fixes & cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-09 17:50:21 +02:00
Fabian Grünbichler
9a66c311ac fix #3608: unbreak removal of scsi controller
the assumption that the index of the controller matches that of the last
removed drive only holds for virtio-scsi-single controller, which makes
the old code print a warning when removing the last drive of a
non-virtio-scsi-single controller except when the indices line up by
chance.

we can simply only call a simplified qemu_iothread_del when removing a
scsi disk of a VM with the virtio-scsi-single controller, and skip the
call for the other controllers which don't support io-threads anyway.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-09-09 17:46:02 +02:00
Constantin Herold
ae776a6288 fix #3581: pass size via argument for memory-backend-ram qmp call
Signed-off-by: Constantin Herold <proxmox8914@herold.me>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-18 10:41:04 +02:00
Fabian Grünbichler
0d519cfc76 bump version to 7.0-13
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-08-05 14:03:33 +02:00