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

Re: [Xen-devel] [help] problem with `tools/xenstore/xs.c: xs_talkv()`





On Thu, Aug 9, 2012 at 5:58 PM, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
On Thu, 2012-08-09 at 10:50 +0100, 马磊 wrote:
>
>
> On Thu, Aug 9, 2012 at 4:21 PM, Ian Campbell <Ian.Campbell@xxxxxxxxxx>
> wrote:
>         On Thu, 2012-08-09 at 08:07 +0100, 马磊 wrote:
>         >
>         >
>         > On Wed, Aug 8, 2012 at 4:32 PM, 马磊 <aware.why@xxxxxxxxx>
>         wrote:
>         >         Hi all,
>         >
>         >             In  xen-4.1.2 src/tools/xenstore/xs.c: xs_talkv
>         function,
>         >          there are several lines as follow:
>         >
>         >
>         >          437        mutex_lock(&h->request_mutex);
>         >
>         >
>         >
>         >          438
>         >
>         >
>         >
>         >          439        if (!xs_write_all(h->fd, &msg,
>         sizeof(msg)))
>         >
>         >
>         >
>         >          440                goto fail;
>         >
>         >
>         >
>         >          441
>         >
>         >
>         >
>         >          442        for (i = 0; i < num_vecs; i++)
>         >
>         >
>         >
>         >          443                if (!xs_write_all(h->fd,
>         >         iovec[i].iov_base, iovec[i].iov_len))
>         >
>         >
>         >
>         >          444                        goto fail;
>         >
>         >
>         >
>         >          445
>         >
>         >
>         >
>         >          446        ret = read_reply(h, &msg.type, len);
>         >
>         >
>         >
>         >          447        if (!ret)
>         >
>         >
>         >
>         >          448                goto fail;
>         >
>         >
>         >
>         >          449
>         >
>         >
>         >
>         >          450        mutex_unlock(&h->request_mutex);
>         >
>         >
>         >
>         >
>         >         The above seems to tell me that after writing to
>         h->fd , the
>         >         read_reply invoking read_message which immediatelly
>          read from
>         >         hd->fd?
>         >         What did it mean by this?
>         >
>         >
>         >
>         >
>         >         Thanks
>         >
>         > If hd->fd refers to a socket descriptor, it's understandable
>         that
>         > writing and then imediatelly reading, in which case the fd
>         is returned
>         > by get_handle(xs_daemon_socket(), flags).
>         >
>         >
>         > But when fd is retrived by get_handle(xs_domain_dev(),
>         flags), it
>         > means to write to a file and then read from the same file
>         imediatelly.
>         > Dose it have something to do with the internal communication
>         > protocol?!
>
>
>         Yes, the xenstore protocol involves both writing messages and
>         reading
>         replies, but that seems trivially obvious so I'm afraid I
>         really have no
>         idea what your question is nor what is confusing you. Perhaps
>         describing
>         in more detail what you are trying to achieve will help?
>
>         Reading http://wiki.xen.org/wiki/Asking_Xen_Devel_Questions
>         might also
>         help you consider what it is you are asking.
>
>
>         >
>         >
>         > Thanks for replying.
>         >
>         >
>         >
>         >
>         >
>         >
>         The final read and write operations are achieved by:
> read(fd, data, len);
> write(fd, data, len);
>
>
> Maybe my confusing lies in this point that what's the distinction
> between the read and write operations on a socket file,
> the /proc/xen/xenbus, a regular file?

/proc/xen/xenbus is not a regular file. /proc is a virtual file system
where the files often have special and magic semantics. /proc/xen/xenbus
is effectively something like a character device, even though it isn't
actually implemented as one.

Take a look at drivers/xen/xenbus/xenbus_dev_frontend.c which is the
driver which backends /proc/xen/xenbus

Ian.


Ian.




I didn't find the xenbus_dev_frontend.c by `` find / -name "*xenbus*"   2>/dev/null `` command.

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