mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-16 03:24:31 +03:00
qemu_domain: add statsSchema to qemuDomainObjPrivate
This patch adds a hashtable for storing the stats schema and a function to refresh it by querying "query-stats-schemas" using qemuMonitorQueryStatsSchema Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
parent
415f8b2233
commit
08af53dcaa
@ -1740,6 +1740,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *priv)
|
|||||||
|
|
||||||
priv->originalMemlock = 0;
|
priv->originalMemlock = 0;
|
||||||
priv->preMigrationMemlock = 0;
|
priv->preMigrationMemlock = 0;
|
||||||
|
|
||||||
|
virHashRemoveAll(priv->statsSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1778,6 +1780,9 @@ qemuDomainObjPrivateFree(void *data)
|
|||||||
g_object_unref(priv->eventThread);
|
g_object_unref(priv->eventThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->statsSchema)
|
||||||
|
g_clear_pointer(&priv->statsSchema, g_hash_table_destroy);
|
||||||
|
|
||||||
g_free(priv);
|
g_free(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1799,6 +1804,8 @@ qemuDomainObjPrivateAlloc(void *opaque)
|
|||||||
priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
|
priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
|
||||||
priv->driver = opaque;
|
priv->driver = opaque;
|
||||||
|
|
||||||
|
priv->statsSchema = NULL;
|
||||||
|
|
||||||
return g_steal_pointer(&priv);
|
return g_steal_pointer(&priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11774,3 +11781,38 @@ qemuDomainObjWait(virDomainObj *vm)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainRefreshStatsSchema:
|
||||||
|
* @driver: qemu driver data
|
||||||
|
* @vm: Pointer to the vm object
|
||||||
|
*
|
||||||
|
* Load data into dom->privateData->statsSchema if not stored
|
||||||
|
*
|
||||||
|
* Returns -1 on failure, 0 otherwise.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
qemuDomainRefreshStatsSchema(virDomainObj *dom)
|
||||||
|
{
|
||||||
|
qemuDomainObjPrivate *priv = dom->privateData;
|
||||||
|
GHashTable *schema = priv->statsSchema;
|
||||||
|
|
||||||
|
if (schema && g_hash_table_size(schema) > 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_STATS_SCHEMAS))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(dom);
|
||||||
|
schema = qemuMonitorQueryStatsSchema(priv->mon, QEMU_MONITOR_QUERY_STATS_PROVIDER_LAST);
|
||||||
|
qemuDomainObjExitMonitor(dom);
|
||||||
|
|
||||||
|
if (!schema)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
g_hash_table_unref(priv->statsSchema);
|
||||||
|
priv->statsSchema = schema;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -242,6 +242,8 @@ struct _qemuDomainObjPrivate {
|
|||||||
|
|
||||||
unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
|
unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no
|
||||||
* restore will be required later */
|
* restore will be required later */
|
||||||
|
|
||||||
|
GHashTable *statsSchema; /* (name, data) pair for stats */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QEMU_DOMAIN_PRIVATE(vm) \
|
#define QEMU_DOMAIN_PRIVATE(vm) \
|
||||||
@ -1098,3 +1100,6 @@ qemuDomainRemoveLogs(virQEMUDriver *driver,
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainObjWait(virDomainObj *vm);
|
qemuDomainObjWait(virDomainObj *vm);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuDomainRefreshStatsSchema(virDomainObj *dom);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user