Commit Graph

1265 Commits

Author SHA1 Message Date
Fabian Ebner
a9c45bd4a4 clone disk: add version guard for qemu-img dd's -l option
It's only available since QEMU 6.2 and doing a check here rather than
bumping the package dependency allows for easy downgrades.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-04-06 17:41:49 +02:00
Fabian Ebner
c1accf9db9 schema: drive: use separate schema when disk allocation is possible
via the special syntax <storeid>:<size>.

Not worth it by itself, but this is anticipating a new 'import-from'
parameter which is only used upon import/allocation, but shouldn't be
part of the schema for the config or other API enpoints.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-04-04 16:41:13 +02:00
Fabian Ebner
39051ac0df api: add endpoint for parsing .ovf files
Co-developed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
[split into its own patch + minor improvements/style fixes]
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
[renamed API handler, since it's not an index]
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-04-04 16:40:55 +02:00
Fabian Ebner
62375438dc clone disk: also clone EFI disk from snapshot
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-04-01 10:24:59 +02:00
Fabian Ebner
1d1f8f9ada clone disk: move check against cloning TPM state of running VM to beginning
where other similar checks are.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-04-01 10:24:59 +02:00
Fabian Ebner
5f9575929a clone disk: assert that drive name is the same for drive-mirror on single VM
because when the VM ID of target and source are the same,
qemu_drive_mirror_monitor() switches the QEMU device node over to the
new backing image. The planned import-from functionality makes it
possible to run into this, although for an a bit unusual use case.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-04-01 10:24:59 +02:00
Fabian Grünbichler
8b8893c3c4 fix #3957: spell 'occurred' correctly
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-03-25 09:06:58 +01:00
Fabian Ebner
a23d57d596 image convert: allow block device as source
Necessary to import from an existing storage using block-device
volumes like ZFS.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
[split into its own patch]
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-14 16:28:55 +01:00
Fabian Ebner
6e55f5799e schema: add pve-volume-id-or-absolute-path
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
[split into its own patch + style fixes]
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
ff84f0e36b efivars size: allow overriding efidisk parameter
For disk import, it should be based on the disk properties that are
passed in rather than on those of a possibly pre-existing disk in the
config.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
25166060ae clone disk: allow cloning from an unused or unreferenced disk
and also when source and target drivename are different. In those
cases, it is done via qemu-img convert/dd.

In preparation to allow import from existing PVE-managed disks.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
7344af7bf8 clone disk: pass in efi vars size rather than config
It's confusing that the config associated to the destination is
actually a reference to the source config for both existing callers.

Also, disk import will need to base the calculation on the passed-in
drive parameters and not just the current config, so this change is in
preparation for that too.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
1196086ff1 clone disk: group source and target parameters
to make the interface more digestible.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
31b1db61c2 clone disk: remove check for min QEMU version 2.7
Upgrading a cluster node entails re-starting or migrating VMs and even
PVE 6.0 already had QEMU 4.0.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
52b361afd6 device unplug: verify that unplugging scsi disk completed
Avoids the error
  adding drive failed: Duplicate ID 'drive-scsi1' for drive
that could happen when switching over to a new disk (e.g. via qm set),
if unplugging wasn't fast enough.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Fabian Ebner
f7765dd72e restore: remove duplicate check
The refactoring in 36d4bdcb86 missed
this. The check is already done as part of the following check_storage
call.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-02-25 09:58:16 +01:00
Moayad Almalat
39abafc8e7 fix #3733: add 20 seconds timeout when VM backup stopped 2022-02-24 13:33:45 +01:00
Thomas Lamprecht
36d4bdcb86 restore: factor out common early checks into closure
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-24 13:29:42 +01:00
Thomas Lamprecht
9f8ba326ce restore: early check cloud init target AllocateSpace permission
Originally-by: Matthias Heiserer <m.heiserer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-24 13:24:01 +01:00
Matthias Heiserer
62af60cd3d fix #3886: QEMU restore: verify storage allows images before writing
When restoring a backup and the storage the disks would be created on
doesn't allow 'images', the process errors without cleanup.
This is the same behaviour we currently have when the storage is
disabled.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
2022-02-24 13:19:49 +01:00
Fabian Ebner
5f5aba2578 clone disk: force raw format for TPM state
The format can't be qcow2 for TPM state, because swtpm reads the file
directly expecting raw data.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-02-17 14:32:51 +01:00
Thomas Lamprecht
64cc310f0a fix #3845: also clamp cpu units to cgroup dependent valid range on hotplug
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-11 09:31:13 +01:00
Thomas Lamprecht
0c6b941e5b config2cmd: drop unused get_cpuunits call
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-11 09:30:22 +01:00
Thomas Lamprecht
e65e35ca6d cpu units: lower minimum for accessing full cgroupv2 range
also clamp that up in the v1 case for compat.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-11 09:29:52 +01:00
Thomas Lamprecht
f43d7f67bf cpu units: handle clamping more centrally
preparation for also clamping on hotplug and lower the minimum in the
schema so that the full v2 range can be used.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-11 09:28:35 +01:00
Fabian Grünbichler
5668463b69 nbd alloc helper: allow passing in explicit format
and make $volname optional, to support remote migration usage without
code duplication.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-02-09 18:48:46 +01:00
Fabian Grünbichler
ad5812d8fb parse_config: optional strict mode
when passing a config from one cluster to another, we want to be strict
when parsing - it's better to fail the migration early and upgrade the
target node instead of failing the migration later (when significant
work for transferring disks and/or state has already been done) or not
at all, but silently lose config settings that the target doesn't
understand.

this also might be helpful in other cases - e.g. when restoring from a
backup.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-02-09 18:47:56 +01:00
Fabian Grünbichler
dbdcc5cde0 schema: use pve-bridge-id
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-02-09 18:47:43 +01:00
Fabian Grünbichler
82a0367149 move map_storage to PVE::JSONSchema::map_id
since we are going to reuse the same mechanism/code for network bridge
mapping and pve-container.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-02-09 18:46:20 +01:00
Fabian Ebner
3b53c47155 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>
2022-01-31 13:10:33 +01:00
Fabian Ebner
d6cdfae417 drive mirror monitor: warn when suspend/resume/freeze/thaw calls fail
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-01-31 13:10:33 +01:00
Oguz Bektas
a644de298c 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>
2021-12-02 19:24:29 +01:00
Fabian Grünbichler
fd95d780a2 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>
2021-11-22 16:55:17 +01:00
Fabian Grünbichler
41c8671e78 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>
2021-11-16 14:03:01 +01:00
Dominik Csapak
9c85548fa1 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>
2021-11-15 15:01:12 +01:00
Oguz Bektas
bec8742495 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>
2021-11-11 14:16:09 +01:00
Fabian Grünbichler
a4d828e35e adapt to renamed storage-pair format
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2021-11-11 10:47:26 +01:00
Fabian Ebner
e5a6919c38 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>
2021-11-11 10:32:17 +01:00
Thomas Lamprecht
cc18103635 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>
2021-11-04 15:30:30 +01:00
Thomas Lamprecht
af2a1a1cdb 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>
2021-11-04 15:30:30 +01:00
Thomas Lamprecht
26b443c846 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>
2021-11-04 15:30:22 +01:00
Constantin Herold
101beafe0d 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>
2021-11-04 12:46:07 +01:00
Thomas Lamprecht
33f8b88782 agent hotplug: small style cleanups & comment addition
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-04 08:46:22 +01:00
Alexandre Derumier
74ea2c65a9 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>
2021-11-04 08:37:03 +01:00
Thomas Lamprecht
e8a268100b vm_commandline: reduce line bloat
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-03 16:35:57 +01:00
Thomas Lamprecht
6971c38ed9 print_keyboarddevice_full: drop unused machine parameter
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-03 16:35:57 +01:00
Thomas Lamprecht
f606d5bd6f scsi_inquiry: refactor and code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-03 16:35:57 +01:00
Thomas Lamprecht
8eb73377c1 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>
2021-11-03 16:21:22 +01:00
Thomas Lamprecht
1f91f7b464 drives: ro: code reduction/refactor
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-27 17:00:24 +02:00
Dominik Csapak
12e1d472e3 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>
2021-10-27 13:53:11 +02:00