diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-05-28 09:30:19 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-05-28 09:30:19 +0100 |
commit | 5cc436c1d2b3b0be3f42104582f53eec3969b43a (patch) | |
tree | 1e30ade146ee7287c486d1309b5d3d2c69a2d9b9 /tools/misc | |
parent | 7f9a888af4b65cb8c22cea3c8295d30d0fedd623 (diff) | |
download | xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.gz xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.bz2 xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.zip |
libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for
logging and error reporting).
Instead the information which was in the global variables is now in a
new xc_interface* opaque structure, which xc_interface open returns
instead of the raw file descriptor; furthermore, logging is done via
xentoollog.
There are three new parameters to xc_interface_open to control the
logging, but existing callers can just pass "0" for all three to get
the old behaviour.
All libxc callers have been adjusted accordingly.
Also update QEMU_TAG for corresponding qemu change.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/misc')
-rw-r--r-- | tools/misc/xen-hptool.c | 34 | ||||
-rw-r--r-- | tools/misc/xen-hvmctx.c | 7 | ||||
-rw-r--r-- | tools/misc/xenlockprof.c | 4 | ||||
-rw-r--r-- | tools/misc/xenperf.c | 5 | ||||
-rw-r--r-- | tools/misc/xenpm.c | 122 |
5 files changed, 87 insertions, 85 deletions
diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c index 7c2bf4acc6..cc4d6739f6 100644 --- a/tools/misc/xen-hptool.c +++ b/tools/misc/xen-hptool.c @@ -5,7 +5,7 @@ #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) -static int xc_fd; +static xc_interface *xch; void show_help(void) { @@ -44,7 +44,7 @@ static int hp_mem_online_func(int argc, char *argv[]) sscanf(argv[0], "%lx", &mfn); printf("Prepare to online MEMORY mfn %lx\n", mfn); - ret = xc_mark_page_online(xc_fd, mfn, mfn, &status); + ret = xc_mark_page_online(xch, mfn, mfn, &status); if (ret < 0) fprintf(stderr, "Onlining page mfn %lx failed, error %x", mfn, ret); @@ -75,7 +75,7 @@ static int hp_mem_query_func(int argc, char *argv[]) sscanf(argv[0], "%lx", &mfn); printf("Querying MEMORY mfn %lx status\n", mfn); - ret = xc_query_page_offline_status(xc_fd, mfn, mfn, &status); + ret = xc_query_page_offline_status(xch, mfn, mfn, &status); if (ret < 0) fprintf(stderr, "Querying page mfn %lx failed, error %x", mfn, ret); @@ -98,7 +98,7 @@ static int hp_mem_query_func(int argc, char *argv[]) extern int xs_suspend_evtchn_port(int domid); -static int suspend_guest(int xc_handle, int xce, int domid, int *evtchn) +static int suspend_guest(xc_interface *xch, int xce, int domid, int *evtchn) { int port, rc, suspend_evtchn = -1; @@ -111,7 +111,7 @@ static int suspend_guest(int xc_handle, int xce, int domid, int *evtchn) fprintf(stderr, "DOM%d: No suspend port, try live migration\n", domid); goto failed; } - suspend_evtchn = xc_suspend_evtchn_init(xc_handle, xce, domid, port); + suspend_evtchn = xc_suspend_evtchn_init(xch, xce, domid, port); if (suspend_evtchn < 0) { fprintf(stderr, "Suspend evtchn initialization failed\n"); @@ -125,7 +125,7 @@ static int suspend_guest(int xc_handle, int xce, int domid, int *evtchn) fprintf(stderr, "Failed to notify suspend channel: errno %d\n", rc); goto failed; } - if (xc_await_suspend(xce, suspend_evtchn) < 0) + if (xc_await_suspend(xch, xce, suspend_evtchn) < 0) { fprintf(stderr, "Suspend Failed\n"); goto failed; @@ -134,7 +134,7 @@ static int suspend_guest(int xc_handle, int xce, int domid, int *evtchn) failed: if (suspend_evtchn != -1) - xc_suspend_evtchn_release(xce, domid, suspend_evtchn); + xc_suspend_evtchn_release(xch, xce, domid, suspend_evtchn); return -1; } @@ -153,7 +153,7 @@ static int hp_mem_offline_func(int argc, char *argv[]) sscanf(argv[0], "%lx", &mfn); printf("Prepare to offline MEMORY mfn %lx\n", mfn); - ret = xc_mark_page_offline(xc_fd, mfn, mfn, &status); + ret = xc_mark_page_offline(xch, mfn, mfn, &status); if (ret < 0) { fprintf(stderr, "Offlining page mfn %lx failed, error %x\n", mfn, ret); if (status & (PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED)) @@ -203,7 +203,7 @@ static int hp_mem_offline_func(int argc, char *argv[]) } domid = status >> PG_OFFLINE_OWNER_SHIFT; - if (suspend_guest(xc_fd, xce, domid, &suspend_evtchn)) + if (suspend_guest(xch, xce, domid, &suspend_evtchn)) { fprintf(stderr, "Failed to suspend guest %d for" " mfn %lx\n", domid, mfn); @@ -211,7 +211,7 @@ static int hp_mem_offline_func(int argc, char *argv[]) return -1; } - result = xc_exchange_page(xc_fd, domid, mfn); + result = xc_exchange_page(xch, domid, mfn); /* Exchange page successfully */ if (result == 0) @@ -228,8 +228,8 @@ static int hp_mem_offline_func(int argc, char *argv[]) "[PG_OFFLINE_PENDING, PG_OFFLINE_OWNED]\n", mfn, domid); } - xc_domain_resume(xc_fd, domid, 1); - xc_suspend_evtchn_release(xce, domid, suspend_evtchn); + xc_domain_resume(xch, domid, 1); + xc_suspend_evtchn_release(xch, xce, domid, suspend_evtchn); xc_evtchn_close(xce); } break; @@ -253,7 +253,7 @@ static int hp_cpu_online_func(int argc, char *argv[]) cpu = atoi(argv[0]); printf("Prepare to online CPU %d\n", cpu); - ret = xc_cpu_online(xc_fd, cpu); + ret = xc_cpu_online(xch, cpu); if (ret < 0) fprintf(stderr, "CPU %d online failed (error %d: %s)\n", cpu, errno, strerror(errno)); @@ -274,7 +274,7 @@ static int hp_cpu_offline_func(int argc, char *argv[]) } cpu = atoi(argv[0]); printf("Prepare to offline CPU %d\n", cpu); - ret = xc_cpu_offline(xc_fd, cpu); + ret = xc_cpu_offline(xch, cpu); if (ret < 0) fprintf(stderr, "CPU %d offline failed (error %d: %s)\n", cpu, errno, strerror(errno)); @@ -307,8 +307,8 @@ int main(int argc, char *argv[]) return 0; } - xc_fd = xc_interface_open(); - if ( xc_fd < 0 ) + xch = xc_interface_open(0,0,0); + if ( !xch ) { fprintf(stderr, "failed to get the handler\n"); return 0; @@ -326,7 +326,7 @@ int main(int argc, char *argv[]) ret = main_options[i].function(argc -2, argv + 2); - xc_interface_close(xc_fd); + xc_interface_close(xch); return !!ret; } diff --git a/tools/misc/xen-hvmctx.c b/tools/misc/xen-hvmctx.c index 060ec7a6b0..38ee945670 100644 --- a/tools/misc/xen-hvmctx.c +++ b/tools/misc/xen-hvmctx.c @@ -377,7 +377,8 @@ static void dump_viridian(void) int main(int argc, char **argv) { - int entry, domid, xch; + int entry, domid; + xc_interface *xch; struct hvm_save_descriptor desc; @@ -387,8 +388,8 @@ int main(int argc, char **argv) exit(1); } - xch = xc_interface_open(); - if ( xch < 0 ) + xch = xc_interface_open(0,0,0); + if ( !xch ) { fprintf(stderr, "Error: can't open libxc handle\n"); exit(1); diff --git a/tools/misc/xenlockprof.c b/tools/misc/xenlockprof.c index 3e22e949a6..e30fbaaf23 100644 --- a/tools/misc/xenlockprof.c +++ b/tools/misc/xenlockprof.c @@ -36,7 +36,7 @@ static void unlock_pages(void *addr, size_t len) int main(int argc, char *argv[]) { - int xc_handle; + xc_interface *xc_handle; uint32_t i, j, n; uint64_t time; double l, b, sl, sb; @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) return 1; } - if ( (xc_handle = xc_interface_open()) == -1 ) + if ( (xc_handle = xc_interface_open(0,0,0)) == 0 ) { fprintf(stderr, "Error opening xc interface: %d (%s)\n", errno, strerror(errno)); diff --git a/tools/misc/xenperf.c b/tools/misc/xenperf.c index 36d1f1d7f3..3730efdbb7 100644 --- a/tools/misc/xenperf.c +++ b/tools/misc/xenperf.c @@ -86,7 +86,8 @@ static void unlock_pages(void *addr, size_t len) int main(int argc, char *argv[]) { - int i, j, xc_handle; + int i, j; + xc_interface *xc_handle; xc_perfc_desc_t *pcd; xc_perfc_val_t *pcv; xc_perfc_val_t *val; @@ -127,7 +128,7 @@ int main(int argc, char *argv[]) } } - if ( (xc_handle = xc_interface_open()) == -1 ) + if ( (xc_handle = xc_interface_open(0,0,0)) == 0 ) { fprintf(stderr, "Error opening xc interface: %d (%s)\n", errno, strerror(errno)); diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index d92ff2ad8a..679b1f39d3 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -34,7 +34,7 @@ #define CPUFREQ_TURBO_UNSUPPORTED 0 #define CPUFREQ_TURBO_ENABLED 1 -static int xc_fd; +static xc_interface *xc_handle; static int max_cpu_nr; /* help message */ @@ -95,12 +95,12 @@ static void print_cxstat(int cpuid, struct xc_cx_stat *cxstat) } /* show cpu idle information on CPU cpuid */ -static int get_cxstat_by_cpuid(int xc_fd, int cpuid, struct xc_cx_stat *cxstat) +static int get_cxstat_by_cpuid(xc_interface *xc_handle, int cpuid, struct xc_cx_stat *cxstat) { int ret = 0; int max_cx_num = 0; - ret = xc_pm_get_max_cx(xc_fd, cpuid, &max_cx_num); + ret = xc_pm_get_max_cx(xc_handle, cpuid, &max_cx_num); if ( ret ) return errno; @@ -117,7 +117,7 @@ static int get_cxstat_by_cpuid(int xc_fd, int cpuid, struct xc_cx_stat *cxstat) return -ENOMEM; } - ret = xc_pm_get_cxstat(xc_fd, cpuid, cxstat); + ret = xc_pm_get_cxstat(xc_handle, cpuid, cxstat); if( ret ) { int temp = errno; @@ -131,24 +131,24 @@ static int get_cxstat_by_cpuid(int xc_fd, int cpuid, struct xc_cx_stat *cxstat) return 0; } -static int show_max_cstate(int xc_fd) +static int show_max_cstate(xc_interface *xc_handle) { int ret = 0; uint32_t value; - if ( (ret = xc_get_cpuidle_max_cstate(xc_fd, &value)) ) + if ( (ret = xc_get_cpuidle_max_cstate(xc_handle, &value)) ) return ret; printf("Max C-state: C%d\n\n", value); return 0; } -static int show_cxstat_by_cpuid(int xc_fd, int cpuid) +static int show_cxstat_by_cpuid(xc_interface *xc_handle, int cpuid) { int ret = 0; struct xc_cx_stat cxstatinfo; - ret = get_cxstat_by_cpuid(xc_fd, cpuid, &cxstatinfo); + ret = get_cxstat_by_cpuid(xc_handle, cpuid, &cxstatinfo); if ( ret ) return ret; @@ -169,18 +169,18 @@ void cxstat_func(int argc, char *argv[]) if ( cpuid >= max_cpu_nr ) cpuid = -1; - show_max_cstate(xc_fd); + show_max_cstate(xc_handle); if ( cpuid < 0 ) { /* show cxstates on all cpus */ int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( show_cxstat_by_cpuid(xc_fd, i) == -ENODEV ) + if ( show_cxstat_by_cpuid(xc_handle, i) == -ENODEV ) break; } else - show_cxstat_by_cpuid(xc_fd, cpuid); + show_cxstat_by_cpuid(xc_handle, cpuid); } static void print_pxstat(int cpuid, struct xc_px_stat *pxstat) @@ -209,12 +209,12 @@ static void print_pxstat(int cpuid, struct xc_px_stat *pxstat) } /* show cpu frequency information on CPU cpuid */ -static int get_pxstat_by_cpuid(int xc_fd, int cpuid, struct xc_px_stat *pxstat) +static int get_pxstat_by_cpuid(xc_interface *xc_handle, int cpuid, struct xc_px_stat *pxstat) { int ret = 0; int max_px_num = 0; - ret = xc_pm_get_max_px(xc_fd, cpuid, &max_px_num); + ret = xc_pm_get_max_px(xc_handle, cpuid, &max_px_num); if ( ret ) return errno; @@ -232,7 +232,7 @@ static int get_pxstat_by_cpuid(int xc_fd, int cpuid, struct xc_px_stat *pxstat) return -ENOMEM; } - ret = xc_pm_get_pxstat(xc_fd, cpuid, pxstat); + ret = xc_pm_get_pxstat(xc_handle, cpuid, pxstat); if( ret ) { int temp = errno; @@ -247,11 +247,11 @@ static int get_pxstat_by_cpuid(int xc_fd, int cpuid, struct xc_px_stat *pxstat) } /* show cpu actual average freq information on CPU cpuid */ -static int get_avgfreq_by_cpuid(int xc_fd, int cpuid, int *avgfreq) +static int get_avgfreq_by_cpuid(xc_interface *xc_handle, int cpuid, int *avgfreq) { int ret = 0; - ret = xc_get_cpufreq_avgfreq(xc_fd, cpuid, avgfreq); + ret = xc_get_cpufreq_avgfreq(xc_handle, cpuid, avgfreq); if ( ret ) { return errno; @@ -260,12 +260,12 @@ static int get_avgfreq_by_cpuid(int xc_fd, int cpuid, int *avgfreq) return 0; } -static int show_pxstat_by_cpuid(int xc_fd, int cpuid) +static int show_pxstat_by_cpuid(xc_interface *xc_handle, int cpuid) { int ret = 0; struct xc_px_stat pxstatinfo; - ret = get_pxstat_by_cpuid(xc_fd, cpuid, &pxstatinfo); + ret = get_pxstat_by_cpuid(xc_handle, cpuid, &pxstatinfo); if ( ret ) return ret; @@ -291,11 +291,11 @@ void pxstat_func(int argc, char *argv[]) /* show pxstates on all cpus */ int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( show_pxstat_by_cpuid(xc_fd, i) == -ENODEV ) + if ( show_pxstat_by_cpuid(xc_handle, i) == -ENODEV ) break; } else - show_pxstat_by_cpuid(xc_fd, cpuid); + show_pxstat_by_cpuid(xc_handle, cpuid); } static uint64_t usec_start, usec_end; @@ -317,28 +317,28 @@ static void signal_int_handler(int signo) } usec_end = tv.tv_sec * 1000000UL + tv.tv_usec; - if ( get_cxstat_by_cpuid(xc_fd, 0, NULL) != -ENODEV ) + if ( get_cxstat_by_cpuid(xc_handle, 0, NULL) != -ENODEV ) { cx_cap = 1; for ( i = 0; i < max_cpu_nr; i++ ) - if ( !get_cxstat_by_cpuid(xc_fd, i, &cxstat_end[i]) ) + if ( !get_cxstat_by_cpuid(xc_handle, i, &cxstat_end[i]) ) for ( j = 0; j < cxstat_end[i].nr; j++ ) sum_cx[i] += cxstat_end[i].residencies[j] - cxstat_start[i].residencies[j]; } - if ( get_pxstat_by_cpuid(xc_fd, 0, NULL) != -ENODEV ) + if ( get_pxstat_by_cpuid(xc_handle, 0, NULL) != -ENODEV ) { px_cap = 1; for ( i = 0; i < max_cpu_nr; i++ ) - if ( !get_pxstat_by_cpuid(xc_fd, i , &pxstat_end[i]) ) + if ( !get_pxstat_by_cpuid(xc_handle, i , &pxstat_end[i]) ) for ( j = 0; j < pxstat_end[i].total; j++ ) sum_px[i] += pxstat_end[i].pt[j].residency - pxstat_start[i].pt[j].residency; } for ( i = 0; i < max_cpu_nr; i++ ) - get_avgfreq_by_cpuid(xc_fd, i, &avgfreq[i]); + get_avgfreq_by_cpuid(xc_handle, i, &avgfreq[i]); printf("Elapsed time (ms): %"PRIu64"\n", (usec_end - usec_start) / 1000UL); for ( i = 0; i < max_cpu_nr; i++ ) @@ -386,7 +386,7 @@ static void signal_int_handler(int signo) free(pxstat); free(sum); free(avgfreq); - xc_interface_close(xc_fd); + xc_interface_close(xc_handle); exit(0); } @@ -447,8 +447,8 @@ void start_gather_func(int argc, char *argv[]) pxstat_start = pxstat; pxstat_end = pxstat + max_cpu_nr; - if ( get_cxstat_by_cpuid(xc_fd, 0, NULL) == -ENODEV && - get_pxstat_by_cpuid(xc_fd, 0, NULL) == -ENODEV ) + if ( get_cxstat_by_cpuid(xc_handle, 0, NULL) == -ENODEV && + get_pxstat_by_cpuid(xc_handle, 0, NULL) == -ENODEV ) { fprintf(stderr, "Xen cpu idle and frequency is disabled!\n"); return ; @@ -456,9 +456,9 @@ void start_gather_func(int argc, char *argv[]) for ( i = 0; i < max_cpu_nr; i++ ) { - get_cxstat_by_cpuid(xc_fd, i, &cxstat_start[i]); - get_pxstat_by_cpuid(xc_fd, i, &pxstat_start[i]); - get_avgfreq_by_cpuid(xc_fd, i, &avgfreq[i]); + get_cxstat_by_cpuid(xc_handle, i, &cxstat_start[i]); + get_pxstat_by_cpuid(xc_handle, i, &pxstat_start[i]); + get_avgfreq_by_cpuid(xc_handle, i, &avgfreq[i]); } if (signal(SIGINT, signal_int_handler) == SIG_ERR) @@ -556,7 +556,7 @@ static void print_cpufreq_para(int cpuid, struct xc_get_cpufreq_para *p_cpufreq) } /* show cpu frequency parameters information on CPU cpuid */ -static int show_cpufreq_para_by_cpuid(int xc_fd, int cpuid) +static int show_cpufreq_para_by_cpuid(xc_interface *xc_handle, int cpuid) { int ret = 0; struct xc_get_cpufreq_para cpufreq_para, *p_cpufreq = &cpufreq_para; @@ -607,7 +607,7 @@ static int show_cpufreq_para_by_cpuid(int xc_fd, int cpuid) goto out; } - ret = xc_get_cpufreq_para(xc_fd, cpuid, p_cpufreq); + ret = xc_get_cpufreq_para(xc_handle, cpuid, p_cpufreq); } while ( ret && errno == EAGAIN ); if ( ret == 0 ) @@ -645,11 +645,11 @@ void cpufreq_para_func(int argc, char *argv[]) /* show cpu freqency information on all cpus */ int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( show_cpufreq_para_by_cpuid(xc_fd, i) == -ENODEV ) + if ( show_cpufreq_para_by_cpuid(xc_handle, i) == -ENODEV ) break; } else - show_cpufreq_para_by_cpuid(xc_fd, cpuid); + show_cpufreq_para_by_cpuid(xc_handle, cpuid); } void scaling_max_freq_func(int argc, char *argv[]) @@ -669,12 +669,12 @@ void scaling_max_freq_func(int argc, char *argv[]) { int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_fd, i, SCALING_MAX_FREQ, freq) ) + if ( xc_set_cpufreq_para(xc_handle, i, SCALING_MAX_FREQ, freq) ) fprintf(stderr, "[CPU%d] failed to set scaling max freq\n", i); } else { - if ( xc_set_cpufreq_para(xc_fd, cpuid, SCALING_MAX_FREQ, freq) ) + if ( xc_set_cpufreq_para(xc_handle, cpuid, SCALING_MAX_FREQ, freq) ) fprintf(stderr, "failed to set scaling max freq\n"); } } @@ -696,12 +696,12 @@ void scaling_min_freq_func(int argc, char *argv[]) { int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_fd, i, SCALING_MIN_FREQ, freq) ) + if ( xc_set_cpufreq_para(xc_handle, i, SCALING_MIN_FREQ, freq) ) fprintf(stderr, "[CPU%d] failed to set scaling min freq\n", i); } else { - if ( xc_set_cpufreq_para(xc_fd, cpuid, SCALING_MIN_FREQ, freq) ) + if ( xc_set_cpufreq_para(xc_handle, cpuid, SCALING_MIN_FREQ, freq) ) fprintf(stderr, "failed to set scaling min freq\n"); } } @@ -723,12 +723,12 @@ void scaling_speed_func(int argc, char *argv[]) { int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_fd, i, SCALING_SETSPEED, speed) ) + if ( xc_set_cpufreq_para(xc_handle, i, SCALING_SETSPEED, speed) ) fprintf(stderr, "[CPU%d] failed to set scaling speed\n", i); } else { - if ( xc_set_cpufreq_para(xc_fd, cpuid, SCALING_SETSPEED, speed) ) + if ( xc_set_cpufreq_para(xc_handle, cpuid, SCALING_SETSPEED, speed) ) fprintf(stderr, "failed to set scaling speed\n"); } } @@ -750,13 +750,13 @@ void scaling_sampling_rate_func(int argc, char *argv[]) { int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_fd, i, SAMPLING_RATE, rate) ) + if ( xc_set_cpufreq_para(xc_handle, i, SAMPLING_RATE, rate) ) fprintf(stderr, "[CPU%d] failed to set scaling sampling rate\n", i); } else { - if ( xc_set_cpufreq_para(xc_fd, cpuid, SAMPLING_RATE, rate) ) + if ( xc_set_cpufreq_para(xc_handle, cpuid, SAMPLING_RATE, rate) ) fprintf(stderr, "failed to set scaling sampling rate\n"); } } @@ -778,13 +778,13 @@ void scaling_up_threshold_func(int argc, char *argv[]) { int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_para(xc_fd, i, UP_THRESHOLD, threshold) ) + if ( xc_set_cpufreq_para(xc_handle, i, UP_THRESHOLD, threshold) ) fprintf(stderr, "[CPU%d] failed to set up scaling threshold\n", i); } else { - if ( xc_set_cpufreq_para(xc_fd, cpuid, UP_THRESHOLD, threshold) ) + if ( xc_set_cpufreq_para(xc_handle, cpuid, UP_THRESHOLD, threshold) ) fprintf(stderr, "failed to set up scaling threshold\n"); } } @@ -818,12 +818,12 @@ void scaling_governor_func(int argc, char *argv[]) { int i; for ( i = 0; i < max_cpu_nr; i++ ) - if ( xc_set_cpufreq_gov(xc_fd, i, name) ) + if ( xc_set_cpufreq_gov(xc_handle, i, name) ) fprintf(stderr, "[CPU%d] failed to set governor name\n", i); } else { - if ( xc_set_cpufreq_gov(xc_fd, cpuid, name) ) + if ( xc_set_cpufreq_gov(xc_handle, cpuid, name) ) fprintf(stderr, "failed to set governor name\n"); } @@ -848,7 +848,7 @@ void cpu_topology_func(int argc, char *argv[]) set_xen_guest_handle(info.cpu_to_node, cpu_to_node); info.max_cpu_index = MAX_NR_CPU-1; - if ( xc_topologyinfo(xc_fd, &info) ) + if ( xc_topologyinfo(xc_handle, &info) ) { printf("Can not get Xen CPU topology: %d\n", errno); return; @@ -890,7 +890,7 @@ void set_sched_smt_func(int argc, char *argv[]) exit(-1); } - rc = xc_set_sched_opt_smt(xc_fd, value); + rc = xc_set_sched_opt_smt(xc_handle, value); printf("%s sched_smt_power_savings %s\n", argv[0], rc? "failed":"succeeded" ); @@ -915,7 +915,7 @@ void set_vcpu_migration_delay_func(int argc, char *argv[]) exit(-1); } - rc = xc_set_vcpu_migration_delay(xc_fd, value); + rc = xc_set_vcpu_migration_delay(xc_handle, value); printf("%s to set vcpu migration delay to %d us\n", rc? "Fail":"Succeed", value ); @@ -932,7 +932,7 @@ void get_vcpu_migration_delay_func(int argc, char *argv[]) exit(-1); } - rc = xc_get_vcpu_migration_delay(xc_fd, &value); + rc = xc_get_vcpu_migration_delay(xc_handle, &value); if (!rc) { printf("Schduler vcpu migration delay is %d us\n", value); @@ -955,7 +955,7 @@ void set_max_cstate_func(int argc, char *argv[]) exit(-1); } - rc = xc_set_cpuidle_max_cstate(xc_fd, (uint32_t)value); + rc = xc_set_cpuidle_max_cstate(xc_handle, (uint32_t)value); printf("set max_cstate to C%d %s\n", value, rc? "failed":"succeeded" ); @@ -978,10 +978,10 @@ void enable_turbo_mode(int argc, char *argv[]) * only make effects on dbs governor */ int i; for ( i = 0; i < max_cpu_nr; i++ ) - xc_enable_turbo(xc_fd, i); + xc_enable_turbo(xc_handle, i); } else - xc_enable_turbo(xc_fd, cpuid); + xc_enable_turbo(xc_handle, cpuid); } void disable_turbo_mode(int argc, char *argv[]) @@ -1000,10 +1000,10 @@ void disable_turbo_mode(int argc, char *argv[]) * only make effects on dbs governor */ int i; for ( i = 0; i < max_cpu_nr; i++ ) - xc_disable_turbo(xc_fd, i); + xc_disable_turbo(xc_handle, i); } else - xc_disable_turbo(xc_fd, cpuid); + xc_disable_turbo(xc_handle, cpuid); } struct { @@ -1043,18 +1043,18 @@ int main(int argc, char *argv[]) return 0; } - xc_fd = xc_interface_open(); - if ( xc_fd < 0 ) + xc_handle = xc_interface_open(0,0,0); + if ( !xc_handle ) { fprintf(stderr, "failed to get the handler\n"); return 0; } - ret = xc_physinfo(xc_fd, &physinfo); + ret = xc_physinfo(xc_handle, &physinfo); if ( ret ) { fprintf(stderr, "failed to get the processor information\n"); - xc_interface_close(xc_fd); + xc_interface_close(xc_handle); return 0; } max_cpu_nr = physinfo.nr_cpus; @@ -1077,7 +1077,7 @@ int main(int argc, char *argv[]) else show_help(); - xc_interface_close(xc_fd); + xc_interface_close(xc_handle); return 0; } |