Commit Graph

898 Commits

Author SHA1 Message Date
Aaron Lauterer
a9ce7583cf usb: Fix local resource check of Spice USB devices
The check relied on the fact that in a regular use case a usb device of
type spice would not have any other settings like `usb3=1`. An exact
match worked fine for this.

This patch changes the behaviour and makes it possible to migrate VMs
with Spice USB devices that have additional usb options set.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-09-21 13:42:47 +02:00
Aaron Lauterer
ae36393d5a usb: Add USB3 capabilities to Spice USB devices
To not change current behaviour and thus breaking live migration USB3
for a Spice USB device requires Qemu v4.1.

The old behavior was that even though technically it was possible to
the set `usb3=1` setting, it was ignored. The bus was hardcoded to
ehci. If another USB2 device was added or the machine type was set to
Q35 an ehci controller was present and the VM was able to boot.

With this patch the behaviour is changing and the bus is set to xhci if
USB3 is set for the Spice USB device and the VM is running under Qemu
v4.1.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-09-21 13:22:17 +02:00
Dominik Csapak
165411f0c2 api: add reboot api call
this creates a reboot request file (inspired by pve-container)
and relies on the 'qm cleanup' call by the qmeventd to detect
and restart the vm afterwards

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-11 14:13:35 +02:00
Dominik Csapak
575d19dab5 refactor vm_stop locked code
we want to reuse most of the code in the locked context of vm_stop
for vm_reboot (since it really is just a vm_stop with a
create_reboot_request in there) so we factor that out into
_do_vm_stop
and note that it has to be called in a locked context

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-11 14:13:35 +02:00
Dominik Csapak
64457ed4aa qm: cleanup: detect and handle reboot trigger
if the reboot trigger file was set, start the vm again
also cleanup the reboot trigger on vm startup, to prevent
leftover files to trigger a reboot at the next shutdown

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-11 14:13:35 +02:00
Dominik Csapak
dae98db96e add create and remove reboot trigger subs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-11 14:13:35 +02:00
Thomas Lamprecht
dae0c8e5fa config_to_command: refactor/cleanup try for hostpci part
try to increase variable declaration to use locality, reduce
duplication of same variable names used, and try to cleanup a bit in
general..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-09-06 19:27:30 +02:00
Aaron Lauterer
c4e1638148 Add support for up to 16 PCI(e) devices
For non pci express passthrough additional addresses are reserved.
For pcie passthrough pcie root ports are needed (unless guest is like
windows 7).

The first 4 pcie root ports are defined by default in the pve-q35*.cfg
files. If more than 4 pcie devices are passed through the needed root
ports are created on demand. This helps to keep live migration possible
without adding a new pve-q35*.cfg file.

For the windows 7 like guests additional addresses are reserved as well.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-09-06 19:27:30 +02:00
Thomas Lamprecht
d282a24d1b spice enhancements: document default values
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-09-04 14:44:04 +02:00
Thomas Lamprecht
caab114a56 followup: code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-09-04 13:26:11 +02:00
Aaron Lauterer
c4df18db91 fix #2041, #2272: Add Spice enhancements
This adds a new config option called `spice_enhancements` with two
optional settings:

* videostreaming
* foldersharing

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-09-04 13:06:49 +02:00
Peter Keresztes Schmidt
cd98c4675b CPU flags: Add aes flag
Signed-off-by: Peter Keresztes Schmidt <peterke@sos.ethz.ch>
2019-08-23 10:37:22 +02:00
Dominik Csapak
8071149be8 qemu_machine_pxe: remove unused parameter
no caller used that parameter, ever

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-08-13 15:35:01 +02:00
Dominik Csapak
1476b99fe9 rework kvm_user_version cache mechanism
we now also save the mtime of the binary and cache per binary (for each
arch; this is done so we have it already when we sometime decide
that we want to split the qemu package for each arch)
so that we get the real version if only pve-qemu-kvm was updated

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-08-13 15:35:01 +02:00
Thomas Lamprecht
b0f96836db q35 already has an 'audio0' device, rename our to "audiodev$id"
The latest changes to our audio device implemenation [0] changed the
naming of the device id to "audio<id>" which in practice resulted in
"audio0".

This conflicts with the predefined audio device in the Q35 configs
that is also using "audio0". The result is that a VM with a
configured audio device and Q35 type will not start.

While we just would had removed the audio0 device if we had detected
this earlier in the new 4.0 q35 config, we cannot do so anymore due
to migration compatibility.

So rename the device from "audio$id" to audiodev$id".

Co-authored-by: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-24 15:06:53 +02:00
Stefan Reiter
3a040a0ead Make hv-tlbflush and hv-evmcs optional and merge flag list
Both flags were causing issues and have been made into optional flags to
be manually selected by the user if needed.

The supported flags have been merged into a single list for convenience.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-07-23 18:15:05 +02:00
Thomas Lamprecht
d5535a00c4 audio follouwp: pull out parsing into a conf_has_audio
now that we finally now what the ID from the audiodev is for let's
factor some format string parsing out making a eventual future multi
audio device support with differen backends quite easy to support
here - once QEMU itself supports that fully.[0][1]

[0]: https://pve.proxmox.com/pipermail/pve-devel/2019-July/038400.html
[1]: https://lists.nongnu.org/archive/html/qemu-devel/2019-07/msg03583.html

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-23 18:14:09 +02:00
Aaron Lauterer
1448547f44 audio dev: specify qemu audio backend
QEMU 4 adds the `-audiodev` parameter to explicitly specify the audio
backend. Setting it avoids occasional error messages when starting a
virtual machine with an audio device and qemu wants to connect it to the
physical audio device.

For now only SPICE is supported as it's also the biggest use case.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-07-22 09:51:03 +02:00
Dominik Csapak
c30e80aba9 remove unused variable
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-07-18 18:48:30 +02:00
Dominik Csapak
d30820d6c3 fix #2275: die on invalid sendkey
sendkey does not return anything if it is succesful and the error otherwise

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-07-18 18:48:30 +02:00
Thomas Lamprecht
b3703d39bd audio dev: follouwp code cleanup and error handling
die if we get some unknown value, which is either a bug (new dev type
added to enum but not here) or a user manual edit error, good to
ccatch both

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-18 09:09:01 +02:00
Thomas Lamprecht
194b65f188 audio dev: add note that this is useful for SPICE
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-18 09:08:40 +02:00
Aaron Lauterer
2e7b59252c Add audio device support
Until now audio devices had to be added manually with the `args` option
in the VMs config file. This adds a new config option to define an audio
device. It is called `audio0` with the extra `0` to be prepared should
we ever implement support for more than one audio device.

Supported devices are:

* ich9-intel-hda: Intel HD Audio Controller, emulates ICH9
* intel-hda: Intel HD Audio Controller, emulates ICH6
* AC97: useful for older OSs like Win XP

If any of the `intel-hda`s is selected two additional devices will be
created: hda-micro and hda-duplex. The `*intel-hda` controllers need at
least one of them as they emulate microphones and speakers (hda-micro)
or line in and out devices (hda-duplex).

Having both is deemed best practice to avoid problems if some software
needs one of the other kind of output/input ports.

I also cleaned up some old, commented out, code regarding audio devices.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-07-18 08:24:39 +02:00
Dominik Csapak
7583d156fd use new pcie port hardware
with qemu 4.0 we can make use of the new pcie-root-ports with settings
for the width/speed which can resolve issues with some hardware combinations
when negioating link speed

so we add a new q35 cfg that we include with machine types >= 4.0
to preserve live migration of machines without passthrough but q35

for details about the link speeds see:

pcie: Enhanced link speed and width support
https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg02827.html

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-07-08 13:31:55 +02:00
Alwin Antreich
85f0511db3 Fix: rtcflags: ignore startdate 'now'
If 'now' is passed to the startdate option, the kvm start fails with
below failure.
 kvm: invalid datetime format
 valid formats: '2006-06-17T16:01:21' or '2006-06-17'

With this patch, 'now' is ignored and not passed to the rtcflags (-rtc).

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
2019-07-04 11:29:26 +02:00
Thomas Lamprecht
32075a2cb8 check_local_storage_availability: only count each unavailable storage once
and some general cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-28 17:39:16 +02:00
Tim Marx
c272ba8db3 migrate: add size to volume attributes
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-28 15:22:33 +02:00
Tim Marx
f25852c27e migrate: handle storage not selected manually in storage config
e.g. local storage was considered not allowed for offline migration
even if it is available on all nodes, this should now be fixed as it
is now considered available on all nodes if a local storage isn't
restricted to a specific subset of the available nodes. The user is
responseable to make sure that the datacenter storage config reflects
the actual setup, so there is no additional check for local storages
which aren't available on all nodes if they are not explicitly marked
at datacenter level.

Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-28 15:22:33 +02:00
Stefan Reiter
1688362d4e Fix guest agent shutdown without timeout
Regression from change allowing timeouts to be set, now shutting down
also works without timeouts again (previously qmp failed because of
the unknown "timeout" parameter passed to it).

We always delete the timeout value from the arguments, regardless of
truthiness. "delete" returns the deleted element, deleting a
non-existant hash entry returns undef, which is fine after this point:

"deleting non-existent elements returns the undefined value in their
corresponding positions."
- https://perldoc.perl.org/functions/delete.html

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-06-25 16:52:24 +02:00
Thomas Lamprecht
71a1e5680b add_hyperv_enlightenments: do not add hv_evmcs for now at all
as Windows VMs on hosts with AMD CPUs do not start at all with
that...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-25 14:32:06 +02:00
Thomas Lamprecht
0b05530b56 followup: move hv_tlbflush under 3.1 machine feature guard
while it really should not pose an issue for live migrations lets be
on the safe side and also add this only with 3.1 or later machines

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-24 17:23:44 +02:00
Stefan Reiter
392dfbf51e fix #2083: Add hv_tlbflush, hv_ipi, hv_evmcs enlightenments
Kernels 4.18+ (4.17+ for evmcs) support new Hyper-V enlightenments for
Windows KVM guests. QEMU supports these since 3.0 and 3.1 respectively.
tlbflush and ipi improve performance on overcommitted systems, evmcs
improves nested virtualization.

It's not entirely clear to me if Win7 already supports these, but since
it doesn't cause any performance penalties (and it works fine without
crashing, which makes sense either way, because Hyper-V enlightenments
are opt-in by the guest OS), enabling it regardless should be fine.
(As opposed to adding a new if branch for win8+)

Feature explanations to the best of my understanding:

hv_tlbflush allows the guest OS to trigger tlb shootdowns via a
hypercall. This allows CPUs to be identified via their vpindex (which
makes hv_vpindex a prerequisite to hv_tlbflush, but that is already
handled in our code). In overcommited configurations, where multiple
vCPUs reside on one pCPU, this increases performance of guest tlb
flushes, by only flushing each pCPU once. It also allows multiple tlb
flushes with only one vmexit.

hv_ipi allows sending inter-processor interrupts via vpindex, once again
making it a prerequisite. Benefits are pretty much as with tlbflush.

hv_evmcs is a VM control structure in L1 guest memory, allowing an L1 guest
to modify L2 VMCS and entering L2 without having the L0 host perform an
expensive VMCS update on trapping the nested vmenter.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-06-24 17:22:35 +02:00
Stefan Reiter
0eb2169136 fix #2244: Allow timeout for guest-agent shutdown
The "guest-shutdown" guest agent call is blocking for some reason, so if
it fails (e.g. agent not installed on guest) only the default timeout of
10 minutes (see QMPClient.pm, sub cmd) would apply.

With this change, if (and only if) a timeout is specified via CLI/API,
it is used instead. In case it is not specified, behaviour stays the
same (default 10 min timeout).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-06-24 17:20:30 +02:00
Wolfgang Bumiller
4f8cfa190a wait for vm scopes to be gone
This should help with the rare case where stop mode backups
fail to restart due to the $vmid.scope not being completely
gone when we want to restart. This queries systemd via dbus,
and if the scope is still there, awaits a UnitRemoved signal
for the scope from dbus.

For now with a 5 second timeout... (given that the processes
are already gone and it's really just waiting for systemd to
wake up, this should be plenty...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-19 10:11:38 +02:00
Thomas Lamprecht
5d004b0038 SMBIOS: followup: allow now 512 characters for full format string
to acutally allow to set the values requested by #2190 we need to
alter the limit a bit, as else the requested values cannot be save.

Just double it to 512, which should be really enough for this, else
go complain to your software vendor for needing such _hacks_ in the
first place..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-11 17:39:22 +02:00
Christian Ebner
1f30ac3a9f fix #2190: Base64 encode SMBIOS value strings in order to allow more characters
On some occasions e.g. license checking, the manufacturer string in the
SMBIOS settings edit has to allow characters such as whitespaces.
https://forum.proxmox.com/threads/proxmox-and-windows-rok-license-for-dell.53236/
In principle SMBIOS allows to pass any zero terminated string to the
corresponding fields in the structure type 1 (System Information).

By base64 encoding the values clashing of the config is avoided.

Relies on the corresponding patch to pve-manager to obtain base64 encoded values.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-06-11 13:04:34 +02:00
Thomas Lamprecht
5dcee818d2 followup: mention new md-clear flag also in description
that should really be autogenerated!

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-07 17:55:34 +02:00
Oguz Bektas
df503832ff add md-clear cpu flag
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-06-07 17:55:24 +02:00
Thomas Lamprecht
dc62a7fafc drop vnc x509 param, deprecated in 2.5 removed in 4.0
while we have 3.0.1 for now, 4.x will come sooner or later so do this
now already..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 09:52:44 +02:00
Thomas Lamprecht
90041ba890 drop references to un-maintained sheepdog plugin
we remove it from pve-storage as it's abandoned

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-04 17:43:11 +02:00
Thomas Lamprecht
8aa2ed7c85 refactor do_snapshots_with_qemu a bit cleaner
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-04 17:41:23 +02:00
Fabian Grünbichler
3e24733bdf vm_resume: correctly honor $nocheck
for both vm_mon_cmd calls. under certain circumstances, the following
sequence of events can otherwise fail when live-migrating under load:

S...source node
T...target node

0: migration is complete, handover from S to T starts
1: S: logically move VM config file from S to T via rename()
2: S: rename returns, config file is (visibly) moved on S
3: S: trigger resume on T via mtunnel
4a: T: call vm_resume while config file move is not yet visible on T
4b: T: call vm_resume while config file move is already visible on T

4a instead of 4b means vm_mon_cmd will die in check_running unless
vm_mon_cmd_nocheck is used.

under heavy pmxcfs load and a slow cluster/corosync network, there can
be a few seconds of delay between 1 and 2, with a subsequent race ending in 4a
instead of 4b.

this issue was reported to occur on bulk migrations.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-05-25 11:28:26 +02:00
Thomas Lamprecht
bf4a933e52 fixup: delete cloudinit disk before restoring
cloudinit is just completely broken...
Until we rewrite this to a sane designe (i.e., never backup, mirror,
... any CI disk anywhere - the state is in the config and gets
created on start and deleted on stop anyway) do this..

Co-developed-by: Mira Limbek <m.limbek@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-05-17 12:09:56 +02:00
Thomas Lamprecht
2b2923aefd QemuServer: code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-05-17 10:53:50 +02:00
Thomas Lamprecht
87056e1821 follouwp: set is_cloudinit in drive to avoid always rechecking
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-05-17 10:53:30 +02:00
Mira Limbeck
c4ab3c5584 map cloudinit disk to new vmid on restore
Resolves the issue of restoring a VM that has a cloudinit drive
configured to a new VMID. The VMID of the disk name gets now remapped
correctly and in the process the cloudinit disk is created with the same size
as in PVE/API2/Qemu.pm create_disks and in PVE/QemuServer/Cloudinit
commit_cloudinit_disk as the same constant is used.

This is done by matching any line starting with either 'ide', 'sata' or
'scsi' and then check if it is a cloudinit drive. As cloudinit drives
are attached as cdrom, only those 3 are possible. For the cloudinit
check we use 'parse_drive' followed by 'drive_is_cloudinit' so no custom
regex is necessary.

'--targetstorage' is also taken into account on restore now for
cloudinit disks. If a target storage is specified the format is either
kept if possible, or changed to the default of that storage.

This should fix #1807 completely. The restore error was already resolved
with commit 7e8ab2a, but the vmid of the disk might not have matched the new
one.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-05-16 16:29:02 +02:00
Thomas Lamprecht
a357092190 fixup: shorter/conciser comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-05-16 16:29:02 +02:00
Mira Limbeck
e1afab6e28 fix clone_disk with formats other than raw/qcow2
with commit 64d1a6a it's now possible to specify a format other than raw
or qcow2 when creating VMs. This can lead to an error when cloning the
VMs and a cloudinit disk with a different format is attached (e.g.
vmdk).

We use QEMU_FORMAT_RE in drive_is_cloudinit and according to the
QEMU_FORMAT_RE we support 7 different formats.

With this change we add any format other than 'raw' as '.<format>' to the
name and no longer die on any other format. Cloudinit disks with invalid
format are not cloned as the drive is recognized as cdrom, not cloudinit.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-05-16 16:27:07 +02:00
Tim Marx
ca6abacf6b migrate: log which local resource causes error
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-05-07 10:22:12 +00:00
Tim Marx
370b05e719 whitespace cleanup
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-05-07 10:22:12 +00:00