[pve-devel] [PATCH qemu-server v3 6/8] snapshot: introduce running-nets-host-mtu property
Fiona Ebner
f.ebner at proxmox.com
Thu Sep 4 14:40:50 CEST 2025
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 at proxmox.com>
---
New in v3.
src/PVE/API2/Qemu.pm | 1 +
src/PVE/QemuConfig.pm | 6 ++++++
src/PVE/QemuServer.pm | 9 +++++++++
src/PVE/QemuServer/RunState.pm | 3 ++-
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 4770fbf8..ec9f31d8 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -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;
diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm
index 33cac3be..d0844c4c 100644
--- a/src/PVE/QemuConfig.pm
+++ b/src/PVE/QemuConfig.pm
@@ -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);
}
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 20e26cd5..e312acb6 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -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.",
diff --git a/src/PVE/QemuServer/RunState.pm b/src/PVE/QemuServer/RunState.pm
index 05e7fb47..6a5fdbd7 100644
--- a/src/PVE/QemuServer/RunState.pm
+++ b/src/PVE/QemuServer/RunState.pm
@@ -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 $@;
--
2.47.2
More information about the pve-devel
mailing list