[pve-devel] [PATCH guest-common 1/4] fix #5900: add helper function
Daniel Herzig
d.herzig at proxmox.com
Thu Dec 5 17:33:29 CET 2024
This patch adds a small helper function to retrieve the bridge name
from the netN parameter string of a container or VM configuration.
Signed-off-by: Daniel Herzig <d.herzig at proxmox.com>
---
src/PVE/GuestHelpers.pm | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
index 592b4a8..c6006ba 100644
--- a/src/PVE/GuestHelpers.pm
+++ b/src/PVE/GuestHelpers.pm
@@ -450,4 +450,15 @@ sub abort_guest_tasks {
return $aborted_tasks;
}
+sub get_bridge {
+ my $net_params = shift;
+ my $param_array = [ split(/,/, $net_params) ];
+ my $bridge;
+ for my $net_param (@$param_array) {
+ $bridge = $net_param if ($net_param =~ /bridge\=/);
+ $bridge =~ s|bridge\=|| if (defined($bridge));
+ }
+ return $bridge;
+}
+
1;
--
2.39.5
More information about the pve-devel
mailing list