]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
fs-front: cope with a missing fs-backend
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 23 Jul 2009 07:57:02 +0000 (08:57 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 23 Jul 2009 07:57:02 +0000 (08:57 +0100)
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>
fs-front.c
main.c

index b22266dd23895d0838c81f2aa7215aa9dc6b768b..7c4d68df5a98127db01edd88be36c6cf49016218 100644 (file)
@@ -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/main.c b/main.c
index 204cf85f8afe0b55b89d7ca7d6a82324e48fa43a..ebdab3392187c7c9e9e515a8f85570a1ccf73229 100644 (file)
--- a/main.c
+++ b/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) {