mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-02 15:25:36 +00:00
add pve-bridge-hotplug script
use it for nic hotplug, because pve-bridge script will not work after a live migration, because of the PVE_MIGRATED_FROM env var. Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
8718099ce4
commit
208ba94e96
1
Makefile
1
Makefile
@ -93,6 +93,7 @@ install: ${PKGSOURCES}
|
||||
install -m 0755 qm ${DESTDIR}${SBINDIR}
|
||||
install -m 0755 qmrestore ${DESTDIR}${SBINDIR}
|
||||
install -m 0755 pve-bridge ${DESTDIR}${VARLIBDIR}/pve-bridge
|
||||
install -m 0755 pve-bridge-hotplug ${DESTDIR}${VARLIBDIR}/pve-bridge-hotplug
|
||||
install -m 0755 pve-bridgedown ${DESTDIR}${VARLIBDIR}/pve-bridgedown
|
||||
install -s -m 0755 vmtar ${DESTDIR}${LIBDIR}
|
||||
install -s -m 0755 sparsecp ${DESTDIR}${LIBDIR}
|
||||
|
@ -1257,7 +1257,7 @@ sub print_netdevice_full {
|
||||
}
|
||||
|
||||
sub print_netdev_full {
|
||||
my ($vmid, $conf, $net, $netid) = @_;
|
||||
my ($vmid, $conf, $net, $netid, $hotplug) = @_;
|
||||
|
||||
my $i = '';
|
||||
if ($netid =~ m/^net(\d+)$/) {
|
||||
@ -1278,9 +1278,10 @@ sub print_netdev_full {
|
||||
my $vmname = $conf->{name} || "vm$vmid";
|
||||
|
||||
my $netdev = "";
|
||||
my $script = $hotplug ? "pve-bridge-hotplug" : "pve-bridge";
|
||||
|
||||
if ($net->{bridge}) {
|
||||
$netdev = "type=tap,id=$netid,ifname=${ifname},script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown$vhostparam";
|
||||
$netdev = "type=tap,id=$netid,ifname=${ifname},script=/var/lib/qemu-server/$script,downscript=/var/lib/qemu-server/pve-bridgedown$vhostparam";
|
||||
} else {
|
||||
$netdev = "type=user,id=$netid,hostname=$vmname";
|
||||
}
|
||||
@ -3599,7 +3600,7 @@ sub qemu_set_link_status {
|
||||
sub qemu_netdevadd {
|
||||
my ($vmid, $conf, $device, $deviceid) = @_;
|
||||
|
||||
my $netdev = print_netdev_full($vmid, $conf, $device, $deviceid);
|
||||
my $netdev = print_netdev_full($vmid, $conf, $device, $deviceid, 1);
|
||||
my %options = split(/[=,]/, $netdev);
|
||||
|
||||
vm_mon_cmd($vmid, "netdev_add", %options);
|
||||
|
39
pve-bridge-hotplug
Executable file
39
pve-bridge-hotplug
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use PVE::QemuServer;
|
||||
use PVE::Tools qw(run_command);
|
||||
use PVE::Network;
|
||||
|
||||
my $iface = shift;
|
||||
|
||||
die "no interface specified\n" if !$iface;
|
||||
|
||||
die "got strange interface name '$iface'\n"
|
||||
if $iface !~ m/^tap(\d+)i(\d+)$/;
|
||||
|
||||
my $vmid = $1;
|
||||
my $netid = "net$2";
|
||||
|
||||
my $conf = PVE::QemuServer::load_config($vmid);
|
||||
|
||||
my $netconf = $conf->{$netid};
|
||||
|
||||
$netconf = $conf->{pending}->{$netid} if defined($conf->{pending}->{$netid});
|
||||
|
||||
die "unable to get network config '$netid'\n"
|
||||
if !defined($netconf);
|
||||
|
||||
my $net = PVE::QemuServer::parse_net($netconf);
|
||||
die "unable to parse network config '$netid'\n" if !$net;
|
||||
|
||||
PVE::Network::tap_create($iface, $net->{bridge});
|
||||
|
||||
# if ovs is under this bridge all traffic control settings will be flushed.
|
||||
# so we need to call tap_rate_limit after tap_plug
|
||||
PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall});
|
||||
|
||||
PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
|
||||
|
||||
exit 0;
|
Loading…
Reference in New Issue
Block a user