snapshot: introduce running-nets-host-mtu property
For VirtIO network devices, it is necessary to preserve the values and presence of the host_mtu setting when restoring a snapshot. See commit "migration: preserve host_mtu for virtio-net devices" for details. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Link: https://lore.proxmox.com/20250904124113.81772-7-f.ebner@proxmox.com
This commit is contained in:
parent
0bcf41ed42
commit
7ceb6b7255
4 changed files with 18 additions and 1 deletions
|
|
@ -2113,6 +2113,7 @@ my $update_vm_api = sub {
|
|||
}
|
||||
push @delete, 'runningmachine' if $conf->{runningmachine};
|
||||
push @delete, 'runningcpu' if $conf->{runningcpu};
|
||||
push @delete, 'running-nets-host-mtu' if $conf->{'running-nets-host-mtu'};
|
||||
}
|
||||
|
||||
PVE::QemuConfig->check_lock($conf) if !$skiplock;
|
||||
|
|
|
|||
|
|
@ -247,6 +247,8 @@ sub __snapshot_save_vmstate {
|
|||
or die "cannot obtain PID for VM $vmid!\n";
|
||||
my $runningcpu = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
|
||||
|
||||
my $nets_host_mtu = PVE::QemuServer::Network::get_nets_host_mtu($vmid, $conf);
|
||||
|
||||
if (!$suspend) {
|
||||
$conf = $conf->{snapshots}->{$snapname};
|
||||
}
|
||||
|
|
@ -254,6 +256,7 @@ sub __snapshot_save_vmstate {
|
|||
$conf->{vmstate} = $statefile;
|
||||
$conf->{runningmachine} = $runningmachine;
|
||||
$conf->{runningcpu} = $runningcpu;
|
||||
$conf->{'running-nets-host-mtu'} = $nets_host_mtu;
|
||||
|
||||
return $statefile;
|
||||
}
|
||||
|
|
@ -473,6 +476,8 @@ sub __snapshot_rollback_hook {
|
|||
# re-initializing its random number generator
|
||||
$conf->{vmgenid} = PVE::QemuServer::generate_uuid();
|
||||
}
|
||||
|
||||
$data->{'nets-host-mtu'} = delete($conf->{'running-nets-host-mtu'});
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -513,6 +518,7 @@ sub __snapshot_rollback_vm_start {
|
|||
statefile => $vmstate,
|
||||
forcemachine => $data->{forcemachine},
|
||||
forcecpu => $data->{forcecpu},
|
||||
'nets-host-mtu' => $data->{'nets-host-mtu'},
|
||||
};
|
||||
PVE::QemuServer::vm_start($storecfg, $vmid, $params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -635,6 +635,15 @@ EODESCR
|
|||
pattern => $PVE::QemuServer::CPUConfig::qemu_cmdline_cpu_re,
|
||||
format_description => 'QEMU -cpu parameter',
|
||||
},
|
||||
'running-nets-host-mtu' => {
|
||||
type => 'string',
|
||||
pattern => 'net\d+=\d+(,net\d+=\d+)*',
|
||||
optional => 1,
|
||||
description =>
|
||||
'List of VirtIO network devices and their effective host_mtu setting. A value of 0'
|
||||
. ' means that the host_mtu parameter is to be avoided for the corresponding device.'
|
||||
. ' This is used internally for snapshots.',
|
||||
},
|
||||
machine => get_standard_option('pve-qemu-machine'),
|
||||
arch => {
|
||||
description => "Virtual processor architecture. Defaults to the host.",
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@ sub vm_suspend {
|
|||
warn $@ if $@;
|
||||
PVE::Storage::deactivate_volumes($storecfg, [$vmstate]);
|
||||
PVE::Storage::vdisk_free($storecfg, $vmstate);
|
||||
delete $conf->@{qw(vmstate runningmachine runningcpu)};
|
||||
delete $conf->@{
|
||||
qw(vmstate runningmachine runningcpu running-nets-host-mtu)};
|
||||
PVE::QemuConfig->write_config($vmid, $conf);
|
||||
};
|
||||
warn $@ if $@;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue