Mini-OS: preparations for 9pfs in xenstore-stubdom
cover Mini-OS: preparations for 9pfs in xenstore-stubdom
This small patch series is doing some preparations for being able to use 9pfs in Xenstore-stubdom.
Juergen Gross (3):
Mini-OS: make xenstore_buf externally visible
Mini-OS: don't crash if no shutdown node is available
Mini-OS: fix 9pfs stat receive format
9pfront.c | 9 +++++---- include/xenbus.h | 2 ++ shutdown.c | 12 ++++-------- xenbus.c | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/3 Mini-OS: make xenstore_buf externally visible
For support of the 9pfs frontend in Xenstore-stubdom xenstore_buf needs to be externally visible.
--- include/xenbus.h | 2 ++ xenbus.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/xenbus.h +2 -0
@@ -8,12 +8,14 @@ typedef unsigned long xenbus_transaction_t;#ifdef CONFIG_XENBUS extern uint32_t xenbus_evtchn; +extern struct xenstore_domain_interface *xenstore_buf;/* Initialize the XenBus system. */ void init_xenbus (void );void get_xenbus (void *p);#else #define xenbus_evtchn ~0 +#define xenstore_buf NULLstatic inline void init_xenbus (void ) {
xenbus.c +1 -1
@@ -44,7 +44,7 @@ #define DEBUG(_f, _a...) ((void)0)#endif -static struct xenstore_domain_interface *xenstore_buf; +struct xenstore_domain_interface *xenstore_buf;static DECLARE_WAIT_QUEUE_HEAD (xb_waitq);DECLARE_WAIT_QUEUE_HEAD (xenbus_watch_queue); static __DECLARE_SEMAPHORE_GENERIC(xb_write_sem, 1);
Signature · 1 line
2.35.3
Re: [PATCH 1/3] Mini-OS: make xenstore_buf externally visible
Quoted 5 lines · Juergen Gross
For support of the 9pfs frontend in Xenstore-stubdom
xenstore_bufneeds to be externally visible.Signed-off-by Juergen Gross <[email protected]>
xenstore_buf will be used by the xen.git patch "[PATCH 24/29] tools/xenstored: map stubdom interface".
Thanks,
Jason
PATCH 2/3 Mini-OS: don't crash if no shutdown node is available
In reply to Juergen GrossIt might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.
In fini_shutdown() clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.
--- shutdown.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
shutdown.c +4 -8
@@ -75,7 +75,9 @@ static void shutdown_thread(void *p)xenbus_wait_for_watch (&events);if ((err =xenbus_read (XBT_NIL , path, &shutdown))) {free (err); -do_exit (); +free (xenbus_unwatch_path_token (XBT_NIL , path, token)); +printk ("Shutdown Xenstore node not available.\n" ); +return ; }if (end_shutdown_thread)
@@ -117,15 +119,9 @@ void init_shutdown(void)void fini_shutdown (void ) { -char *err; - end_shutdown_thread =1 ;xenbus_release_wait_for_watch (&events); - err =xenbus_unwatch_path_token (XBT_NIL , path, token); -if (err) { -free (err); -do_exit (); - } +free (xenbus_unwatch_path_token (XBT_NIL , path, token)); }#endif
Signature · 1 line
2.35.3
Re: [PATCH 2/3] Mini-OS: don't crash if no shutdown node is available
Quoted 9 lines · Juergen Gross
It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.
In
fini_shutdown()clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.Signed-off-by Juergen Gross <[email protected]>
Re: [PATCH 2/3] Mini-OS: don't crash if no shutdown node is available
In reply to Juergen GrossQuoted 8 lines · Juergen Gross
It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.
In
fini_shutdown()clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.Signed-off-by Juergen Gross <[email protected]>
Which cases might we not have a control/shutdown node?
I'm all for coping better with its absence, but it's not a piece of the Xen ABI which is optional.
And on that front, not crashing is good, but why remove the watch? What if it comes into existence later? Is there any problem with just leaving the watch outstanding?
~Andrew
Re: [PATCH 2/3] Mini-OS: don't crash if no shutdown node is available
Quoted 11 lines · Andrew Cooper
Quoted 8 lines · Juergen Gross
It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.
In
fini_shutdown()clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.Signed-off-by Juergen Gross <[email protected]>Which cases might we not have a control/shutdown node?
Xenstore-stubdom. It should _never_ shutdown, and it isn't really under control of Xen tools (other than being created).
Quoted 2 lines
I'm all for coping better with its absence, but it's not a piece of the Xen ABI which is optional.
I'd like to differ here. See reasoning above.
Quoted 3 lines
And on that front, not crashing is good, but why remove the watch? What if it comes into existence later? Is there any problem with just leaving the watch outstanding?
A needless waste of memory in Xenstore-stubdom.
Juergen
Re: [PATCH 2/3] Mini-OS: don't crash if no shutdown node is available
Quoted 13 lines · Juergen Gross
Quoted 11 lines · Andrew Cooper
Quoted 8 lines · Juergen Gross
It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.
In
fini_shutdown()clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.Signed-off-by Juergen Gross <[email protected]>Which cases might we not have a control/shutdown node?
Quoted 7 lines
Xenstore-stubdom. It should _never_ shutdown, and it isn't really under control of Xen tools (other than being created).
Quoted 2 lines
I'm all for coping better with its absence, but it's not a piece of the Xen ABI which is optional.
I'd like to differ here. See reasoning above.
If we're going to permit this configuration, then I think it needs an extension to xenstore-paths to make it officially optional.
And I think it's reasonable to support, but I wouldn't go as far as saying "never". If you've cleaved the global xenstored in twain/trine/etc, then individual parts of it can shut down normally.
~Andrew
Re: [PATCH 2/3] Mini-OS: don't crash if no shutdown node is available
Quoted 20 lines · Andrew Cooper
Quoted 19 lines · Juergen Gross
Quoted 11 lines · Andrew Cooper
Quoted 8 lines · Juergen Gross
It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.
In
fini_shutdown()clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.Signed-off-by Juergen Gross <[email protected]>Which cases might we not have a control/shutdown node?
Xenstore-stubdom. It should _never_ shutdown, and it isn't really under control of Xen tools (other than being created).
Quoted 2 lines
I'm all for coping better with its absence, but it's not a piece of the Xen ABI which is optional.
Quoted 8 lines
Quoted 1 line
I'd like to differ here. See reasoning above.
If we're going to permit this configuration, then I think it needs an extension to xenstore-paths to make it officially optional.
And I think it's reasonable to support, but I wouldn't go as far as saying "never". If you've cleaved the global xenstored in twain/trine/etc, then individual parts of it can shut down normally.
Xenstore-stubdom is a very special case. I don't think its shutdown node can be under control of the normal Xen tools, as only the stubdom can know whether it is able to react in any sensible way to it. It needs to take specific measures to ensure that even its ABI-compliant reaction to a shutdown request is visible to Xen tools (remember that this reaction is a write to the shutdown node causing a watch event in dom0, which won't work with Xenstore going down).
In the end there is no way the shutdown node can be present when starting Xenstore-stubdom. There is no Xenstore at the time the node is probed in today's Mini-OS boot sequence.
Juergen
PATCH 3/3 Mini-OS: fix 9pfs stat receive format
In reply to Juergen GrossThe format string of the received data for the 9pfs stat command is missing the initial 2 byte total length specifier. Add it.
--- 9pfront.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
9pfront.c +5 -4
@@ -711,6 +711,7 @@ static int p9_create(struct dev_9pfs *dev, uint32_t fid, char *path,static int p9_stat (struct dev_9pfs *dev,uint32_t fid,struct p9_stat *stat) {struct req *req =get_free_req (dev); +uint16_t total;int ret;if ( !req )
@@ -719,10 +720,10 @@ static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat)memset (stat,0 ,sizeof (*stat)); req->cmd =P9_CMD_STAT ;send_9p (dev, req,"U" , fid); -rcv_9p (dev, req,"uuUQUUULSSSSSUUU" , &stat->size, &stat->type, &stat->dev, - stat->qid, &stat->mode, &stat->atime, &stat->mtime, &stat->length, - &stat->name, &stat->uid, &stat->gid, &stat->muid, &stat->extension, - &stat->n_uid, &stat->n_gid, &stat->n_muid); +rcv_9p (dev, req,"uuuUQUUULSSSSSUUU" , &total, &stat->size, &stat->type, + &stat->dev, stat->qid, &stat->mode, &stat->atime, &stat->mtime, + &stat->length, &stat->name, &stat->uid, &stat->gid, &stat->muid, + &stat->extension, &stat->n_uid, &stat->n_gid, &stat->n_muid); ret = req->result;
Signature · 1 line
2.35.3
Re: [PATCH 3/3] Mini-OS: fix 9pfs stat receive format
Quoted 24 lines · Juergen Gross
The format string of the received data for the 9pfs stat command is missing the initial 2 byte total length specifier. Add it.
Fixes 2d1dfccd3aa3 ("Mini-OS: add read and write support to 9pfsfront")Signed-off-by Juergen Gross <[email protected]>--- 9pfront.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)9pfront.c +1
-0@@ -711,6 +711,7 @@ static int p9_create(struct dev_9pfs *dev, uint32_t fid, char *path,static int p9_stat (struct dev_9pfs *dev,uint32_t fid,struct p9_stat *stat) {struct req *req =get_free_req (dev); +uint16_t total;int ret;if ( !req )@@ -719,10 +720,10 @@ static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat)memset (stat,0 ,sizeof (*stat));
9pfront.c static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat) · line 726
Quoted 10 lines
9pfront.c +4
-4req->cmd =P9_CMD_STAT ;send_9p (dev, req,"U" , fid); -rcv_9p (dev, req,"uuUQUUULSSSSSUUU" , &stat->size, &stat->type, &stat->dev, - stat->qid, &stat->mode, &stat->atime, &stat->mtime, &stat->length, - &stat->name, &stat->uid, &stat->gid, &stat->muid, &stat->extension, - &stat->n_uid, &stat->n_gid, &stat->n_muid); +rcv_9p (dev, req,"uuuUQUUULSSSSSUUU" , &total, &stat->size, &stat->type, + &stat->dev, stat->qid, &stat->mode, &stat->atime, &stat->mtime, + &stat->length, &stat->name, &stat->uid, &stat->gid, &stat->muid, + &stat->extension, &stat->n_uid, &stat->n_gid, &stat->n_muid);
total is unused by the linux frontend end as well. Looks like QEMU hard codes the value as 0.
Thanks,
Jason