[pve-devel] [PATCH 4/7] pve-bridge : find node where conf file is located.

Dietmar Maurer dietmar at proxmox.com
Thu Aug 23 11:02:58 CEST 2012


I did that a bit different - I simply pass the node inside an environment variable.
Hope that change will work also.

> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> Sent: Dienstag, 21. August 2012 12:22
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH 4/7] pve-bridge : find node where conf file is
> located.
> 
> tap interface name is too short to pass nodename, so we need to search it
> 
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>  PVE/QemuServer.pm |   21 +++++++++++++++++++--
>  pve-bridge        |    2 +-
>  2 files changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index
> c4631bf..7709883 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -21,7 +21,7 @@ use PVE::SafeSyslog;
>  use Storable qw(dclone);
>  use PVE::Exception qw(raise raise_param_exc);  use PVE::Storage; -use
> PVE::Tools qw(run_command lock_file file_read_firstline);
> +use PVE::Tools qw(run_command lock_file file_read_firstline
> +dir_glob_foreach);
>  use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file
> cfs_lock_file);  use PVE::INotify;  use PVE::ProcFSTools; @@ -1499,17
> +1499,34 @@ sub destroy_vm {  }
> 
>  sub load_config {
> -    my ($vmid, $node) = @_;
> +    my ($vmid, $node, $findnode) = @_;
> 
>      my $cfspath = cfs_config_path($vmid, $node);
> 
>      my $conf = PVE::Cluster::cfs_read_file($cfspath);
> +    if(!defined($conf) && $findnode){
> +	$node = find_node_config($vmid);
> +	$cfspath = cfs_config_path($vmid, $node);
> +	$conf = PVE::Cluster::cfs_read_file($cfspath);
> +    }
> 
>      die "no such VM ('$vmid')\n" if !defined($conf);
> 
>      return $conf;
>  }
> 
> +sub find_node_config {
> +    my($vmid) = @_;
> +
> +    my $findnode = undef;
> +    dir_glob_foreach("/etc/pve/nodes/", '(\S+)', sub {
> +	my ($node) = @_;
> +	$findnode =  $node if (-f "/etc/pve/nodes/$node/qemu-
> server/$vmid.conf");
> +    });
> +
> +    return $findnode;
> +}
> +
>  sub parse_vm_config {
>      my ($filename, $raw) = @_;
> 
> diff --git a/pve-bridge b/pve-bridge
> index fdee920..56c960f 100755
> --- a/pve-bridge
> +++ b/pve-bridge
> @@ -15,7 +15,7 @@ die "got strange interface name '$iface'\n"
>  my $vmid = $1;
>  my $netid = "net$2";
> 
> -my $conf = PVE::QemuServer::load_config ($vmid);
> +my $conf = PVE::QemuServer::load_config ($vmid, undef, 1);
> 
>  die "unable to get network config '$netid'\n"
>      if !$conf->{$netid};
> --
> 1.7.2.5
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





More information about the pve-devel mailing list