]> git.proxmox.com Git - pve-cluster.git/blobdiff - data/src/memdb.c
use simple files for LXC configuration
[pve-cluster.git] / data / src / memdb.c
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;
-                       }       
+                       }
                }
        }