* problem using xenbus interface
@ 2005-08-08 12:26 NAHieu
2005-08-08 13:39 ` Dan Smith
2005-08-09 2:21 ` Rusty Russell
0 siblings, 2 replies; 7+ messages in thread
From: NAHieu @ 2005-08-08 12:26 UTC (permalink / raw)
To: xen-devel
Hello,
I a writing a small kernel module for domU, in which I use xenbus and
have some problems:
I use xenbus_scanf to read value of "/restart_mode", but the below
code always failed (got non-zero err)
err = xenbus_scanf("/", "restart_mode", "%s", mode);
Another code like below also failed (I try to make a new node
"/domain/<DOM>/test" with xenbus_mkdir):
err = xenbus_mkdir("/", "test");
I am using the latest xen pulled from -unstable repository. I guess
the problem is I didnt use xenbus interface properly (?) Anybody could
give me some helps?
Thank you a lot,
NAH
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem using xenbus interface
2005-08-08 12:26 problem using xenbus interface NAHieu
@ 2005-08-08 13:39 ` Dan Smith
2005-08-09 6:47 ` aq
2005-08-09 2:21 ` Rusty Russell
1 sibling, 1 reply; 7+ messages in thread
From: Dan Smith @ 2005-08-08 13:39 UTC (permalink / raw)
To: NAHieu; +Cc: List: Xen Developers
> err = xenbus_scanf("/", "restart_mode", "%s", mode);
This will try to read //restart_mode, not /domain/<DOM>/restart_mode,
which I assume is not what you want.
Also, there is no way to access keys in the /domain/<DOM> directly,
only keys in subfolders. For example, you should be using something
like /domain/<DOM>/control/restart_mode, like this:
err = xenbus_scanf("control", "restart_mode", "%s", mode);
Note the absence of the leading '/' in the directory parameter. This
means the location is relative to the "home directory" of the domain.
> err = xenbus_mkdir("/", "test");
As I understand it, the plan is to remove the xenbus_mkdir() kernel
interface. Directories should be created by the tools. You should
have Xend (or something else) do the creation before the kernel needs
it.
You may want to take a look at the XenBus wiki page some of us have
been working on, which might help:
http://wiki.xensource.com/xenwiki/XenBus
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms@us.ibm.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem using xenbus interface
2005-08-08 12:26 problem using xenbus interface NAHieu
2005-08-08 13:39 ` Dan Smith
@ 2005-08-09 2:21 ` Rusty Russell
2005-08-09 2:53 ` NAHieu
` (2 more replies)
1 sibling, 3 replies; 7+ messages in thread
From: Rusty Russell @ 2005-08-09 2:21 UTC (permalink / raw)
To: NAHieu; +Cc: xen-devel
On Mon, 2005-08-08 at 21:26 +0900, NAHieu wrote:
> Hello,
>
> I a writing a small kernel module for domU, in which I use xenbus and
> have some problems:
>
> I use xenbus_scanf to read value of "/restart_mode", but the below
> code always failed (got non-zero err)
>
> err = xenbus_scanf("/", "restart_mode", "%s", mode);
OK, if you start the xenstored with "--trace-file=/tmp/trace" you can
see what's happening in that file.
In this case, it's actually a bug in xenbus_scanf: it will ask to read
"//restart_mode" which is an invalid path since it has two "/" in a row.
But it's not a big problem because you shouldn't be writing in the top
level directory anyway...
I would recommend the following:
1) Use xenbus_read here, not xenbus_scanf, since you are just reading a
single string and xenbus_read won't overflow on long strings.
2) Use "restart-mode" not "restart_mode": we've chosen - over _ so far.
3) Use the two args "restart-mode", "": that will be restart-mode inside
your domain's home directory, rather than at the top level.
> Another code like below also failed (I try to make a new node
> "/domain/<DOM>/test" with xenbus_mkdir):
>
> err = xenbus_mkdir("/", "test");
Same problem: it would be "xenbus_mkdir("/test", "")" and you probably
don't want to do that at the top level anyway (when we turn permission
checking back on, that will not work).
Hope that helps!
Rusty.
(PS. Heading to the wiki now to do some remedial documentation).
--
A bad analogy is like a leaky screwdriver -- Richard Braakman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem using xenbus interface
2005-08-09 2:21 ` Rusty Russell
@ 2005-08-09 2:53 ` NAHieu
2005-08-09 3:14 ` NAHieu
2005-08-09 3:34 ` NAHieu
2 siblings, 0 replies; 7+ messages in thread
From: NAHieu @ 2005-08-09 2:53 UTC (permalink / raw)
To: Rusty Russell, Dan Smith; +Cc: xen-devel
Hi Rusty and Dan,
Those are the best answers I can get. Thank you a lot.
Too bad that XenBus has very little documentation, so there are so
much confuses. Hopefully somebody knows it well enough will put out
more docs.
Best regards,
NAH
On 8/9/05, Rusty Russell <rusty@rustcorp.com.au> wrote:
> On Mon, 2005-08-08 at 21:26 +0900, NAHieu wrote:
> > Hello,
> >
> > I a writing a small kernel module for domU, in which I use xenbus and
> > have some problems:
> >
> > I use xenbus_scanf to read value of "/restart_mode", but the below
> > code always failed (got non-zero err)
> >
> > err = xenbus_scanf("/", "restart_mode", "%s", mode);
>
> OK, if you start the xenstored with "--trace-file=/tmp/trace" you can
> see what's happening in that file.
>
> In this case, it's actually a bug in xenbus_scanf: it will ask to read
> "//restart_mode" which is an invalid path since it has two "/" in a row.
> But it's not a big problem because you shouldn't be writing in the top
> level directory anyway...
>
> I would recommend the following:
>
> 1) Use xenbus_read here, not xenbus_scanf, since you are just reading a
> single string and xenbus_read won't overflow on long strings.
>
> 2) Use "restart-mode" not "restart_mode": we've chosen - over _ so far.
>
> 3) Use the two args "restart-mode", "": that will be restart-mode inside
> your domain's home directory, rather than at the top level.
>
> > Another code like below also failed (I try to make a new node
> > "/domain/<DOM>/test" with xenbus_mkdir):
> >
> > err = xenbus_mkdir("/", "test");
>
> Same problem: it would be "xenbus_mkdir("/test", "")" and you probably
> don't want to do that at the top level anyway (when we turn permission
> checking back on, that will not work).
>
> Hope that helps!
> Rusty.
> (PS. Heading to the wiki now to do some remedial documentation).
> --
> A bad analogy is like a leaky screwdriver -- Richard Braakman
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem using xenbus interface
2005-08-09 2:21 ` Rusty Russell
2005-08-09 2:53 ` NAHieu
@ 2005-08-09 3:14 ` NAHieu
2005-08-09 3:34 ` NAHieu
2 siblings, 0 replies; 7+ messages in thread
From: NAHieu @ 2005-08-09 3:14 UTC (permalink / raw)
To: Rusty Russell; +Cc: xen-devel
On 8/9/05, Rusty Russell <rusty@rustcorp.com.au> wrote:
> On Mon, 2005-08-08 at 21:26 +0900, NAHieu wrote:
> > Hello,
> >
> > I a writing a small kernel module for domU, in which I use xenbus and
> > have some problems:
> >
> > I use xenbus_scanf to read value of "/restart_mode", but the below
> > code always failed (got non-zero err)
> >
> > err = xenbus_scanf("/", "restart_mode", "%s", mode);
>
> OK, if you start the xenstored with "--trace-file=/tmp/trace" you can
> see what's happening in that file.
>
> In this case, it's actually a bug in xenbus_scanf: it will ask to read
> "//restart_mode" which is an invalid path since it has two "/" in a row.
> But it's not a big problem because you shouldn't be writing in the top
> level directory anyway...
>
> I would recommend the following:
>
> 1) Use xenbus_read here, not xenbus_scanf, since you are just reading a
> single string and xenbus_read won't overflow on long strings.
>
> 2) Use "restart-mode" not "restart_mode": we've chosen - over _ so far.
>
> 3) Use the two args "restart-mode", "": that will be restart-mode inside
> your domain's home directory, rather than at the top level.
>
> > Another code like below also failed (I try to make a new node
> > "/domain/<DOM>/test" with xenbus_mkdir):
> >
> > err = xenbus_mkdir("/", "test");
>
> Same problem: it would be "xenbus_mkdir("/test", "")" and you probably
> don't want to do that at the top level anyway (when we turn permission
> checking back on, that will not work).
Sorry, I have another question here: suppose that it is fine (ok, I
know I should not do that), what are the difference between:
xenbus_mkdir("/", "test");
and:
xenbus_mkdir("/test", "");
Dont they do the same thing??
I am confused here: why xenbus_mkdir() needs 2 args? Why we dont use
just one arg, like:
xenbus_mkdir("/test")
Is that not more intuitive?
Many thanks,
NAH
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem using xenbus interface
2005-08-09 2:21 ` Rusty Russell
2005-08-09 2:53 ` NAHieu
2005-08-09 3:14 ` NAHieu
@ 2005-08-09 3:34 ` NAHieu
2 siblings, 0 replies; 7+ messages in thread
From: NAHieu @ 2005-08-09 3:34 UTC (permalink / raw)
To: Rusty Russell; +Cc: xen-devel
On 8/9/05, Rusty Russell <rusty@rustcorp.com.au> wrote:
> On Mon, 2005-08-08 at 21:26 +0900, NAHieu wrote:
> > Hello,
> >
> > I a writing a small kernel module for domU, in which I use xenbus and
> > have some problems:
> >
> > I use xenbus_scanf to read value of "/restart_mode", but the below
> > code always failed (got non-zero err)
> >
> > err = xenbus_scanf("/", "restart_mode", "%s", mode);
>
> OK, if you start the xenstored with "--trace-file=/tmp/trace" you can
> see what's happening in that file.
>
> In this case, it's actually a bug in xenbus_scanf: it will ask to read
> "//restart_mode" which is an invalid path since it has two "/" in a row.
> But it's not a big problem because you shouldn't be writing in the top
> level directory anyway...
>
> I would recommend the following:
>
> 1) Use xenbus_read here, not xenbus_scanf, since you are just reading a
> single string and xenbus_read won't overflow on long strings.
>
> 2) Use "restart-mode" not "restart_mode": we've chosen - over _ so far.
>
Rusty, as I understand, you meant that at the moment, it is "restart-mode"?
But as I checked in the latest -unstable, it is "restart_mode". So it
(and others) will be converted to "restart-mode" in the future?
Thank you a lot,
NAH
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: problem using xenbus interface
2005-08-08 13:39 ` Dan Smith
@ 2005-08-09 6:47 ` aq
0 siblings, 0 replies; 7+ messages in thread
From: aq @ 2005-08-09 6:47 UTC (permalink / raw)
To: Dan Smith; +Cc: NAHieu, List: Xen Developers
On 8/8/05, Dan Smith <danms@us.ibm.com> wrote:
>
> > err = xenbus_scanf("/", "restart_mode", "%s", mode);
>
> This will try to read //restart_mode, not /domain/<DOM>/restart_mode,
> which I assume is not what you want.
>
> Also, there is no way to access keys in the /domain/<DOM> directly,
> only keys in subfolders. For example, you should be using something
> like /domain/<DOM>/control/restart_mode, like this:
>
> err = xenbus_scanf("control", "restart_mode", "%s", mode);
>
> Note the absence of the leading '/' in the directory parameter. This
> means the location is relative to the "home directory" of the domain.
>
> > err = xenbus_mkdir("/", "test");
>
> As I understand it, the plan is to remove the xenbus_mkdir() kernel
> interface. Directories should be created by the tools. You should
> have Xend (or something else) do the creation before the kernel needs
> it.
I have another idea on this: if directories must be created by tools,
we (or somebody desires) will have to patch Xend (or whatever)
everytime we have a new kernel module. Imagine that we have 100 third
party drivers in the future, are we willing to patch Xend 100 times?
Let domU create xenstore nodes itself is a good thing: new kernel
drivers can be self-contained.
I hope we will not remove xenbus_mkdir(), or if we do, replace it with
another equally.
regards,
aq
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-08-09 6:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-08 12:26 problem using xenbus interface NAHieu
2005-08-08 13:39 ` Dan Smith
2005-08-09 6:47 ` aq
2005-08-09 2:21 ` Rusty Russell
2005-08-09 2:53 ` NAHieu
2005-08-09 3:14 ` NAHieu
2005-08-09 3:34 ` NAHieu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.