mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/xenstored: mount 9pfs device in stubdom
Mount the 9pfs device in stubdom enabling it to use files. This has to happen in a worker thread in order to allow the main thread handling the required Xenstore accesses in parallel. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Julien Grall <jgrall@amazon.com>
This commit is contained in:
1 parent
e21d9dbf44
commit
297a2587e6
3 files changed
+62
No files matched your search
@@ -36,6 +36,8 @@
|
||||
#include "list.h"
|
||||
#include "hashtable.h"
|
||||
|
||||
#define XENSTORE_LIB_DIR XEN_LIB_DIR "/xenstore"
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
/* O_CLOEXEC support is needed for Live Update in the daemon case. */
|
||||
@@ -399,6 +401,10 @@ void handle_special_fds(void);
|
||||
int get_socket_fd(void);
|
||||
void set_socket_fd(int fd);
|
||||
|
||||
#ifdef __MINIOS__
|
||||
void mount_9pfs(void);
|
||||
#endif
|
||||
|
||||
/* Close stdin/stdout/stderr to complete daemonize */
|
||||
void finish_daemonize(void);
|
||||
|
||||
|
||||
@@ -1236,6 +1236,8 @@ void stubdom_init(void)
|
||||
barf_perror("Failed to initialize stubdom");
|
||||
|
||||
xenevtchn_notify(xce_handle, stubdom->port);
|
||||
|
||||
mount_9pfs();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,20 @@
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <syslog.h>
|
||||
#include "talloc.h"
|
||||
#include "core.h"
|
||||
#include "utils.h"
|
||||
#include <xen/grant_table.h>
|
||||
#include <mini-os/lib.h>
|
||||
#include <mini-os/9pfront.h>
|
||||
#include <mini-os/sched.h>
|
||||
#include <mini-os/xenbus.h>
|
||||
#include <mini-os/xmalloc.h>
|
||||
|
||||
#define P9_STATE_PATH "device/9pfs/0/state"
|
||||
|
||||
static void *p9_device;
|
||||
|
||||
void finish_daemonize(void)
|
||||
{
|
||||
@@ -74,3 +84,47 @@ int get_socket_fd(void)
|
||||
void set_socket_fd(int fd)
|
||||
{
|
||||
}
|
||||
|
||||
static void mount_thread(void *p)
|
||||
{
|
||||
xenbus_event_queue events = NULL;
|
||||
char *err;
|
||||
char *dummy;
|
||||
|
||||
err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events);
|
||||
if (err) {
|
||||
log("error \"%s\" when setting watch on \"%s\"\n", err,
|
||||
P9_STATE_PATH);
|
||||
free(err);
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
xenbus_wait_for_watch(&events);
|
||||
|
||||
/*
|
||||
* We only care for existence of the state node.
|
||||
* State changes are handled in init_9pfront().
|
||||
*/
|
||||
err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy);
|
||||
if (!err)
|
||||
break;
|
||||
free(err);
|
||||
}
|
||||
|
||||
free(dummy);
|
||||
|
||||
err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs");
|
||||
if (err) {
|
||||
log("error \"%s\" when unwatching \"%s\", leaking watch\n",
|
||||
err, P9_STATE_PATH);
|
||||
free(err);
|
||||
}
|
||||
|
||||
p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
|
||||
}
|
||||
|
||||
void mount_9pfs(void)
|
||||
{
|
||||
create_thread("mount-9pfs", mount_thread, NULL);
|
||||
}
|
||||