Commit Graph

209 Commits

Author SHA1 Message Date
Thomas Lamprecht
305e9cec5d memory hot plug: round down to nearest even phys-bits for heuristics
Mira found out that 41 phys-bits the limit is pretty much the same as
with 40, as such odd sizes are a bit unexpected anyway lets mask the
LSB and use that as base, that way we're good again.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-17 17:45:59 +01:00
Thomas Lamprecht
33b0d3b7be memory hotplug: rework max memory handling, make phys-bits dependent
QEMU 7.1 introduced some actual checks for the max memory value in
1caab5cf86bd ("i386/pc: bounds check phys-bits against max used GPA")
and while correct it breaks our by-luck working hard coded max mem of
4 TB for cases with smaller phys bit address sizes, like some older
CPUs or most CPU types have per default if not 'host' or 'max'.

QEMU uses 40 bits per default if the CPU isn't set to host or
phys-bits is not set explicitly.

For 40 bit it seems that depending on machine type one has a max
possible mem of: i440 -> 752, q35 -> 722 GiB, but instead of reducing
it to 704 GiB (512+1128+64) in a hard coded way we acutally check for
the bit size that will probably be used and use that to determine the
max memory size useable.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-17 16:54:49 +01:00
Thomas Lamprecht
d1901fe2ce cpu config: indentation fixup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-17 16:46:40 +01:00
Leo Nunner
f5a88e9870 fix #4321: properly check cloud-init drive permissions
The process for editing Cloud-init drives checked for inconsistent
permissions: for adding, the VM.Config.Disk permission was needed, while
the VM.Config.CDROM permission was needed to remove a drive. The regex
in drive_is_cloudinit needed to be adapted since the drive names have
different formats before/after they are actually generated.

Due to the regex letting names fall through before, Cloud-init drives
were being checked as disks, even though they are actually treated as
CDROM drives. Due to this, it makes more sense to check for
VM.Config.CDROM instead, while also requiring VM.Config.Cloudinit, since
generating a Cloud-init drive already generates default values that are
passed to the VM.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
2022-11-17 08:10:28 +01:00
Wolfgang Bumiller
1b5706cd16 drop get_pending_changes and simplify cloudinit_pending api call
- The forced-remove flag wasn't really used AFAICT and makes
  no sense IMO.
- Whether or not we care about non-MAC changes does not
  belong here, but should instead taken into account in the
  actual hotplug path recording the cloud-init state (iow.
  into $cloudinit_record_changed().)
  (This is not done here atm.)
- It seems much simpler to just have:
  * 'old' = the old value if it's not a new value
  * 'new' = the new value unless it's being deleted
  * If only one of them is set it's an addition or removal.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-16 18:17:07 +01:00
Wolfgang Bumiller
4b785da1a9 delay cloudinit generation in hotplug
Hotpluggieg generated a cloudinit image based on old values
in order to attach the device and later update it again, but
the update was only done if cloudinit hotplug was enabled.
This is weird, let's not.

Also introduce 'apply_cloudinit_config' which also write the
config, which, as it turns out, is the only thing we
actually need anyway, currently.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-16 18:17:07 +01:00
Wolfgang Bumiller
0337d531a0 Partially-revert "cloudinit: add cloudinit section for current generated config"
This partially reverts commit 95a5135dad.
Particularly the unprotected write to the config when
generating the cloudinit file. We leave the rest as is for
now and update the callers to deal with the config later.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-11-16 18:17:07 +01:00
Wolfgang Bumiller
3de134ef4a Revert "cloudinit: avoid unsafe write of VM config"
This reverts commit b137c30c3a.

In preparation of fixing the special:cloudinig section.
2022-11-16 18:16:56 +01:00
Thomas Lamprecht
b137c30c3a cloudinit: avoid unsafe write of VM config
there's no guarantee that we're locked here and it also produces
unnecessary extra IO in most cases.

While at it also avoid that a special:cloudinit section is added on
start to *every* VM, which caused another bug to trigger (see prev.
commit) and is just odd for users that ain't using cloudinit

Note in two call sites that we may need to write the config indeed
out there on the caller side.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-16 12:03:53 +01:00
Thomas Lamprecht
05eae0f21f cleanup validate_cpu_conf
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-15 08:49:04 +01:00
Thomas Lamprecht
f6b24f427d usb: fixup: include USB config only for non-q35 again
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-11 07:43:03 +01:00
Thomas Lamprecht
342f049352 usb: small style/code cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-10 17:02:34 +01:00
Thomas Lamprecht
e68881e4a3 usb: get controllers: avoid separate loop for usb 2 devs and improve variable names
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-10 17:02:34 +01:00
Thomas Lamprecht
871ebe1775 usb: rename check_usb_index into assert_usb_index_is_useable
to better convey that this might die

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-10 17:02:34 +01:00
Dominik Csapak
0c3d18ef13 USB: increase max usb devices to 14 for newer machine version and ostype
for machine versions >= 7.1 and ostype linux or windows > 7, we use the
qemu-xhci controller where we have up to 14 usable ports, so make them
available to the user

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-10 17:02:34 +01:00
Dominik Csapak
4862922a2b fix #4324: USB: use qemu-xhci for machine versions >= 7.1
going by reports in the forum (e.g. [0]) and semi-official qemu
information[1], we should prefer qemu-xhci over nec-usb-xhci

for compatibility purposes, we guard that behind the machine version,
so that guests with a fixed version don't suddenly have a different usb
controller after a reboot (which could potentially break some hardcoded
guest configs)

0: https://forum.proxmox.com/threads/proxmox-usb-connect-disconnect-loop.117063/
1: https://www.kraxel.org/blog/2018/08/qemu-usb-tips/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-10 17:02:34 +01:00
Dominik Csapak
3deccbd7d0 USB: use machine_type_is_q35 instead of regex
we refactored that into PVE::QemuServer::Machine a while ago, so we can
use it here

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-10 17:02:34 +01:00
Dominik Csapak
b06a24927c USB: print_usbdevice_full: error out on invalid configuration
should not happen normally, but an inattentive user of that function
may forget to check the validity of the parsed device, so err
on the safe side here

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-10 17:02:34 +01:00
Dominik Csapak
238af88edc move 'windows_version' to Helpers
to avoid a cyclic dependency when we want to use that in PVE::QemuServer::USB

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-10 17:02:34 +01:00
Dominik Csapak
6fa358a334 pci: make mediated device sysfs path independent of PCI id
mdevs have a host-unique UUID they are indexed with in the PCI-id
independent `/sys/bus/mdev/devices/<uuid>` path, so there is no need
to go through the PCI id for them.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-11-09 09:06:19 +01:00
Thomas Lamprecht
2fa64dbddd pci: add/improve HW reservation comments
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-09 08:55:55 +01:00
Dominik Csapak
1b189121fc vm start/stop: cleanup passed-through pci devices in more situations
if the preparing of PCI devices or the start of the VM fails, we need
to cleanup the PCI devices (reservations *and* mdevs), or else it
might happen that there are leftovers which must be manually removed.

to include also mdevs now, refactor the cleanup code from
'vm_stop_cleanup' into it's own function, and call that instead of
only 'remove_pci_reservation'

also simplifies the code, such that it now removes all PCI ids
reserved for that VMID, since we cannot have multiple VMs with the
same VMID anyway

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-09 08:49:45 +01:00
Alexandre Derumier
2be1fb0af4 api2: add cloudinit config api
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2022-11-08 17:24:59 +01:00
Alexandre Derumier
95a5135dad cloudinit: add cloudinit section for current generated config.
Instead using vm pending options for pending cloudinit generated config,

write current generated cloudinit config in a new [special:cloudinit] SECTION.

Currently, some options like vm name, nic mac address can be hotplugged,
so they are not way to know if the cloud-init disk is already updated.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2022-11-08 17:23:30 +01:00
Alexandre Derumier
9c88e85446 migration: test targetnode min version for cloudinit section
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
2022-11-08 17:23:30 +01:00
Thomas Lamprecht
adc67fe917 cpu config: fix depreacation mapping on CPU hotplug of custom types
we need to do the independent of is_custom_model to ensure the
reported model is understood by QEMU

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reported-by: Fiona Ebner <f.ebner@proxmox.com>
2022-08-30 09:25:06 +02:00
Thomas Lamprecht
0d6962f935 cpu config: map depreacated IceLake-Client CPU type to IceLake-Server
the former CPU type never existed on the market and will be dropped
by QEMU 7.1, so map it to the server variant as they're pretty much
identical anyway FIWCT.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-08-30 09:09:13 +02:00
Thomas Lamprecht
b0ab346381 cpu config: minor code style nits/comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-08-30 09:09:13 +02:00
Dominik Csapak
bbf96e0f1e automatically add 'uuid' parameter when passing through NVIDIA vGPU
When passing through an NVIDIA vGPU via mediated devices, their
software needs the qemu process to have the 'uuid' parameter set to the
one of the vGPU. Since it's currently not possible to pass through multiple
vGPUs to one VM (seems to be an NVIDIA driver limitation at the moment),
we don't have to take care about that.

Sadly, the place we do this, it does not show up in 'qm showcmd' as we
don't (want to) query the pci devices in that case, and then we don't
have a way of knowing if it's an NVIDIA card or not. But since this
is informational with QEMU anyway, i'd say we can ignore that.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-08-12 13:42:33 +02:00
Alexandre Derumier
9b1971c5c9 cpuconfig: add amd epyc milan model
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2022-05-20 09:45:18 +02:00
Dominic Jäger
e6ac9fed7b api: support VM disk import
Extend qm importdisk functionality to the API.

Co-authored-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Co-authored-by: Dominic Jäger <d.jaeger@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-04-04 16:41:13 +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
Dominik Csapak
d8a7e9e881 PCI: allow longer pci domains
some systems[0] have pci domains longer than the default ('0000') of 4
characters, so change the regex to allow at least 4.

0: https://forum.proxmox.com/threads/problem-with-gpu-passthrough-in-a-virtual-machine.105720/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-03-16 18:03:35 +01:00
Thomas Lamprecht
11f9264fed cpu config: code format/whitespace fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-16 15:53:00 +01:00
Fabian Ebner
84c253e947 parse ovf: untaint path when calling file_size_info
Prepare for calling parse_ovf via API, where the -T switch is used.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2022-03-11 10:45:59 +01:00
Nicholas Sherlock
d806b017ac 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>
2022-01-25 10:59:23 +01:00
Mira Limbeck
ea18b60455 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>
2021-12-21 15:45:18 +01:00
Dominik Csapak
1319908f5d 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>
2021-11-15 16:57:52 +01:00
Aaron Lauterer
1071373027 Drive: add valid_drive_names_with_unused
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2021-11-09 16:16:00 +01:00
Thomas Lamprecht
115cb432bc 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>
2021-11-04 13:14:17 +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
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
Thomas Lamprecht
2c29655663 Revert "config_aware_timeout: add 5s if TPM is configured"
This reverts commit d4e1e1f862.

It's bogus, the VM start timeout is only starting to tick after we
started the TPM already...
2021-10-18 09:47:42 +02:00
Thomas Lamprecht
d4e1e1f862 config_aware_timeout: add 5s if TPM is configured
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-18 09:43:46 +02:00
Thomas Lamprecht
c077cc166e cloudinit: opennebula: refactor to reduce code bloat
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Thomas Lamprecht
2eee6748a0 cloudinit: better use of string variable interpolation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 19:58:16 +02:00
Thomas Lamprecht
d01de38cb6 pci: prepare: improve no-IOMMU error message
give some context

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

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

Among other things:

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

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

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

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

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-15 14:44:50 +02:00