Commit Graph

1459 Commits

Author SHA1 Message Date
Fiona Ebner
6ee6046ef2 fix #5562: tpm: avoid warning about undefined value when version is not explicitly set
Fixes: f9dde219 ("fix #3075: add TPM v1.2 and v2.0 support via swtpm")
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-07-01 10:37:37 +02:00
Fiona Ebner
581b678320 vma restore: bump timeout for reading header
With high IO pressure, 5 seconds might not be enough, even if the
request is small.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-18 17:48:45 +02:00
Fiona Ebner
4e06882ba5 vma restore: improve timeout error messages
The generic "got timeout" message cannot be associated to a certain
code path and also isn't very user-friendly. Use dedicated messages
for each stage and also suggest why the timeout for reading the header
might have happened, i.e. because it was corrupted.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-18 17:48:45 +02:00
Fiona Ebner
daf64a27b9 fix #5440: hmp helpers: drive{add, del}: increase timeout
The default timeout for HMP commands is 5 seconds.

While it should be rather fast to attach a new drive to QEMU, a busy
system might take longer, so future-proof and increase to 60 seconds.

On the other hand, detaching a drive needs to complete any pending IO
on it, so use the same 10 minutes timeout that's used for
drive-related QMP commands.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-06-11 13:56:44 +02:00
Fiona Ebner
c799e40fbf suspend: continue cleanup even if savevm-end QMP command fails
The savevm-end command also fails when no snapshot operation was
started before. In particular, this is the case when savevm-start
failed early, because of unmigratable devices.

Avoid potentially leaving an orphaned volume and snasphot-related
configuration keys around by continuing with cleanup instead.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-05-15 19:37:22 +02:00
Fiona Ebner
ce8a5a4b7e schema: fix description of migrate_downtime parameter
Since commit 865ef132 ("implement dynamic migration_downtime") the
migration downtime will be automatically increased when migration
cannot converge at the very end. Update the description to reflect
reality.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-05-03 19:32:45 +02:00
Thomas Lamprecht
6ba1f1c0c3 os type: add Windows Server 2025 as supported with win11 type
Martin tested the 2025 preview and it worked fine  using the win11 OS
type.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-20 16:19:17 +02:00
Dominik Csapak
4fd49b4a04 clone disk: prevent 'uninitialized value' warning for unused check
since commit
1f743141 (fix #1905: Allow moving unused disks)

we want to check the source drive name for 'unused', but in case of
importing a volume from the 'import' content type (e.g. from esxi),
there is no source drive name. So we have to first check if it's
defined.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-04-19 08:58:40 +02:00
Filip Schauer
1f743141e3 fix #1905: Allow moving unused disks
In the past, moving unused disks to another storage was prohibited due
to oversights in the handling of unused disks. This commit rectifies
this limitation by allowing the movement of unused disks.

Historical context:
* 16 Sep 2010 r5164 qemu-server/pve2: The disknames sub was removed.
* 17 Sep 2010 r5170 qemu-server/pve2: Unused disks were introduced.
* 28 Jan 2011 r5461 qemu-server/pve2: The same disknames sub that was
   removed in r5164 was brought back. Since unused disks were not around
   yet in r5164 the disknames sub did not consider unused disks.
* 6-8 Aug 2012 c1175c92..f91b2e45 qemu-server.git: Disk resize was
   introduced. In commit c1175c92 in sub qemu_block_resize unused disks
   were not taken into account and in commit 2f48a4f5 (8 Aug 2012) the
   resize API call was changed to only allow disks matching the ones in
   the disknames sub. Since sub disknames did not contain any unused
   disks, those were not allowed at all in the resize API call.
* 27 May 2013 586bfa78 qemu-server.git: Disk move was introduced. The
   API call implementation borrowed heavily from disk resize, including
   the behaviour of not taking unused disks into account. Thus, unused
   disk could not be moved, which persists to this day.

In summary, this behaviour was introduced because the handling of unused
disks was overlooked and it was never changed.

There is no inherent reason why unused disks should be restricted from
being moved to another storage. These disks cannot use the
qemu_drive_mirror, but they can still be moved with qemu_img_convert,
the same way as any other disk of a stopped VM.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2024-04-12 11:45:25 +02:00
Markus Frank
2db4c27283 fix #3784: config: Parameter for guest vIOMMU + test-cases
vIOMMU enables the option to passthrough pci devices to L2 VMs in L1
VMs via Nested Virtualisation and adds an extra isolation.

Uses the new property-string from the "config: define machine schema
as property-string"-commit to add the viommu option to the machine
parameter.

Currently there are two vIOMMU implementation in QEMU to choose:
intel or virtio

Virtio-iommu is more recent but less used in production than intel-iommu.

The assert_valid_machine_property function prevents using intel-iommu with
i440fx.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
 [ TL: tiny coding style fix to extract variable inside if expr ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-11 16:40:17 +02:00
Markus Frank
8082eb8ca1 config: define machine schema as property-string
Convert the machine parameter to a property-string and use the machine
type as the default key for backward compatibility.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
2024-04-11 10:18:27 +02:00
Thomas Lamprecht
20fc9811ec style fix: improve device-type variable name
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-10 13:56:50 +02:00
Hannes Duerr
6906c2ab33 drive: style fix the name of the get_scsi_device_type method
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-10 13:56:50 +02:00
Dominik Csapak
f0923f49e9 usb: fix undef error on string match
'$entry->{host}' can be empty, so we have to check for that before
doing a regex check, otherwise we get ugly errors in the log

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-22 14:17:53 +01:00
Wolfgang Bumiller
ddca7afe61 import: remove useless typoed error message
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-14 13:37:16 +01:00
Wolfgang Bumiller
eb06e48657 support live-import for 'import-from' disk options on create
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-13 16:29:58 +01:00
Wolfgang Bumiller
5b8d01f575 generalize live restore code
instead of a "pbs-backing" parameter we now have a
"live-restore-backing" parameter containing the `-blockdev` arg and
its name, which also means we print the blockdev earlier

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-11 10:41:42 +01:00
Thomas Lamprecht
4f2404057e config: update network: code-style & readability improvements
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-10 18:29:53 +01:00
Thomas Lamprecht
7c0f763d0c config: apply pending: code-style & readability improvements
among other things, avoid one indentation level by returning early
from the eval.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-10 18:29:26 +01:00
Thomas Lamprecht
3fde43d2ec config: pending network: avoid undef-warning on old/new comparison
A network device of a VM does not necessarily has to be connected to
an actual bridge, so when a new pending value is set we need to use
the undef-safe compare helpers when checking if there was a change
between old and new value, as otherwise one gets ugly "use of
uninitialized value in string ne" warnings.

Link: https://forum.proxmox.com/threads/143072/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-10 18:27:22 +01:00
Wolfgang Bumiller
9a1b5d0e71 add missing import
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-10 16:00:43 +01:00
Thomas Lamprecht
5ebb6018ed cpu config: implement is_native_arch locally for now
could be a better fit in PVE::Tools, like proposed by Filip, but OTOH.
Tools is already crowded as is, so wait if we need it on more places
outside of qemu-server.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-08 15:16:40 +01:00
Filip Schauer
d1a7abd07c cpu config: Unify the default value for 'kvm'
Make the default value for 'kvm' consistent, taking into account
whether the VM will run on the same CPU architecture as the host.

This would be a breaking change to CPU hotplug for VMs with a
different CPU architecture running on an x86_64 host, as in this case
the default CPU type for CPU hotplug changes from 'kvm64' to 'qemu64'.
However, CPU hotplug of non x86_64 architectures is not supported
anyway, so this is not a breaking change after all.

It should be noted that this change does alter the CPU hotplug
behaviour when emulating an x86_64 CPU on a non-x86_64 host. This is
however not officially supported in Proxmox VE.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2024-03-08 14:24:37 +01:00
Filip Schauer
bb42334981 Move is_native from PVE::QemuServer to PVE::Tools
Move is_native from PVE::QemuServer to PVE::Tools and rename it to
is_native_arch to be more descriptive.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2024-03-08 14:24:32 +01:00
Filip Schauer
89d5b1c90b prevent starting a 32-bit VM using a 64-bit OVMF BIOS
Instead of starting a VM with a 32-bit CPU type and a 64-bit OVMF image,
throw an error before starting the VM telling the user that OVMF is not
supported on 32-bit CPU types.

To obtain a list of 32-bit CPU types, refer to the builtin_x86_defs in
target/i386/cpu.c of QEMU. Exclude any entries that have the long mode
feature (CPUID_EXT2_LM).

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2024-03-08 14:24:32 +01:00
Dominik Csapak
a672c578e0 mediated device pass-through: fix race condition on VM reboot
When rebooting a VM from PVE (via CLI/API), the reboot code is called
under a guest lock, which creates a reboot request, shuts down the VM
and then calls the regular cleanup code, which includes the mdev
cleanup.

In parallel, the qmeventd observes that the VM process has gone, and
starts 'qm cleanup' which is (among other tasks) also starts the VM
again if a reboot from the PVE side is pending.
The qmeventd synchronizes this through a lock on the guest, with a
default timeout of 10 seconds.

Since we currently also always wait 10 seconds for the NVIDIA driver
to clean up the mdev, this creates a race condition for the cleanup
lock. IOW., when the call to `qm cleanup` starts before we started to
sleep for 10 seconds, it will not be able to acquire its lock and not
start the vm again.

To avoid the race condition in practice, do two things:
* increase the timeout in `qm cleanup` to 60 seconds.
  Technically this still might run into a timeout, as we can configure
  up to 16 mediated devices with each delaying 10 seconds in the worst
  case, but realistically most users won't configure more than two or
  three of them, if even that.

* change the hard-coded `sleep 10` to a loop sleeping for 1 second
  each before checking the state again. This shortens the timeout when
  the NVIDIA driver did not require the full 10s to finish the
  clean-up.

Further, add a bit of logging, so one can properly see in the task log
what is happening at which point in time.

Fixes: 49c51a60 (pci: workaround nvidia driver issue on mdev cleanup)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
 [ TL: change warn to print, reword commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-08 14:15:38 +01:00
Hannes Duerr
d1feab4aa2 fix #4957: add vendor and product information passthrough for SCSI-Disks
adds vendor and product information for SCSI devices to the json schema
and checks in the VM create/update API call if it is possible to add
these to QEMU as a device option

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
[FE: add missing space to exception message
     use config option for exception e.g. scsi0 rather than 'product'
     style fixes]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-01-26 11:12:58 +01:00
Fabian Grünbichler
c1b2092d5e qemu_volume_snapshot_delete: drop (now) unused parameter
since we always determine the deviceid, passing in a possibly wrong value makes
no sense and could actually re-introduce bugs.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2024-01-09 10:25:11 +01:00
Fiona Ebner
c60586838a fix #2258: select correct device when removing drive snapshot via QEMU
The QMP command needs to be issued for the device where the disk is
currently attached, not for the device where the disk was attached at
the time the snapshot was taken.

Fixes the following scenario with a disk image for which
do_snapshots_with_qemu() is true (i.e. qcow2 or RBD+krbd=0):
1. Take snapshot while disk image is attached to a given bus+ID.
2. Detach disk image.
3. Attach disk image to a different bus+ID.
4. Remove snapshot.

Previously, this would result in an error like:
> blockdev-snapshot-delete-internal-sync' failed - Cannot find device=drive-scsi1 nor node_name=drive-scsi1

While the $running parameter for volume_snapshot_delete() is planned
to be removed on the next storage plugin APIAGE reset, it currently
causes an immediate return in Storage/Plugin.pm. So passing a truthy
value would prevent removing a snapshot from an unused qcow2 disk that
was still used at the time the snapshot was taken. Thus, and because
some exotic third party plugin might be using it for whatever reason,
it's necessary to keep passing the same value as before.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-01-09 10:11:17 +01:00
Hannes Duerr
a17c753528 drive: Create get_scsi_devicetype
Encapsulation of the functionality for determining the scsi device type
in a new function for reusability in QemuServer/Drive.pm

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
2024-01-05 16:26:25 +01:00
Hannes Duerr
ad464e0b87 Move path_is_scsi to QemuServer/Drive.pm
Prepare for introduction of new helper

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
2024-01-05 16:26:25 +01:00
Fiona Ebner
498d7da470 fix #4501: TCP migration: start vm: move port reservation and usage closer together
Currently, volume activation, PCI reservation and resetting systemd
scope happen in between, so the 5 second expiretime used for port
reservation is not always enough.

It's possible to defer telling QEMU where it should listen for
migration and do so after it has been started via QMP. Therefore, the
port reservation can be moved very close to the actual usage.

Mentioned here for completeness and can still be done as an additional
change later if desired: next_migrate_port could be modified to
optionally return the open socket and it should be possible to pass
the file descriptor directly to QEMU, but that would require accepting
the connection before on the Perl side (otherwise leads to ENOTCONN
107). While it would avoid any races, it's not the most elegant
and the change at hand should be enough in all practical situations.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Acked-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
2024-01-03 11:31:53 +01:00
Fiona Ebner
2754b7e4d6 schema: mention that migration with VNC clipboard is not yet supported
as this might be surprising to users.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-11-29 10:25:16 +01:00
Stefan Lendl
0b034c15f4 sdn: pass vmid and hostname to add_dhcp_mapping
if no DHCP mapping was found in IPAM it will request a new IP which
requires these values.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
2023-11-21 20:51:56 +01:00
Wolfgang Bumiller
8497232bf5 fixup an sdn call outside the have_sdn guard
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-21 13:25:51 +01:00
Alexandre Derumier
3f14f206a0 nic online bridge/vlan change: link disconnect/reconnect
We want to notify guest of the change, so it can resubmit dhcp request,
or send gratuitous arp,...

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-21 13:24:50 +01:00
Alexandre Derumier
e6e6c2934d nic hotplug: add_dhcp_mapping
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-21 13:24:48 +01:00
Alexandre Derumier
89229af914 vm_destroy: delete ip from ipam
Co-Authored-By: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-21 13:24:46 +01:00
Alexandre Derumier
ee8d2dea5c api2: create|restore|clone: add_free_ip
Co-Authored-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-21 13:24:44 +01:00
Alexandre Derumier
c944fef885 vmnic add|remove : add|del ip in ipam
Co-Authored-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-21 13:24:41 +01:00
Markus Frank
b62997a171 config: enable VNC clipboard parameter in vga_fmt
add option to use the qemu vdagent implementation to enable the VNC
clipboard. When enabled with SPICE the spice-vdagent gets replaced
with the QEMU implementation.

This patch does not solve #1406, but does allow copy and paste with a
running X-session, when spice-vdagent is installed on the guest.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
2023-11-20 16:20:08 +01:00
Fiona Ebner
dec371d96c vm start: add warning about deprecated machine version
While there already is a warning from QEMU proper, that one is not
visible as a task warning and it's not straightforward to make it be
one, because QEMU is started inside a run_fork(). It's also more
future-proof to have the detection explicit on our side and the
documentation can be referenced.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-11-12 18:48:01 +01:00
Thomas Lamprecht
c351659d87 add some comments for legacy 2MB OVMF image builds
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-11 15:09:42 +01:00
Alexandre Derumier
6cb2338f53 nbd-stop: increase timeout to 25s
This can seemingly need a bit longer than expected, and better than
erroring out on migration is to wait a bit longer.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2023-11-06 19:45:55 +01:00
Alexandre Derumier
5bb8815a3f add|del_bridge_fdb: remove unused firewall param 2023-10-25 13:02:45 +02:00
Alexandre Derumier
d797bb62c3 cpu hotplug: cannot change feature online
The vCPUs are passed as devices with specific id only when CPU
hot-plug is enable at cold start.

So, we can't enable/disable allow-hotplug online as then vCPU hotplug
API will thrown errors not finding core id.

Not enforcing this could also lead to migration failure, as the QEMU
command line for the target VM could be made different than the one it
was actually running with, causing a crash of the target as Fiona
observed [0].

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

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
 [ TL: Reflowed & expanded commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-24 11:46:52 +02:00
Filip Schauer
6f0627d4bd backup, migrate: fix races with suspended VMs that can wake up
Fix races with ACPI-suspended VMs which could wake up during migration
or during a suspend-mode backup.

Revert prevention, of ACPI-suspended VMs automatically resuming after
migration, introduced by 7ba974a682. The commit introduced a
potential problem that causes a suspended VM that wakes up during
migration to remain paused after the migration finishes.

This can be fixed once QEMU preserves the 'suspended' runstate during
migration (current patch on the qemu-devel list [0]) by checking for
the 'suspended' runstate on the target after migration.

Furthermore the commit increased the race window during the
preparation of a suspend-mode backup, when a suspended VM wakes up
between the vm_is_paused check in PVE::VZDump::QemuServer::prepare and
PVE::VZDump::QemuServer::qga_fs_freeze. This causes the code to skip
fs-freeze even if the VM has woken up, potentially leaving the file
system in an inconsistent state.

To prevent this, do not treat the suspended runstate as paused when
migrating or archiving a VM.

[0]: https://lists.nongnu.org/archive/html/qemu-devel/2023-08/msg05260.html

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
 [ TL: massage in Fiona's extra info into commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-16 16:48:47 +02:00
Filip Schauer
7ba974a682 Fix ACPI-suspended VMs resuming after migration
Add checks for "suspended" and "prelaunch" runstates when checking
whether a VM is paused.

This fixes the following issues:
* ACPI-suspended VMs automatically resuming after migration
* Shutdown and reboot commands timing out instead of failing
  immediately on suspended VMs

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2023-10-10 09:27:18 +02:00
Alexandre Derumier
7f8c808772 add memory parser
In preparation to add more properties to the memory configuration like
maximum hotpluggable memory and whether virtio-mem devices should be
used.

This also allows to get rid of the cyclic include of PVE::QemuServer
in the memory module.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
[FE: also convert new usage in get_derived_property
     remove cyclic include of PVE::QemuServer
     add commit message]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-09-18 17:08:48 +02:00
Fiona Ebner
87b0f305e7 introduce QMPHelpers module
moving qemu_{device,object}{add,del} helpers there for now.

In preparation to remove the cyclic include of PVE::QemuServer in the
memory module and generally for better modularity in the future.

No functional change intended.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-09-18 17:08:48 +02:00