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

Alexandre Derumier aderumier at odiso.com
Thu Aug 16 07:25:24 CEST 2012


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 06daf3c..35489aa 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



More information about the pve-devel mailing list