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

Re: [Libvir] New vs old-style hypercalls



On Tue, Jun 12, 2007 at 03:34:04PM +0100, Richard W.M. Jones wrote:
> 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;
> 
>     cmd = IOCTL_PRIVCMD_HYPERCALL;
>     ret = ioctl(fd, cmd, (unsigned long) &hc);
> 
>     if ((ret != -1) && (ret != 0)) {
> #ifdef DEBUG
>         fprintf(stderr, "Using new hypervisor call: %X\n", ret);
> #endif
>         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.

  yes but I prefer doing an extra hypercall once at the library init than 
trying to dig out whether on that particuliar box the structure will be
the same or not.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/


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