From: BitKeeper B. <ri...@su...> - 2005-01-14 09:02:03
|
ChangeSet 1.1710.1.3, 2005/01/13 12:59:47+00:00, maf...@fl...search The getdomaininfo hypercall now listens to the exec_domain parameter that was already passed to it, and performs some basic sanity checking. Added exec_domain (aka vcpu) parameters to xc_domain_getfullinfo() and xc_domain_get_cpu_usage(). tools/libxc/xc.h | 4 +++- tools/libxc/xc_domain.c | 3 +++ tools/libxc/xc_linux_build.c | 1 + tools/libxc/xc_linux_restore.c | 1 + tools/libxc/xc_linux_save.c | 8 ++++---- tools/libxc/xc_plan9_build.c | 1 + tools/libxc/xc_private.c | 4 +++- tools/libxc/xc_vmx_build.c | 1 + xen/common/dom0_ops.c | 9 ++++++++- 9 files changed, 25 insertions(+), 7 deletions(-) diff -Nru a/tools/libxc/xc.h b/tools/libxc/xc.h --- a/tools/libxc/xc.h 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc.h 2005-01-14 04:02:00 -05:00 @@ -62,13 +62,15 @@ xc_dominfo_t *info); int xc_domain_getfullinfo(int xc_handle, u32 domid, + u32 vcpu, xc_domaininfo_t *info, full_execution_context_t *ctxt); int xc_domain_setcpuweight(int xc_handle, u32 domid, float weight); long long xc_domain_get_cpu_usage(int xc_handle, - domid_t domid); + domid_t domid, + int vcpu); typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t; diff -Nru a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_domain.c 2005-01-14 04:02:00 -05:00 @@ -88,6 +88,7 @@ { op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)next_domid; + op.u.getdomaininfo.exec_domain = 0; // FIX ME?!? op.u.getdomaininfo.ctxt = NULL; /* no exec context info, thanks. */ if ( do_dom0_op(xc_handle, &op) < 0 ) break; @@ -121,6 +122,7 @@ int xc_domain_getfullinfo(int xc_handle, u32 domid, + u32 vcpu, xc_domaininfo_t *info, full_execution_context_t *ctxt) { @@ -129,6 +131,7 @@ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = (u16)vcpu; op.u.getdomaininfo.ctxt = ctxt; rc = do_dom0_op(xc_handle, &op); diff -Nru a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_linux_build.c 2005-01-14 04:02:00 -05:00 @@ -370,6 +370,7 @@ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) diff -Nru a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c --- a/tools/libxc/xc_linux_restore.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_linux_restore.c 2005-01-14 04:02:00 -05:00 @@ -177,6 +177,7 @@ /* Get the domain's shared-info frame. */ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)dom; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = NULL; if ( do_dom0_op(xc_handle, &op) < 0 ) { diff -Nru a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c --- a/tools/libxc/xc_linux_save.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_linux_save.c 2005-01-14 04:02:00 -05:00 @@ -232,8 +232,8 @@ gettimeofday(&wall_now, NULL); - d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0 )/1000; - d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid )/1000; + d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0, /* FIXME */ 0 )/1000; + d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid, /* FIXME */ 0 )/1000; if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) ) printf("ARRHHH!!\n"); @@ -331,7 +331,7 @@ retry: - if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, info, ctxt) ) + if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, /* FIXME */ 0, info, ctxt) ) { xcio_error(ioctxt, "Could not get full domain info"); return -1; @@ -444,7 +444,7 @@ return 1; } - if ( xc_domain_getfullinfo( xc_handle, domid, &info, &ctxt) ) + if ( xc_domain_getfullinfo( xc_handle, domid, /* FIXME */ 0, &info, &ctxt) ) { xcio_error(ioctxt, "Could not get full domain info"); goto out; diff -Nru a/tools/libxc/xc_plan9_build.c b/tools/libxc/xc_plan9_build.c --- a/tools/libxc/xc_plan9_build.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_plan9_build.c 2005-01-14 04:02:00 -05:00 @@ -467,6 +467,7 @@ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t) domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = ctxt; if ((do_dom0_op(xc_handle, &op) < 0) || ((u32) op.u.getdomaininfo.domain != domid)) { diff -Nru a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c --- a/tools/libxc/xc_private.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_private.c 2005-01-14 04:02:00 -05:00 @@ -160,12 +160,13 @@ } -long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid ) +long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid, int vcpu ) { dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = (u16)vcpu; op.u.getdomaininfo.ctxt = NULL; if ( (do_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) @@ -248,6 +249,7 @@ dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = NULL; return (do_dom0_op(xc_handle, &op) < 0) ? -1 : op.u.getdomaininfo.tot_pages; diff -Nru a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c --- a/tools/libxc/xc_vmx_build.c 2005-01-14 04:02:00 -05:00 +++ b/tools/libxc/xc_vmx_build.c 2005-01-14 04:02:00 -05:00 @@ -430,6 +430,7 @@ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; + op.u.getdomaininfo.exec_domain = 0; op.u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) diff -Nru a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c --- a/xen/common/dom0_ops.c 2005-01-14 04:02:00 -05:00 +++ b/xen/common/dom0_ops.c 2005-01-14 04:02:00 -05:00 @@ -354,7 +354,14 @@ op->u.getdomaininfo.domain = d->id; - ed = d->exec_domain[0]; // op->u.getdomaininfo.exec_domain]; + if ( (op->u.getdomaininfo.exec_domain >= MAX_VIRT_CPUS) || + !d->exec_domain[op->u.getdomaininfo.exec_domain] ) + { + ret = -EINVAL; + break; + } + + ed = d->exec_domain[op->u.getdomaininfo.exec_domain]; op->u.getdomaininfo.flags = (test_bit( DF_DYING, &d->d_flags) ? DOMFLAGS_DYING : 0) | |