Commit 8d4b6557 authored by Yathindra Naik's avatar Yathindra Naik

Patch in rest of the hypercalls.

parent d6c9840b
......@@ -882,7 +882,7 @@ int libxl_domain_setcap(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
*/
char *tok;
int size = 0;
int list[64];
int list[64] = {-1};
printf ("Splitting string \"%s\" into tokens:\n",info->cap_values);
tok = strtok (info->cap_values," ,.-");
......@@ -890,19 +890,99 @@ int libxl_domain_setcap(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
while (tok != NULL)
{
printf ("%s\n",tok);
if ( strncmp(tok, "memory_map", 10) == 0 )
list[0] = 0;
else if ( strncmp(tok, "memory_pin_page", 15) == 0 )
if ( strncmp(tok,"memory_pin_page",strlen("memory_pin_page")) == 0 )
list[1] = 1;
else if ( strncmp(tok, "boo", 3) == 0 )
if ( strncmp(tok,"security_domaininfo",strlen("security_domaininfo")) == 0 )
list[2] = 2;
if ( strncmp(tok,"setvcpucontext",strlen("setvcpucontext")) == 0 )
list[3] = 3;
if ( strncmp(tok,"pausedomain",strlen("pausedomain")) == 0 )
list[4] = 4;
if ( strncmp(tok,"unpausedomain",strlen("unpausedomain")) == 0 )
list[5] = 5;
if ( strncmp(tok,"resumedomain",strlen("resumedomain")) == 0 )
list[6] = 6;
if ( strncmp(tok,"max_vcpus",strlen("max_vcpus")) == 0)
list[7] = 7;
if ( strncmp(tok,"destroydomain",strlen("destroydomain")) == 0 )
list[8] = 8;
if ( strncmp(tok,"vcpuaffinity",strlen("vcpuaffinity")) == 0 )
list[9] = 9;
if ( strncmp(tok,"scheduler",strlen("schedule")) == 0)
list[10] = 10;
if ( strncmp(tok,"getdomaininfo",strlen("getdomaininfo")) == 0 )
list[11] = 11;
if ( strncmp(tok,"getvcpucontext",strlen("getvcpucontext")) == 0 )
list[12] = 12;
if ( strncmp(tok,"getvcpuinfo",strlen("getvcpuinfo")) == 0 )
list[13] = 13;
if ( strncmp(tok,"domain_settime",strlen("domain_settime")) == 0 )
list[14] = 14;
if ( strncmp(tok,"set_target",strlen("set_target")) == 0 )
list[15] = 15;
if ( strncmp(tok,"domctl",strlen("domctl")) == 0 )
list[16] = 16;
if ( strncmp(tok,"set_virq_handler",strlen("set_virq_handler")) == 0 )
list[17] = 17;
if ( strncmp(tok,"setdomainmaxmem",strlen("setdomainmaxmem")) == 0 )
list[21] = 21;
if ( strncmp(tok,"setdomainhandle",strlen("setdomainhandle")) == 0 )
list[22] = 22;
if ( strncmp(tok,"setdebugging",strlen("setdebugging")) == 0 )
list[23] = 23;
if ( strncmp(tok,"grant_mapref",strlen("grant_mapref")) == 0 )
list[35] = 35;
if ( strncmp(tok,"grant_unmapref",strlen("grant_unmapref")) == 0 )
list[36] = 36;
if ( strncmp(tok,"grant_setup",strlen("grant_setup")) == 0 )
list[37] = 37;
if ( strncmp(tok,"grant_transfer",strlen("grant_transfer")) == 0 )
list[38] = 38;
if ( strncmp(tok,"grant_copy",strlen("grant_copy")) == 0 )
list[39] = 39;
if ( strncmp(tok,"grant_query_size",strlen("grant_query_size")) == 0 )
list[40] = 40;
if ( strncmp(tok,"memory_adjust_reservation",strlen("memory_adjust_reservation")) == 0 )
list[41] = 41;
if ( strncmp(tok,"memory_stat_reservation",strlen("memory_stat_reservation")) == 0 )
list[42] = 42;
if ( strncmp(tok,"console_io",strlen("console_io")) == 0 )
list[43] = 43;
if( strncmp(tok, "profile",strlen("profile")) == 0 )
list[44] = 44;
if ( strncmp(tok,"schedop_shutdown",strlen("schedop_shutdown")) == 0 )
list[45] = 45;
if( strncmp(tok,"evtchn_unbound",strlen("evtchn_unbound")) == 0 )
list[46] = 46;
if ( strncmp(tok,"evtchn_interdomain",strlen("evtchn_interdomain")) == 0 )
list[47] = 47;
if ( strncmp(tok,"evtchn_send",strlen("evtchn_send")) == 0 )
list[48] = 48;
if ( strncmp(tok,"evtchn_status",strlen("evtchn_status")) == 0 )
list[49] = 49;
if ( strncmp(tok,"evtchn_reset",strlen("evtchn_reset")) == 0 )
list[50] = 50;
if ( strncmp(tok,"get_pod_target",strlen("get_pod_target")) == 0 )
list[52] = 52;
if ( strncmp(tok,"set_pod_target",strlen("set_pod_target")) == 0 )
list[53] = 53;
if ( strncmp(tok,"map_domain_pirq",strlen("map_domain_pirq")) == 0 )
list[54] = 54;
if ( strncmp(tok,"irq_permission",strlen("irq_permission")) == 0 )
list[55] = 55;
if ( strncmp(tok,"iomem_permission",strlen("iomem_permission")) == 0 )
list[56] = 56;
if ( strncmp(tok,"pci_config_permission",strlen("pci_config_permission")) == 0 )
list[57] = 57;
++size;
tok = strtok (NULL, " ,.-");
}
printf("Calling xc_cap_grant().\n");
ret = xc_cap_grant(ctx->xch,0,domid,1,list,size);
if(size > 0)
{
printf("Calling xc_cap_grant().\n");
ret = xc_cap_grant(ctx->xch,0,domid,1,list,size);
}
return ret;
}
......
......@@ -381,7 +381,7 @@ out:
return ret;
}
int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info,
int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, libxl_capabilities *cap,
uint32_t *domid)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
......@@ -415,6 +415,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info,
/* Ultimately, handle is an array of 16 uint8_t, same as uuid */
libxl_uuid_copy((libxl_uuid *)handle, &info->uuid);
printf("Calling xc_domain_create from libxl__domain_make\n");
ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid);
if (ret < 0) {
LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "domain creation fail");
......@@ -422,12 +423,11 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info,
goto out;
}
#ifdef CONFIG_XENCAP
libxl_capabilities *cap = d_config.cap;
ret = libxl_domain_setcap(ctx, cap, domid);
ret = libxl_domain_setcap(ctx, cap, *domid);
if (ret) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot grant capabilities: %d", ret);
ret = ERROR_FAIL;
goto error_out;
rc = ERROR_FAIL;
goto out;
}
#endif
ret = xc_cpupool_movedomain(ctx->xch, info->poolid, *domid);
......@@ -515,7 +515,7 @@ retry_transaction:
libxl__sprintf(gc, "%s/hvmloader/generation-id-address", dom_path),
rwperm, ARRAY_SIZE(rwperm));
vm_list = libxl_list_vm(ctx, &nb_vm);
vm_list = libxl_list_vm(ctx, &nb_vm);
if (!vm_list) {
LOG(ERROR, "cannot get number of running guests");
rc = ERROR_FAIL;
......@@ -649,7 +649,7 @@ static void initiate_domain_create(libxl__egc *egc,
ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
if (ret) goto error_out;
ret = libxl__domain_make(gc, &d_config->c_info, &domid);
ret = libxl__domain_make(gc, &d_config->c_info, d_config->cap, &domid);
if (ret) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
dcs->guest_domid = domid;
......
......@@ -807,7 +807,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
stubdom_state->pv_ramdisk.path = "";
/* fixme: this function can leak the stubdom if it fails */
ret = libxl__domain_make(gc, &dm_config->c_info, &sdss->pvqemu.guest_domid);
ret = libxl__domain_make(gc, &dm_config->c_info, dm_config->cap, &sdss->pvqemu.guest_domid);
if (ret)
goto out;
uint32_t dm_domid = sdss->pvqemu.guest_domid;
......
......@@ -1266,6 +1266,7 @@ _hidden void libxl__exec(libxl__gc *gc, int stdinfd, int stdoutfd,
* on exit (even error exit), domid may be valid and refer to a domain */
_hidden int libxl__domain_make(libxl__gc *gc,
libxl_domain_create_info *info,
libxl_capabilities *cap,
uint32_t *domid);
_hidden int libxl__domain_build(libxl__gc *gc,
......
......@@ -174,6 +174,7 @@ CAMLprim value stub_xc_domain_create(value xch, value ssidref,
}
caml_enter_blocking_section();
printf("In libxl__build_pre before calling xc_domain_create()\n");
result = xc_domain_create(_H(xch), c_ssidref, h, c_flags, &domid);
caml_leave_blocking_section();
......@@ -657,6 +658,7 @@ CAMLprim value stub_xc_domain_set_memmap_limit(value xch, value domid,
int retval;
v = Int64_val(map_limitkb);
retval = xc_domain_set_memmap_limit(_H(xch), _D(domid), v);
if (retval)
failwith_xc(_H(xch));
......
......@@ -136,6 +136,7 @@ static PyObject *pyxc_domain_create(XcObject *self,
}
}
printf("Calling xc_domain_create from pyxc_domain_create()\n");
if ( (ret = xc_domain_create(self->xc_handle, ssidref,
handle, flags, &dom)) < 0 )
return pyxc_error_to_exception(self->xc_handle);
......
......@@ -25,6 +25,7 @@ static int build(xc_interface *xch, char** argv)
rv = xc_flask_context_to_sid(xch, argv[3], strlen(argv[3]), &ssid);
if (rv) return rv;
printk("Calling xc_domain_create from build()\n");
rv = xc_domain_create(xch, ssid, handle, 0, &domid);
if (rv) return rv;
rv = xc_domain_max_vcpus(xch, domid, 1);
......
......@@ -290,6 +290,7 @@ void __init arch_init_memory(void)
BUG_ON(IS_ERR(dom_xen));
INIT_LIST_HEAD(&dom_xen->arch.pdev_list);
printk("returned to arch_init_memory()\n");
/*
* Initialise our DOMID_IO domain.
* This domain owns I/O pages that are within the range of the page_info
......
......@@ -1314,6 +1314,7 @@ void __init __start_xen(unsigned long mbi_p)
bootstrap_map, cmdline) != 0)
panic("Could not set up DOM0 guest OS\n");
printk("returned to _start_xen()\n");
/* Scrub RAM that is still free and so may go to an unprivileged domain. */
scrub_heap_pages();
......
......@@ -473,6 +473,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
}
#endif
d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref);
printk("returned to XEN_GUEST_HANDLE\n");
if ( IS_ERR(d) )
{
ret = PTR_ERR(d);
......
......@@ -159,6 +159,16 @@ int cap_grant(struct domain *from, struct domain *to, int type, void *list, int
int *ptr = (int*)list;
TT_DBG("In cap_grant()\n");
printk("from domain: 0x%p\n",from);
printk("to domain: 0x%p\n",to);
if(from == NULL || to == NULL)
return 1;
if(from->cap_space)
printk("from->cap_space: 0x%p\n",from->cap_space);
if(to->cap_space)
printk("to->cap_space: 0x%p\n",to->cap_space);
switch(type)
{
......@@ -168,6 +178,8 @@ int cap_grant(struct domain *from, struct domain *to, int type, void *list, int
{
index = ptr[i];
if(index == -1)
continue;
to->cap_space->cap_hypercalls[index] = from->cap_space->cap_hypercalls[index];
TT_DBG("Granting Capability: Domain %d, Capability: 0x%x\n",to->domain_id, from->cap_space->cap_hypercalls[index].magic);
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment