[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Using Xen's hypercall interface?


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Rig Gel <rigelras@xxxxxxxxx>
  • Date: Mon, 7 Jul 2014 20:31:34 +0300
  • Delivery-date: Mon, 07 Jul 2014 17:32:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>


Hi

/proc/xen/privcmd seem to exist only from dom0,Â
is there any extension or ko i should load in order to find it on other
kernels ?Â




On Mon, Jul 7, 2014 at 2:26 AM, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
On 06/07/2014 23:23, Rig Gel wrote:
Hi all,

- I'm sorry if this is a repost, I was informed that this is the correct mailing list only after sending a msg to xen-users -Â

I would like to compile a simple ELF which would make a simple a hypercall from a guest in order to
learn a bit more about the Xen Hypercall interface.
I tried including the hypervisor.h and -I'ing the ./extras/mini-os/ dir but it seems that I'm missing a few flags or paths in order ot make it fully compile correctlyÂ

Can anyone hint or explain a bit what is the appropriate way to link against Xen's header files ?Â
I only need hypervisor.h in order to call some hypercallsÂ

Attached below a sample of my code -

#include <hypervisor.h>

...
snipÂ
...

void test_xen_version(int vers) {
  HYPERVISOR_xen_version(vers);
}

( using the xe_version hypercall is just a mere example, I would like to just know how to link/compile correctly against the required header files/libs )

It is not possible to make hypercalls from userspace directly. Allowing such would cause all kinds of security problems. Linux and other operating systems a kernel driver which allow hypercalls via ioctl()s on /dev/xen/privcmd.

You are best starting with libxenctrl which is a thin userspace library including OS abstraction to make hypercalls.

From memory, something like:

#include <stdio.h>
#include <xenctrl.h>

int main(void)
{
ÂÂÂ xc_interface *xch = xc_interface_open(NULL, NULL, 0);
ÂÂÂ int ver = xc_version(xch, XENVER_version, NULL);

ÂÂÂ printf("Xen version %d.%d\n", ver >> 16, ver & 0xffff);
ÂÂÂ xc_interface_close(xch);
ÂÂÂ return 0;
}

and compiled with `gcc foo.c -o foo -I/path/to/xenctrl.h -L/path/to/libxenctrl.so -lxenctrl`

ought to get you started.

~Andrew


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.