pci passthrough: enable live-migration for capable mapped-devices

Set the 'enable-migration' QEMU command-line flag to on for
live-migration marked mapped devices, as the default is 'auto', but
for those which are marked as capable for live-migration, we want to
explicitly enable that, so that we get an early error on start if the
driver does not support live-migration.

With that we can drop such devices from being a migration blocker.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [TL: squash and re-order similar changes together]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2025-03-11 14:20:43 +01:00 committed by Thomas Lamprecht
parent 0f55e8be84
commit b86d32dcb2
2 changed files with 13 additions and 1 deletions

View File

@ -2519,6 +2519,12 @@ sub check_local_resources {
my $mapped_device = { name => $name }; my $mapped_device = { name => $name };
$mapped_res->{$k} = $mapped_device; $mapped_res->{$k} = $mapped_device;
if ($pci_map->{ids}->{$name}->{'live-migration-capable'}) {
$mapped_device->{'live-migration'} = 1;
# don't add mapped device with live migration as blocker
next;
}
# don't add mapped devices as blocker for offline migration but still iterate over # don't add mapped devices as blocker for offline migration but still iterate over
# all mappings above to collect on which nodes they are available. # all mappings above to collect on which nodes they are available.
next if !$state; next if !$state;

View File

@ -433,9 +433,11 @@ sub parse_hostpci {
die "PCI device mapping not found for '$mapping'\n" if !$devices || !scalar($devices->@*); die "PCI device mapping not found for '$mapping'\n" if !$devices || !scalar($devices->@*);
my $config = PVE::Mapping::PCI::config(); my $config = PVE::Mapping::PCI::config();
my $mapping_cfg = $config->{ids}->{$mapping};
$res->{'live-migration-capable'} = 1 if $mapping_cfg->{'live-migration-capable'};
for my $device ($devices->@*) { for my $device ($devices->@*) {
eval { PVE::Mapping::PCI::assert_valid($mapping, $device, $config->{ids}->{$mapping}) }; eval { PVE::Mapping::PCI::assert_valid($mapping, $device, $mapping_cfg) };
die "PCI device mapping invalid (hardware probably changed): $@\n" if $@; die "PCI device mapping invalid (hardware probably changed): $@\n" if $@;
push $alternatives->@*, [split(/;/, $device->{path})]; push $alternatives->@*, [split(/;/, $device->{path})];
} }
@ -692,6 +694,10 @@ sub print_hostpci_devices {
$devicestr .= ",host=$pcidevice->{id}"; $devicestr .= ",host=$pcidevice->{id}";
} }
if ($d->{'live-migration-capable'}) {
$devicestr .= ",enable-migration=on";
}
my $mf_addr = $multifunction ? ".$j" : ''; my $mf_addr = $multifunction ? ".$j" : '';
$devicestr .= ",id=${id}${mf_addr}${pciaddr}${mf_addr}"; $devicestr .= ",id=${id}${mf_addr}${pciaddr}${mf_addr}";