* Zero-sized reads from XenBus block
@ 2016-03-01 21:29 Sergei Lebedev
2016-03-02 16:13 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Sergei Lebedev @ 2016-03-01 21:29 UTC (permalink / raw)
To: xen-devel
Hi list,
I’m not sure if this is the expected behaviour, but it seems zero-sized reads from /dev/xen/xenbus block. Here’s sample code in Python
import os
fd = os.open("/dev/xen/xenbus", os.O_RDWR)
os.read(fd, 0) # Blocks.
The issue is not language-specific, similar code in C blocks as well.
Regards,
Sergei
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Zero-sized reads from XenBus block 2016-03-01 21:29 Zero-sized reads from XenBus block Sergei Lebedev @ 2016-03-02 16:13 ` Wei Liu 2016-03-02 16:35 ` Roger Pau Monné 0 siblings, 1 reply; 5+ messages in thread From: Wei Liu @ 2016-03-02 16:13 UTC (permalink / raw) To: Sergei Lebedev Cc: Wei Liu, xen-devel, David Vrabel, Boris Ostrovsky, Roger Pau Monné CC Linux kernel and FreeBSD maintainers. On Wed, Mar 02, 2016 at 12:29:26AM +0300, Sergei Lebedev wrote: > Hi list, > > I’m not sure if this is the expected behaviour, but it seems zero-sized reads from /dev/xen/xenbus block. Here’s sample code in Python > > import os > > fd = os.open("/dev/xen/xenbus", os.O_RDWR) > os.read(fd, 0) # Blocks. > > The issue is not language-specific, similar code in C blocks as well. > > Regards, > Sergei > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zero-sized reads from XenBus block 2016-03-02 16:13 ` Wei Liu @ 2016-03-02 16:35 ` Roger Pau Monné 2016-03-02 17:14 ` Boris Ostrovsky 0 siblings, 1 reply; 5+ messages in thread From: Roger Pau Monné @ 2016-03-02 16:35 UTC (permalink / raw) To: Wei Liu, Sergei Lebedev; +Cc: Boris Ostrovsky, David Vrabel, xen-devel El 2/3/16 a les 17:13, Wei Liu ha escrit: > CC Linux kernel and FreeBSD maintainers. > > On Wed, Mar 02, 2016 at 12:29:26AM +0300, Sergei Lebedev wrote: >> Hi list, >> >> I’m not sure if this is the expected behaviour, but it seems zero-sized reads from /dev/xen/xenbus block. Here’s sample code in Python >> >> import os >> >> fd = os.open("/dev/xen/xenbus", os.O_RDWR) >> os.read(fd, 0) # Blocks. >> >> The issue is not language-specific, similar code in C blocks as well. I've tested your code on FreeBSD (after replacing /dev/xen/xenbus with /dev/xen/xenstore), and it doesn't block there. AFAICT this is because 0-size reads never get to the device "read" routine on FreeBSD, or else it would block. Roger. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zero-sized reads from XenBus block 2016-03-02 16:35 ` Roger Pau Monné @ 2016-03-02 17:14 ` Boris Ostrovsky 2016-03-03 17:03 ` David Vrabel 0 siblings, 1 reply; 5+ messages in thread From: Boris Ostrovsky @ 2016-03-02 17:14 UTC (permalink / raw) To: Roger Pau Monné, Wei Liu, Sergei Lebedev; +Cc: David Vrabel, xen-devel On 03/02/2016 11:35 AM, Roger Pau Monné wrote: > El 2/3/16 a les 17:13, Wei Liu ha escrit: >> CC Linux kernel and FreeBSD maintainers. >> >> On Wed, Mar 02, 2016 at 12:29:26AM +0300, Sergei Lebedev wrote: >>> Hi list, >>> >>> I’m not sure if this is the expected behaviour, but it seems zero-sized reads from /dev/xen/xenbus block. Here’s sample code in Python >>> >>> import os >>> >>> fd = os.open("/dev/xen/xenbus", os.O_RDWR) >>> os.read(fd, 0) # Blocks. >>> >>> The issue is not language-specific, similar code in C blocks as well. > I've tested your code on FreeBSD (after replacing /dev/xen/xenbus with > /dev/xen/xenstore), and it doesn't block there. AFAICT this is because > 0-size reads never get to the device "read" routine on FreeBSD, or else > it would block. This is how xenbus driver is designed --- it always blocks until something is written there. It should indeed return zero right away but I wonder whether someone might count on current implementation (in the toolstack or elsewhere). Based on FreeBSD behavior I'd think this shouldn't be the case. -boris _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Zero-sized reads from XenBus block 2016-03-02 17:14 ` Boris Ostrovsky @ 2016-03-03 17:03 ` David Vrabel 0 siblings, 0 replies; 5+ messages in thread From: David Vrabel @ 2016-03-03 17:03 UTC (permalink / raw) To: Boris Ostrovsky, Roger Pau Monné, Wei Liu, Sergei Lebedev Cc: David Vrabel, xen-devel On 02/03/16 17:14, Boris Ostrovsky wrote: > On 03/02/2016 11:35 AM, Roger Pau Monné wrote: >> El 2/3/16 a les 17:13, Wei Liu ha escrit: >>> CC Linux kernel and FreeBSD maintainers. >>> >>> On Wed, Mar 02, 2016 at 12:29:26AM +0300, Sergei Lebedev wrote: >>>> Hi list, >>>> >>>> I’m not sure if this is the expected behaviour, but it seems >>>> zero-sized reads from /dev/xen/xenbus block. Here’s sample code in >>>> Python >>>> >>>> import os >>>> fd = os.open("/dev/xen/xenbus", os.O_RDWR) >>>> os.read(fd, 0) # Blocks. >>>> >>>> The issue is not language-specific, similar code in C blocks as well. >> I've tested your code on FreeBSD (after replacing /dev/xen/xenbus with >> /dev/xen/xenstore), and it doesn't block there. AFAICT this is because >> 0-size reads never get to the device "read" routine on FreeBSD, or else >> it would block. > > This is how xenbus driver is designed --- it always blocks until > something is written there. I'm not sure I'd say that it was designed that way, but it's the way it is. > It should indeed return zero right away but I wonder whether someone > might count on current implementation (in the toolstack or elsewhere). > Based on FreeBSD behavior I'd think this shouldn't be the case. POSIX says: "Before any action described below is taken, and if nbyte is zero, the read() function may detect and return errors as described below. In the absence of errors, or if error detection is not performed, the read() function shall return zero and have no other results" xenbus_file_read() should be fixed to handle zero-length reads correctly. But since the semantics of a zero length read are woolly (it /may/ check for errors), I would suggest no application should do this and as such fixing this doesn't need to be a high priority. David _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-03 17:03 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-01 21:29 Zero-sized reads from XenBus block Sergei Lebedev 2016-03-02 16:13 ` Wei Liu 2016-03-02 16:35 ` Roger Pau Monné 2016-03-02 17:14 ` Boris Ostrovsky 2016-03-03 17:03 ` David Vrabel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).