mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: Report TSC frequency in host CPU capabilities
This patch adds a new <counter name='tsc' frequency='N' scaling='on|off'/> element into the host CPU capabilities XML. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
f0f6faba63
commit
c277b9ad5c
@ -112,6 +112,7 @@ virCPUDefFree(virCPUDefPtr def)
|
|||||||
|
|
||||||
virCPUDefFreeModel(def);
|
virCPUDefFreeModel(def);
|
||||||
VIR_FREE(def->cache);
|
VIR_FREE(def->cache);
|
||||||
|
VIR_FREE(def->tsc);
|
||||||
VIR_FREE(def);
|
VIR_FREE(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +234,13 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
|||||||
*copy->cache = *cpu->cache;
|
*copy->cache = *cpu->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cpu->tsc) {
|
||||||
|
if (VIR_ALLOC(copy->tsc) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
*copy->tsc = *cpu->tsc;
|
||||||
|
}
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -286,6 +294,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
char *cpuMode;
|
char *cpuMode;
|
||||||
char *fallback = NULL;
|
char *fallback = NULL;
|
||||||
char *vendor_id = NULL;
|
char *vendor_id = NULL;
|
||||||
|
char *tscScaling = NULL;
|
||||||
|
virHostCPUTscInfoPtr tsc = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
*cpu = NULL;
|
*cpu = NULL;
|
||||||
@ -402,6 +412,32 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
_("invalid microcode version"));
|
_("invalid microcode version"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virXPathBoolean("boolean(./counter[@name='tsc'])", ctxt) > 0) {
|
||||||
|
if (VIR_ALLOC(tsc) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virXPathULongLong("./counter[@name='tsc']/@frequency", ctxt,
|
||||||
|
&tsc->frequency) < 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Invalid TSC frequency"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
tscScaling = virXPathString("string(./counter[@name='tsc']/@scaling)",
|
||||||
|
ctxt);
|
||||||
|
if (tscScaling) {
|
||||||
|
int scaling = virTristateBoolTypeFromString(tscScaling);
|
||||||
|
if (scaling < 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Invalid TSC scaling attribute"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
tsc->scaling = scaling;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(def->tsc, tsc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(def->model = virXPathString("string(./model[1])", ctxt)) &&
|
if (!(def->model = virXPathString("string(./model[1])", ctxt)) &&
|
||||||
@ -587,6 +623,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
VIR_FREE(fallback);
|
VIR_FREE(fallback);
|
||||||
VIR_FREE(vendor_id);
|
VIR_FREE(vendor_id);
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
|
VIR_FREE(tscScaling);
|
||||||
|
VIR_FREE(tsc);
|
||||||
virCPUDefFree(def);
|
virCPUDefFree(def);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -744,6 +782,16 @@ virCPUDefFormatBuf(virBufferPtr buf,
|
|||||||
virBufferAsprintf(buf, "<microcode version='%u'/>\n",
|
virBufferAsprintf(buf, "<microcode version='%u'/>\n",
|
||||||
def->microcodeVersion);
|
def->microcodeVersion);
|
||||||
|
|
||||||
|
if (def->type == VIR_CPU_TYPE_HOST && def->tsc) {
|
||||||
|
virBufferAddLit(buf, "<counter name='tsc'");
|
||||||
|
virBufferAsprintf(buf, " frequency='%llu'", def->tsc->frequency);
|
||||||
|
if (def->tsc->scaling) {
|
||||||
|
virBufferAsprintf(buf, " scaling='%s'",
|
||||||
|
virTristateBoolTypeToString(def->tsc->scaling));
|
||||||
|
}
|
||||||
|
virBufferAddLit(buf, "/>\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (def->sockets && def->cores && def->threads) {
|
if (def->sockets && def->cores && def->threads) {
|
||||||
virBufferAddLit(buf, "<topology");
|
virBufferAddLit(buf, "<topology");
|
||||||
virBufferAsprintf(buf, " sockets='%u'", def->sockets);
|
virBufferAsprintf(buf, " sockets='%u'", def->sockets);
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
# include "virarch.h"
|
# include "virarch.h"
|
||||||
# include "numa_conf.h"
|
# include "numa_conf.h"
|
||||||
# include "virenum.h"
|
# include "virenum.h"
|
||||||
|
# include "virhostcpu.h"
|
||||||
|
|
||||||
# define VIR_CPU_VENDOR_ID_LENGTH 12
|
# define VIR_CPU_VENDOR_ID_LENGTH 12
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ struct _virCPUDef {
|
|||||||
size_t nfeatures_max;
|
size_t nfeatures_max;
|
||||||
virCPUFeatureDefPtr features;
|
virCPUFeatureDefPtr features;
|
||||||
virCPUCacheDefPtr cache;
|
virCPUCacheDefPtr cache;
|
||||||
|
virHostCPUTscInfoPtr tsc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user