Dan Smith
2006-Mar-17 22:33 UTC
[Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
This patch adds an ioctl interface to /proc/xen/xenbus to allow simple access to xenstore from domU. This patch introduces only xenbus_read() support, but write, remove, etc could be easily added. Also, this interface can be easily moved to /dev/xen/xenbus (or something similar) later. The following snippet of a C program provides easy access to xenstore nodes from inside a domU: #include <xen/io/xenbus.h> int main(int argc, char **argv) { int fd; int ret; struct xenbus_ioctl param; fd = open("/proc/xen/xenbus", O_RDWR); strcpy(param.path, argv[1]); ret = ioctl(fd, 0, ¶m); printf("%s\n", param.value); } Comments welcome, of course ;) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Muli Ben-Yehuda
2006-Mar-18 07:14 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
On Fri, Mar 17, 2006 at 02:33:36PM -0800, Dan Smith wrote:> This patch adds an ioctl interface to /proc/xen/xenbus to allow simple > access to xenstore from domU. This patch introduces only > xenbus_read() support, but write, remove, etc could be easily added. > Also, this interface can be easily moved to /dev/xen/xenbus (or > something similar) later.Hmm, wouldn''t a virtual file system be a much better fit for xenstore access? the kernel community considers ioctls Evil with a capital E. Cheers, Muli -- Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Mar-18 09:50 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
On 18 Mar 2006, at 07:14, Muli Ben-Yehuda wrote:>> This patch adds an ioctl interface to /proc/xen/xenbus to allow simple >> access to xenstore from domU. This patch introduces only >> xenbus_read() support, but write, remove, etc could be easily added. >> Also, this interface can be easily moved to /dev/xen/xenbus (or >> something similar) later. > > Hmm, wouldn''t a virtual file system be a much better fit for xenstore > access? the kernel community considers ioctls Evil with a capital E.Also, we already support xenstore access via read/write on that device file. And libxenstore knows how to target that read/write interface. Why would we add an ioctl to do the same thing? -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Anthony Liguori
2006-Mar-18 17:56 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
Muli Ben-Yehuda wrote:> On Fri, Mar 17, 2006 at 02:33:36PM -0800, Dan Smith wrote: > > >> This patch adds an ioctl interface to /proc/xen/xenbus to allow simple >> access to xenstore from domU. This patch introduces only >> xenbus_read() support, but write, remove, etc could be easily added. >> Also, this interface can be easily moved to /dev/xen/xenbus (or >> something similar) later. >> > > Hmm, wouldn''t a virtual file system be a much better fit for xenstore > access? the kernel community considers ioctls Evil with a capital E. >I''m not sure how one would express the transaction semantics of xenstore via a virtual filesystem. There is also an awkward mapping between some of the attributes of xenstore (for instance, there''s no way to determine if an attribute returned by a list is a directory or not) that makes a filesystem non-trivial. If you remember, I had written a fuse filesystem front-end for xenstore at one point. It''s definitely neat, but I think we would have to make some changes to Xenstore for it to really work out well. Regards, Anthony Liguori> Cheers, > Muli >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Anthony Liguori
2006-Mar-18 18:02 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
Keir Fraser wrote:>> Hmm, wouldn''t a virtual file system be a much better fit for xenstore >> access? the kernel community considers ioctls Evil with a capital E. > > Also, we already support xenstore access via read/write on that device > file. And libxenstore knows how to target that read/write interface. > Why would we add an ioctl to do the same thing?Hi Keir, We had discussed this in a previous thread and I thought you were okay with this approach. The /proc/xen/xenbus interface requires full parsing of the XenBus protocol. This requires libxenstore in domU. Today, libxenstore is shipped with the rest of the tools package on most distros. If one wants to write a Xen-aware application for a domU, that brings in a pretty large number of unnecessary dependencies. Also, for 32 bit management apps in a 64 bit environment, it makes things very nasty (should we build a 32 bit and 64 bit version of libxenstore? Is the protocol 32/64 bit safe?). Ideally, an app could just use a simple interface to /proc/xen/xenbus to access XenStore. That solves all of the above problems elegantly. An ioctl() interface seemed like the most obvious approach that wouldn''t break existing apps. Of course, any suggestion for a better interface would be appreciated. The general problem of xenstore access in domU is a big issue for us (and I assume it will be for most people building Xen management infrastructure). It would really help to have a good solution for 3.0.2. Regards, Anthony Liguori> -- Keir > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Mar-18 19:32 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
On 18 Mar 2006, at 18:02, Anthony Liguori wrote:> We had discussed this in a previous thread and I thought you were okay > with this approach. The /proc/xen/xenbus interface requires full > parsing of the XenBus protocol. This requires libxenstore in domU. > Today, libxenstore is shipped with the rest of the tools package on > most distros. If one wants to write a Xen-aware application for a > domU, that brings in a pretty large number of unnecessary > dependencies. Also, for 32 bit management apps in a 64 bit > environment, it makes things very nasty (should we build a 32 bit and > 64 bit version of libxenstore? Is the protocol 32/64 bit safe?). > > Ideally, an app could just use a simple interface to /proc/xen/xenbus > to access XenStore. That solves all of the above problems elegantly. > An ioctl() interface seemed like the most obvious approach that > wouldn''t break existing apps. Of course, any suggestion for a better > interface would be appreciated.Either way you''re going to have an abstraction layer in your apps that hides the grotty details of how you access xenstore via /proc/xen/xenbus, whether it''s via the read/write interface or via ioctls. That given, why not just statically link with libxenstore, or even include xs.h, xs.c and xs_lib.c in your applications? They''re small, so no significant bloat, and LGPL, so no fear of GPL bleed into your management apps. The protocol is 32/64-bit safe. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Muli Ben-Yehuda
2006-Mar-19 00:10 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
On Sat, Mar 18, 2006 at 11:56:27AM -0600, Anthony Liguori wrote:> I''m not sure how one would express the transaction semantics of xenstore > via a virtual filesystem.file open - transaction begin, file close - transaction commit, if you need multiple "files" in a single transaction, you make this a special file. Not very elegant, but as plan9 shows us, nearly anything can be represented as a file{system}.> There is also an awkward mapping between some > of the attributes of xenstore (for instance, there''s no way to determine > if an attribute returned by a list is a directory or not)If it has "sub attributes", represent it as a directory.> If you remember, I had written a fuse filesystem front-end for xenstore > at one point. It''s definitely neat, but I think we would have to make > some changes to Xenstore for it to really work out well.Ok. I freely acknowledge knowing very little about xenstore and how to best represent its data. I do however know what the review comments for upstream inclusion of any new ioctls would be like ;-) Cheers, Muli -- Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Gerd Hoffmann
2006-Mar-20 08:38 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
> We had discussed this in a previous thread and I thought you were okay > with this approach. The /proc/xen/xenbus interface requires full > parsing of the XenBus protocol. This requires libxenstore in domU. > Today, libxenstore is shipped with the rest of the tools package on most > distros.Changing this and move libxenstore to another package (to avoid pulling in xend with python if everything you want is xenstore access) isn''t a big problem ... btw: are xenstore watches supposed to work inside domU? cheers, Gerd -- Gerd ''just married'' Hoffmann <kraxel@suse.de> I''m the hacker formerly known as Gerd Knorr. http://www.suse.de/~kraxel/just-married.jpeg _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ewan Mellor
2006-Mar-20 08:52 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
On Mon, Mar 20, 2006 at 09:38:22AM +0100, Gerd Hoffmann wrote:> > We had discussed this in a previous thread and I thought you were okay > > with this approach. The /proc/xen/xenbus interface requires full > > parsing of the XenBus protocol. This requires libxenstore in domU. > > Today, libxenstore is shipped with the rest of the tools package on most > > distros. > > Changing this and move libxenstore to another package (to avoid pulling > in xend with python if everything you want is xenstore access) isn''t a > big problem ... > > btw: are xenstore watches supposed to work inside domU?Watches work in kernel space in domU (the frontends to the split device drivers use them), but they don''t work in userspace there. The problem is that there is no support in xenbus for blocking a userspace process waiting for a watch to fire. In domain 0, Xend uses a unix domain socket straight to Xenstored: it can block on that, as it''s not going through the Xenbus kernel-level driver. If someone wanted to add such support, that would be appreciated. Ewan. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Mar-20 10:08 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
On 20 Mar 2006, at 08:52, Ewan Mellor wrote:> Watches work in kernel space in domU (the frontends to the split device > drivers use them), but they don''t work in userspace there. The > problem is > that there is no support in xenbus for blocking a userspace process > waiting > for a watch to fire.There''s no need for special-case blocking in the kernel. The libxenstore reader thread will block on read() and then wake up other threads as necessary by writing to a pipe. All that''s needed in the kernel is some bookkeeping to allow demux and teardown if the device file is closed. Some of that can be pushed to xenstored if we extend it to support multiple connections over a single shared page, but it''s not really necessary. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Gerd Hoffmann
2006-Mar-20 10:10 UTC
Re: [Xen-devel] [PATCH] Add an ioctl interface for simple xenstore access
> Watches work in kernel space in domU (the frontends to the split device > drivers use them), but they don''t work in userspace there. The problem is > that there is no support in xenbus for blocking a userspace process waiting > for a watch to fire. > > In domain 0, Xend uses a unix domain socket straight to Xenstored: it can > block on that, as it''s not going through the Xenbus kernel-level driver.Huh? Sleeping on the unix socket and sleeping on the /proc/xen/xenbus filehandle should work equally well, shouldn''t it? Well, right now there is no poll support, so you can''t stuff the filehandle into select()-loop. But that is trivially fixable, patch below (compile-tested only though). Or did I miss the real problem? cheers, Gerd -- Gerd ''just married'' Hoffmann <kraxel@suse.de> I''m the hacker formerly known as Gerd Knorr. http://www.suse.de/~kraxel/just-married.jpeg _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel