Hook script and VM configuration

Matthieu Le Corre

Renowned Member
Apr 18, 2016
33
2
73
Nantes - France
Hi,
We are setting up a brand new PVE instance dedicated to our firewalls stacks.
All those FWs rely on VFs for there network interfaces.

The old solution was based on libvirt, and VFs could be dynamically attributed to VMs.

To mimick this behaviour I've setup an pre-start hook script that get info from the config.description and then setup the VF accordingly .
It check that the VF is not assigned to any VMs then feed the config file.

However, it seems that even if this a pre-start, configuration is already loaded from file and modification are not applied to the VM to be run.
I've also tried to use "qm config set" or "pvesh set" without any success as then both try to lock the VM and so, fail.

Is there a better way to handle that ?
Why does with pre-start the configuration is already lock ?
 

Attachments

Last edited:
I've looked at the QemuServer.pm code to check how the hook script is launch and found that is is simply run on the vm_start_nolock function.

I've added $conf = PVE::QemuConfig->load_config($vmid); at line 4964 of QemuServer.pm

Naively I thought that triggering a conf reload juste after that would solve my problem, but it not working.
My questions is, what's am I missing ?

PS: I've initially created this thread into the networking section of the forum, but it seems more a configuration situation, If some admin can move it,
this would be nice ;)
 
I've not changed this patch since the beginning, it is still applied to pve 7.2.11

Code:
cat dynamic_configuration.patch
--- /root/QemuServer.pm    2021-03-22 15:29:28.955293274 +0100
+++ /usr/share/perl5/PVE/QemuServer.pm 2021-03-22 15:30:53.795779826 +0100
@@ -5029,6 +5029,12 @@
 
     PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-start', 1);
 
+    # DSIN-20220222: Patch a Mamatt
+    # update cache
+    PVE::Cluster::cfs_update();
+    # reload conf in case pre start update it
+    $conf = PVE::QemuConfig->load_config($vmid);
+
     my $forcemachine = $params->{forcemachine};
     my $forcecpu = $params->{forcecpu};
     if ($resume) {
 
  • Like
Reactions: scr4tchy

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!