On Thu, 2021-04-08 at 11:51 -0400, Dawid Zamirski wrote:
Apparenlly exising code was dealing with stripping down Intel CPU
models
as reported by Hyper-V host but was still having issues with my AMD
CPU
for which Hyper-V returns "AMD FX(tm)-8350 Eight-Core Processor".
Therefore, this patch deals with it by stripping out the "
Processor" part, and if there's another CPU that we don't know of
yet that causes trouble, trim the resulting string to 32 characters
rather than failing as the node info has other information that are
more useful than the model.
---
src/hyperv/hyperv_driver.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 17f5be1f0d..6e03aa4f18 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1948,14 +1948,14 @@ hypervNodeGetInfo(virConnectPtr conn,
virNodeInfoPtr info)
if (STRPREFIX(tmp, " ")) {
memmove(tmp, tmp + 1, strlen(tmp + 1) + 1);
continue;
- } else if (STRPREFIX(tmp, "(R)") || STRPREFIX(tmp, "(C)"))
{
+ } else if (STRCASEPREFIX(tmp, "(R)") || STRCASEPREFIX(tmp,
"(C)")) {
memmove(tmp, tmp + 3, strlen(tmp + 3) + 1);
continue;
- } else if (STRPREFIX(tmp, "(TM)")) {
+ } else if (STRCASEPREFIX(tmp, "(TM)")) {
memmove(tmp, tmp + 4, strlen(tmp + 4) + 1);
continue;
- } else if (STRPREFIX(tmp, " @ ")) {
- /* Remove " @ X.YZGHz" from the end. */
+ } else if (STRPREFIX(tmp, " @ ") || STRPREFIX(tmp, "
Processor")) {
+ /* Remove " @ X.YZGHz" or " Processor" from the end. */
*tmp = '\0';
break;
}
@@ -1963,13 +1963,12 @@ hypervNodeGetInfo(virConnectPtr conn,
virNodeInfoPtr info)
++tmp;
}
+ /* trim whatever is left to 32 characters - better this than
nothing */
+ processorList->data->Name[31] = '\0';
+
/* Fill struct */
- if (virStrcpyStatic(info->model, processorList->data->Name) < 0)
{
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("CPU model %s too long for destination"),
- processorList->data->Name);
+ if (virStrcpyStatic(info->model, processorList->data->Name) < 0)
return -1;
- }
info->memory = computerSystem->data->TotalPhysicalMemory / 1024;
/* byte to kilobyte */
info->mhz = processorList->data->MaxClockSpeed;
Apparently, I've forgotten to add --signed-off to my commit. I'll send
V2 after initial review.