Mark Williamson wrote, on the 05/04/2008 23.14:
> Take a look in the Xen Linux tree at the drivers/xen/blkfront/ for
some creation of grant references. As Samuel says, searching for grant
table functions under drivers/xen/ is going to find you some interesting
examples in various places.
>
I studied the suggested code and I wrote something to test my
understanding. It compiles and run fine, but I've got a problem: when I
read the value of the shared structure it's not right.
This is the function, contained in a module, that creates the grant:
static void offer_page()
{
int code;
struct foo foo_struct;
foo_struct.numero = 5;
if ( ( code = gnttab_grant_foreign_access(0,
virt_to_mfn(&foo_struct), 0)) == -1) {
printk(KERN_INFO "grant error\n");
}
}
In userspace I use the following code to read the granted page:
void grant(int xcg_handle, int domid)
{
struct foo *foo_struct;
void *buf;
int i;
buf = xc_gnttab_map_grant_ref(xcg_handle, domid, 851, PROT_READ);
// yes, ugly hardcoded value
if (buf != NULL) {
foo_struct = (struct foo *) buf;
printf("numero = %d\n", foo_struct->numero);
}
}
I'd expect it to print five, but it always write zero. What am I doing
wrong here?
> hope that helps,
> Cheers,
> Mark
Thanks,
Carlo
--
È molto più bello sapere qualcosa di tutto, che sapere tutto di una cosa.
Blaise Pascal
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|