Commit 57361ae3 authored by Yathindra Naik's avatar Yathindra Naik

Changes I've made to support Linux hypercalls, Virtual ethernet

identification and some fixes. Also note that instead of having
to read and learn ip address from xenstore about NFS clients,
I've simply communicated the ip address when libxl initializes
the virtual ethernet device.
parent 83a4e47a
......@@ -8,32 +8,55 @@
int xc_cap_create(xc_interface *xch, /*uint32_t domid,*/ struct capability *cap)
{
DECLARE_CAP_OP;
int ret;
DPRINTF("xc_cap_op: xc_cap_create().\n");
cap_op.cmd = XEN_CAP_OP_cap_create;
/*cap_op.domain = domid;*/
cap_op.u.cap_create.cap = cap;
return do_cap_op(xch, &cap_op);
ret = do_cap_op(xch, &cap_op);
if (!ret)
cap = cap_op.u.cap_create.cap;
return ret;
}
int xc_cap_grant(xc_interface *xch,
/*uint32_t from_domid,*/
uint32_t to_domid,
void *list,
struct capability *list,
int size)
{
DECLARE_CAP_OP;
int ret;
int i;
DECLARE_HYPERCALL_BUFFER(struct capability, arg);
DPRINTF("xc_cap_op: xc_cap_grant().\n");
arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg)*size);
if ( arg == NULL )
{
PERROR("Could not allocate memory for xc_get_caps_hypercall hypercall");
return 1;
}
cap_op.cmd = XEN_CAP_OP_cap_grant;
/* Not sure if I should init the domid here as we
* are not using it in cap_op.c
*/
/*cap_op.domain = (domid_t)from_domid;*/
/*cap_op.u.cap_grant.from = (domid_t)from_domid;*/
cap_op.u.cap_grant.to = (domid_t)to_domid;
cap_op.u.cap_grant.list = list;
cap_op.u.cap_grant.size = size;
return do_cap_op(xch, &cap_op);
cap_op.u.cap_grant.list = (struct capability *)HYPERCALL_BUFFER_AS_ARG(arg);
for (i = 0; i < size; ++i)
{
DPRINTF("xc_cap_grant: list[%d] 0x%x addr %p\n",i, list[i].magic, (void*)&list[i]);
arg[i] = list[i];
}
// set_xen_guest_handle(cap_op.u.cap_grant.list, list);
ret = do_cap_op(xch, &cap_op);
// xc_hypercall_bounce_post(xch, list);
xc_hypercall_buffer_free(xch, arg);
return ret;
}
int xc_cap_check(xc_interface *xch,
......@@ -53,11 +76,28 @@ void xc_get_caps_hypercall(xc_interface *xch,
struct capability *cap)
{
DECLARE_CAP_OP;
DPRINTF("xc_cap_op: xc_get_caps_hypercall\n");
int ret;
// DECLARE_HYPERCALL_BOUNCE(cap, sizeof(struct capability), XC_HYPERCALL_BUFFER_BOUNCE_IN);
// DECLARE_HYPERCALL_BUFFER(struct capability, arg);
// arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
// if ( arg == NULL )
// {
// PERROR("Could not allocate memory for xc_get_caps_hypercall hypercall");
// return;
// }
DPRINTF("xc_cap_op: xc_get_caps_hypercall sent capability 0x%x addr %p\n",cap->magic,cap);
cap_op.cmd = XEN_CAP_OP_get_caps_hypercall;
//cap_op.domain = (domid_t)domain;
cap_op.u.get_caps_hypercall.tok = tok;
cap_op.u.get_caps_hypercall.cap = cap;
do_cap_op(xch, &cap_op);
cap_op.u.get_caps_hypercall.cap = cap;//(struct capability *)HYPERCALL_BUFFER_AS_ARG(arg);
// arg = cap;
//set_xen_guest_handle(cap_op.u.get_caps_hypercall.cap, cap);
ret = do_cap_op(xch, &cap_op);
//cap = cap_op.u.get_caps_hypercall.cap;
DPRINTF("xc_cap_op: xc_get_caps_hypercall rcvd capability 0x%x addr %p\n",cap->magic, (void*)cap);
//xc_hypercall_bounce_post(xch, cap);
//xc_hypercall_buffer_free(xch, arg);
}
......@@ -2248,7 +2248,7 @@ int xc_cap_create(xc_interface *xch, struct capability *cap);
* The owner of the capability can grant it to other VM by invoking this function.
* Returns success - 1 or failure - 0.
*/
int xc_cap_grant(xc_interface *xch, uint32_t to_domid, void *list, int size);
int xc_cap_grant(xc_interface *xch, uint32_t to_domid, struct capability *list, int size);
/**
* Check if the VM has access to a protected resource.
......
......@@ -371,7 +371,7 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Caps for %s is NULL!\n",name_path);
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Granting caps for %s failed\n",name_path);
}
#endif
......@@ -526,11 +526,18 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
#ifdef CONFIG_XENCAP
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/vm", dom_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/vm is NULL!\n",dom_path);
{
LOG(ERROR, "Caps for %s/vm is NULL!\n",dom_path);
return ERROR_FAIL;
}
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
{
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
return ERROR_FAIL;
}
}
#endif
rc = libxl__domain_rename(gc, domid, info->name, preserved_name, t);
......@@ -543,21 +550,33 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
#ifdef CONFIG_XENCAP
caps = xs_get_caps(ctx->xsh, t, libxl__sprintf(gc, "%s/uuid", vm_path));
if (caps == NULL)
LOG(ERROR, "Caps for %s/uuid is NULL!\n",vm_path);
{
LOG(ERROR, "Caps for %s/uuid is NULL!\n",vm_path);
return ERROR_FAIL;
}
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
if (xc_cap_grant(ctx->xch, domid, list, 1))
{
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
return ERROR_FAIL;
}
}
caps = NULL;
caps = xs_get_caps(ctx->xsh, t, vm_path);
if (caps == NULL)
LOG(ERROR, "Caps for %s is NULL!\n",vm_path);
{
LOG(ERROR, "Caps for %s is NULL!\n",vm_path);
return ERROR_FAIL;
}
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
{
LOG(ERROR, "Granting caps for %s failed\n",vm_path);
return ERROR_FAIL;
}
}
#endif
if (!xs_transaction_end(ctx->xsh, t, 0))
......@@ -932,13 +951,13 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
#ifdef CONFIG_XENCAP
int libxl_domain_setcapfiles(libxl_ctx *ctx, libxl_capabilities *info,
uint32_t domid)
int libxl_domain_setcapfiles(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid)
{
int ret = 0;
char *tok;
int size = 0;
char buf[1024];
struct capability caps;
int fd = open("/proc/cap_files", O_RDWR);
if ( fd == -1 ) {
......@@ -947,27 +966,33 @@ int libxl_domain_setcapfiles(libxl_ctx *ctx, libxl_capabilities *info,
};
printf ("Splitting string \"%s\" into tokens:\n",info->cap_values);
tok = strtok (info->cap_values," ,.-\n\t");
tok = strtok (info->cap_values," ,.\n\t");
while (tok != NULL)
{
++size;
printf("Calling CAP_WRITE_IOCTL for %s\n",tok);
// Write the file name to procfs
if(ioctl(fd, CAP_WRITE_IOCTL, tok) < 0)
perror("CAP_WRITE_IOCTL");
tok = strtok (NULL, " ,.\n\t");
// Read the capability for the file
if(ioctl(fd, CAP_READ_IOCTL, buf) < 0)
perror("CAP_READ_IOCTL");
printf("CAP_READ_IOCTL: %s\n", buf);
tok = strtok (NULL, " ,.-\n\t");
}
if(size > 0)
{
//printf("Calling xc_cap_grant().\n");
//ret = xc_cap_grant(ctx->xch,domid,list,size);
sscanf(buf,"%d",&caps.magic);
printf("CAP_READ_IOCTL: 0x%x\n", caps.magic);
printf("Calling xc_cap_grant().\n");
ret = xc_cap_grant(ctx->xch,domid,&caps,1);
if (ret)
printf("xc_cap_grant failed!\n");
}
close(fd);
return ret;
}
......@@ -990,16 +1015,22 @@ int libxl_domain_setcap(libxl_ctx *ctx, libxl_capabilities *info, uint32_t domid
while (tok != NULL)
{
printf ("%s\n",tok);
list[size].magic = size;
xc_get_caps_hypercall(ctx->xch,tok,&list[size]);
printf("Get_caps_hypercall: Token: %s Hypercall: 0x%x\n",tok,list[size].magic);
printf("Get_caps_hypercall: Token: %s Hypercall: 0x%x addr %p\n",tok,list[size].magic,(void*)&list[size]);
printf("Calling xc_cap_grant().\n");
ret = xc_cap_grant(ctx->xch,domid,&list[size],1);
if (ret)
printf("xc_cap_grant failed!\n");
++size;
tok = strtok (NULL, " ,.-");
}
/*
if(size > 0)
{
printf("Calling xc_cap_grant().\n");
ret = xc_cap_grant(ctx->xch,domid,list,size);
}
}*/
return ret;
}
......@@ -2710,6 +2741,17 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
libxl__device *device;
char *dompath, **l;
unsigned int nb, rc;
#ifdef CONFIG_XENCAP
char *ip = NULL; // ip addr which is strdup'ed
char *domip = NULL; // contains strdup'ed domid+ip pair
char domipstr[20]; // domid + ip pair
char buf[1024]; // to read back from ioctl
int fd = open("/proc/cap_ip", O_RDWR);
if (fd == -1) {
perror("open");
}
#endif
rc = libxl__device_nic_setdefault(gc, nic, domid);
if (rc) goto out;
......@@ -2763,9 +2805,32 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac)));
if (nic->ip) {
flexarray_append(back, "ip");
flexarray_append(back, libxl__strdup(gc, nic->ip));
flexarray_append(back, (ip=libxl__strdup(gc, nic->ip)));
}
#ifdef CONFIG_XENCAP
if (!ip)
printf("libxl__device_nic_add: Copying ip addr into buffer failed!\n");
printf("Concat/strdup ip addr/domid pair\n");
sprintf(domipstr,"%d ",domid);
// concatenate dom + ip to send through ioctl
strcat(domipstr, ip);
domip = libxl__strdup(gc, domipstr);
printf("Sending %s to ioctl\n",domip);
if(ioctl(fd, CAP_WRITE_IOCTL, domip) < 0)
perror("CAP_WRITE_IOCTL");
if(ioctl(fd, CAP_READ_IOCTL, buf) < 0)
perror("CAP_READ_IOCTL");
printf("Read back %s from ioctl\n",buf);
close(fd);
#endif
if (nic->rate_interval_usecs > 0) {
flexarray_append(back, "rate");
flexarray_append(back, libxl__sprintf(gc, "%"PRIu64",%"PRIu32"",
......@@ -4128,7 +4193,7 @@ retry_transaction:
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Caps for %s is NULL!\n",libxl__sprintf(gc, "%s/cpu/%u", dompath, i));
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Granting caps for %s failed\n",libxl__sprintf(gc, "%s/cpu/%u", dompath, i));
}
......
......@@ -500,7 +500,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/vm\n",dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, list, 1))
LOG(ERROR, "Granting caps for %s/vm failed\n",dom_path);
}
#endif
......@@ -539,7 +539,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/device/suspend\n",dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, list, 1))
LOG(ERROR, "Granting caps for %s/device/suspend failed\n",dom_path);
}
#endif
......@@ -599,7 +599,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/uuid\n",vm_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, list, 1))
LOG(ERROR, "Granting caps for %s/uuid failed\n",vm_path);
}
......@@ -610,7 +610,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/name\n",vm_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, list, 1))
LOG(ERROR, "Granting caps for %s/name failed\n",vm_path);
}
#endif
......@@ -631,7 +631,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/control/platform-feature-multiprocessor-suspend", dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, list, 1))
LOG(ERROR, "Granting caps for %s/control/platform-feature-multiprocessor-suspend is NULL", dom_path);
}
......@@ -642,7 +642,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for %s/control/platform-feature-xs_reset_watches", dom_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, *domid, &list, 1))
if (xc_cap_grant(ctx->xch, *domid, list, 1))
LOG(ERROR, "Granting caps for %s/control/platform-feature-xs_reset_watches is NULL", dom_path);
}
#endif
......
......@@ -147,13 +147,13 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for domid %d for %s/backend\n",device->domid, frontend_path);
LOG(DEBUG, "caps[0]: %d\n",caps[0].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, list, 1))
LOG(DEBUG, "Granting caps for %s/backend failed\n",frontend_path);
}
if (!xc_cap_check(ctx->xch, device->domid, &caps[1])) {
list[0] = caps[1];
LOG(DEBUG, "caps[1]: %d\n", caps[1].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, list, 1))
LOG(DEBUG, "Granting caps for %s/backend failed\n",frontend_path);
}
caps = xs_get_caps(ctx->xsh, t, frontend_child);
......@@ -163,14 +163,14 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for domid %d for %s\n",device->domid, frontend_child);
LOG(DEBUG, "caps[0]: %d\n",caps[0].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",frontend_child);
}
if (!xc_cap_check(ctx->xch, device->domid, &caps[1])) {
list[0] = caps[1];
LOG(DEBUG, "Granting caps for domid %d for %s\n",device->domid, frontend_child);
LOG(DEBUG, "caps[1]: %d\n",caps[1].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",frontend_child);
}
#endif
......@@ -194,7 +194,7 @@ retry_transaction:
list[0] = caps[0];
LOG(DEBUG, "Granting caps for domid %d for %s/frontend\n", device->domid, backend_path);
LOG(DEBUG, "caps[0]: %d caps[1]: %d\n",caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, device->domid, &list, 1))
if (xc_cap_grant(ctx->xch, device->domid, list, 1))
LOG(DEBUG, "Granting caps for %s/frontend failed\n",backend_path);
}
#endif
......
......@@ -219,7 +219,7 @@ retry_transaction:
LOG(ERROR, "Caps for %s/state-%d is NULL!\n",be_path,i);
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(ERROR, "Granting caps for %s/state-%d failed\n",be_path, i);
}
......@@ -228,7 +228,7 @@ retry_transaction:
LOG(ERROR, "Caps for %s/state is NULL!\n",be_path);
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
list[0] = caps[0];
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(ERROR, "Granting caps for %s/state failed\n",be_path);
}
#endif
......
......@@ -403,7 +403,7 @@ int libxl__remove_file_or_directory(libxl__gc *gc, const char *path)
int libxl__remove_directory(libxl__gc *gc, const char *dirpath)
{
int rc = 0;
DIR *d = 0;
static DIR *d = 0;
d = opendir(dirpath);
if (!d) {
......
......@@ -71,7 +71,7 @@ int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
if (!xc_cap_check(ctx->xch, domid, &list[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s/%s", domid, dir, kvs[i]);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(DEBUG, "Granting caps for %s/%s failed\n",dir, kvs[i]);
}
}
......@@ -80,7 +80,7 @@ int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
if (!xc_cap_check(ctx->xch, domid, &list[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s/%s", domid, dir, kvs[i]);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(DEBUG, "Granting caps for %s/%s failed\n",dir, kvs[i]);
}
}
......@@ -94,7 +94,7 @@ int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
if (!xc_cap_check(ctx->xch, domid, &list[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, dir);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",dir);
}
}
......@@ -103,7 +103,7 @@ int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
if (!xc_cap_check(ctx->xch, domid, &list[1])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, dir);
LOG(DEBUG, "caps[0]: %d and caps[1]: %d", caps[0].magic, caps[1].magic);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",dir);
}
}
......@@ -125,7 +125,7 @@ void libxl__xs_grant_caps(libxl__gc *gc, xs_transaction_t t, char *path, uint32_
list[0] = caps[0];
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(DEBUG, "Granting caps for %s failed\n",path);
}
}
......@@ -133,7 +133,7 @@ void libxl__xs_grant_caps(libxl__gc *gc, xs_transaction_t t, char *path, uint32_
list[0] = caps[1];
if (!xc_cap_check(ctx->xch, domid, &caps[1])) {
LOG(DEBUG, "Granting caps for domain %d for %s", domid, path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(DEBUG, "Granting caps for %s failed\n", path);
}
}
......@@ -207,7 +207,7 @@ int libxl__xs_write(libxl__gc *gc, xs_transaction_t t,
list[0] = caps[0];
if (!xc_cap_check(ctx->xch, domid, &caps[0])) {
LOG(DEBUG, "Granting caps for %s", path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(ERROR, "Granting caps for %s failed\n",path);
}
}
......@@ -215,7 +215,7 @@ int libxl__xs_write(libxl__gc *gc, xs_transaction_t t,
list[0] = caps[1];
if (!xc_cap_check(ctx->xch, domid, &caps[1])) {
LOG(DEBUG, "Granting caps for %s", path);
if (xc_cap_grant(ctx->xch, domid, &list, 1))
if (xc_cap_grant(ctx->xch, domid, list, 1))
LOG(ERROR, "Granting caps for %s failed\n",path);
}
}
......
......@@ -184,6 +184,7 @@ static PyObject *pyxc_domain_unpause(XcObject *self, PyObject *args)
* Ex: "cap_hypercalls='timer, foo, blah, ...'"
* We need individual stings from this list to process.
*/
#if 0
static PyObject *pyxc_cap_hypercalls(XcObject *self, PyObject *args)
{
uint32_t to_dom, dom, cap_flag;
......@@ -221,7 +222,7 @@ static PyObject *pyxc_cap_hypercalls(XcObject *self, PyObject *args)
Py_INCREF(Py_None);
return zero;
}
#endif
#endif
static PyObject *pyxc_domain_destroy_hook(XcObject *self, PyObject *args)
......@@ -2405,13 +2406,14 @@ static PyMethodDef pyxc_methods[] = {
"Returns: [int] 0 on success; -1 on error.\n" },
#ifdef CONFIG_XENCAP
#if 0
{ "cap_hypercalls",
(PyCFunction)pyxc_cap_hypercalls,
METH_VARARGS, "\n"
"Adds the list of hypercalls that this domain is allowed to make.\n"
" dom [int]: Identifier of domain to be unpaused.\n\n"
" cap_hypercalls [list of strings]: List of hypercalls to be allowed.\n" },
#endif
#endif
{ "domain_destroy",
......
......@@ -982,7 +982,7 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
if (!xc_cap_check(xch,owner_domid,&node->caps[0]))
{
list[0] = node->caps[0];
if ((xc_cap_grant(xch,owner_domid,&list,1)) == 1)
if ((xc_cap_grant(xch,owner_domid,list,1)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -992,7 +992,7 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
if (!xc_cap_check(xch,owner_domid,&node->caps[1]))
{
list[0] = node->caps[1];
if ((xc_cap_grant(xch,owner_domid,&list,1)) == 1)
if ((xc_cap_grant(xch,owner_domid,list,1)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -1050,7 +1050,7 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
if (flag && to_domid != 0)
{
/* Read or Write Caps */
if ((xc_cap_grant(xch,to_domid,&list,1)) == 1)
if ((xc_cap_grant(xch,to_domid,list,1)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -1059,7 +1059,7 @@ bool xs_strings_to_caps(unsigned int num, struct node *node, const char *strings
else if (!flag && to_domid != 0)
{
/* Both the flags */
if ((xc_cap_grant(xch,to_domid,&list,2)) == 1)
if ((xc_cap_grant(xch,to_domid,list,2)) == 1)
{
log("xs_strings_to_caps: Error in xc_cap_grant.\n");
goto out;
......@@ -1381,12 +1381,12 @@ static struct node *construct_node(struct connection *conn, const char *name)
log("Construct_node: Guest domain: %d is making an entry in Xenstore\n",domid);
list[0] = node->caps[0];
log("construct_node: Granting read cap to domain:%d for node: %s\n",domid,node->name);
if (xc_cap_grant(xch, domid, &list, 1) == 1)
if (xc_cap_grant(xch, domid, list, 1) == 1)
log("construct_node: Error in xc_cap_grant.\n");
list[0] = node->caps[1];
log("construct_node: Granting write cap to domain:%d for node: %s\n",domid,node->name);
if (xc_cap_grant(xch, domid, &list, 1) == 1)
if (xc_cap_grant(xch, domid, list, 1) == 1)
log("construct_node: Error in xc_cap_grant.\n");
}
#endif
......
......@@ -737,14 +737,12 @@ void paging_teardown(struct domain *d)
/* Call once all of the references to the domain have gone away */
void paging_final_teardown(struct domain *d)
{
printk("In paging_final_teardown()\n");
if ( hap_enabled(d) )
hap_final_teardown(d);
else
shadow_final_teardown(d);
p2m_final_teardown(d);
printk("Leaving paging_final_teardown()\n");
}
/* Enable an arbitrary paging-assistance mode. Call once at domain
......
......@@ -46,7 +46,7 @@
#include <asm/setup.h>
#include <xen/cpu.h>
#include <asm/nmi.h>
#include <xen/xen-cap.h>
#include <public/xen-cap.h>
/* opt_nosmp: If true, secondary processors are ignored. */
static bool_t __initdata opt_nosmp;
......
......@@ -5,10 +5,11 @@
#include <xen/sched.h>
#include <xen/hypercall.h>
#include <xen/xmalloc.h>
#include <xen/guest_access.h>
#include <asm/current.h>
#include <public/cap_op.h>
#include <xen/xen-cap.h>
#include <public/xen-cap.h>
static DEFINE_SPINLOCK(cap_lock);
......@@ -34,27 +35,28 @@ long do_cap_op(XEN_GUEST_HANDLE(xen_cap_op_t) u_cap_op)
{
case XEN_CAP_OP_cap_create:
{
/* struct domain *d; */
//struct domain *d;
struct capability *cap;
TT_DBG("XEN_CAP_OP_cap_create hypercall: domid:%d\n", op->domain);
ret = -ESRCH;
/*
d = rcu_lock_domain_by_id(op->domain);
TT_DBG("XEN_CAP_OP_cap_create hypercall: domid:%d Addr of Cap %p\n", op->domain, (void*)op->u.cap_create.cap);
/*d = rcu_lock_domain_by_id(op->domain);
if ( d == NULL )
{
TT_ERR("Failed to rcu_lock_dom_by_id:%d\n", op->domain);
break;
}
*/
}*/
cap = op->u.cap_create.cap;
if ((ret = cap_create(cap)) == 1)
TT_ERR("cap_create failed\n");
// rcu_unlock_domain(d);
if (copy_to_guest(u_cap_op, op, 1))
{
TT_ERR("copy_to_guest failed!\n");
ret = -EFAULT;
}
//rcu_unlock_domain(d);
}
break;
......@@ -62,38 +64,83 @@ long do_cap_op(XEN_GUEST_HANDLE(xen_cap_op_t) u_cap_op)
{
//struct domain *d;
struct domain *to;
void *list;
struct capability *list;
int i;
int size;
ret = -ESRCH;
/*
d = rcu_lock_domain_by_id(op->domain);
/*d = rcu_lock_domain_by_id(op->domain);
if ( d == NULL )
{
TT_ERR("Failed to rcu_lock_dom_by_id:%d\n", op->domain);
break;
}
*/
TT_DBG("XEN_CAP_OP_cap_grant hypercall: domid:%d\n", op->domain);
}*/
to = rcu_lock_domain_by_id(op->u.cap_grant.to);
if ( to == NULL )
{
TT_ERR("Failed to rcu_lock_dom_by_id:%d\n", to->domain_id);
break;
}
list = op->u.cap_grant.list;
size = op->u.cap_grant.size;
list = op->u.cap_grant.list;
for (i = 0; i < size; ++i)
TT_DBG("XEN_CAP_OP_cap_grant: sent Capability 0x%x addr %p\n",list[i].magic, (void*)&list[i]);
if ( (ret = cap_grant(to,list,size)) != 0 )
{
TT_ERR("cap_grant failed when called from xc_cap_grant().\n");
rcu_unlock_domain(to);
return ret;
}
/*
list = xmalloc_array(struct capability, size);
if (list == NULL)
{
TT_ERR("XEN_CAP_OP_cap_grant: xmalloc_array failed\n");