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};
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)
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);
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;
char *dirname = NULL;
char *base = NULL;
- char *nodename = NULL;
g_mutex_lock (&memdb->mutex);
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;
}
}
- 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);
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;
- }
+ }
}
}
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++;
}