unsigned int *pnr_chars, int clear);
int xc_send_debug_keys(int handle, char *keys);
int xc_physinfo(int handle, xc_physinfo_t *put_info);
-int xc_pcpu_info(int handle, int max_cpus, uint64_t *info, int *nr_cpus);
+int xc_pcpu_info(
+ int handle, int max_cpus, xen_sysctl_cpuinfo_t *info, int *nr_cpus);
int xc_sched_id(int handle, int *sched_id);
int xc_version(int handle, int cmd, void *arg);
int xc_evtchn_alloc_unbound(int handle, unsigned int domid,
return ret;
}
+static void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits)
+{
+ uint64_t l;
+ int i, j, b;
+
+ for (i = 0, b = 0; nbits > 0; i++, b += sizeof(l)) {
+ l = lp[i];
+ for (j = 0; (j < sizeof(l)) && (nbits > 0); j++) {
+ bp[b+j] = l;
+ l >>= 8;
+ nbits -= 8;
+ }
+ }
+}
+
+static void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits)
+{
+ uint64_t l;
+ int i, j, b;
+
+ for (i = 0, b = 0; nbits > 0; i++, b += sizeof(l)) {
+ l = 0;
+ for (j = 0; (j < sizeof(l)) && (nbits > 0); j++) {
+ l |= (uint64_t)bp[b+j] << (j*8);
+ nbits -= 8;
+ }
+ lp[i] = l;
+ }
+}
+
int xc_vcpu_setaffinity(int handle, unsigned int domid, int vcpu,
uint64_t cpumap)
{
int ret;
+ uint8_t local[sizeof(cpumap)];
DECLARE_DOMCTL(XEN_DOMCTL_setvcpuaffinity, domid);
domctl.u.vcpuaffinity.vcpu = vcpu;
domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(cpumap) * 8;
- set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, (uint8_t *) &cpumap);
+ bitmap_64_to_byte(local, &cpumap, sizeof(cpumap)*8);
+ set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local);
if (mlock(&cpumap, sizeof(cpumap)) != 0) {
xc_error_set("mlock failed: %s", strerror(errno));
uint64_t *cpumap)
{
int ret;
+ uint8_t local[sizeof(*cpumap)];
DECLARE_DOMCTL(XEN_DOMCTL_getvcpuaffinity, domid);
domctl.u.vcpuaffinity.vcpu = vcpu;
domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(*cpumap) * 8;
- set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, cpumap);
+ set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local);
if (mlock(cpumap, sizeof(*cpumap)) != 0) {
xc_error_set("mlock failed: %s", strerror(errno));
if (ret < 0)
xc_error_dom_set(domid, "vcpu %d get affinity", vcpu);
munlock(cpumap, sizeof(*cpumap));
+ bitmap_byte_to_64(cpumap, local, sizeof(*cpumap) * 8);
return ret;
}
int ret;
DECLARE_DOMCTL(XEN_DOMCTL_getvcpucontext, domid);
domctl.u.vcpucontext.vcpu = vcpu;
- set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
+ set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt->c);
if (mlock(ctxt, sizeof(*ctxt)) != 0) {
xc_error_set("mlock failed: %s", strerror(errno));
int ret;
DECLARE_DOMCTL(XEN_DOMCTL_setvcpucontext, domid);
domctl.u.vcpucontext.vcpu = vcpu;
- set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
+ set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt->c);
if (mlock(ctxt, sizeof(*ctxt)) != 0) {
xc_error_set("mlock failed: %s", strerror(errno));
return 0;
}
-int xc_pcpu_info(int handle, int max_cpus, uint64_t *info, int *nr_cpus)
+int xc_pcpu_info(
+ int handle, int max_cpus, xen_sysctl_cpuinfo_t *info, int *nr_cpus)
{
DECLARE_SYSCTL(XEN_SYSCTL_getcpuinfo);
int ret;
CAMLparam3(xc_handle, domid, cpu);
CAMLlocal1(context);
int ret;
- struct vcpu_guest_context ctxt;
+ vcpu_guest_context_any_t ctxt;
ret = xc_vcpu_getcontext(_H(xc_handle), _D(domid), Int_val(cpu), &ctxt);
context = caml_alloc_string(sizeof(ctxt));
- memcpy(String_val(context), (char *) &ctxt, sizeof(ctxt));
+ memcpy(String_val(context), (char *) &ctxt.c, sizeof(ctxt.c));
CAMLreturn(context);
}
{
CAMLparam2(xc_handle, nr_cpus);
CAMLlocal2(pcpus, v);
- uint64_t *info;
+ xen_sysctl_cpuinfo_t *info;
int r, size;
if (Int_val(nr_cpus) < 1)
caml_invalid_argument("nr_cpus");
- info = calloc(Int_val(nr_cpus) + 1, sizeof(uint64_t));
+ info = calloc(Int_val(nr_cpus) + 1, sizeof(*info));
if (!info)
caml_raise_out_of_memory();
int i;
pcpus = caml_alloc(size, 0);
for (i = 0; i < size; i++) {
- v = caml_copy_int64(info[i]);
+ v = caml_copy_int64(info[i].idletime);
caml_modify(&Field(pcpus, i), v);
}
} else