aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-03-01 12:26:13 +0000
committerIan Campbell <ian.campbell@citrix.com>2012-03-01 12:26:13 +0000
commit5fc905880c021ebb6e2a346619f050def5933aba (patch)
treec5817126fc3aca283ba5b764dc3a5f08ca9ad3ae
parent1341ac67a346d29acf95b46ca849414f23f11dde (diff)
downloadxen-5fc905880c021ebb6e2a346619f050def5933aba.tar.gz
xen-5fc905880c021ebb6e2a346619f050def5933aba.tar.bz2
xen-5fc905880c021ebb6e2a346619f050def5933aba.zip
libxl: remove sysctl.h from public interface
Using sysctl.h is restricted to "node control tools only" and requires magic defines. Therefore make its use internal to libxl. Also removes an indirect include of domctl.h which has the same restrction. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
-rw-r--r--tools/libxl/libxl.c21
-rw-r--r--tools/libxl/libxl.h6
-rw-r--r--tools/libxl/libxl_types.idl14
-rw-r--r--tools/libxl/libxl_utils.c34
-rw-r--r--tools/libxl/libxl_utils.h2
-rw-r--r--tools/libxl/xl_cmdimpl.c44
6 files changed, 47 insertions, 74 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 327b0402d2..8c9259ffc8 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -491,7 +491,7 @@ libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx *ctx, int *nb_pool)
}
ptr = tmp;
ptr[i].poolid = info->cpupool_id;
- ptr[i].sched_id = info->sched_id;
+ ptr[i].sched = info->sched_id;
ptr[i].n_dom = info->n_dom;
if (libxl_cpumap_alloc(ctx, &ptr[i].cpumap)) {
xc_cpupool_infofree(ctx->xch, info);
@@ -2750,7 +2750,10 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
physinfo->sharing_used_frames = xc_sharing_used_frames(ctx->xch);
physinfo->nr_nodes = xcphysinfo.nr_nodes;
memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap));
- physinfo->phys_cap = xcphysinfo.capabilities;
+
+ physinfo->cap_hvm = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm);
+ physinfo->cap_hvm_directio =
+ !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm_directio);
return 0;
}
@@ -2961,14 +2964,11 @@ out:
return rc;
}
-/*
- * returns one of the XEN_SCHEDULER_* constants from public/domctl.h
- */
-int libxl_get_sched_id(libxl_ctx *ctx)
+libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
{
- int sched, ret;
+ libxl_scheduler sched, ret;
- if ((ret = xc_sched_id(ctx->xch, &sched)) != 0) {
+ if ((ret = xc_sched_id(ctx->xch, (int *)&sched)) != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
return ERROR_FAIL;
}
@@ -3443,7 +3443,8 @@ int libxl_get_freecpus(libxl_ctx *ctx, libxl_cpumap *cpumap)
return 0;
}
-int libxl_cpupool_create(libxl_ctx *ctx, const char *name, int schedid,
+int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
+ libxl_scheduler sched,
libxl_cpumap cpumap, libxl_uuid *uuid,
uint32_t *poolid)
{
@@ -3459,7 +3460,7 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char *name, int schedid,
return ERROR_NOMEM;
}
- rc = xc_cpupool_create(ctx->xch, poolid, schedid);
+ rc = xc_cpupool_create(ctx->xch, poolid, sched);
if (rc) {
LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
"Could not create cpupool");
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 5d904eecae..d1110f4a23 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -138,7 +138,6 @@
#include <xentoollog.h>
#include <xen/sched.h>
-#include <xen/sysctl.h>
#include <libxl_uuid.h>
#include <_libxl_list.h>
@@ -584,7 +583,7 @@ int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
unsigned int max_vcpus, libxl_cpumap *cpumap);
int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_cpumap *cpumap);
-int libxl_get_sched_id(libxl_ctx *ctx);
+libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx);
int libxl_sched_credit_domain_get(libxl_ctx *ctx, uint32_t domid,
@@ -627,7 +626,8 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx, uint32_t domid, char* uuid,
int libxl_tmem_freeable(libxl_ctx *ctx);
int libxl_get_freecpus(libxl_ctx *ctx, libxl_cpumap *cpumap);
-int libxl_cpupool_create(libxl_ctx *ctx, const char *name, int schedid,
+int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
+ libxl_scheduler sched,
libxl_cpumap cpumap, libxl_uuid *uuid,
uint32_t *poolid);
int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index d6554b3074..567e48d437 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -105,6 +105,14 @@ libxl_bios_type = Enumeration("bios_type", [
(3, "ovmf"),
])
+# Consistent with values defined in domctl.h
+libxl_scheduler = Enumeration("scheduler", [
+ (4, "sedf"),
+ (5, "credit"),
+ (6, "credit2"),
+ (7, "arinc653"),
+ ])
+
#
# Complex libxl types
#
@@ -164,7 +172,7 @@ libxl_dominfo = Struct("dominfo",[
libxl_cpupoolinfo = Struct("cpupoolinfo", [
("poolid", uint32),
- ("sched_id", uint32),
+ ("sched", libxl_scheduler),
("n_dom", uint32),
("cpumap", libxl_cpumap)
])
@@ -388,7 +396,9 @@ libxl_physinfo = Struct("physinfo", [
("nr_nodes", uint32),
("hw_cap", libxl_hwcap),
- ("phys_cap", uint32),
+
+ ("cap_hvm", bool),
+ ("cap_hvm_directio", bool),
], dispose_fn=None, dir=DIR_OUT)
libxl_cputopology = Struct("cputopology", [
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index cd819c808c..227364cffe 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -19,18 +19,6 @@
#include "libxl_internal.h"
-struct schedid_name {
- char *name;
- int id;
-};
-
-static struct schedid_name schedid_name[] = {
- { "credit", XEN_SCHEDULER_CREDIT },
- { "sedf", XEN_SCHEDULER_SEDF },
- { "credit2", XEN_SCHEDULER_CREDIT2 },
- { NULL, -1 }
-};
-
const char *libxl_basename(const char *name)
{
const char *filename;
@@ -151,28 +139,6 @@ int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name,
return ret;
}
-int libxl_name_to_schedid(libxl_ctx *ctx, const char *name)
-{
- int i;
-
- for (i = 0; schedid_name[i].name != NULL; i++)
- if (strcmp(name, schedid_name[i].name) == 0)
- return schedid_name[i].id;
-
- return ERROR_INVAL;
-}
-
-char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid)
-{
- int i;
-
- for (i = 0; schedid_name[i].name != NULL; i++)
- if (schedid_name[i].id == schedid)
- return schedid_name[i].name;
-
- return "unknown";
-}
-
int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid)
{
GC_INIT(ctx);
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index f3002fd601..a4f5bf2d81 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -24,8 +24,6 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid);
char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);
int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name, uint32_t *poolid);
char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid);
-int libxl_name_to_schedid(libxl_ctx *ctx, const char *name);
-char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid);
int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid);
int libxl_is_stubdom(libxl_ctx *ctx, uint32_t domid, uint32_t *target_domid);
int libxl_create_logfile(libxl_ctx *ctx, char *name, char **full_name);
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index d60e22b337..b8b7b5452c 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3693,15 +3693,15 @@ int main_vcpuset(int argc, char **argv)
static void output_xeninfo(void)
{
const libxl_version_info *info;
- int sched_id;
+ libxl_scheduler sched;
if (!(info = libxl_get_version_info(ctx))) {
fprintf(stderr, "libxl_get_version_info failed.\n");
return;
}
- if ((sched_id = libxl_get_sched_id(ctx)) < 0) {
- fprintf(stderr, "get_sched_id sysctl failed.\n");
+ if ((sched = libxl_get_scheduler(ctx)) < 0) {
+ fprintf(stderr, "get_scheduler sysctl failed.\n");
return;
}
@@ -3709,7 +3709,7 @@ static void output_xeninfo(void)
printf("xen_minor : %d\n", info->xen_version_minor);
printf("xen_extra : %s\n", info->xen_version_extra);
printf("xen_caps : %s\n", info->capabilities);
- printf("xen_scheduler : %s\n", libxl_schedid_to_name(ctx, sched_id));
+ printf("xen_scheduler : %s\n", libxl_scheduler_to_string(sched));
printf("xen_pagesize : %u\n", info->pagesize);
printf("platform_params : virt_start=0x%"PRIx64"\n", info->virt_start);
printf("xen_changeset : %s\n", info->changeset);
@@ -3757,9 +3757,9 @@ static void output_physinfo(void)
for (i = 0; i < 8; i++)
printf("%08x%c", info.hw_cap[i], i < 7 ? ':' : '\n');
printf("virt_caps :");
- if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm)
+ if (info.cap_hvm)
printf(" hvm");
- if (info.phys_cap & XEN_SYSCTL_PHYSCAP_hvm_directio)
+ if (info.cap_hvm_directio)
printf(" hvm_directio");
printf("\n");
vinfo = libxl_get_version_info(ctx);
@@ -4065,7 +4065,7 @@ static int sched_sedf_domain_output(
}
static int sched_domain_output(
- uint32_t sched, int (*output)(int), const char *cpupool)
+ libxl_scheduler sched, int (*output)(int), const char *cpupool)
{
libxl_dominfo *info;
libxl_cpupoolinfo *poolinfo = NULL;
@@ -4094,7 +4094,7 @@ static int sched_domain_output(
}
for (p = 0; !rc && (p < n_pools); p++) {
- if ((poolinfo[p].sched_id != sched) ||
+ if ((poolinfo[p].sched != sched) ||
(cpupool && (poolid != poolinfo[p].poolid)))
continue;
@@ -4175,7 +4175,7 @@ int main_sched_credit(int argc, char **argv)
}
if (!dom) { /* list all domain's credit scheduler info */
- return -sched_domain_output(XEN_SCHEDULER_CREDIT,
+ return -sched_domain_output(LIBXL_SCHEDULER_CREDIT,
sched_credit_domain_output, cpupool);
} else {
find_domain(dom);
@@ -4251,7 +4251,7 @@ int main_sched_credit2(int argc, char **argv)
}
if (!dom) { /* list all domain's credit scheduler info */
- return -sched_domain_output(XEN_SCHEDULER_CREDIT2,
+ return -sched_domain_output(LIBXL_SCHEDULER_CREDIT2,
sched_credit2_domain_output, cpupool);
} else {
find_domain(dom);
@@ -4353,7 +4353,7 @@ int main_sched_sedf(int argc, char **argv)
}
if (!dom) { /* list all domain's credit scheduler info */
- return -sched_domain_output(XEN_SCHEDULER_SEDF,
+ return -sched_domain_output(LIBXL_SCHEDULER_SEDF,
sched_sedf_domain_output, cpupool);
} else {
find_domain(dom);
@@ -5292,9 +5292,8 @@ int main_cpupoolcreate(int argc, char **argv)
XLU_Config *config;
const char *buf;
const char *name;
- const char *sched;
uint32_t poolid;
- int schedid = -1;
+ libxl_scheduler sched = 0;
XLU_ConfigList *cpus;
XLU_ConfigList *nodes;
int n_cpus, n_nodes, i, n;
@@ -5389,17 +5388,16 @@ int main_cpupoolcreate(int argc, char **argv)
}
if (!xlu_cfg_get_string (config, "sched", &buf, 0)) {
- if ((schedid = libxl_name_to_schedid(ctx, buf)) < 0) {
+ if ((libxl_scheduler_from_string(buf, &sched)) < 0) {
fprintf(stderr, "Unknown scheduler\n");
return -ERROR_FAIL;
}
} else {
- if ((schedid = libxl_get_sched_id(ctx)) < 0) {
- fprintf(stderr, "get_sched_id sysctl failed.\n");
+ if ((sched = libxl_get_scheduler(ctx)) < 0) {
+ fprintf(stderr, "get_scheduler sysctl failed.\n");
return -ERROR_FAIL;
}
}
- sched = libxl_schedid_to_name(ctx, schedid);
if (libxl_get_freecpus(ctx, &freemap)) {
fprintf(stderr, "libxl_get_freecpus failed\n");
@@ -5467,14 +5465,14 @@ int main_cpupoolcreate(int argc, char **argv)
printf("Using config file \"%s\"\n", filename);
printf("cpupool name: %s\n", name);
- printf("scheduler: %s\n", sched);
+ printf("scheduler: %s\n", libxl_scheduler_to_string(sched));
printf("number of cpus: %d\n", n_cpus);
if (dryrun_only)
return 0;
poolid = 0;
- if (libxl_cpupool_create(ctx, name, schedid, cpumap, &uuid, &poolid)) {
+ if (libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid)) {
fprintf(stderr, "error on creating cpupool\n");
return -ERROR_FAIL;
}
@@ -5559,7 +5557,7 @@ int main_cpupoollist(int argc, char **argv)
}
if (!opt_cpus) {
printf("%3d %9s y %4d", n,
- libxl_schedid_to_name(ctx, poolinfo[p].sched_id),
+ libxl_scheduler_to_string(poolinfo[p].sched),
poolinfo[p].n_dom);
}
printf("\n");
@@ -5744,7 +5742,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
int c;
int n;
uint32_t poolid;
- int schedid;
+ libxl_scheduler sched;
int n_pools;
int node;
int n_cpus;
@@ -5765,7 +5763,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
return -ERROR_NOMEM;
}
poolid = poolinfo[0].poolid;
- schedid = poolinfo[0].sched_id;
+ sched = poolinfo[0].sched;
for (p = 0; p < n_pools; p++) {
libxl_cpupoolinfo_dispose(poolinfo + p);
}
@@ -5845,7 +5843,7 @@ int main_cpupoolnumasplit(int argc, char **argv)
snprintf(name, 15, "Pool-node%d", node);
libxl_uuid_generate(&uuid);
poolid = 0;
- ret = -libxl_cpupool_create(ctx, name, schedid, cpumap, &uuid, &poolid);
+ ret = -libxl_cpupool_create(ctx, name, sched, cpumap, &uuid, &poolid);
if (ret) {
fprintf(stderr, "error on creating cpupool\n");
goto out;