5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-10 01:18:01 +03:00
Commit Graph

1099 Commits

Author SHA1 Message Date
Stefan Reiter
acc10e5159 migrate: enable dirty-bitmap migration
We query QEMU if it's safe before enabling it, as on versions without
the necessary patches it not only would be useless, but can actually
lead to hangs.

PBS state is always migrated, as it's a small amount of data anyway, so
we don't need to set a specific flag for it.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-10-29 18:18:02 +01:00
Stefan Reiter
4c27b18c08 bootorder: don't print empty 'order=' property
Specifying 'boot: order=' was intended to be used for an empty bootorder
(i.e. no boot devices), but as it turns out our format parser doesn't
like empty '-list' properties if they are nested in a subformat.

Fixing this in JSONSchema sounds like a risky move, so instead just
write 'boot: ' (without 'order=') to indicate an empty bootorder. The
rest of the code handles it just fine, as this was valid before too.

Incidentally also fixes a bug where you couldn't create a new VM without
any disks if no explicit 'boot' property was specified (i.e. a simple
'qm create 100' without any parameters would fail).

Reported-by: Dominic Jäger <d.jaeger@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-10-22 08:47:45 +02:00
Thomas Lamprecht
50bbe37787 comment out USB hotplug code
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-19 15:31:38 +02:00
Thomas Lamprecht
808a65b522 fix some FH close
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-19 15:30:53 +02:00
Thomas Lamprecht
41af2dfc25 PCI: use warnings/strict and fix setting $vga from config2command
fixes commit 74c17b7a23 which moved
this code here, but forgot to pass $vga ref, as the module was not
using warning nor strict mode this was not caught..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 18:03:32 +02:00
Thomas Lamprecht
f7d1505b0c tree wide cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 18:03:32 +02:00
Thomas Lamprecht
ca3ac88200 drop legacy __read_avail code
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 16:52:29 +02:00
Thomas Lamprecht
e5d611c382 fix various conditionally declared vars
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 16:52:11 +02:00
Thomas Lamprecht
d1c1af4b02 tree wide cleanup of s/return undef/return/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 16:20:05 +02:00
Mira Limbeck
d0abc7746a fix clone_disk failing for nonexistent cloudinit disk
After migration or a rollback the cloudinit disk might not be allocated, so
volume_size_info() fails. As we override the value anyway for cloudinit
and efi disks simply move the volume_size_info() call into the 'else'
branch.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-10-16 15:39:43 +02:00
Fabian Ebner
32e5405084 fix typos
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-10-16 15:39:13 +02:00
Stefan Reiter
2141a802b8 fix #3010: add 'bootorder' parameter for better control of boot devices
(also fixes #3011)

Deprecates the old-style 'boot' and 'bootdisk' options by adding a new
'order=' subproperty to 'boot'.

This allows a user to specify more than one disk in the boot order,
helping with newer versions of SeaBIOS/OVMF where disks without a
bootindex won't be initialized at all (breaks soft-raid and some LVM
setups).

This also allows specifying a bootindex for USB and hostpci devices,
which was not possible before. Floppy boot support is not supported in
the new model, but I doubt that will be a problem (AFAICT we can't even
attach floppy disks to a VM?).

Default behaviour is intended to stay the same, i.e. while new VMs will
receive the new 'order' property, it will be set so the VM starts the
same as before (using get_default_bootorder).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-10-14 12:30:50 +02:00
Stefan Reiter
5cfa9f5f73 add new 'boot' property format and introduce legacy conversion helpers
The format is unused in this commit, but will replace the current
string-based format of the 'boot' property. It is included since the
parameter of bootorder_from_legacy follows it.

Two helper methods are introduced:
* bootorder_from_legacy: Parses the legacy format into a hash closer to
    what the new format represents
* get_default_bootdevices: Encapsulates the legacy default behaviour if
    nothing is specified in the boot order

resolve_first_disk is simplified and gets a new $cdrom parameter to
control the behaviour of excluding CD-ROMs or instead searching for only
them.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-10-14 12:30:50 +02:00
Stefan Reiter
d0a86b2425 fix indentation
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-10-14 12:30:50 +02:00
Thomas Lamprecht
4df98f2f14 line length and formatting fixes
In accord to updated perl style guide
https://pve.proxmox.com/wiki/Perl_Style_Guide#Breaking_long_lines_and_strings

Mostly try to avoid >100 column lines and update some descriptions
from 80 to 100 column limit, improving readability.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-02 14:07:12 +02:00
Stefan Reiter
f36e9894ff fix #2570: add 'keephugepages' config
We already keep hugepages if they are created with the kernel
commandline (hugepagesz=x hugepages=y), but some setups (specifically
hugepages across multiple NUMA nodes) cannot be configured that way.
Since we always clear these hugepages at VM shutdown, rebooting a VM
that uses them might not work, since the requested count might not be
available anymore by the time we want to use them (also, we would then
no longer allocate them correctly on the NUMA nodes).

Add a 'keephugepages' parameter to skip cleanup and simply leave them
untouched.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-09-02 12:45:57 +02:00
Fabian Grünbichler
4ef13a7f9a fix #2862: properly backup (all) VM templates
until we maybe have a 'pbs-backup' that links Qemu and PBS like
'pbs-restore', we need to do a regular backup for the template case to
support all storage types and image formats.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-08-21 13:45:55 +02:00
Stoiko Ivanov
b5d32c6be2 print_vga_device: check if bios is defined
Otherwise a warning is printed if the bios is not set in the config.

reported via community forum:
https://forum.proxmox.com/threads/warning-in-qemuserver.74683/

reproduced and tested that the patch fixes the issue.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-08-21 10:12:27 +02:00
Aaron Lauterer
789fe8e818 cfg2cmd: vga: fix #2749: disable edid for Win+BIOS+VGA machines
Edid support was added with Qemu 5. Windows guests seem to not be able
to get all possible resolutions if the default std VGA device is used as
GPU and the VM boots in BIOS mode. The result is that only one of the
following three resolutions can be configured:

800x600
1024x768
1920x1080

It is important to note that just booting a Windows VM with the edid=off
parameter will not make the large list of resolutions available. It
seems that Windows is caching the list of possible resolutions
somewhere [0].

Uninstalling the 'Microsoft Basic Display Adapter' in the device manager
and rebooting the VM is one way I found to force Windows to recreate the
list of possible resolutions.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>

[0] https://lists.nongnu.org/archive/html/qemu-devel/2020-07/msg07128.html
2020-08-19 18:22:43 +02:00
Fabian Ebner
a1cbe55cc7 Add missing die statements
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-08-11 14:34:56 +02:00
Fabian Grünbichler
503e96f8de fix #2857: restore: pass keyfile to pbs-restore
if configured. otherwise restoring encrypted backups will be quite
hard..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-07-20 11:08:26 +02:00
Fabian Ebner
d544e0e0cb set resume parameter for vm_start_nolock if there is a vmstate
In config_to_command, '-loadstate' will be added whenever there is a
vmstate in the config. But in vm_start_nolock, the resume parameter
is used to calculate the appropriate timeout and to remove the vmstate
after the start. The resume parameter was only set if there is a
'suspended' lock, but apparently [0] we cannot rely on the lock to be
set if and only if there is a vmstate.

[0]: https://forum.proxmox.com/threads/task-error-start-failed.72450

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-07-13 12:29:59 +02:00
Dominik Csapak
7de7f675c2 fix mdev cmdline generation
during refactoring, the vmid got lost, but is necessary to get
the correct mdev id

Fixes commit 74c17b7a23
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
[ reference fixed commit ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-13 10:29:25 +02:00
Wolfgang Bumiller
dea4b04c1c Add comment about pbs env vars
pbs-restore might not stay there like that forever and if
this code path changes we should remember to also remove the
environment variables

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-07-10 11:44:54 +02:00
Fabian Ebner
9b29cbd0ed update_disksize: make interface leaner
Pass new size directly, so the function doesn't need to know about
how some hash is organized. And return a message directly, instead
of both size-strings. Also dropped the wantarray, because both
existing callers use the message anyways.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-07-01 09:18:13 +02:00
Stefan Reiter
13d689792e fix #2794: allow legacy IGD passthrough
Legacy IGD passthrough requires address 00:1f.0 to not be assigned to
anything on QEMU startup (currently it's assigned to bridge pci.2).
Changing this in general would break live-migration, so introduce a new
hostpci parameter "legacy-igd", which if set to 1 will move that bridge
to be nested under bridge 1.

This is safe because:
* Bridge 1 is unconditionally created on i440fx, so nesting is ok
* Defaults are not changed, i.e. PCI layout only changes when the new
parameter is specified manually
* hostpci forbids migration anyway

Additionally, the PT device has to be assigned address 00:02.0 in the
guest as well, which is usually used for VGA assignment. Luckily, IGD PT
requires vga=none, so that is not an issue either.

See https://git.qemu.org/?p=qemu.git;a=blob;f=docs/igd-assign.txt

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-06-25 13:25:35 +02:00
Stefan Reiter
74c17b7a23 cfg2cmd: hostpci: move code to PCI.pm
To avoid further cluttering config_to_command with subsequent changes.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-06-25 13:25:35 +02:00
Thomas Lamprecht
0530177bd1 netdev MTU: stricter checks and warn if not possible on netdev
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-04 11:19:13 +02:00
Alexandre Derumier
61a14cde8d add virtio host_mtu feature.
This add a new "mtu" param to vm nic,
and force the mtu in the guest for virtio nic only.

Special value: 1 = set the same value than the bridge
2020-06-04 10:58:49 +02:00
Dominik Csapak
55fb78aa4a fix pbs-restore call for non raw images
if we have a format, give it to pbs-restore too
fixes restore of non-raw (e.g. qcow2) images

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-04 10:56:09 +02:00
Dominik Csapak
bf5aef9be3 fix #2697: map netdev_add options to correct json types
netdev_add is now a proper qmp command, which means that it verifies
the parameter types properly

instead of sending strings, we now have to choose the correct
types for the parameters

bool for vhost
and uint64 for queues

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-08 12:55:32 +02:00
Fabian Grünbichler
a2ec5a6705 qmrestore: fix restore from STDIN
the special case was dropped when moving this to pve-storage.

fixes commit c6d517835a

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-07 16:12:10 +02:00
Aaron Lauterer
1cc5ed1bc4 cfg2cmd: set audiodev parameter only on qemu >= 4.2
fixes commit 940e2a3a06

QEMU 4.1 will fail to start a guest with an audio device set with:
> Property '.audiodev' not found

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-06 15:14:15 +02:00
Stefan Reiter
058531889f rng: die when trying to pass through disconnected hwrng
If /dev/hwrng exists, but no actual generator is connected (or it is
disabled on the host), QEMU will happily start the VM but crash as soon
as the guest accesses the VirtIO RNG device.

To prevent this unfortunate behaviour, check if a useable hwrng is
connected to the host before allowing the VM to be started.

While at it, clean up config_to_command by moving new and existing rng
source checks to a seperate sub.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-05-06 14:23:04 +02:00
Stefan Reiter
b57d4863e2 cfg2cmd: fix uninitialized value warning on OVMF w/o efidisk
It's possible to have a VM with OVMF but without an efidisk, so don't
call parse_drive on a potential undef value.

Partial revert of 818c3b8d91 ("cfg2cmd: ovmf: code cleanup")

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-05-06 14:23:04 +02:00
Fabian Grünbichler
8284121451 QemuServer: drop unused imported locking functions
lock_file is used by PVE::QemuServer::Memory, but it does properly 'use
PVE::Tools ...' itself so we can drop them in the main module.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-05-04 17:33:32 +02:00
Alwin Antreich
f43a4f127c Fix #2124: Add support for zstd
Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
2020-05-04 11:19:35 +02:00
Alwin Antreich
c6d517835a restore: replace archive format/compression
regex to reduce the code duplication, as archive_info and
decompressor_info provides the same information as well.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
2020-05-04 11:19:35 +02:00
Thomas Lamprecht
d60cbb97ec _do_vm_stop: only warn if QMP command failed but VM is actually stopped
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-03 11:12:54 +02:00
Fabian Ebner
0b953b8e34 cleanup: get rid of unnecessary closures
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-29 13:49:46 +02:00
Fabian Ebner
ae180b8f08 Include vmstate and unused volumes in foreach_volid
and refactor the test_volid closure. Like this get_replicatable_volumes doesn't
need a separate loop for unused volumes anymore. For get_vm_volumes, which is used
for activation/deactivation of volumes at migration and deactivation in vm_stop_cleanup,
includes those volumes now. For migration it's an improvement, because those volumes
might need to be migrated and for vm_stop_cleanup it shouldn't hurt. The last user
of foreach_volid is check_vm_disks_local used by migrate_vm_precondition,
where information about the additional volumes doesn't hurt either.

Note that replicate is (still) set by default, so the behavior for
get_replicatable_volumes for unused volumes should not change.

Hibernation vmstate files are now also included and recognized as 'is_vmstate'.
The 'size' attribute will not be overwritten by subsequent iterations for the
same volid anymore (a volid may appear both in the config and in snapshots),
so the size from the current config is now preferred.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-29 12:14:40 +02:00
Fabian Ebner
b24f07d406 Fix test_volid call for vmstate and fix check for snapshots on migration
by excluding vmstate. It is referenced by snapshots, but
is not a volume containing a snapshot.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-29 12:14:40 +02:00
Thomas Lamprecht
5364990d26 restore: small code cleanup for parse_backup_hints
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-29 11:05:19 +02:00
Dominik Csapak
30a1155658 restore: use correct storage for format check for cloudinit drives
when a backup includes a cloudinit disk on a non-existent storage,
the restore fails with 'storage' does not exist

this happens because we want to get the format of the disk, by
checking the source storage

we fix this by using the target storage first and only the source as
fallback

this will still fail if neither storage exists
(which is ok, since we cannot restore then anyway)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-29 10:33:45 +02:00
Thomas Lamprecht
b01de19922 cfg2cmd: factor out audio device generation
and version guard it with 4.0 machines, just do be sure

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-17 15:20:13 +02:00
Aaron Lauterer
940e2a3a06 cfg2cmd: Add the audiodev property to audio devs
With Qemu 4.2 a new `audiodev` property was introduced [0] to explicitly
specify the backend to be used for the audio device. This is accompanied
with a warning that the fallback to the default audio backend is
deprecated.

[0] https://wiki.qemu.org/ChangeLog/4.2#Audio

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2020-04-17 14:23:16 +02:00
Thomas Lamprecht
818c3b8d91 cfg2cmd: ovmf: code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-15 18:30:53 +02:00
Fabian Ebner
cc1a3820db sync_disks: use allow_rename to avoid collisions on the target storage
This makes it possible to migrate a VM with volumes store1:vm-123-disk-0
store2:vm-123-disk-0 to some targetstorage. Also prevents migration failure
when there is an orphaned disk with the same volid on the target.

To avoid confusion, the name should not change for 'vmstate'-volumes.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Fabian Ebner
912792e245 Switch to using foreach_volume instead of foreach_drive
It was necessary to move foreach_volid back to QemuServer.pm

In VZDump/QemuServer.pm and QemuMigrate.pm the dependency on
QemuConfig.pm was already there, just the explicit "use" was missing.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Thomas Lamprecht
2f6f002c04 config_to_command: indentation, whitspace and newline fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-08 17:44:37 +02:00