[Libvir] New vs old-style hypercalls

Richard W.M. Jones rjones at redhat.com
Tue Jun 12 14:34:04 UTC 2007

In xen_internal.c we've got code which claims to sniff out whether we 
are using new-style hypercall ioctls or old-style hypercall ioctls.

     hc.op = __HYPERVISOR_xen_version;
     hc.arg[0] = (unsigned long) XENVER_version;
     hc.arg[1] = 0;

     ret = ioctl(fd, cmd, (unsigned long) &hc);

     if ((ret != -1) && (ret != 0)) {
#ifdef DEBUG
         fprintf(stderr, "Using new hypervisor call: %X\n", ret);
         hv_version = ret;
         xen_ioctl_hypercall_cmd = cmd;
         goto detect_v2;

      * check if the old hypercall are actually working
     v0_hc.op = __HYPERVISOR_xen_version;
     v0_hc.arg[0] = (unsigned long) XENVER_version;
     v0_hc.arg[1] = 0;
     cmd = _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t));
     ret = ioctl(fd, cmd, (unsigned long) &v0_hc);

But on 64 bit platforms (not 32 bit) cmd will be identical, so we'll 
just be trying the same ioctl twice.

 From <xen/linux/privcmd.h>:

     typedef struct privcmd_hypercall
         __u64 op;
         __u64 arg[5];
     } privcmd_hypercall_t;

     #define IOCTL_PRIVCMD_HYPERCALL                                 \
         _IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t))

 From src/xen_internal.c:

     typedef struct v0_hypercall_struct {
         unsigned long op;
         unsigned long arg[5];
     } v0_hypercall_t;

     cmd = _IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t));

On 64 bit platforms, both structures will be the same size.


Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070612/680ff924/attachment-0001.bin>

More information about the libvir-list mailing list