]> git.proxmox.com Git - pve-cluster.git/blobdiff - data/src/status.c
pmxcfs: vminfo_type_to_string: fixup indendation and parenthesis
[pve-cluster.git] / data / src / status.c
index 3896fcbe910f6840b228056442eefb6804e9963d..5e51d59a2c5816610b8f03e602e2064ee49d0733 100644 (file)
@@ -81,6 +81,7 @@ static memdb_change_t memdb_change_array[] = {
        { .path = "user.cfg" },
        { .path = "domains.cfg" },
        { .path = "priv/shadow.cfg" },
+       { .path = "priv/tfa.cfg" },
        { .path = "datacenter.cfg" },
        { .path = "vzdump.cron" },
        { .path = "ha/crm_commands" },
@@ -89,6 +90,8 @@ static memdb_change_t memdb_change_array[] = {
        { .path = "ha/groups.cfg" },
        { .path = "ha/fence.cfg" },
        { .path = "status.cfg" },
+       { .path = "replication.cfg" },
+       { .path = "ceph.conf" },
 };
 
 static GMutex mutex;
@@ -156,6 +159,19 @@ static void vminfo_free(vminfo_t *vminfo)
        g_free(vminfo);
 }
 
+static const char *vminfo_type_to_string(vminfo_t *vminfo)
+{
+       if (vminfo->vmtype == VMTYPE_QEMU) {
+               return "qemu";
+       } else if (vminfo->vmtype == VMTYPE_OPENVZ) {
+               return "openvz";
+       } else if (vminfo->vmtype == VMTYPE_LXC) {
+               return "lxc";
+       } else {
+               return "unknown";
+       }
+}
+
 void cfs_clnode_destroy(
        cfs_clnode_t *clnode)
 {
@@ -729,16 +745,7 @@ cfs_create_vmlist_msg(GString *str)
                int first = 1;
                while (g_hash_table_iter_next (&iter, &key, &value)) {
                        vminfo_t *vminfo = (vminfo_t *)value;
-                       char *type;
-                       if (vminfo->vmtype == VMTYPE_QEMU) {
-                               type = "qemu";
-                       } else if (vminfo->vmtype == VMTYPE_OPENVZ) {
-                               type = "openvz";
-                       } else if (vminfo->vmtype == VMTYPE_LXC) {
-                               type = "lxc";
-                       } else {
-                               type = "unknown";
-                       }
+                       const char *type = vminfo_type_to_string(vminfo);
 
                        if (!first)
                                g_string_append_printf(str, ",\n");
@@ -789,7 +796,9 @@ kventry_hash_set(
        g_return_val_if_fail(data != NULL, FALSE);
 
        kventry_t *entry;
-       if ((entry = (kventry_t *)g_hash_table_lookup(kvhash, key))) {
+       if (!len) {
+               g_hash_table_remove(kvhash, key);
+       } else if ((entry = (kventry_t *)g_hash_table_lookup(kvhash, key))) {
                g_free(entry->data);
                entry->data = g_memdup(data, len);
                entry->len = len;
@@ -1075,10 +1084,13 @@ void
 cfs_rrd_dump(GString *str)
 {
        time_t ctime;
-       time(&ctime);
 
+       g_mutex_lock (&mutex);
+
+       time(&ctime);
        if (rrd_dump_buf && (ctime - rrd_dump_last) < 2) {
                g_string_assign(str, rrd_dump_buf);
+               g_mutex_unlock (&mutex);
                return;
        }
 
@@ -1107,6 +1119,8 @@ cfs_rrd_dump(GString *str)
        if (rrd_dump_buf)
                g_free(rrd_dump_buf);
        rrd_dump_buf = g_strdup(str->str);
+
+       g_mutex_unlock (&mutex);
 }
 
 static gboolean
@@ -1298,7 +1312,7 @@ cfs_create_status_msg(
 
        if (!nodename || !nodename[0] || !strcmp(nodename, cfs.nodename)) {
                kvhash = cfs_status.kvhash;
-       } else {
+       } else if (cfs_status.clinfo && cfs_status.clinfo->nodes_byname) {
                cfs_clnode_t *clnode;
                if ((clnode = g_hash_table_lookup(cfs_status.clinfo->nodes_byname, nodename)))
                        kvhash = clnode->kvhash;
@@ -1662,4 +1676,3 @@ cfs_set_quorate(
 
        g_mutex_unlock (&mutex);
 }
-