virDomainCapsCPUModels *models)
{
g_autoptr(virCPUData) cpuData = NULL;
+ unsigned int addrsz;
int ret;
if (virCPUx86DriverInitialize() < 0)
VIR_DEBUG("Host CPU does not support invariant TSC");
}
+ if (virHostCPUGetPhysAddrSize(&addrsz) == 0) {
+ virCPUMaxPhysAddrDef *addr = g_new0(virCPUMaxPhysAddrDef, 1);
+
+ addr->bits = addrsz;
+ cpu->addr = addr;
+ }
+
return ret;
}
#endif
}
+static int
+virHostCPUParsePhysAddrSize(FILE *cpuinfo, unsigned int *addrsz)
+{
+ char line[1024];
+
+ while (fgets(line, sizeof(line), cpuinfo) != NULL) {
+ char *str;
+ char *endptr;
+
+ if (!(str = STRSKIP(line, "address sizes")))
+ continue;
+
+ /* Skip the colon. */
+ if ((str = strstr(str, ":")) == NULL)
+ goto error;
+ str++;
+
+ /* Parse the number of physical address bits */
+ if (virStrToLong_ui(str, &endptr, 10, addrsz) < 0)
+ goto error;
+
+ return 0;
+ }
+
+ error:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing or invalid CPU address size in %s"),
+ CPUINFO_PATH);
+ return -1;
+}
+
+
int
virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
virArch arch,
return virHostCPUReadSignature(virArchFromHost(), cpuinfo, signature);
}
+int
+virHostCPUGetPhysAddrSize(unsigned int *size)
+{
+ g_autoptr(FILE) cpuinfo = NULL;
+
+ if (!(cpuinfo = fopen(CPUINFO_PATH, "r"))) {
+ virReportSystemError(errno, _("Failed to open cpuinfo file '%s'"),
+ CPUINFO_PATH);
+ return -1;
+ }
+
+ return virHostCPUParsePhysAddrSize(cpuinfo, size);
+}
+
#else
int
return 0;
}
+int
+virHostCPUGetPhysAddrSize(unsigned int *size)
+{
+ return 0;
+}
+
#endif /* __linux__ */
int
unsigned int *cores,
unsigned int *threads);
+
int virHostCPUGetKVMMaxVCPUs(void) G_NO_INLINE;
int virHostCPUStatsAssign(virNodeCPUStatsPtr param,
int virHostCPUGetSignature(char **signature);
+int virHostCPUGetPhysAddrSize(unsigned int *size);
+
int virHostCPUGetHaltPollTime(pid_t pid,
unsigned long long *haltPollSuccess,
unsigned long long *haltPollFail);