This way more drivers can utilize the functionality without copying
the code. And we can therefore test it in one place for all of them.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/capabilities.c | 22 ++++++++++++++++++++++
src/conf/capabilities.h | 2 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 25 +------------------------
4 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index d798d5364cc2..08907aced1b9 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -1413,3 +1413,25 @@ virCapabilitiesInitNUMA(virCapsPtr caps)
VIR_FREE(pageinfo);
return ret;
}
+
+int
+virCapabilitiesInitPages(virCapsPtr caps)
+{
+ int ret = -1;
+ unsigned int *pages_size = NULL;
+ size_t npages;
+
+ if (virNumaGetPages(-1 /* Magic constant for overall info */,
+ &pages_size, NULL, NULL, &npages) < 0)
+ goto cleanup;
+
+ caps->host.pagesSize = pages_size;
+ pages_size = NULL;
+ caps->host.nPagesSize = npages;
+ npages = 0;
+
+ ret = 0;
+ cleanup:
+ VIR_FREE(pages_size);
+ return ret;
+}
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 3cb305b50b4a..d10eef3afdea 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -299,6 +299,8 @@ virBitmapPtr virCapabilitiesGetCpusForNodemask(virCapsPtr caps,
int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo);
+int virCapabilitiesInitPages(virCapsPtr caps);
+
int virCapabilitiesInitNUMA(virCapsPtr caps);
#endif /* __VIR_CAPABILITIES_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0d3a68a92b87..00ab8b9dfe63 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -60,6 +60,7 @@ virCapabilitiesGetCpusForNodemask;
virCapabilitiesGetNodeInfo;
virCapabilitiesHostSecModelAddBaseLabel;
virCapabilitiesInitNUMA;
+virCapabilitiesInitPages;
virCapabilitiesNew;
virCapabilitiesSetHostCPU;
virCapabilitiesSetNetPrefix;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7dafbbc61524..26de4de92756 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1084,29 +1084,6 @@ virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
}
-static int
-virQEMUCapsInitPages(virCapsPtr caps)
-{
- int ret = -1;
- unsigned int *pages_size = NULL;
- size_t npages;
-
- if (virNumaGetPages(-1 /* Magic constant for overall info */,
- &pages_size, NULL, NULL, &npages) < 0)
- goto cleanup;
-
- caps->host.pagesSize = pages_size;
- pages_size = NULL;
- caps->host.nPagesSize = npages;
- npages = 0;
-
- ret = 0;
- cleanup:
- VIR_FREE(pages_size);
- return ret;
-}
-
-
virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
{
virCapsPtr caps;
@@ -1134,7 +1111,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
VIR_WARN("Failed to get host power management capabilities");
/* Add huge pages info */
- if (virQEMUCapsInitPages(caps) < 0)
+ if (virCapabilitiesInitPages(caps) < 0)
VIR_WARN("Failed to get pages info");
/* Add domain migration transport URIs */
--
2.12.0