Hello- I have posted to this list several times re-iterating the same problem (trying to figure out an API mechanism between Xen and the user space), and I haven''t heard much from you guys. Could someone at least point me to the file(s) that handle the API communication between Xen and XM? Ideally, I would like to find a way to read/write to a file/device from within the scheduler, but no one has said anything useful about how to accomplish this. I apologize for the repeated attempts to get the same information, but I know there are people on this list who could help me, or at least point me in the right direction. Any help is appreciated. Thanks --Derek _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
I assume that the only API mechanism for Xen/XM is the hypercalls, right? sorry, but I am somewhat new to xen. Thanks! --Derek On Mon, Aug 10, 2009 at 8:58 AM, weiming <zephyr.zhao@gmail.com> wrote:> Hello, > > Do you mean hypercalls? > > On Mon, Aug 10, 2009 at 9:48 AM, Derek Riley < > derek.riley@isis.vanderbilt.edu> wrote: > >> Hello- >> I have posted to this list several times re-iterating the same problem >> (trying to figure out an API mechanism between Xen and the user space), and >> I haven''t heard much from you guys. >> >> Could someone at least point me to the file(s) that handle the API >> communication between Xen and XM? Ideally, I would like to find a way to >> read/write to a file/device from within the scheduler, but no one has said >> anything useful about how to accomplish this. >> >> I apologize for the repeated attempts to get the same information, but I >> know there are people on this list who could help me, or at least point me >> in the right direction. Any help is appreciated. Thanks >> --Derek >> >> _______________________________________________ >> 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
Hi Derek -- I think perhaps the problem is that your goal (at least as I interpret it) is not possible. The Xen hypervisor doesn''t have any way of writing to a file. And as far as I know, there is no way to make a hypercall from "user space", only from the kernel of a paravirtualized OS. It *is* possible for an xm command executed as root to provoke (via ioctl??) a hypercall from dom0 OS kernel to pass a buffer, for Xen to fill in information to that buffer, and for an OS kernel to put that buffer someplace that could be read by a user process. But that doesn''t sound like it would meet your goal. If this is close enough, a key file is tools/python/xen/lowlevel/xc/xc.c and a recent patch that plumbs an xm command from the linux command line through to xc.c is at http://xenbits.xensource.com/staging/xen-unstable.hg?rev/03063e309356 I''m afraid I can''t help much with all the python code though. I''ve mostly mimicked code written by others and debugged it until it worked. Hope that points you in the right direction! -----Original Message----- From: Derek Riley [mailto:derek.riley@isis.vanderbilt.edu] Sent: Monday, August 10, 2009 7:49 AM To: xen-devel@lists.xensource.com Subject: [Xen-devel] Xen help Hello- I have posted to this list several times re-iterating the same problem (trying to figure out an API mechanism between Xen and the user space), and I haven''t heard much from you guys. Could someone at least point me to the file(s) that handle the API communication between Xen and XM? Ideally, I would like to find a way to read/write to a file/device from within the scheduler, but no one has said anything useful about how to accomplish this. I apologize for the repeated attempts to get the same information, but I know there are people on this list who could help me, or at least point me in the right direction. Any help is appreciated. Thanks --Derek _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Derek, You''ve twice been pointed to xentrace as an example of how to pass information between Xen and a user-space program. That uses the general Xen "paradigm" of hypercalls, event channels, and shared memory. If you have more questions on how that works, or specific advice for implementing a modified version that does "import", feel free to ask those questions here. Starting from scratch with the same basic question isn''t going to get you any further than it did the first two times. -George On Mon, Aug 10, 2009 at 2:48 PM, Derek Riley<derek.riley@isis.vanderbilt.edu> wrote:> Hello- > I have posted to this list several times re-iterating the same problem > (trying to figure out an API mechanism between Xen and the user space), and > I haven''t heard much from you guys. > > Could someone at least point me to the file(s) that handle the API > communication between Xen and XM? Ideally, I would like to find a way to > read/write to a file/device from within the scheduler, but no one has said > anything useful about how to accomplish this. > > I apologize for the repeated attempts to get the same information, but I > know there are people on this list who could help me, or at least point me > in the right direction. Any help is appreciated. Thanks > --Derek > > _______________________________________________ > 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
On Tue, Aug 11, 2009 at 2:55 PM, Derek Riley<derek.riley@isis.vanderbilt.edu> wrote:> To re-iterate what I posted, xentrace appears to be a 1-way communication > mechanism that goes the "wrong way" for what I need. I need to be able to > pass information from the user space to the Xen scheduler, and Xentrace does > just the opposite.Sure, xentrace copies data from the hypervisor and writes it to a file. But the same basic technique can be turned around: you can write a new interface so that a program in dom0 can read data from a file and feed it into the hypervisor, to be read by (if I recall correctly) your new scheduler feature. So, how might you adapt the basic technique xentrace uses to put stuff into the hypervisor instead of taking out out of the hypervisor? -George _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
(Please keep the discussion on the list.) Because Xen doesn''t have any state, and it can''t directly invoke a user-space process or prevent it from being preempted by the guest, there cannot be locks on communications between Xen and a user-space process. Instead, specific read/write ordering discipline is used. A brief description can be found in the original Xen paper, here: http://leitl.org/docs/intel/IR-TR-2003-114-110720030715_178.pdf, particularly section 3.2. Basically, there is conceptually a shared "ring" of a fixed size. There are also shared indexes, a producer and consumer index. Rules are that only Xen will modify the producer index, and will only increment it; only xentrace will modify the consumer interface, and will only increment it. xentrace will never increment consumer past producer; and Xen will never increment producer past (consumer + buffer size). Generalized Xen producer code: if ( ring->prod + 1 < ring->cons + ring->size ) { ring->element[(ring prod+1)%ring->size] = trace_record; ring->prod++; } Generalized xentrace consumer code: if ( ring->prod > ring->cons ) { trace_record = ring->element[(ring->cons)%ring->size]; ring->cons++; write(fd, trace_record); } As long as the reads and writes happen in the proper order, there are no races (or only benign ones). Does that make sense? As always, the devil''s in the details (sleeping, waking, event channels, lost records, variable-sized records, multiple pcpus, &c). But hopefully that will be enough to get you started. -George On Wed, Aug 12, 2009 at 12:12 PM, Derek Riley<derek.riley@isis.vanderbilt.edu> wrote:> Thanks for the reply; the interface that you suggest sounds ideal. I am new > to Xen and relatively new to kernel programming, so I don''t really > understand how buffers can be used to pass information or what types of > mutex or other issues must be considered. I haven''t found the xentrace (or > any other Xen code for that matter) very readable or understandable. I have > spent most of my programming life working with user space processes and > parallel code. Any help or suggestions are appreciated. Thanks for your > time and patience. > --Derek > > On Wed, Aug 12, 2009 at 5:00 AM, George Dunlap <dunlapg@umich.edu> wrote: >> >> On Tue, Aug 11, 2009 at 2:55 PM, Derek >> Riley<derek.riley@isis.vanderbilt.edu> wrote: >> > To re-iterate what I posted, xentrace appears to be a 1-way >> > communication >> > mechanism that goes the "wrong way" for what I need. I need to be able >> > to >> > pass information from the user space to the Xen scheduler, and Xentrace >> > does >> > just the opposite. >> >> Sure, xentrace copies data from the hypervisor and writes it to a >> file. But the same basic technique can be turned around: you can >> write a new interface so that a program in dom0 can read data from a >> file and feed it into the hypervisor, to be read by (if I recall >> correctly) your new scheduler feature. >> >> So, how might you adapt the basic technique xentrace uses to put stuff >> into the hypervisor instead of taking out out of the hypervisor? >> >> -George > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel