|
|
43fe83 |
From 7f9ba4690a2d5353e0b66686ce2569a795e225c4 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <7f9ba4690a2d5353e0b66686ce2569a795e225c4.1383922566.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Fri, 8 Nov 2013 12:33:21 +0100
|
|
|
43fe83 |
Subject: [PATCH] Ensure 'arch' is always set in cpuArchNodeData
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1008989
|
|
|
43fe83 |
|
|
|
43fe83 |
The s390, ppc and arm CPU drivers never set the 'arch' field
|
|
|
43fe83 |
in their impl of cpuArchNodeData. This leads to error messages
|
|
|
43fe83 |
being reported from cpuDataFree later, due to trying to use
|
|
|
43fe83 |
VIR_ARCH_NONE.
|
|
|
43fe83 |
|
|
|
43fe83 |
#0 virRaiseErrorFull (filename=filename@entry=0x76f94434 "cpu/cpu.c", funcname=funcname@entry=0x76f942dc <__FUNCTION__.18096> "cpuGetSubDriver", linenr=linenr@entry=58,
|
|
|
43fe83 |
domain=domain@entry=31, code=code@entry=1, level=level@entry=VIR_ERR_ERROR, str1=0x76f70e18 "internal error: %s",
|
|
|
43fe83 |
str2=str2@entry=0x7155f2ec "undefined hardware architecture", str3=str3@entry=0x0, int1=int1@entry=-1, int2=int2@entry=-1, fmt=0x76f70e18 "internal error: %s")
|
|
|
43fe83 |
at util/virerror.c:646
|
|
|
43fe83 |
#1 0x76e682ea in virReportErrorHelper (domcode=domcode@entry=31, errorcode=errorcode@entry=1, filename=0x76f94434 "cpu/cpu.c",
|
|
|
43fe83 |
funcname=0x76f942dc <__FUNCTION__.18096> "cpuGetSubDriver", linenr=linenr@entry=58, fmt=0x76f7e7e4 "%s") at util/virerror.c:1292
|
|
|
43fe83 |
#2 0x76ed82d4 in cpuGetSubDriver (arch=<optimized out>) at cpu/cpu.c:57
|
|
|
43fe83 |
#3 cpuGetSubDriver (arch=VIR_ARCH_NONE) at cpu/cpu.c:51
|
|
|
43fe83 |
#4 0x76ed8818 in cpuDataFree (data=data@entry=0x70c22d78) at cpu/cpu.c:216
|
|
|
43fe83 |
#5 0x716aaec0 in virQEMUCapsInitCPU (arch=VIR_ARCH_ARMV7L, caps=0x70c29a08) at qemu/qemu_capabilities.c:867
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 66ec11ade4664c85a158a2c309517baa8b5b048f)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/cpu/cpu.c | 2 +-
|
|
|
43fe83 |
src/cpu/cpu.h | 2 +-
|
|
|
43fe83 |
src/cpu/cpu_arm.c | 8 ++++++--
|
|
|
43fe83 |
src/cpu/cpu_powerpc.c | 12 +++++-------
|
|
|
43fe83 |
src/cpu/cpu_s390.c | 4 +++-
|
|
|
43fe83 |
src/cpu/cpu_x86.c | 4 ++--
|
|
|
43fe83 |
6 files changed, 18 insertions(+), 14 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
|
|
|
43fe83 |
index 7989b45..2660761 100644
|
|
|
43fe83 |
--- a/src/cpu/cpu.c
|
|
|
43fe83 |
+++ b/src/cpu/cpu.c
|
|
|
43fe83 |
@@ -244,7 +244,7 @@ cpuNodeData(virArch arch)
|
|
|
43fe83 |
return NULL;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
- return driver->nodeData();
|
|
|
43fe83 |
+ return driver->nodeData(arch);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
|
|
|
43fe83 |
index ad6ccfb..f016e2f 100644
|
|
|
43fe83 |
--- a/src/cpu/cpu.h
|
|
|
43fe83 |
+++ b/src/cpu/cpu.h
|
|
|
43fe83 |
@@ -69,7 +69,7 @@ typedef void
|
|
|
43fe83 |
(*cpuArchDataFree) (virCPUDataPtr data);
|
|
|
43fe83 |
|
|
|
43fe83 |
typedef virCPUDataPtr
|
|
|
43fe83 |
-(*cpuArchNodeData) (void);
|
|
|
43fe83 |
+(*cpuArchNodeData) (virArch arch);
|
|
|
43fe83 |
|
|
|
43fe83 |
typedef virCPUCompareResult
|
|
|
43fe83 |
(*cpuArchGuestData) (virCPUDefPtr host,
|
|
|
43fe83 |
diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
|
|
|
43fe83 |
index 25e25ba..c7dbffc 100644
|
|
|
43fe83 |
--- a/src/cpu/cpu_arm.c
|
|
|
43fe83 |
+++ b/src/cpu/cpu_arm.c
|
|
|
43fe83 |
@@ -31,11 +31,15 @@
|
|
|
43fe83 |
static const virArch archs[] = { VIR_ARCH_ARMV7L };
|
|
|
43fe83 |
|
|
|
43fe83 |
static virCPUDataPtr
|
|
|
43fe83 |
-ArmNodeData(void)
|
|
|
43fe83 |
+ArmNodeData(virArch arch)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virCPUDataPtr data;
|
|
|
43fe83 |
|
|
|
43fe83 |
- ignore_value(VIR_ALLOC(data));
|
|
|
43fe83 |
+ if (VIR_ALLOC(data) < 0)
|
|
|
43fe83 |
+ return NULL;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ data->arch = arch;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
return data;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
|
|
|
43fe83 |
index 55a4153..be07af1 100644
|
|
|
43fe83 |
--- a/src/cpu/cpu_powerpc.c
|
|
|
43fe83 |
+++ b/src/cpu/cpu_powerpc.c
|
|
|
43fe83 |
@@ -350,21 +350,23 @@ ppcDataFree(virCPUDataPtr data)
|
|
|
43fe83 |
VIR_FREE(data);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
-#if defined(__powerpc__) || defined(__powerpc64__)
|
|
|
43fe83 |
static virCPUDataPtr
|
|
|
43fe83 |
-ppcNodeData(void)
|
|
|
43fe83 |
+ppcNodeData(virArch arch)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virCPUDataPtr cpuData;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (VIR_ALLOC(cpuData) < 0)
|
|
|
43fe83 |
return NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ cpuData->arch = arch;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+#if defined(__powerpc__) || defined(__powerpc64__)
|
|
|
43fe83 |
asm("mfpvr %0"
|
|
|
43fe83 |
: "=r" (cpuData->data.ppc.pvr));
|
|
|
43fe83 |
+#endif
|
|
|
43fe83 |
|
|
|
43fe83 |
return cpuData;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
-#endif
|
|
|
43fe83 |
|
|
|
43fe83 |
static int
|
|
|
43fe83 |
ppcUpdate(virCPUDefPtr guest ATTRIBUTE_UNUSED,
|
|
|
43fe83 |
@@ -468,11 +470,7 @@ struct cpuArchDriver cpuDriverPowerPC = {
|
|
|
43fe83 |
.decode = ppcDecode,
|
|
|
43fe83 |
.encode = NULL,
|
|
|
43fe83 |
.free = ppcDataFree,
|
|
|
43fe83 |
-#if defined(__powerpc__) || defined(__powerpc64__)
|
|
|
43fe83 |
.nodeData = ppcNodeData,
|
|
|
43fe83 |
-#else
|
|
|
43fe83 |
- .nodeData = NULL,
|
|
|
43fe83 |
-#endif
|
|
|
43fe83 |
.guestData = NULL,
|
|
|
43fe83 |
.baseline = ppcBaseline,
|
|
|
43fe83 |
.update = ppcUpdate,
|
|
|
43fe83 |
diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c
|
|
|
43fe83 |
index cbfae42..e0d3174 100644
|
|
|
43fe83 |
--- a/src/cpu/cpu_s390.c
|
|
|
43fe83 |
+++ b/src/cpu/cpu_s390.c
|
|
|
43fe83 |
@@ -32,13 +32,15 @@
|
|
|
43fe83 |
static const virArch archs[] = { VIR_ARCH_S390, VIR_ARCH_S390X };
|
|
|
43fe83 |
|
|
|
43fe83 |
static virCPUDataPtr
|
|
|
43fe83 |
-s390NodeData(void)
|
|
|
43fe83 |
+s390NodeData(virArch arch)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virCPUDataPtr data;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (VIR_ALLOC(data) < 0)
|
|
|
43fe83 |
return NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ data->arch = arch;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
return data;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
43fe83 |
index 083cfee..e8e1990 100644
|
|
|
43fe83 |
--- a/src/cpu/cpu_x86.c
|
|
|
43fe83 |
+++ b/src/cpu/cpu_x86.c
|
|
|
43fe83 |
@@ -1731,7 +1731,7 @@ cpuidSet(uint32_t base, virCPUx86CPUID **set)
|
|
|
43fe83 |
|
|
|
43fe83 |
|
|
|
43fe83 |
static virCPUDataPtr
|
|
|
43fe83 |
-x86NodeData(void)
|
|
|
43fe83 |
+x86NodeData(virArch arch)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virCPUDataPtr cpuData = NULL;
|
|
|
43fe83 |
virCPUx86Data *data;
|
|
|
43fe83 |
@@ -1748,7 +1748,7 @@ x86NodeData(void)
|
|
|
43fe83 |
goto error;
|
|
|
43fe83 |
data->extended_len = ret;
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (!(cpuData = x86MakeCPUData(virArchFromHost(), &data)))
|
|
|
43fe83 |
+ if (!(cpuData = x86MakeCPUData(arch, &data)))
|
|
|
43fe83 |
goto error;
|
|
|
43fe83 |
|
|
|
43fe83 |
return cpuData;
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.4.2
|
|
|
43fe83 |
|