aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-07-23 08:57:02 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-07-23 08:57:02 +0100
commit70ad90095b7b4ae26266878a48b0abae9717010b (patch)
treecefec28462e2c51935279c8dc436075797658df7
parent5d3f9fe2300d5ca93611eb4b41ed038472c14ac4 (diff)
downloadxen-70ad90095b7b4ae26266878a48b0abae9717010b.tar.gz
xen-70ad90095b7b4ae26266878a48b0abae9717010b.tar.bz2
xen-70ad90095b7b4ae26266878a48b0abae9717010b.zip
fs-front: cope with a missing fs-backend
Obviously save\restore is not going to work if fs-backend is missing, but at least the stubdom will be able to work correctly in all the other cases. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
-rw-r--r--extras/mini-os/fs-front.c49
-rw-r--r--extras/mini-os/main.c5
2 files changed, 44 insertions, 10 deletions
diff --git a/extras/mini-os/fs-front.c b/extras/mini-os/fs-front.c
index b22266dd23..7c4d68df5a 100644
--- a/extras/mini-os/fs-front.c
+++ b/extras/mini-os/fs-front.c
@@ -193,6 +193,9 @@ int fs_open(struct fs_import *import, char *file)
struct fsif_request *req;
int fd;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -234,6 +237,9 @@ int fs_close(struct fs_import *import, int fd)
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -274,6 +280,9 @@ ssize_t fs_read(struct fs_import *import, int fd, void *buf,
ssize_t ret;
int i;
+ if (!import)
+ return -1;
+
BUG_ON(len > PAGE_SIZE * FSIF_NR_READ_GNTS);
/* Prepare request for the backend */
@@ -345,6 +354,9 @@ ssize_t fs_write(struct fs_import *import, int fd, void *buf,
ssize_t ret, to_copy;
int i;
+ if (!import)
+ return -1;
+
BUG_ON(len > PAGE_SIZE * FSIF_NR_WRITE_GNTS);
/* Prepare request for the backend */
@@ -413,6 +425,9 @@ int fs_stat(struct fs_import *import,
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -455,6 +470,9 @@ int fs_truncate(struct fs_import *import,
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -495,6 +513,9 @@ int fs_remove(struct fs_import *import, char *file)
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -543,6 +564,9 @@ int fs_rename(struct fs_import *import,
char old_header[] = "old: ";
char new_header[] = "new: ";
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -594,6 +618,9 @@ int fs_create(struct fs_import *import, char *name,
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -641,6 +668,9 @@ char** fs_list(struct fs_import *import, char *name,
char **files, *current_file;
int i;
+ if (!import)
+ return NULL;
+
DEBUG("Different masks: NR_FILES=(%llx, %d), ERROR=(%llx, %d), HAS_MORE(%llx, %d)\n",
NR_FILES_MASK, NR_FILES_SHIFT, ERROR_MASK, ERROR_SHIFT, HAS_MORE_FLAG, HAS_MORE_SHIFT);
@@ -696,6 +726,9 @@ int fs_chmod(struct fs_import *import, int fd, int32_t mode)
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -736,6 +769,9 @@ int64_t fs_space(struct fs_import *import, char *location)
struct fsif_request *req;
int64_t ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -777,6 +813,9 @@ int fs_sync(struct fs_import *import, int fd)
struct fsif_request *req;
int ret;
+ if (!import)
+ return -1;
+
/* Prepare request for the backend */
back_req_id = reserve_fsif_request(import);
DEBUG("Backend request id=%d\n", back_req_id);
@@ -1231,20 +1270,20 @@ void init_fs_frontend(void)
{
struct minios_list_head *entry;
struct fs_import *import = NULL;
- printk("Initing FS fronend(s).\n");
+ printk("Initing FS frontend(s).\n");
- //exports = probe_exports();
add_export(&exports, 0);
minios_list_for_each(entry, &exports)
{
import = minios_list_entry(entry, struct fs_import, list);
printk("FS export [dom=%d, id=%d] found\n",
import->dom_id, import->export_id);
- init_fs_import(import);
+ if (init_fs_import(import) != 0) {
+ fs_import = import;
+ break;
+ }
}
- fs_import = import;
-
if (!fs_import)
printk("No FS import\n");
}
diff --git a/extras/mini-os/main.c b/extras/mini-os/main.c
index 204cf85f8a..ebdab33921 100644
--- a/extras/mini-os/main.c
+++ b/extras/mini-os/main.c
@@ -69,11 +69,6 @@ static void call_main(void *p)
#endif
#ifdef CONFIG_QEMU
- if (!fs_import) {
- printk("No FS backend found, is it running?\n");
- do_exit();
- }
-
/* Fetch argc, argv from XenStore */
domid = xenbus_read_integer("target");
if (domid == -1) {