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.her...@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to