Change virQEMUCapsInitPages to virCapabilitiesInitPages

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@redhat.com>
This commit is contained in:
Martin Kletzander 2017-03-11 16:32:13 +01:00
parent d2d1dec1f5
commit 335f6373f1
4 changed files with 26 additions and 24 deletions

View File

@ -1413,3 +1413,25 @@ virCapabilitiesInitNUMA(virCapsPtr caps)
VIR_FREE(pageinfo); VIR_FREE(pageinfo);
return ret; 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;
}

View File

@ -299,6 +299,8 @@ virBitmapPtr virCapabilitiesGetCpusForNodemask(virCapsPtr caps,
int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo); int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo);
int virCapabilitiesInitPages(virCapsPtr caps);
int virCapabilitiesInitNUMA(virCapsPtr caps); int virCapabilitiesInitNUMA(virCapsPtr caps);
#endif /* __VIR_CAPABILITIES_H */ #endif /* __VIR_CAPABILITIES_H */

View File

@ -60,6 +60,7 @@ virCapabilitiesGetCpusForNodemask;
virCapabilitiesGetNodeInfo; virCapabilitiesGetNodeInfo;
virCapabilitiesHostSecModelAddBaseLabel; virCapabilitiesHostSecModelAddBaseLabel;
virCapabilitiesInitNUMA; virCapabilitiesInitNUMA;
virCapabilitiesInitPages;
virCapabilitiesNew; virCapabilitiesNew;
virCapabilitiesSetHostCPU; virCapabilitiesSetHostCPU;
virCapabilitiesSetNetPrefix; virCapabilitiesSetNetPrefix;

View File

@ -1086,29 +1086,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 virQEMUCapsInit(virQEMUCapsCachePtr cache)
{ {
virCapsPtr caps; virCapsPtr caps;
@ -1136,7 +1113,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
VIR_WARN("Failed to get host power management capabilities"); VIR_WARN("Failed to get host power management capabilities");
/* Add huge pages info */ /* Add huge pages info */
if (virQEMUCapsInitPages(caps) < 0) if (virCapabilitiesInitPages(caps) < 0)
VIR_WARN("Failed to get pages info"); VIR_WARN("Failed to get pages info");
/* Add domain migration transport URIs */ /* Add domain migration transport URIs */