]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
2 years agod/control: bump (build-)dependency of libpve-guest-common-perl
Thomas Lamprecht [Wed, 9 Feb 2022 17:45:48 +0000 (18:45 +0100)]
d/control: bump (build-)dependency of libpve-guest-common-perl

to get new helpers for snapshot

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoagent: code style fix
Thomas Lamprecht [Wed, 9 Feb 2022 17:45:14 +0000 (18:45 +0100)]
agent: code style fix

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosnapshot: implement __snapshot_activate_storages
Fabian Ebner [Thu, 13 Jan 2022 11:04:02 +0000 (12:04 +0100)]
snapshot: implement __snapshot_activate_storages

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoclone: repeat more checks after locking
Fabian Grünbichler [Tue, 8 Feb 2022 08:00:31 +0000 (09:00 +0100)]
clone: repeat more checks after locking

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone disk: don't modify drive parameter
Fabian Ebner [Thu, 27 Jan 2022 14:01:55 +0000 (15:01 +0100)]
clone disk: don't modify drive parameter

While existing callers are not using the parameter after the call,
the modification is rather unexpected and could lead to bugs quickly.

Also avoid setting an undef value in the hash, but use delete instead.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoapi: move disk: fork before locking
Fabian Ebner [Thu, 27 Jan 2022 14:01:54 +0000 (15:01 +0100)]
api: move disk: fork before locking

using the familiar early+repeated checks pattern from other API calls.
Only intended functional changes are with regard to locking/forking.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoapi: clone: fork before locking
Fabian Ebner [Thu, 27 Jan 2022 14:01:53 +0000 (15:01 +0100)]
api: clone: fork before locking

using the familiar early+repeated checks pattern from other API calls.
Only intended functional changes are with regard to locking/forking.

For a full clone of a running VM without guest agent, this also fixes
issuing vm_{resume,suspend} calls for drive mirror completion.
Previously, those just timed out, because of not getting the lock:

> create full clone of drive scsi0 (rbdkvm:vm-104-disk-0)
> Formatting '/var/lib/vz/images/105/vm-105-disk-0.raw', fmt=raw
> size=4294967296 preallocation=off
> drive mirror is starting for drive-scsi0
> drive-scsi0: transferred 2.0 MiB of 4.0 GiB (0.05%) in 0s
> drive-scsi0: transferred 635.0 MiB of 4.0 GiB (15.50%) in 1s
> drive-scsi0: transferred 1.6 GiB of 4.0 GiB (40.50%) in 2s
> drive-scsi0: transferred 3.6 GiB of 4.0 GiB (90.23%) in 3s
> drive-scsi0: transferred 4.0 GiB of 4.0 GiB (100.00%) in 4s, ready
> all 'mirror' jobs are ready
> suspend vm
> trying to acquire lock...
> can't lock file '/var/lock/qemu-server/lock-104.conf' - got timeout
> drive-scsi0: Cancelling block job
> drive-scsi0: Done.
> resume vm
> trying to acquire lock...
> can't lock file '/var/lock/qemu-server/lock-104.conf' - got timeout

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agodrive mirror monitor: warn when suspend/resume/freeze/thaw calls fail
Fabian Ebner [Thu, 27 Jan 2022 14:01:52 +0000 (15:01 +0100)]
drive mirror monitor: warn when suspend/resume/freeze/thaw calls fail

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agopci: allow override of PCI vendor/device ids
Nicholas Sherlock [Tue, 18 Jan 2022 21:38:39 +0000 (21:38 +0000)]
pci: allow override of PCI vendor/device ids

This allows mobile- and vGPUs to be presented to the guest as if they
were the original desktop variants of the card. It also allows
device-ID variants that guests don't know about to be renamed to
match compatible sibling devices the guest does have drivers for
(e.g. to remove manufacturer-specific vendor ID variants that prevent
the use of a device which would otherwise have a supported chipset)

e.g. hostpci0: 03:00,vendor-id=0x8086,device-id=0x10f6

Signed-off-by: Nicholas Sherlock <n.sherlock@gmail.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agofix #3792: cloudinit: use of uninitialized value
Mira Limbeck [Mon, 20 Dec 2021 14:03:59 +0000 (15:03 +0100)]
fix #3792: cloudinit: use of uninitialized value

With the patch adding vendor-data support to cloud-init, a use of
uninitialized value was introduced. This can be fixed by setting it to
an empty string if no vendor-data is defined.

vendor-data can only be set via --cicustom and is optional.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2 years agoavoid writing the config if there are no pending changes to apply
Oguz Bektas [Thu, 2 Dec 2021 11:43:03 +0000 (12:43 +0100)]
avoid writing the config if there are no pending changes to apply

We drop properties which we do not understand and we call
`vmconfig_apply_pending` on stop and before start, so if a user tried
to edit the config or downgraded qemu-server they may get stuff
dropped from the config just by doing a stop/start, which may be a
bit too confusing, also the write is just unnecessary then.

we also have the same skipping logic when starting vms, this way we
avoid calling 'write_config' when there are no present changes to
commit.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agobump version to 7.1-4
Thomas Lamprecht [Mon, 22 Nov 2021 16:07:17 +0000 (17:07 +0100)]
bump version to 7.1-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomigrate: send updated TPM state volid to target node
Fabian Grünbichler [Mon, 22 Nov 2021 10:30:11 +0000 (11:30 +0100)]
migrate: send updated TPM state volid to target node

The volid may change if local-storage migration is involved, we need
to tell the target node the new one and update the in-memory config
for starting the target VM accordingly.

Reported here: https://forum.proxmox.com/threads/99906/#post-431345

this possibly breaks migration new -> old iff
- spice is not used (else the explicit ticket wins because it comes
  later)
- a local TPM state volume is used
- that local TPM state volume has a different volume id on the target
  node (switched storage, volname already taken, ..)

because the target node will then mis-interpret the tpmstate0 line as
spice ticket and set it accordingly. if the old tpm state volume ID does
not exist on the target node, migration will fail. if it exists by
chance, it might work albeit with a wrong spice ticket (new because of
this patch) and tpm state volume (pre-existing breakage).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agomigrate: improve start STDIN-parameter parsing
Fabian Grünbichler [Mon, 22 Nov 2021 10:30:10 +0000 (11:30 +0100)]
migrate: improve start STDIN-parameter parsing

only do the compat fallback if no explicit spice ticket was given, and
warn on unknown parameters on STDIN.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobump version to 7.1-3
Thomas Lamprecht [Tue, 16 Nov 2021 13:04:49 +0000 (14:04 +0100)]
bump version to 7.1-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomigrate: skip tpmstate for NBD migration
Fabian Grünbichler [Tue, 16 Nov 2021 10:52:15 +0000 (11:52 +0100)]
migrate: skip tpmstate for NBD migration

This patch fixes the wrong attempt of setting up an NBD server for
the replicated TPM state volume, in contrast to the other volumes the
TPM state is managed by swtpm and isn't available to QEMU for
block-migration/bitmap tracking.

Note that we do migrate the state volume via a storage migration
anyway if necessary.

This code path was only triggered for replicated VMs with TPM.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.1-2
Thomas Lamprecht [Mon, 15 Nov 2021 15:59:27 +0000 (16:59 +0100)]
bump version to 7.1-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoexclude efidisk and tpmstate for boot disk selection
Dominik Csapak [Mon, 15 Nov 2021 15:56:41 +0000 (16:56 +0100)]
exclude efidisk and tpmstate for boot disk selection

else we cannot create a vm without a disk but with a tpmstate/efidisk,
since the api tries to generate the default bootorder with them included

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agobump version to 7.1-1
Thomas Lamprecht [Mon, 15 Nov 2021 15:27:06 +0000 (16:27 +0100)]
bump version to 7.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopci: do not reserve pci-ids for mediated devices
Dominik Csapak [Mon, 15 Nov 2021 13:07:35 +0000 (14:07 +0100)]
pci: do not reserve pci-ids for mediated devices

else a user cannot use more than one mdev per card per host.
We do not need to reserve them at all, since sysfs will error out
on creation/reuse anyway

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoapi: update: fix missing newline in background-delayed task error
Thomas Lamprecht [Mon, 15 Nov 2021 08:21:48 +0000 (09:21 +0100)]
api: update: fix missing newline in background-delayed task error

this error path is mostly used for re-attaching disks and the like,
and the "check if task is already done" part uses a method to read
the task status that will never include a trailing newline, so add it
our self to avoid "... at /usr/share/perl5/PVE/API2/Qemu.pm line
1480. (500)"

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocfg2cmd: disable SMM when display=none and SeaBIOS is both used
Oguz Bektas [Thu, 11 Nov 2021 12:05:58 +0000 (13:05 +0100)]
cfg2cmd: disable SMM when display=none and SeaBIOS is both used

issue reported in community forum [0][1], like "serial[n]" display we
also need to set this option for "none", otherwise we get a boot
loop.

[0]: https://forum.proxmox.com/threads/99508
[1]: https://forum.proxmox.com/threads/97310/post-427129

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.0-19
Thomas Lamprecht [Thu, 11 Nov 2021 11:49:13 +0000 (12:49 +0100)]
bump version to 7.0-19

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: move disk: schema indentation and style-nit fixes
Thomas Lamprecht [Thu, 11 Nov 2021 13:00:57 +0000 (14:00 +0100)]
api: move disk: schema indentation and style-nit fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoqm: move-disk: to not make reassign specific options fixed
Thomas Lamprecht [Thu, 11 Nov 2021 12:36:53 +0000 (13:36 +0100)]
qm: move-disk: to not make reassign specific options fixed

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoqm: style/indentation/cleanup fixes for command definition
Thomas Lamprecht [Thu, 11 Nov 2021 12:34:35 +0000 (13:34 +0100)]
qm: style/indentation/cleanup fixes for command definition

and record some possible FIXMEs for a next point/major release

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependency on libpve-common-perl
Thomas Lamprecht [Thu, 11 Nov 2021 11:40:19 +0000 (12:40 +0100)]
d/control: bump versioned dependency on libpve-common-perl

to ensure the renamed 'storage-pair' is handled correctly..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomigrate: factor out storage checks
Fabian Grünbichler [Fri, 5 Nov 2021 13:03:52 +0000 (14:03 +0100)]
migrate: factor out storage checks

to re-use them for incoming remote migrations.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoadapt to renamed storage-pair format
Fabian Grünbichler [Fri, 5 Nov 2021 13:03:51 +0000 (14:03 +0100)]
adapt to renamed storage-pair format

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agod/control: add pve-ha-manager to B-D
Fabian Grünbichler [Fri, 5 Nov 2021 13:03:50 +0000 (14:03 +0100)]
d/control: add pve-ha-manager to B-D

it's needed for tests to succeed.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agocfg2cmd: turn smm off when SeaBIOS and serial display are used
Fabian Ebner [Fri, 5 Nov 2021 13:06:11 +0000 (14:06 +0100)]
cfg2cmd: turn smm off when SeaBIOS and serial display are used

Since commit 277d33454f77ec1d1e0bc04e37621e4dd2424b67 in pve-qemu,
smm=off is no longer the default, but with SeaBIOS and serial display,
this can lead to a boot loop.

Reported in the community forum [0] and reproduced with a Debian 10
VM.

[0]: https://forum.proxmox.com/threads/pve-7-0-all-vms-with-cloud-init-seabios-fail-during-boot-process-bootloop-disk-not-found.97310/post-427129

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agodisk reassign: add unused disks directly to config
Aaron Lauterer [Wed, 10 Nov 2021 17:00:13 +0000 (18:00 +0100)]
disk reassign: add unused disks directly to config

Using $update_vm_api for unused disks will cause them to end up as a
pending change if the VM is running.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agodisk reassign: fix assigning to unused slot
Fabian Grünbichler [Wed, 10 Nov 2021 11:41:04 +0000 (12:41 +0100)]
disk reassign: fix assigning to unused slot

this broke with the previous simplification.

Tested-by: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoreassign disk: more cleanup
Fabian Grünbichler [Wed, 10 Nov 2021 11:11:03 +0000 (12:11 +0100)]
reassign disk: more cleanup

avoid re-using the toplevel variable name

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoreassign disk: fix permission checks
Fabian Grünbichler [Wed, 10 Nov 2021 10:20:20 +0000 (11:20 +0100)]
reassign disk: fix permission checks

with `storage` being optional (and not allowed for reassign operations),
the ACL path in the schema can end up as `/storage/-`, which is wrong.
replace it with an explicit check:

- target `storage` for move disk
- storage from source disk for reassign disk (we only rename here, but
  it's still a new volume on that storage after all)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoreassign disk: various improvements
Fabian Grünbichler [Wed, 10 Nov 2021 10:19:16 +0000 (11:19 +0100)]
reassign disk: various improvements

some style, some missing checks. some duplication reduced a bit.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoapi: move-disk: cleanup very long lines
Aaron Lauterer [Tue, 9 Nov 2021 14:55:36 +0000 (15:55 +0100)]
api: move-disk: cleanup very long lines

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agoapi: move-disk: add move to other VM
Aaron Lauterer [Tue, 9 Nov 2021 14:55:35 +0000 (15:55 +0100)]
api: move-disk: add move to other VM

The goal of this is to expand the move-disk API endpoint to make it
possible to move a disk to another VM. Previously this was only possible
with manual intervertion either by renaming the VM disk or by manually
adding the disks volid to the config of the other VM.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agoDrive: add valid_drive_names_with_unused
Aaron Lauterer [Tue, 9 Nov 2021 14:55:34 +0000 (15:55 +0100)]
Drive: add valid_drive_names_with_unused

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agocli: qm: change move_disk to move-disk
Aaron Lauterer [Tue, 9 Nov 2021 14:55:33 +0000 (15:55 +0100)]
cli: qm: change move_disk to move-disk

also add alias to keep move_disk working.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agoconfig: rollback is possible: add blockers parameter
Fabian Ebner [Thu, 12 Aug 2021 11:01:04 +0000 (13:01 +0200)]
config: rollback is possible: add blockers parameter

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agobump version to 7.0-18
Thomas Lamprecht [Thu, 4 Nov 2021 14:30:01 +0000 (15:30 +0100)]
bump version to 7.0-18

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocfg2cmd: switch off ACPI hotplug on bridges for q35 VMs
Thomas Lamprecht [Thu, 21 Oct 2021 07:51:22 +0000 (09:51 +0200)]
cfg2cmd: switch off ACPI hotplug on bridges for q35 VMs

See commit 17858a1695 (hw/acpi/ich9: Set ACPI PCI hot-plug as default
on Q35)[0] in upstream QEMU repository for details about why the change
was made.

As that change affects systemds predictable interface naming[1],
e.g., by going from a previously `ens18` name to `enp6s18`, it may
have rather bad effects for users that did not setup some .link files
to enforce a specific naming by an more stable information like the
NIC's MAC-Address

The alternative would be making the preferred mode of hotplug an
option like `hotplug-mode=<acpi|pcie>`, but it does not seems like
one would like to change that much in the first place...

Note the changes to the tests and especially the tests with q35
machines that did not change.

[0]: https://gitlab.com/qemu-project/qemu/-/commit/17858a1695
[1]: https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html#Naming

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotests: cfg2cmd: add a few q35 related tests
Thomas Lamprecht [Thu, 21 Oct 2021 07:29:00 +0000 (09:29 +0200)]
tests: cfg2cmd: add a few q35 related tests

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoconfig: meta: also save the QEMU version installed during creation
Thomas Lamprecht [Thu, 21 Oct 2021 07:19:54 +0000 (09:19 +0200)]
config: meta: also save the QEMU version installed during creation

This is intended to be used to apply some workarounds for the
non-windows ostyped VMs which we'd still like to not pin on a
specific machine version, as normally Linux et al. can cope with such
changes on fresh boot just fine and until now this was a once every
few year issue (albeit systemd's "predictable" interface naming has
some potential to pick up on churn frequency).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoconfig: add new meta property with the VM creation time
Thomas Lamprecht [Thu, 21 Oct 2021 07:10:49 +0000 (09:10 +0200)]
config: add new meta property with the VM creation time

currently we only add the creation time (ctime), that was requested
as low priority wish from some users from time to time.

Note that the meta info is not available in the update API endpoints,
and at the moment the code should not change/add/delete it either in
any place.

We may want to update in on actions like clone or backup-restore in
the future, e.g., to also save the time of that event and possibly
the original source VMID, put that can be thought out later.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocloud init: add comment regarding 3 MiB size limit
Thomas Lamprecht [Thu, 4 Nov 2021 12:14:09 +0000 (13:14 +0100)]
cloud init: add comment regarding 3 MiB size limit

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Originally-by: Mira Limbeck <m.limbeck@proxmox.com>
2 years agofix #2429: allow to specify cloud-init vendor snippet via cicustom
Constantin Herold [Sat, 30 Oct 2021 14:49:41 +0000 (16:49 +0200)]
fix #2429: allow to specify cloud-init vendor snippet via cicustom

Signed-off-by: Constantin Herold <proxmox8914@herold.me>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
2 years agoagent hotplug: small style cleanups & comment addition
Thomas Lamprecht [Thu, 4 Nov 2021 07:45:31 +0000 (08:45 +0100)]
agent hotplug: small style cleanups & comment addition

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoqemu-agent: allow hotplug of fstrim_cloned_disk option.
Alexandre Derumier [Wed, 6 Oct 2021 21:58:44 +0000 (23:58 +0200)]
qemu-agent: allow hotplug of fstrim_cloned_disk option.

This option don't have any impact on device itself.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 years agotest: cfg2cmd: fix command output
Thomas Lamprecht [Wed, 3 Nov 2021 15:45:57 +0000 (16:45 +0100)]
test: cfg2cmd: fix command output

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agovm_commandline: reduce line bloat
Thomas Lamprecht [Wed, 3 Nov 2021 15:21:05 +0000 (16:21 +0100)]
vm_commandline: reduce line bloat

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoprint_keyboarddevice_full: drop unused machine parameter
Thomas Lamprecht [Wed, 3 Nov 2021 15:20:41 +0000 (16:20 +0100)]
print_keyboarddevice_full: drop unused machine parameter

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoscsi_inquiry: refactor and code cleanup
Thomas Lamprecht [Wed, 3 Nov 2021 15:19:10 +0000 (16:19 +0100)]
scsi_inquiry: refactor and code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agokvm_user_version: add explicit return statement
Thomas Lamprecht [Wed, 3 Nov 2021 15:18:00 +0000 (16:18 +0100)]
kvm_user_version: add explicit return statement

while perl returns the (scalar) result of the last expression
automatically its still nicer to explicitly do so..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agodrives: ro: code reduction/refactor
Thomas Lamprecht [Wed, 27 Oct 2021 15:00:24 +0000 (17:00 +0200)]
drives: ro: code reduction/refactor

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agodrives: expose 'readonly' flag of qemu for scsi/virtio
Dominik Csapak [Wed, 27 Oct 2021 11:35:27 +0000 (13:35 +0200)]
drives: expose 'readonly' flag of qemu for scsi/virtio

this allows a user to set a drive to 'read-only'. This can be useful
if a disk should not be written to, or if the backing file/source is
not writable (like a mapped pbs backup to /dev/loopX).

the option is named 'ro', to achieve consistency with containers

while this could also be achieved by setting 'snapshot=1', this would
create a temporary file in /var/tmp which can get quite big.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agovzdump: increase timeout for QMP 'cont' after backup start
Stefan Reiter [Wed, 27 Oct 2021 11:34:54 +0000 (13:34 +0200)]
vzdump: increase timeout for QMP 'cont' after backup start

Since 'backup' can now work asynchronously, QEMU may not be ready to
receive the next QMP command ('cont') immediately. Thus, increase the
timeout, to avoid aborted backups in slow environments.

There may be a deeper QEMU bug hidden under the covers here too, but at
least one user reported success with simply increasing the timeout:
https://forum.proxmox.com/threads/pve7-pbs2-backup-timeout-qmp-command-cont-failed-got-timeout.95212/page-2#post-426261

See also:
https://bugzilla.proxmox.com/show_bug.cgi?id=3693
https://forum.proxmox.com/threads/problem-seit-update-auf-7-0.97388/
https://forum.proxmox.com/threads/error-with-backup-when-backing-up-qmp-command-query-backup-failed-got-wrong-command-id.88017/page-3#post-416339

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2 years agovm start: only print tpm-related message if there is an instance
Fabian Ebner [Wed, 27 Oct 2021 06:49:37 +0000 (08:49 +0200)]
vm start: only print tpm-related message if there is an instance

Otherwise, this can produce an undef warning and be misleading.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agofix removing cpulimit on running vm
Dominik Csapak [Tue, 12 Oct 2021 11:20:52 +0000 (13:20 +0200)]
fix removing cpulimit on running vm

like in pve-container:
04a62bd ("fix #3506: config: fix removing the cpulimit of a running CT")

reported in the forums (no bug# yet):
https://forum.proxmox.com/threads/issue-with-removing-cpu-limit-from-running-vm.97799/

note that this will break CGv1 without the following fix installed:
https://git.proxmox.com/?p=pve-common.git;a=commitdiff;h=d37a71867

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Oguz Bektas <o.bektas@proxmox.com>
Reviewed-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agouse non SMM ovmf code file for i440fx machines
Dominik Csapak [Mon, 11 Oct 2021 12:10:24 +0000 (14:10 +0200)]
use non SMM ovmf code file for i440fx machines

ovmf with SMM enabled will not boot on i440fx (hangs on graphics
initialization), so load the non SMM variant.

should be no issue regarding live-migration since it never worked with
this anyway.

adapts the test and adds one with q35

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-by: Stefan Reiter <s.reiter@proxmox.com>
2 years agobump version to 7.0-17
Thomas Lamprecht [Thu, 21 Oct 2021 09:58:18 +0000 (11:58 +0200)]
bump version to 7.0-17

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoconfig properties: refactor skipping internal options to declarative
Thomas Lamprecht [Thu, 21 Oct 2021 06:23:08 +0000 (08:23 +0200)]
config properties: refactor skipping internal options to declarative

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotests: fixup simple1-template.conf.cmd
Thomas Lamprecht [Wed, 20 Oct 2021 16:18:31 +0000 (18:18 +0200)]
tests: fixup simple1-template.conf.cmd

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocode and indentation cleanups
Thomas Lamprecht [Wed, 20 Oct 2021 15:31:45 +0000 (17:31 +0200)]
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>
2 years agoconfig2cmd: code cleanup and indentation reduction
Thomas Lamprecht [Wed, 20 Oct 2021 13:39:20 +0000 (15:39 +0200)]
config2cmd: code cleanup and indentation reduction

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoindentation and fixes
Thomas Lamprecht [Wed, 20 Oct 2021 10:56:57 +0000 (12:56 +0200)]
indentation and fixes

with some style/tw thrown in-between

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix overly long/short lines and typos
Thomas Lamprecht [Wed, 20 Oct 2021 06:24:08 +0000 (08:24 +0200)]
fix overly long/short lines and typos

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoostype: support Windows 11/Server 2022
Stefan Reiter [Mon, 11 Oct 2021 12:55:18 +0000 (14:55 +0200)]
ostype: support Windows 11/Server 2022

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2 years agoRevert "config_aware_timeout: add 5s if TPM is configured"
Thomas Lamprecht [Mon, 18 Oct 2021 07:47:42 +0000 (09:47 +0200)]
Revert "config_aware_timeout: add 5s if TPM is configured"

This reverts commit d4e1e1f86232c2c0e2924302fab2f968ef8218b1.

It's bogus, the VM start timeout is only starting to tick after we
started the TPM already...

2 years agoconfig_aware_timeout: add 5s if TPM is configured
Thomas Lamprecht [Mon, 18 Oct 2021 07:43:14 +0000 (09:43 +0200)]
config_aware_timeout: add 5s if TPM is configured

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoswtmp: die early in startup check
Thomas Lamprecht [Mon, 18 Oct 2021 07:42:36 +0000 (09:42 +0200)]
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>
2 years agocode style: readability cleanups
Thomas Lamprecht [Mon, 18 Oct 2021 07:40:03 +0000 (09:40 +0200)]
code style: readability cleanups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoswtpm: wait for pidfile
Stefan Reiter [Thu, 14 Oct 2021 09:28:49 +0000 (11:28 +0200)]
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>
2 years agosnapshot: fix tpmstate with rbd
Stefan Reiter [Thu, 14 Oct 2021 09:28:48 +0000 (11:28 +0200)]
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>
2 years agovm_start: better name systemd scope property variable
Thomas Lamprecht [Mon, 18 Oct 2021 07:41:18 +0000 (09:41 +0200)]
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>
2 years agocloudinit: opennebula: refactor to reduce code bloat
Thomas Lamprecht [Fri, 15 Oct 2021 14:55:27 +0000 (16:55 +0200)]
cloudinit: opennebula: refactor to reduce code bloat

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocloudinit: better use of string variable interpolation
Thomas Lamprecht [Fri, 15 Oct 2021 14:54:27 +0000 (16:54 +0200)]
cloudinit: better use of string variable interpolation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopci: prepare: improve no-IOMMU error message
Thomas Lamprecht [Fri, 15 Oct 2021 17:57:58 +0000 (19:57 +0200)]
pci: prepare: improve no-IOMMU error message

give some context

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3258: block vm start when pci device is already in use
Dominik Csapak [Thu, 7 Oct 2021 13:45:31 +0000 (15:45 +0200)]
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>
2 years agopci reservation: rework helpers style and readability wise
Thomas Lamprecht [Fri, 15 Oct 2021 16:08:22 +0000 (18:08 +0200)]
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>
2 years agopci reservation: move lock/reservation file into /run/qemu-server
Thomas Lamprecht [Fri, 15 Oct 2021 15:02:21 +0000 (17:02 +0200)]
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>
2 years agopci reservation: encode locklessness of parsers in name
Thomas Lamprecht [Fri, 15 Oct 2021 12:44:47 +0000 (14:44 +0200)]
pci reservation: encode locklessness of parsers in name

to avoid that they're misused

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopci: add helpers to (un)reserve pciids for a vm
Dominik Csapak [Thu, 7 Oct 2021 13:45:30 +0000 (15:45 +0200)]
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>
2 years agopci related code cleanups
Thomas Lamprecht [Mon, 11 Oct 2021 06:39:28 +0000 (08:39 +0200)]
pci related code cleanups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopci: use local helper to generated generate_mdev_uuid
Thomas Lamprecht [Mon, 11 Oct 2021 06:38:26 +0000 (08:38 +0200)]
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>
2 years agopci: prepare_pci_device: fixup parameter name
Thomas Lamprecht [Mon, 11 Oct 2021 06:37:35 +0000 (08:37 +0200)]
pci: prepare_pci_device: fixup parameter name

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopci: refactor pci device preparation
Dominik Csapak [Thu, 7 Oct 2021 13:45:29 +0000 (15:45 +0200)]
pci: refactor pci device preparation

makes the vm start a bit less crowded

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agobump version to 7.0-16
Thomas Lamprecht [Tue, 5 Oct 2021 18:22:22 +0000 (20:22 +0200)]
bump version to 7.0-16

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotests: cfg2cmd: add 4MB-EFI-secboot and TPM test
Thomas Lamprecht [Tue, 5 Oct 2021 18:20:51 +0000 (20:20 +0200)]
tests: cfg2cmd: add 4MB-EFI-secboot and TPM test

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoefi: use vendor-agonstic "pre-enrolled-keys" + description fix
Thomas Lamprecht [Tue, 5 Oct 2021 16:35:25 +0000 (18:35 +0200)]
efi: use vendor-agonstic "pre-enrolled-keys" + description fix

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependency on pve-edk2-firmware 3.20210831-1
Thomas Lamprecht [Tue, 5 Oct 2021 16:09:38 +0000 (18:09 +0200)]
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>
2 years agoovmf: support secure boot with 4m and 4m-ms efidisk types
Stefan Reiter [Tue, 5 Oct 2021 16:02:06 +0000 (18:02 +0200)]
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>
2 years agopci: to not capture first group in PCIRE
Dominik Csapak [Tue, 5 Oct 2021 13:11:58 +0000 (15:11 +0200)]
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>
2 years agobump version to 7.0-15
Thomas Lamprecht [Tue, 5 Oct 2021 05:25:22 +0000 (07:25 +0200)]
bump version to 7.0-15

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: add dependency for swtpm and swtpm-tools
Thomas Lamprecht [Tue, 5 Oct 2021 05:09:12 +0000 (07:09 +0200)]
d/control: add dependency for swtpm and swtpm-tools

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: wrap-and-sort -tkn
Thomas Lamprecht [Tue, 5 Oct 2021 05:08:32 +0000 (07:08 +0200)]
d/control: wrap-and-sort -tkn

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agostart: warn about terminating the swtpm instance
Thomas Lamprecht [Tue, 5 Oct 2021 05:05:39 +0000 (07:05 +0200)]
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>
2 years agotrivial: indentation/formatting fixup
Thomas Lamprecht [Tue, 5 Oct 2021 05:05:07 +0000 (07:05 +0200)]
trivial: indentation/formatting fixup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3075: add TPM v1.2 and v2.0 support via swtpm
Stefan Reiter [Mon, 4 Oct 2021 15:29:20 +0000 (17:29 +0200)]
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>