Commit Graph

3139 Commits

Author SHA1 Message Date
Thomas Lamprecht
3234f5639d vzdump: pbs: factor out getting and checking encryption keys
factor the common checks for disk-less and "normal" backups out into
its own helper, avoiding code duplication and ensuring that the
messages and checks stay in sync.

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

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-06 17:44:18 +02:00
Thomas Lamprecht
76690de1e9 vzdump: reword "master-key but no encryption key" message
.. and make it use a warn level, which can then also mark the whole
task as potentially problematic as with a new enough pve-guest-common
the REST environment worker warn counters are then increased.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-06 15:39:30 +02:00
Thomas Lamprecht
b241ddbf15 vzdump: log only once that encryption is enabled
our backup logs are still quite noise at the task start part so avoid
logging that the task is running with encryption enabled twice for
the master-key feature.

The definedness check on master_keyfile isn't required anymore, it
was never for the no-disk case, and for the standard case it isn't
since  781fb80 ("vzdump: error out for master-key backup but no QEMU
support")

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-06 15:01:13 +02:00
Thomas Lamprecht
781fb80309 vzdump: error out for master-key backup but no QEMU support
Our QEMU gained master-key support for Proxmox VE 6.4 with initial
QEMU 5.2.0 packaging in 0b8da68 ("add PBS master key support")
version.
As we're now two major releases in the future any VM needs to run
with a newer QEMU version we can just make this a hard-error, as
there really should be no use-case left. After all we only support
upgrading directly to the next major release, so one needs to do at
least a migration (or shutdown) of the VM to reboot the node for
upgrading to Proxmox VE 8, so the lowest QEMU version baseline is 6.0
for Proxmox VE 8 (i.e., the version from PVE 7.0).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-06 15:01:13 +02:00
Thomas Lamprecht
b84587f312 vzdump: drop unused pathlist variable for PBS no-disk code path
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-06 15:01:13 +02:00
Fabian Grünbichler
fbd3dde735 fix #4822: vzdump: fix pbs encryption for no-disk guests
these are backed up directly with proxmox-backup-client, and the invocation was
lacking the key parameters.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-06 15:01:13 +02:00
Thomas Lamprecht
f46596539f bump version to 8.0.6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 13:06:38 +02:00
Fiona Ebner
e9f12f967a migration: fix issue with qcow2 cloudinit disk live migration
The check for with_snapshots for qcow2 needs to happen for these too.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-21 12:48:11 +02:00
Fiona Ebner
1e5405838a migration: add trailing newline to aliased volumes error message
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-21 12:48:11 +02:00
Fiona Ebner
219719aada foreach volid helper: make $pending parameter behave like a boolean
Avoids potential future mistake with passing in an explicit 0.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
ee2febbaa0 tests: add migration alias check
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
07f2e57c98 migration: fail when aliased volume is detected
Aliased volids can lead to unexpected behavior in a migration.

An aliased volid can happen if we have two storage configurations,
pointing to the same place. The resulting 'path' for a disk image
will be the same.
Therefore, stop the migration in such a case.

The check works by comparing the path returned by the storage plugin.

We decided against checking the storages themselves being aliased. It is
not possible to infer that reliably from just the storage configuration
options alone.

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
60404e3c1a tests: add migration test for pending disk
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
6e9c4929be qemuserver: migration: test_volid: change attr name and ref handling
Since we don't scan all storages for matching disk images anymore for a
migration we don't have any images found via storage alone. They will be
referenced in the config somewhere.

Therefore, there is no need for the 'storage' ref.
The 'referenced_in_config' is not really needed and can apply to both,
attached and unused disk images.

Therefore the QemuServer::foreach_volid() will change the
'referenced_in_config' attribute to an 'is_attached' one that only
applies to disk images that are in the _main_ config part and are not
unused.

In QemuMigrate::scan_local_volumes() we can then quite easily map the
refs to each state, attached, unused, referenced_in_{pending,snapshot}.

The refs are mostly used for informational use to print out in the logs
why a disk image is part of the migration. Except for the 'attached' case.

In the future the extra step of the refs in QemuMigrate could probably
be streamlined even more.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
a0dbed5a6d migration: only migrate disks used by the guest
When scanning all configured storages for disk images belonging to the
VM, the migration could easily fail if a storage is not available, but
enabled. That storage might not even be used by the VM at all.

By not scanning all storages and only looking at the disk images
referenced in the VM config, we can avoid unnecessary failures.
Some information that used to be provided by the storage scanning needs
to be fetched explicilty (size, format).

Behaviorally the biggest change is that unreferenced disk images will
not be migrated anymore. Only images referenced in the config will be
migrated.

The tests have been adapted accordingly.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
0b7a0b78db qemuserver: foreach_volid: always include pending disks
All calling sites except for QemuConfig.pm::get_replicatable_volumes()
already enabled it. Making it the non-configurable default results in a
change in the VM replication.  Now a disk image only referenced in the
pending section will also be replicated.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Aaron Lauterer
6328c554c1 qemuserver: foreach_volid: include pending volumes
Make it possible to optionally iterate over disks in the pending section
of VMs, similar as to how snapshots are handled already.

This is for example useful in the migration if we don't want to rely on
the scanning of all storages.

All calling sites are adapted and enable it, except for
QemuConfig::get_replicatable_volumes as that would cause a change for
the replication if pending disks would be included.

The following lists the calling sites and if they should be fine with
the change (source [0]):

1. QemuMigrate: scan_local_volumes(): needed to include pending disk
   images
2. API2/Qemu.pm: check_vm_disks_local() for migration precondition:
   related to migration, so more consistent with pending
3. QemuConfig.pm: get_replicatable_volumes(): would change the behavior
   of the replication, will not use it for now.
4. QemuServer.pm: get_vm_volumes(): is used multiple times by:
4a. vm_stop_cleanup() to deactivate/unmap: should also be fine with
    including pending
4b. QemuMigrate.pm: in prepare(): part of migration, so more consistent
    with pending
4c. QemuMigrate.pm: in phase3_cleanup() for deactivation: part of
    migration, so more consistent with pending

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

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-21 12:48:11 +02:00
Fiona Ebner
ec11b92abb cloudinit: restore previous default for package upgrades
Commit efa3355d ("fix #3428: cloudinit: add parameter for upgrade on
boot") changed the default, but this is a breaking change. The bug
report was only about making the option configurable.

The commit doesn't give an explicit reason for why, and arguably,
doing the upgrade is not an issue for most users. It also leads to a
different cloud-init instance ID, because of the different setting,
which in turn leads to ssh host key regeneration within the VM.

Reported-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-21 12:40:58 +02:00
Fiona Ebner
178c355ded schema: cloudinit: document default for ciupgrade
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-21 12:40:58 +02:00
Thomas Lamprecht
52b66c4244 bump version to 8.0.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 09:17:44 +02:00
Thomas Lamprecht
3d79cf5536 vm start: always reset any failed-state of the VM systemd scope
The scope can get into failed state for some issues like OOM kills of
the whole scope, in that case a user cannot re-start the VM until
they manually reset it.

Do this for now inline to avoid a pve-common bump as done in [0]
(location was suggested by me thinking we could maybe do it over
dbus, but as we have a stop command here already it probably doesn't
matters)

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

Originally-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 09:14:47 +02:00
Thomas Lamprecht
728404c03d vm start: factor out silencing systemd stop-scope command
will be reused in the next commit

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-21 09:13:04 +02:00
Fabian Grünbichler
621edb2b65 restore: extend permissions checks
to allow early checking of the merged config, if the backup archive
passed in is a proper volume where extraction is possible.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-20 19:42:48 +02:00
Fabian Grünbichler
c36214d2a6 restore: refactor archive parsing
to avoid duplicate work, always set 'volid' to the backup volume's volid, if it
was successfully parsed as such.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-20 19:40:26 +02:00
Alexandre Derumier
c961ab6d80 cpuconfig: add missing qemu 8.0 cpu models
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-06-19 17:02:00 +02:00
Thomas Lamprecht
fd4de45d77 bump version to 8.0.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-19 07:24:52 +02:00
Dominik Csapak
42ac818005 add test for mapped pci devices
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-19 07:21:49 +02:00
Dominik Csapak
92cd9b1840 migration: check for mapped resources
they can only be migrated to nodes where there exists a mapping and if
the migration is done offline

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-19 07:21:49 +02:00
Dominik Csapak
bc1a58607c api: migrate preconditions: use new check_local_resources info
for offline migration, limit the allowed nodes to the ones where the
mapped resources are available

this adds new info to the api call namely the 'mapped-resources' list,
as well as the 'unavailable-resources' info in the 'not_allowed_nodes'
object

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-19 07:21:49 +02:00
Dominik Csapak
a52eb3c4e9 check local resources: extend for mapped resources
by adding them to their own list, saving the nodes where they are not
allowed, and return those on 'wantarray' so we don't break existing
callers that don't expect it.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-19 07:21:07 +02:00
Dominik Csapak
9b71c34d61 enable cluster mapped PCI devices for guests
this patch allows configuring pci devices that are mapped via cluster
resource mapping when the user has 'Resource.Use' on the ACL path
'/mapping/pci/{ID}' (in  addition to the usual required vm config
privileges)

When given multiple mappings in the config, we use them as alternatives
for the passthrough, and will select the first free one on startup.
It is using our regular pci reservation mechanism for regular devices and
we introduce a selection mechanism for mediated devices.

A few changes to the inner workings were required to make this work well:
* parse_hostpci now returns a different structure where we have a list
  of lists (first level is for the different alternatives and second
  level is for the different devices that should be passed through
  together)
* factor out the 'parse_hostpci_devices' which parses each device from
  the config and does some precondition checks
* reserve_pci_usage now behaves slightly different when trying to
  reserve an device with the same VMID that's already reserved for,
  since for checking which alternative we can use, we already must
  reserve one (this means that qm showcmd can actually reserve devices,
  albeit only for up to 10 seconds)
* configuring a mediated device on a multifunction device is not
  supported anymore, and results in failure to start (previously, it
  just chose the first device to do it). This is a breaking change
* configuring a single pci device twice on different hostpci slots now
  fails during commandline generation instead on qemu start, so we had
  to adapt one test where this occurred (it could never have worked
  anyway)
* we now check permissions during clone/restore, meaning raw/real
  devices can only be cloned/restored by root@pam from now on.
  this is a breaking change.

Fixes #3574: Improve SR-IOV usability
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-16 16:24:02 +02:00
Dominik Csapak
e3971865b4 enable cluster mapped USB devices for guests
this patch allows configuring usb devices that are mapped via
cluster resource mapping when the user has 'Mapping.Use' on the ACL
path '/mapping/usb/{ID}' (in addition to the usual required vm config
privileges)

for now, this is only valid if there is exactly one mapping for the
host, since we don't track passed through usb devices yet

This now also checks permissions on clone/restore, meaning a
'non-mapped' device can only be cloned/restored as root@pam user.
That is a breaking change.

Refactor the checks for restoring into a sub, so we have central place
where we can add such checks

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-16 16:24:02 +02:00
Dominik Csapak
0cf8d56c6d usb: refactor usb code and move some into USB module
similar to how we handle the PCI module and format. This makes the
'verify_usb_device' method and format unnecessary since
we simply check the format with a regex.

while doing tihs, i noticed that we don't correctly check for the
case-insensitive variant for 'spice' during hotplug, so fix that too

With this we can also remove some parameters from the get_usb_devices
and get_usb_controllers functions

while were at it, refactor the permission checks for the usb config too
and use the new 'my sub' style for the functions

also make print_usbdevice_full parse the device itself, so we don't have
to do it in multiple places (especially in places where we don't see
that this is needed)

No functional change intended

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By:  Markus Frank <m.frank@proxmox.com>
2023-06-16 16:24:02 +02:00
Aaron Lauterer
e3aad44126 migration: add target_storage_check_available
We use this in a few places. By factoring it into its own function, we
can avoid running slightly different checks in various places.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2023-06-16 15:03:28 +02:00
Thomas Lamprecht
56d28037b5 helpers: actualy future proof and allow also checking releases
ensuring the editor state is saved helps -.-

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-16 13:53:52 +02:00
Thomas Lamprecht
e17312c99f helpers: future proof and allow also checking releases
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-16 13:26:43 +02:00
Thomas Lamprecht
9c6eabf028 fix #4784: helpers: cope with native versions in manager version check
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-16 13:22:40 +02:00
Fiona Ebner
5854213953 status: fix description of qmpstatus property
Using the word 'agent' is highly confusing here as there is no QMP
agent and thus wrongly suggests that the value is related to the
guest agent[0].

[0]: https://forum.proxmox.com/threads/123590/post-537716

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-14 13:33:56 +02:00
Alexandre Derumier
1359e23fb4 cpuconfig: add new x86-64-vX models
https://gitlab.com/x86-psABIs/x86-64-ABI/
https://lists.gnu.org/archive/html/qemu-devel/2021-06/msg01592.html
"
In 2020, AMD, Intel, Red Hat, and SUSE worked together to define
three microarchitecture levels on top of the historical x86-64
baseline:

  * x86-64:    original x86_64 baseline instruction set
  * x86-64-v2: vector instructions up to Streaming SIMD
               Extensions 4.2 (SSE4.2)  and Supplemental
               Streaming SIMD Extensions 3 (SSSE3), the
               POPCNT instruction, and CMPXCHG16B
  * x86-64-v3: vector instructions up to AVX2, MOVBE,
               and additional bit-manipulation instructions.
  * x86-64-v4: vector instructions from some of the
               AVX-512 variants.
"

This patch add new builtin model derivated from qemu64 model,
to be compatible between intel/amd.

mandatory flags from qemu-doc generator:
https://gitlab.com/qemu/qemu/-/blob/master/scripts/cpu-x86-uarch-abi.py

levels = [
    [ # x86-64 baseline
        "cmov",
        "cx8",
        "fpu",
        "fxsr",
        "mmx",
        "syscall",
        "sse",
        "sse2",
    ],
    [ # x86-64-v2
        "cx16",
        "lahf-lm",
        "popcnt",
        "pni",
        "sse4.1",
        "sse4.2",
        "ssse3",
    ],
    [ # x86-64-v3
        "avx",
        "avx2",
        "bmi1",
        "bmi2",
        "f16c",
        "fma",
        "abm",
        "movbe",
	"xsave"  #missing from qemu doc currently
    ],
    [ # x86-64-v4
        "avx512f",
        "avx512bw",
        "avx512cd",
        "avx512dq",
        "avx512vl",
    ],
]

x86-64-v1 : I'm skipping it, as it's basicaly qemu64|kvm64 -vme,-cx16 for compat Opteron_G1 from 2004
            so will use it as qemu64|kvm64 is higher are not working on opteron_g1 anyway

x86-64-v2 : Derived from qemu, +popcnt;+pni;+sse4.1;+sse4.2;+ssse3

min intel: Nehalem
min amd : Opteron_G3

x86-64-v2-AES : Derived from qemu, +aes;+popcnt;+pni;+sse4.1;+sse4.2;+ssse3

min intel: Westmere
min amd : Opteron_G3

x86-64-v3 : Derived from qemu64 +aes;+popcnt;+pni;+sse4.1;+sse4.2;+ssse3;+avx;+avx2;+bmi1;+bmi2;+f16c;+fma;+abm;+movbe+xsave

min intel: Haswell
min amd : EPYC_v1

x86-64-v4 : Derived from qemu64 +aes;+popcnt;+pni;+sse4.1;+sse4.2;+ssse3;+avx;+avx2;+bmi1;+bmi2;+f16c;+fma;+abm;+movbe;+xsave;+avx512f;+avx512bw;+avx512cd;+avx512dq;+avx512vl

min intel: Skylake
min amd : EPYC_v4

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-06-12 17:30:11 +02:00
Thomas Lamprecht
60302a968a bump version to 8.0.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-09 12:20:45 +02:00
Fabian Grünbichler
525c6c6271 qemu: fix permission check call
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-09 12:10:46 +02:00
Thomas Lamprecht
77eebd880c bump version to 8.0.2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-09 10:28:56 +02:00
Thomas Lamprecht
2a93450466 d/control: bump versioned dependency for libpve-access-control-perl
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-09 10:24:05 +02:00
Fiona Ebner
814053b4c3 qm: remote migration: improve error when storage cannot be found
It can also be a permission issue, so the current error can be
a bit confusing.

Reported in the community forum:
https://forum.proxmox.com/threads/120619/post-562660

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-09 09:49:40 +02:00
Thomas Lamprecht
3f9c3a04d1 d/control: bump versioned dependency for libpve-guest-common-perl
to ensure we got the vnet access check helper available for us, and
also that the get_derived_property interface is available for our
users

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-08 17:50:50 +02:00
Thomas Lamprecht
951714ea92 restore: check bridge access when actual config is available
This was not only rather inefficient (getting the config from the
archive twice) but also wrong, as we can override options on restore,
so we can do the check only when the backed-up config and override
config got merged.

If this is to late from POV of volume deletion or the like, then the
issue is that those things happen to early, as we can only know what
to do with the actual target config, so destructive actions that
happen before that are wrong by design.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-08 17:50:50 +02:00
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
Alexandre Derumier
9cfd06d944 api: check bridge access for create, update, clone & restore
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-08 17:47:53 +02:00
Fiona Ebner
3dd16f4a6c config: implement method to calculate derived properties from a config
See the corresponding commit in guest-common for more information.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-08 17:47:53 +02:00
Fiona Ebner
502870a04c qmeventd: extract vmid from cgroup file instead of cmdline
This is the single remaining user of the id argument. The id argument
is a Proxmox-specific extension to QEMU, which we'd like to drop to
reduce our differences with upstream QEMU.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-07 19:37:09 +02:00