mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-06-15 18:48:44 +00:00
sdn: use sdn tap_create|plug
Signed-off-by: Alexandre Derumier <aderumier@odiso.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
86a2e85a26
commit
28e129cccb
@ -51,6 +51,12 @@ use PVE::QemuServer::Monitor qw(mon_cmd);
|
|||||||
use PVE::QemuServer::PCI qw(print_pci_addr print_pcie_addr print_pcie_root_port);
|
use PVE::QemuServer::PCI qw(print_pci_addr print_pcie_addr print_pcie_root_port);
|
||||||
use PVE::QemuServer::USB qw(parse_usb_device);
|
use PVE::QemuServer::USB qw(parse_usb_device);
|
||||||
|
|
||||||
|
my $have_sdn;
|
||||||
|
eval {
|
||||||
|
require PVE::Network::SDN::Zones;
|
||||||
|
$have_sdn = 1;
|
||||||
|
};
|
||||||
|
|
||||||
my $EDK2_FW_BASE = '/usr/share/pve-edk2-firmware/';
|
my $EDK2_FW_BASE = '/usr/share/pve-edk2-firmware/';
|
||||||
my $OVMF = {
|
my $OVMF = {
|
||||||
x86_64 => [
|
x86_64 => [
|
||||||
@ -4562,7 +4568,12 @@ sub vmconfig_update_net {
|
|||||||
safe_string_ne($oldnet->{trunks}, $newnet->{trunks}) ||
|
safe_string_ne($oldnet->{trunks}, $newnet->{trunks}) ||
|
||||||
safe_num_ne($oldnet->{firewall}, $newnet->{firewall})) {
|
safe_num_ne($oldnet->{firewall}, $newnet->{firewall})) {
|
||||||
PVE::Network::tap_unplug($iface);
|
PVE::Network::tap_unplug($iface);
|
||||||
|
|
||||||
|
if ($have_sdn) {
|
||||||
|
PVE::Network::SDN::Zones::tap_plug($iface, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks}, $newnet->{rate});
|
||||||
|
} else {
|
||||||
PVE::Network::tap_plug($iface, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks}, $newnet->{rate});
|
PVE::Network::tap_plug($iface, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks}, $newnet->{rate});
|
||||||
|
}
|
||||||
} elsif (safe_num_ne($oldnet->{rate}, $newnet->{rate})) {
|
} elsif (safe_num_ne($oldnet->{rate}, $newnet->{rate})) {
|
||||||
# Rate can be applied on its own but any change above needs to
|
# Rate can be applied on its own but any change above needs to
|
||||||
# include the rate in tap_plug since OVS resets everything.
|
# include the rate in tap_plug since OVS resets everything.
|
||||||
|
@ -2,10 +2,17 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use PVE::QemuServer;
|
use PVE::QemuServer;
|
||||||
use PVE::Tools qw(run_command);
|
use PVE::Tools qw(run_command);
|
||||||
use PVE::Network;
|
use PVE::Network;
|
||||||
|
|
||||||
|
my $have_sdn;
|
||||||
|
eval {
|
||||||
|
require PVE::Network::SDN::Zones;
|
||||||
|
$have_sdn = 1;
|
||||||
|
};
|
||||||
|
|
||||||
my $iface = shift;
|
my $iface = shift;
|
||||||
|
|
||||||
my $hotplug = 0;
|
my $hotplug = 0;
|
||||||
@ -36,8 +43,12 @@ die "unable to get network config '$netid'\n"
|
|||||||
my $net = PVE::QemuServer::parse_net($netconf);
|
my $net = PVE::QemuServer::parse_net($netconf);
|
||||||
die "unable to parse network config '$netid'\n" if !$net;
|
die "unable to parse network config '$netid'\n" if !$net;
|
||||||
|
|
||||||
PVE::Network::tap_create($iface, $net->{bridge});
|
if ($have_sdn) {
|
||||||
|
PVE::Network::SDN::Zones::tap_create($iface, $net->{bridge});
|
||||||
PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}, $net->{trunks}, $net->{rate});
|
PVE::Network::SDN::Zones::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}, $net->{trunks}, $net->{rate});
|
||||||
|
} else {
|
||||||
|
PVE::Network::tap_create($iface, $net->{bridge});
|
||||||
|
PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}, $net->{trunks}, $net->{rate});
|
||||||
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user