The new API is called virCPUDataFree. Individual CPU drivers are no
longer required to implement their own freeing function unless they need
to free architecture specific data from virCPUData.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/bhyve/bhyve_capabilities.c | 2 +-
src/cpu/cpu.c | 21 +++++++--------------
src/cpu/cpu.h | 4 ++--
src/cpu/cpu_arm.c | 7 -------
src/cpu/cpu_ppc64.c | 6 +++---
src/cpu/cpu_s390.c | 7 -------
src/cpu/cpu_x86.c | 22 +++++++++++-----------
src/libvirt_private.syms | 2 +-
src/libxl/libxl_capabilities.c | 4 ++--
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_monitor_json.c | 2 +-
src/qemu/qemu_parse_command.c | 2 +-
src/qemu/qemu_process.c | 2 +-
src/vmware/vmware_conf.c | 2 +-
src/vz/vz_driver.c | 2 +-
tests/cputest.c | 6 +++---
tests/qemumonitorjsontest.c | 4 ++--
17 files changed, 38 insertions(+), 59 deletions(-)
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 1dc0593af..52d6ca782 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -68,7 +68,7 @@ virBhyveCapsInitCPU(virCapsPtr caps,
ret = 0;
cleanup:
- cpuDataFree(data);
+ virCPUDataFree(data);
return ret;
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 3063f00eb..45a17bf46 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -331,7 +331,7 @@ virCPUDataNew(virArch arch)
/**
- * cpuDataFree:
+ * virCPUDataFree:
*
* @data: CPU data structure to be freed
*
@@ -340,26 +340,19 @@ virCPUDataNew(virArch arch)
* Returns nothing.
*/
void
-cpuDataFree(virCPUDataPtr data)
+virCPUDataFree(virCPUDataPtr data)
{
struct cpuArchDriver *driver;
VIR_DEBUG("data=%p", data);
- if (data == NULL)
+ if (!data)
return;
- if ((driver = cpuGetSubDriver(data->arch)) == NULL)
- return;
-
- if (driver->free == NULL) {
- virReportError(VIR_ERR_NO_SUPPORT,
- _("cannot free CPU data for %s architecture"),
- virArchToString(data->arch));
- return;
- }
-
- (driver->free)(data);
+ if ((driver = cpuGetSubDriver(data->arch)) && driver->dataFree)
+ driver->dataFree(data);
+ else
+ VIR_FREE(data);
}
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index ceb1e7256..0324284b9 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -116,7 +116,7 @@ struct cpuArchDriver {
virCPUArchCompare compare;
cpuArchDecode decode;
cpuArchEncode encode;
- cpuArchDataFree free;
+ cpuArchDataFree dataFree;
cpuArchNodeData nodeData;
cpuArchBaseline baseline;
virCPUArchUpdate update;
@@ -166,7 +166,7 @@ virCPUDataPtr
virCPUDataNew(virArch arch);
void
-cpuDataFree (virCPUDataPtr data);
+virCPUDataFree(virCPUDataPtr data);
virCPUDataPtr
cpuNodeData (virArch arch);
diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index 653b06b2f..3a0ee2b14 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -37,12 +37,6 @@ static const virArch archs[] = {
VIR_ARCH_AARCH64,
};
-static void
-armDataFree(virCPUDataPtr data)
-{
- VIR_FREE(data);
-}
-
static int
virCPUarmUpdate(virCPUDefPtr guest,
@@ -117,7 +111,6 @@ struct cpuArchDriver cpuDriverArm = {
.compare = virCPUarmCompare,
.decode = NULL,
.encode = NULL,
- .free = armDataFree,
.nodeData = NULL,
.baseline = armBaseline,
.update = virCPUarmUpdate,
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 180ad87d1..a7c8545db 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -705,7 +705,7 @@ ppc64DriverDecode(virCPUDefPtr cpu,
}
static void
-ppc64DriverFree(virCPUDataPtr data)
+virCPUppc64DataFree(virCPUDataPtr data)
{
if (!data)
return;
@@ -741,7 +741,7 @@ ppc64DriverNodeData(virArch arch)
return nodeData;
error:
- ppc64DriverFree(nodeData);
+ virCPUppc64DataFree(nodeData);
return NULL;
}
@@ -901,7 +901,7 @@ struct cpuArchDriver cpuDriverPPC64 = {
.compare = virCPUppc64Compare,
.decode = ppc64DriverDecode,
.encode = NULL,
- .free = ppc64DriverFree,
+ .dataFree = virCPUppc64DataFree,
.nodeData = ppc64DriverNodeData,
.baseline = ppc64DriverBaseline,
.update = virCPUppc64Update,
diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c
index 0248328db..9503e8e2b 100644
--- a/src/cpu/cpu_s390.c
+++ b/src/cpu/cpu_s390.c
@@ -33,12 +33,6 @@
static const virArch archs[] = { VIR_ARCH_S390, VIR_ARCH_S390X };
-static void
-s390DataFree(virCPUDataPtr data)
-{
- VIR_FREE(data);
-}
-
static virCPUCompareResult
virCPUs390Compare(virCPUDefPtr host ATTRIBUTE_UNUSED,
virCPUDefPtr cpu ATTRIBUTE_UNUSED,
@@ -115,7 +109,6 @@ struct cpuArchDriver cpuDriverS390 = {
.compare = virCPUs390Compare,
.decode = NULL,
.encode = NULL,
- .free = s390DataFree,
.nodeData = NULL,
.baseline = NULL,
.update = virCPUs390Update,
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 0058abef7..3b540f99c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -304,7 +304,7 @@ virCPUx86DataClear(virCPUx86Data *data)
static void
-x86FreeCPUData(virCPUDataPtr data)
+virCPUx86DataFree(virCPUDataPtr data)
{
if (!data)
return;
@@ -1455,7 +1455,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
return cpuData;
error:
- x86FreeCPUData(cpuData);
+ virCPUx86DataFree(cpuData);
cpuData = NULL;
goto cleanup;
}
@@ -1641,7 +1641,7 @@ x86Compute(virCPUDefPtr host,
return ret;
error:
- x86FreeCPUData(guestData);
+ virCPUx86DataFree(guestData);
ret = VIR_CPU_COMPARE_ERROR;
goto cleanup;
}
@@ -2033,12 +2033,12 @@ x86Encode(virArch arch,
return 0;
error:
- x86FreeCPUData(data_forced);
- x86FreeCPUData(data_required);
- x86FreeCPUData(data_optional);
- x86FreeCPUData(data_disabled);
- x86FreeCPUData(data_forbidden);
- x86FreeCPUData(data_vendor);
+ virCPUx86DataFree(data_forced);
+ virCPUx86DataFree(data_required);
+ virCPUx86DataFree(data_optional);
+ virCPUx86DataFree(data_disabled);
+ virCPUx86DataFree(data_forbidden);
+ virCPUx86DataFree(data_vendor);
return -1;
}
@@ -2380,7 +2380,7 @@ x86NodeData(virArch arch)
return cpuData;
error:
- x86FreeCPUData(cpuData);
+ virCPUx86DataFree(cpuData);
return NULL;
}
#endif
@@ -2718,7 +2718,7 @@ struct cpuArchDriver cpuDriverX86 = {
.compare = virCPUx86Compare,
.decode = x86DecodeCPUData,
.encode = x86Encode,
- .free = x86FreeCPUData,
+ .dataFree = virCPUx86DataFree,
#if defined(__i386__) || defined(__x86_64__)
.nodeData = x86NodeData,
#else
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cc5be84ea..56db100b5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -987,7 +987,6 @@ virSecretObjSetValueSize;
# cpu/cpu.h
cpuBaseline;
cpuBaselineXML;
-cpuDataFree;
cpuDecode;
cpuEncode;
cpuNodeData;
@@ -997,6 +996,7 @@ virCPUCompareXML;
virCPUConvertLegacy;
virCPUDataCheckFeature;
virCPUDataFormat;
+virCPUDataFree;
virCPUDataNew;
virCPUDataParse;
virCPUGetModels;
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 622e9f6bb..117055cf2 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -145,7 +145,7 @@ libxlCapsNodeData(virCPUDefPtr cpu, libxl_hwcap hwcap,
return cpudata;
error:
- cpuDataFree(cpudata);
+ virCPUDataFree(cpudata);
return NULL;
}
@@ -198,7 +198,7 @@ libxlCapsInitCPU(virCapsPtr caps, libxl_physinfo *phy_info,
}
cleanup:
- cpuDataFree(data);
+ virCPUDataFree(data);
return ret;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2ba82456e..6ca6ea702 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1091,7 +1091,7 @@ virQEMUCapsInitCPU(virCapsPtr caps,
ret = 0;
cleanup:
- cpuDataFree(data);
+ virCPUDataFree(data);
return ret;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b4da12167..cfb7f50aa 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6592,7 +6592,7 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
return cpudata;
error:
- cpuDataFree(cpudata);
+ virCPUDataFree(cpudata);
return NULL;
}
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 405e65549..a215027c1 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1606,7 +1606,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
goto cleanup;
is_32bit = (virCPUDataCheckFeature(cpuData, "lm") != 1);
- cpuDataFree(cpuData);
+ virCPUDataFree(cpuData);
} else if (model) {
is_32bit = STREQ(model, "qemu32");
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b9df01da5..95af7c283 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3843,7 +3843,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
ret = true;
cleanup:
- cpuDataFree(guestcpu);
+ virCPUDataFree(guestcpu);
return ret;
}
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 4222f4e38..5b1b5f5fd 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -118,7 +118,7 @@ vmwareCapsInit(void)
cleanup:
virCPUDefFree(cpu);
- cpuDataFree(data);
+ virCPUDataFree(data);
return caps;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 6aade90c4..181775809 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -151,7 +151,7 @@ vzBuildCapabilities(void)
}
cleanup:
- cpuDataFree(data);
+ virCPUDataFree(data);
return caps;
error:
diff --git a/tests/cputest.c b/tests/cputest.c
index 8612e920e..8d761af61 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -439,7 +439,7 @@ cpuTestHasFeature(const void *arg)
ret = 0;
cleanup:
- cpuDataFree(hostData);
+ virCPUDataFree(hostData);
virCPUDefFree(host);
return ret;
}
@@ -489,7 +489,7 @@ cpuTestCPUID(bool guest, const void *arg)
cleanup:
VIR_FREE(hostFile);
VIR_FREE(host);
- cpuDataFree(hostData);
+ virCPUDataFree(hostData);
virCPUDefFree(cpu);
VIR_FREE(result);
return ret;
@@ -549,7 +549,7 @@ cpuTestJSONCPUID(const void *arg)
cleanup:
qemuMonitorTestFree(testMon);
- cpuDataFree(cpuData);
+ virCPUDataFree(cpuData);
virCPUDefFree(cpu);
VIR_FREE(result);
VIR_FREE(json);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 5b2d6bb34..402c87d45 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2410,7 +2410,7 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
VIR_FREE(dataFile);
VIR_FREE(jsonStr);
VIR_FREE(actual);
- cpuDataFree(cpuData);
+ virCPUDataFree(cpuData);
qemuMonitorTestFree(test);
return ret;
}
@@ -2455,7 +2455,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
ret = 0;
cleanup:
qemuMonitorTestFree(test);
- cpuDataFree(cpuData);
+ virCPUDataFree(cpuData);
return ret;
}
--
2.11.1