examples/vm_power_manager: fix build with libvirt < 1.0

virNodeGetCPUMap introduced in libvirt 1.0. In some linux distributions
like Ubuntu12/14 and Fedora18, libvirt version is older than 1.0. So this
sample will not build pass.

Replace "virNodeGetCPUMap" with another libvirt API "virNodeGetInfo".

Signed-off-by: Marvin Liu <yong.liu@intel.com>
This commit is contained in:
Yong Liu 2015-12-07 15:24:17 +08:00 committed by Thomas Monjalon
parent 3f3d601071
commit f7f14fe390

View File

@ -734,7 +734,7 @@ connect_hypervisor(const char *path)
int int
channel_manager_init(const char *path) channel_manager_init(const char *path)
{ {
int n_cpus; virNodeInfo info;
LIST_INIT(&vm_list_head); LIST_INIT(&vm_list_head);
if (connect_hypervisor(path) < 0) { if (connect_hypervisor(path) < 0) {
@ -756,13 +756,12 @@ channel_manager_init(const char *path)
goto error; goto error;
} }
n_cpus = virNodeGetCPUMap(global_vir_conn_ptr, NULL, NULL, 0); if (virNodeGetInfo(global_vir_conn_ptr, &info)) {
if (n_cpus <= 0) { RTE_LOG(ERR, CHANNEL_MANAGER, "Unable to retrieve node Info\n");
RTE_LOG(ERR, CHANNEL_MANAGER, "Unable to get the number of Host "
"CPUs\n");
goto error; goto error;
} }
global_n_host_cpus = (unsigned)n_cpus;
global_n_host_cpus = (unsigned)info.cpus;
if (global_n_host_cpus > CHANNEL_CMDS_MAX_CPUS) { if (global_n_host_cpus > CHANNEL_CMDS_MAX_CPUS) {
RTE_LOG(WARNING, CHANNEL_MANAGER, "The number of host CPUs(%u) exceeds the " RTE_LOG(WARNING, CHANNEL_MANAGER, "The number of host CPUs(%u) exceeds the "