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

[Xen-devel] Suggestion: Improve hypercall Interface to get real return value


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Yanzhang Li <liyz@xxxxxxxxxx>
  • Date: Wed, 5 Dec 2012 14:21:20 +0800 (CST)
  • Delivery-date: Wed, 05 Dec 2012 06:51:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

Hello everyone,

I am a user of Xen and I have encountered a problem when trying to get the 
return value from hypercall in TOOLS. I found that when programs in TOOLS 
called hypercall and failed, it would get return value -1 instead of the real 
return value given by Hypervisor.

The reason is that the hypercall interface of TOOLS uses ioctl to call 
hypercall, and ioctl will only return -1 when failure occurs. The related code 
is in xen-4.2.0/tools/libxc/xc_linux_osdep.c:
    static int linux_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall)
    {
        int fd = (int)h;
        return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
    }

While I don't think this is a good idea, because some tools may wish to use 
real return value. For example, in xen-4.2.0/tools/memshr/interface.c, the 
function memshr_vbd_issue_ro_request will switch variable ret which comes from 
return value of hypercall do_memory_op:
    switch(ret)
    {
        case XENMEM_SHARING_OP_S_HANDLE_INVALID:
            ââ
            break;
        case XENMEM_SHARING_OP_C_HANDLE_INVALID:
            ââ
            break;
        default:
            break;
}

So I think if we could modify the interface a little bit to return the real 
error number, it would be beneficial to many TOOLS developers including myself. 
My suggested modification is simple:
    static int linux_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall)
    {
        int fd = (int)h;
        int ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
        if (ret < 0)
            return -errno;
        return ret;
    }

Do you think this would be a good modification? 
Also, I am curious why the original design didn't do that. Is it a bug or is it 
designed that way intentionally?
Any suggestions and comments will be highly appreciated.

Thanks!
Best Regards,
Yanzhang Li

_______________________________________________
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®.