5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-24 02:04:10 +03:00

1865 Commits

Author SHA1 Message Date
Fabian Ebner
ea5b400812 sync_disks: log output of storage_migrate
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Fabian Ebner
49a5a0d84b sync_disks: be more verbose if storage_migrate fails
If storage_migrate dies, the error message might not include the
volume ID or the target storage ID, but those might be good to know.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +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
97ece9ddce Update volume IDs in one go
Use 'update_volume_ids' for the live-migrated disks as well.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Fabian Ebner
bcd5401acc Allow specifying targetstorage for offline migration
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Fabian Ebner
37666e4caa Take note of changes to the volume IDs when migrating and update the config
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Fabian Ebner
092538833e Allow parsing vmstate entries
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-04-08 22:11:54 +02:00
Fabian Ebner
1f726e0a85 Use new storage_migrate interface
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
Stefan Reiter
b516c84871 Ignore version checks when using QEMU -rc releases
Upstream marks these as having a micro-version of >=90, unfortunately the
machine versions are bumped earlier so testing them is made unnecessarily
difficult, since the version checking code would abort on migrations etc...

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
[ Thomas: do so refactor ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-08 17:44:37 +02:00
Thomas Lamprecht
8cea210f99 cpu config: add upcoming EPYC-Rome CPU type
will be included with QEMU 5.0

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-08 17:06:52 +02:00
Fabian Grünbichler
e1cfa02e62 config: harmonize bridge pattern
so that pve-container and qemu-server use the same one, in preparation
for moving it to JSONSchema and having a bridgepair format.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-08 14:11:33 +02:00
Stefan Reiter
9f9792d3dc fix #2318: allow phys-bits CPU setting
Can be specified for a particular VM or via a custom CPU model (VM takes
precedence).

QEMU's default limit only allows up to 1TB of RAM per VM. Increasing the
physical address bits available to a VM can fix this.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-04-07 17:27:58 +02:00
Stefan Reiter
c4581b9cc5 Rework get_cpu_options and allow custom CPU models
If a cputype is custom (check via prefix), try to load options from the
custom CPU model config, and set values accordingly.

While at it, extract currently hardcoded values into seperate sub and add
reasonings.

Since the new flag resolving outputs flags in sorted order for
consistency, adapt the test cases to not break. Only the order is
changed, not which flags are present.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-By: Fabian Ebner <f.ebner@proxmox.com>
Tested-By: Fabian Ebner <f.ebner@proxmox.com>
2020-04-07 17:27:58 +02:00
Stefan Reiter
45619185a6 Add helpers to better structure CPU option handling
To avoid hardcoding even more CPU-flag related things for custom CPU
models, introduce a dynamic approach to resolving flags.

resolve_cpu_flags takes a list of hashes (as documented in the
comment) and resolves them to a valid "-cpu" argument without
duplicates. This also helps by providing a reason why specific CPU flags
have been added, and thus allows for useful warning messages should a
flag be overwritten by another.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-By: Fabian Ebner <f.ebner@proxmox.com>
Tested-By: Fabian Ebner <f.ebner@proxmox.com>
2020-04-07 17:27:58 +02:00
Stefan Reiter
ea1c21108f Include "-cpu" parameter with snapshots/suspend
Just like with live-migration, custom CPU models might change after a
snapshot has been taken (or a VM suspended), which would lead to a
different QEMU invocation on rollback/resume.

Save the "-cpu" argument as a new "runningcpu" option into the VM conf
akin to "runningmachine" and use as override during rollback/resume.

No functional change with non-custom CPU types intended.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-04-07 17:27:58 +02:00
Stefan Reiter
58c64ad5d9 Include "-cpu" parameter with live-migration
This is required to support custom CPU models, since the
"cpu-models.conf" file is not versioned, and can be changed while a VM
using a custom model is running. Changing the file in such a state can
lead to a different "-cpu" argument on the receiving side.

This patch fixes this by passing the entire "-cpu" option (extracted
from /proc/.../cmdline) as a "qm start" parameter. Note that this is
only done if the VM to migrate is using a custom model (which we can
check just fine, since the <vmid>.conf *is* versioned with pending
changes), thus not breaking any live-migration directionality.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-04-07 17:27:58 +02:00
Thomas Lamprecht
b6d9b54b5b map_storage: check for definedness not perl-truthiness
as else it would reject possible a valid set value

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-07 17:25:38 +02:00
Thomas Lamprecht
e214cda8f5 followup: s/targetstorage map/storage map/ for parameter exceptions
to reduce duplicated info in the error slightly

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-07 17:20:37 +02:00
Thomas Lamprecht
abff03211f followup: refactor loop to use perls values
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-07 17:15:28 +02:00
Fabian Grünbichler
84da82174e vm_start: collect and return migration info
in addition to printing it. preparation for remote cluster migration,
where we want to return this in a structured fashion over the migration
tunnel instead of parsing stdout via SSH.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-07 17:07:36 +02:00
Fabian Grünbichler
ba5396b580 vm_start: split NBD disk allocation further
into one sub that retrieves the local disks, and the actual NBD
allocation. that way, remote incoming migration can just call the NBD
allocation with a custom list of volume names/storages/..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-07 17:07:32 +02:00
Fabian Grünbichler
aea447bb9d migrate: check storage permissions and content type
both where previously missing. the existing 'check_storage_access'
helper is not applicable here since it operates on a full set of VM
config options, not just storage IDs.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-07 17:07:23 +02:00
Fabian Grünbichler
bf8fc5a307 migrate: allow arbitrary source->target storage maps
the syntax is backwards compatible, providing a single storage ID or '1'
works like before. the new helper ensures consistent behaviour at all
call sites.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-02 17:47:14 +02:00
Stefan Reiter
c05f1b33ea migration: fix downtime limit auto-increase
485449e37 ("qmp: use migrate-set-parameters in favor of deprecated options")
changed the initial "migrate_set_downtime" QMP call to the more recent
"migrate-set-parameters", but forgot to do so for the auto-increase code
further below.

Since the units of the two calls don't match, this would have caused the
auto-increase to increase the limit to absurd levels as soon as it kicked
in (ms treated as s).

Update the second call to the new version as well, and while at it remove
the unnecessary "defined()" check for $migrate_downtime, which is always
initialized from the defaults anyway.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-04-02 16:48:51 +02:00
Fabian Grünbichler
e5fd1c6591 restore: parse volid with $noerr
otherwise VMA files passed in as paths instead of as volids don't
work anymore.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-02 15:14:42 +02:00
Fabian Grünbichler
13cfe3b7a7 vm_start: split out NBD disk allocation
as preparation of targetstorage mapping and remote migration. this also
removes re-using of the $local_volumes hash in the original code.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-01 18:43:00 +02:00
Fabian Grünbichler
3898a56343 vm_start: split out lock + initial checks
to start breaking up vm_start before extending parts for new migration
features like storage and network mapping.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-01 18:41:58 +02:00
Fabian Grünbichler
0c498cca36 vm_start: condense signature
as preparation for refactoring it further. remote migration will add
another 1-2 parameters, and it is already unwieldly enough as it is.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-01 17:42:15 +02:00
Fabian Grünbichler
6a039d06e9 migrate: improve cleanup_remotedisks
to also handle cases where disk allocation failed in the remote
vm_start, and we only have a bitmap but no target drive information.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-01 17:41:07 +02:00
Fabian Grünbichler
0c4fef3f26 rescan: fix call to foreach_volume
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-04-01 13:02:59 +02:00
Fabian Ebner
ca04977c63 update_disk_config: use config volume iterators instead of loops
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-30 09:59:48 +02:00
Fabian Ebner
beed0e3b0c Implement volume-related helpers and use new foreach_volume
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-30 09:59:48 +02:00
Dominik Csapak
818ce80ec1 fix efidisks on storages with minimum sizes bigger than OVMF_VARS.fd
on storages where the minimum size of images is bigger than the real
OVMF_VARS.fd file, they get padded to their minimum size

when using such an image, qemu maps it fully to the vm, but the efi
does not find the vars region and creates a file on the first efi
partition it finds

this breaks some settings in the ovmf, such as resolution

to fix this, we have to specify the size for the pflash, so that
qemu only maps the first n bytes in the vm (this only works for
raw files, not for qcow2)

we also have to use the correct size when converting between storages
in 'clone_disk' (used for move disk and cloning vms) and when
live migrating to different storages

when we now expect that the source image is always correctly used/created
(e.g. raw with size=x in pflash argument) then we always create the
target correctly

when encountering users which have a non-valid image (e.g. a efidisk
moved from zfs to qcow2 before this patch), we have to tell them to
recreate the efidisk and the settings on it

we have to version_guard it to 4.1+pve2 (since we haven't bumped yet
since the change to pve2)

also add 2 tests, one for the old version and one for the new

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-by: Stefan Reiter <s.reiter@proxmox.com>
[ Thomas: rebased to master ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-30 09:41:55 +02:00
Fabian Ebner
5c50a84f23 migration with targetstorage: check if target storage supports images
This makes sure that live migration also respects content types.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-27 14:32:42 +01:00
Thomas Lamprecht
2cd808d331 migrate sync disks: split long line
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-27 10:17:54 +01:00
Thomas Lamprecht
b10afa311d migrate sync_disks: use own variable for often referenced storage config
also fix two places where we used $self->{vmid} even if $vmid was in
scope (and the same).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-27 10:13:10 +01:00
Fabian Grünbichler
9b3f5a5c99 migrate: cleanup disk/bitmaps if 'qm start' failed
since bitmaps are set early on, and 'qm start' potentially has allocated
the disks but still failed. we can only clean up what we know about
anyway, so the disk part is still only best effort.

also use replicated_volumes instead of bitmap existence to check for
replicated volumes, since 'qm start' on an old node that does not
understand replicated volumes might have allocated a new volume that we
DO want to clean up, and not skip.

also cleanup disks after stopping target VM, otherwise we might end up
in a situation where the target VM is still running and using the disks,
thus blocking the disk cleanup.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-27 07:54:44 +01:00
Fabian Grünbichler
7f5fb49a7c migrate: fix auto-vivification in cleanup_bitmaps
this does not currently trigger since nothing uses $self->{target_drive}
afterwards.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-27 07:54:44 +01:00
Fabian Grünbichler
88126be3f7 migrate: fix replication false-positives
by only checking for replicatable volumes when a replication job is
defined, and passing only actually replicated volumes to the target node
via STDIN, and back via STDOUT.

otherwise this can pick up theoretically replicatable, but not actually
replicated volumes and treat them wrong.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-27 07:54:44 +01:00
Fabian Grünbichler
1dbe979c7c CPUConfig: fix module load when pmxcfs is unavailable
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-26 09:03:07 +01:00
Thomas Lamprecht
e485854100 vzdump: fix up PBS plugin
fixes commit 0b2f574b4ccd68ba7c1ebf1927beeff33cca179d

enforce_vm_running_for_backup is now witout return value, for the PBS
I forgot to remove an now outdated call to handle_vm_powerstate, drop
that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-26 08:51:29 +01:00
Stefan Reiter
5d008ad383 Verify VM-specific CPU configs seperately
$cpu_fmt is being reused for custom CPUs as well as VM-specific CPU
settings. The "pve-vm-cpu-conf" format is introduced to verify a config
specifically for use as VM-specific settings.

"pve-cpu-conf" is registered for use in custom CPU API calls (where no
additional checks are required).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-03-25 18:42:24 +01:00
Stefan Reiter
b3e894883a Adapt CPUConfig to handle custom models
Turn CPUConfig into a SectionConfig with parsing/writing support for
custom CPU models. IO is handled using cfs.

Namespacing will be provided using "custom-" prefix for custom model
names (in VM config only, cpu-models.conf will contain unprefixed
names).

Includes two overrides to avoid writing redundant information to the
config file, additionally get_custom_model is used to retrieve a custom
model configuration by name.

Resolve custom names in print_cpu_device when a custom cpu is passed.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-03-25 18:42:21 +01:00
Fabian Ebner
47250f03ef Fix calls to get_replicateable_volumes
There is a need to set $noerr, because otherwise migration for a
VM with a non-replicatable volume fails with:
missing replicate feature on volume 'myfs:107/vm-107-disk-2.raw'

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2020-03-25 14:53:17 +01:00
Thomas Lamprecht
6d7450cbec qemu migrate: sort and split module usage
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-25 10:05:58 +01:00
Thomas Lamprecht
28e6e180bc add basic version check for live-migration with replicated disks
as we need at least pve-qemu in 4.2 for this to work, the target side
is implicitly checked with "to old version" check for migrate or the
mirror will fail anyway.

Just use the simple "qemu binary version check", as we could stil
live migrate an older snapshot with older machine versions if both
sides have a recent enough qemu.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-25 10:02:36 +01:00
Fabian Grünbichler
9b6efe436d migrate: add live-migration of replicated disks
with incremental drive-mirror and dirty-bitmap tracking.

1.) get replicated disks that are currently referenced by running VM
2.) add a block-dirty-bitmap to each of them
3.) replicate ALL replicated disks
4.) pass bitmaps from 2) to drive-mirror for disks from 1)
5.) skip replicated disks when cleaning up volumes on either source or
target

added error handling is just removing the bitmaps if an error occurs at
any point after 2, except when the handover to the target node has
already happened, since the bitmaps are cleaned up together with the
source VM in that case.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
2020-03-24 12:22:32 +01:00
Fabian Grünbichler
b9f44d2773 migrate: add replication info to disk overview
to make migration logs a bit easier to grasp with a quick glance.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stefan Reiter <s.reiter@proxmox.com>
2020-03-24 11:54:32 +01:00