]> git.proxmox.com Git - pve-cluster.git/commitdiff
use simple files for LXC configuration
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 3 Aug 2015 04:27:01 +0000 (06:27 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 3 Aug 2015 04:27:01 +0000 (06:27 +0200)
data/PVE/Cluster.pm
data/src/memdb.c
data/src/status.c

index 27b2dd9d83887c7228f9ce2759869235c4b3d846..043b4f12be1ec6e01aa6c9733d18d8fc82b2fa76 100644 (file)
@@ -792,18 +792,12 @@ sub cfs_file_version {
 
     my $version;
     my $infotag;
-    if ($filename =~ m!^nodes/[^/]+/(openvz|qemu-server)/(\d+)\.conf$!) {
+    if ($filename =~ m!^nodes/[^/]+/(openvz|lxc|qemu-server)/(\d+)\.conf$!) {
        my ($type, $vmid) = ($1, $2);
        if ($vmlist && $vmlist->{ids} && $vmlist->{ids}->{$vmid}) {
            $version = $vmlist->{ids}->{$vmid}->{version};
        }
        $infotag = "/$type/";
-    } elsif ($filename =~ m!^nodes/[^/]+/lxc/(\d+)/config$!) {
-       my $vmid = $1;
-       if ($vmlist && $vmlist->{ids} && $vmlist->{ids}->{$vmid}) {
-           $version = $vmlist->{ids}->{$vmid}->{version};
-       }
-       $infotag = "/lxc/";
     } else {
        $infotag = $filename;
        $version = $versions->{$filename};
index 0a65db3c6af12e999844f2b530a6346685c3a584..af20e05c2ecbe6e9096f9859b8b3722fcb71261d 100644 (file)
@@ -222,26 +222,6 @@ name_is_vm_config(
        return TRUE;
 }
 
-static gboolean 
-name_is_vm_config_dir(
-       const char *name, 
-       guint32 *vmid_ret)
-{
-       if (!name || name[0] < '1' || name[0] > '9')
-               return FALSE;
-
-       char *end = NULL;
-       guint32 vmid =  strtoul(name, &end, 10);
-
-       if (!end || end[0] != 0)
-               return FALSE;
-
-       if (vmid_ret)
-               *vmid_ret = vmid;
-
-       return TRUE;
-}
-
 static gboolean
 valid_nodename(
        const char *nodename) 
@@ -318,19 +298,8 @@ path_contain_vm_config(
 
        split_path(path, &dirname, &base);
 
-       if ((nodename = dir_contain_vm_config(dirname, vmtype_ret))) {
-               if (*vmtype_ret == VMTYPE_LXC) {
-                       if (!name_is_vm_config_dir(base, vmid_ret)) {
-                               g_free(nodename);
-                               nodename = NULL;
-                       }
-               } else {
-                       if (!name_is_vm_config(base, vmid_ret)) {
-                               g_free(nodename);
-                               nodename = NULL;
-                       }
-               }
-       }
+       if (name_is_vm_config(base, vmid_ret))
+               nodename = dir_contain_vm_config(dirname, vmtype_ret);
        
        if (dirname) g_free (dirname);
        if (base) g_free (base);
@@ -364,28 +333,15 @@ vmlist_add_dir(
 
                memdb_tree_entry_t *node_te = (memdb_tree_entry_t *)value;
 
-               if (vmtype == VMTYPE_LXC) {
-                       if (node_te->type != DT_DIR)
-                               continue;
-
-                       guint32 vmid = 0;
-                       if (!name_is_vm_config_dir(node_te->name, &vmid))
-                               continue;
-
-                       if (!vmlist_hash_insert_vm(vmlist, vmtype, vmid, nodename, FALSE))
-                               ret = FALSE;
-
-               } else {
-                       if (node_te->type != DT_REG)
-                               continue;
+               if (node_te->type != DT_REG)
+                       continue;
 
-                       guint32 vmid = 0;
-                       if (!name_is_vm_config(node_te->name, &vmid))
-                               continue;
+               guint32 vmid = 0;
+               if (!name_is_vm_config(node_te->name, &vmid))
+                       continue;
 
-                       if (!vmlist_hash_insert_vm(vmlist, vmtype, vmid, nodename, FALSE))
-                               ret = FALSE;
-               }
+               if (!vmlist_hash_insert_vm(vmlist, vmtype, vmid, nodename, FALSE))
+                       ret = FALSE;
        }
 
        return ret;
@@ -619,7 +575,6 @@ int memdb_mkdir(
 
        char *dirname = NULL;
        char *base = NULL;
-       char *nodename = NULL;
 
        g_mutex_lock (&memdb->mutex);
 
@@ -650,17 +605,6 @@ int memdb_mkdir(
                goto ret;
        }
 
-       guint32 vmid = 0;
-       int vmtype = 0;
-
-       if ((nodename = path_contain_vm_config(path, &vmtype, &vmid))) {
-               if (vmlist_different_vm_exists(vmtype, vmid, nodename)) {
-                       ret = -EEXIST;
-                       goto ret;
-               }
-       }
-       
-
        memdb_tree_entry_t *te;
        if ((te = memdb_lookup_dir_entry(memdb, base, parent))) {
                ret = -EEXIST;
@@ -699,15 +643,11 @@ int memdb_mkdir(
                }
        }
 
-       if (nodename)
-               vmlist_register_vm(vmtype, vmid, nodename);
-
        ret = 0;
 
  ret:
        g_mutex_unlock (&memdb->mutex);
 
-       if (nodename) g_free (nodename);
        if (dirname) g_free (dirname);
        if (base) g_free (base);
 
@@ -1199,12 +1139,12 @@ memdb_rename(
 
        from_node = path_contain_vm_config(from, &from_vmtype, &from_vmid);
 
-       if ((nodename = path_contain_vm_config(to, &vmtype, &vmid))) {
+       if (from_te->type == DT_REG && (nodename = path_contain_vm_config(to, &vmtype, &vmid))) {
                if (vmlist_different_vm_exists(vmtype, vmid, nodename)) {
                        if (!(from_node && vmid == from_vmid)) {
                                ret = -EEXIST;
                                goto ret;
-                       }       
+                       }
                }
        }
 
index 97c97d75b5a4bc5373d28547057203ec97efee1e..a7a495c19abae05c59e5c0630fac2071696aa479 100644 (file)
@@ -762,18 +762,6 @@ record_memdb_change(const char *path)
 
        memdb_change_t *ce;
 
-       unsigned int vmid = 0;
-       char nodename[256];
-       char rest[4096];
-       if (cfs_status.vmlist &&
-           sscanf(path, "nodes/%255[^/]/lxc/%u/%4095s", nodename, &vmid, rest) == 3) {
-               vminfo_t *vminfo = (vminfo_t *)g_hash_table_lookup(cfs_status.vmlist, &vmid);
-               if (vminfo && (vminfo->vmtype == VMTYPE_LXC && strcmp(vminfo->nodename, nodename) == 0)) {
-                       cfs_status.vmlist_version++;
-                       vminfo->version = ++vminfo_version_counter;
-               }
-       }
-       
        if ((ce = (memdb_change_t *)g_hash_table_lookup(cfs_status.memdb_changes, path))) {
                ce->version++;
        }