mirror of
				https://git.proxmox.com/git/qemu-server
				synced 2025-11-04 02:00:32 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			774 B
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			774 B
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/perl -w
 | 
						|
 | 
						|
use strict;
 | 
						|
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 $migratedfrom = $ENV{PVE_MIGRATED_FROM};
 | 
						|
 | 
						|
my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
 | 
						|
 | 
						|
die "unable to get network config '$netid'\n"
 | 
						|
    if !$conf->{$netid};
 | 
						|
 | 
						|
my $net = PVE::QemuServer::parse_net($conf->{$netid});
 | 
						|
die "unable to parse network config '$netid'\n" if !$net;
 | 
						|
 | 
						|
PVE::Network::tap_create($iface, $net->{bridge});
 | 
						|
 | 
						|
PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
 | 
						|
 | 
						|
PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag});
 | 
						|
 | 
						|
exit 0;
 |