Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
libvirt.29155
c647bf29-capabilities-Report-number-of-host-CPU...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File c647bf29-capabilities-Report-number-of-host-CPU-physical-addr.patch of Package libvirt.29155
From 98ebbcdb3f71660196abbd86c792e5904e715a22 Mon Sep 17 00:00:00 2001 From: Jim Fehlig <jfehlig@suse.com> Date: Fri, 29 Jul 2022 13:34:34 -0600 Subject: [PATCH 3/9] capabilities: Report number of host CPU physical address bits Signed-off-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> (cherry picked from commit c647bf29afb9890c792172ecf7db2c9c27babbb6) Conflicts: src/util/virhostcpu.h --- src/cpu/cpu_x86.c | 8 +++++++ src/libvirt_private.syms | 1 + src/util/virhostcpu.c | 52 ++++++++++++++++++++++++++++++++++++++++ src/util/virhostcpu.h | 2 ++ 4 files changed, 63 insertions(+) Index: libvirt-8.0.0/src/cpu/cpu_x86.c =================================================================== --- libvirt-8.0.0.orig/src/cpu/cpu_x86.c +++ libvirt-8.0.0/src/cpu/cpu_x86.c @@ -2685,6 +2685,7 @@ virCPUx86GetHost(virCPUDef *cpu, virDomainCapsCPUModels *models) { g_autoptr(virCPUData) cpuData = NULL; + unsigned int addrsz; int ret; if (virCPUx86DriverInitialize() < 0) @@ -2731,6 +2732,13 @@ virCPUx86GetHost(virCPUDef *cpu, 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 Index: libvirt-8.0.0/src/libvirt_private.syms =================================================================== --- libvirt-8.0.0.orig/src/libvirt_private.syms +++ libvirt-8.0.0/src/libvirt_private.syms @@ -2400,6 +2400,7 @@ virHostCPUGetMicrocodeVersion; virHostCPUGetMSR; virHostCPUGetOnline; virHostCPUGetOnlineBitmap; +virHostCPUGetPhysAddrSize; virHostCPUGetPresentBitmap; virHostCPUGetSignature; virHostCPUGetStats; Index: libvirt-8.0.0/src/util/virhostcpu.c =================================================================== --- libvirt-8.0.0.orig/src/util/virhostcpu.c +++ libvirt-8.0.0/src/util/virhostcpu.c @@ -572,6 +572,38 @@ virHostCPUParseFrequency(FILE *cpuinfo, } +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, @@ -1534,6 +1566,20 @@ virHostCPUGetSignature(char **signature) 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 @@ -1543,6 +1589,12 @@ virHostCPUGetSignature(char **signature) return 0; } +int +virHostCPUGetPhysAddrSize(unsigned int *size) +{ + return 0; +} + #endif /* __linux__ */ int Index: libvirt-8.0.0/src/util/virhostcpu.h =================================================================== --- libvirt-8.0.0.orig/src/util/virhostcpu.h +++ libvirt-8.0.0/src/util/virhostcpu.h @@ -86,6 +86,8 @@ virHostCPUTscInfo *virHostCPUGetTscInfo( int virHostCPUGetSignature(char **signature); +int virHostCPUGetPhysAddrSize(unsigned int *size); + int virHostCPUGetHaltPollTime(pid_t pid, unsigned long long *haltPollSuccess, unsigned long long *haltPollFail);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor