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

Re: [Xen-devel] ioctl handling in netbsd_privcmd_hypercall()



2012/1/18 Olaf Hering <olaf@xxxxxxxxx>:
> On Wed, Jan 18, Roger Pau Monnà wrote:
>
>> 2012/1/18 Olaf Hering <olaf@xxxxxxxxx>:
>> >
>> > I was looking at the slightly broken error handling in the new
>> > xc_mem_paging_load() function and stumbled over the ioctl() handling in
>> > netbsd_privcmd_hypercall().
>> >
>> > Is ioctl() on NetBSD special? I would have expected it returns -1 on
>> > error and the caller can deal with errno if it actually wants to.
>> > But instead it returns the negative errno value or what the hypervisor
>> > returned.
>>
>> I haven't done this code, so I don't know if there are some hidden
>> subtleties here, but according to NetBSD ioctl(2) man page[0], it
>> returns -1 on error and errno is set to indicate the error.
>
> Could you check wether a "return ioctl(....);" works as well?

I've checked it, and realized why NetBSD needs to return
hypercall->retval, that's because Linux ioctls return < 0 on error,
and >= 0 on success (you can return a meaningful value from ioctl[0]),
but NetBSD ioctls only return < 0 on error, or 0 on success. I've
spotted that memory operations return the size of the memory region on
success, that's why NetBSD needs to return hypercall->retval. What I
don't know if why it returns -errno on error, it should return the
return value of the ioctl call (error variable). I will submit a patch
adding a comment to netbsd_privcmd_hypercall and another one to return
error instead of -errno.

[0] http://linux.die.net/man/2/ioctl

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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