Skip to contentSkip to conversation

fs-front: cope with a missing fs-backend

PATCH New Stefano Stabellini 1 participant 1 message Jul 22, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs-front: cope with a missing fs-backend

Hi all,
this patch fixes fs-front so that is able to 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.

---

extras/mini-os/fs-front.c +44 -5
diff -r be056dcaceb4 extras/mini-os/fs-front.c
@@ -193,6 +193,9 @@
     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 @@
     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);
@@ -273,6 +279,9 @@
     struct fsif_request *req;
     ssize_t ret;
     int i;
+
+    if (!import)
+        return -1;
 
     BUG_ON(len > PAGE_SIZE * FSIF_NR_READ_GNTS);
 
@@ -344,6 +353,9 @@
     struct fsif_request *req;
     ssize_t ret, to_copy;
     int i;
+
+    if (!import)
+        return -1;
 
     BUG_ON(len > PAGE_SIZE * FSIF_NR_WRITE_GNTS);
 
@@ -413,6 +425,9 @@
     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 @@
     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 @@
     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);
@@ -542,6 +563,9 @@
     int ret;
     char old_header[] = "old: ";
     char new_header[] = "new: ";
+
+    if (!import)
+        return -1;
 
     /* Prepare request for the backend */
     back_req_id = reserve_fsif_request(import);
@@ -594,6 +618,9 @@
     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);
@@ -640,6 +667,9 @@
     struct fsif_request *req;
     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 @@
     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);
@@ -735,6 +768,9 @@
     RING_IDX back_req_id; 
     struct fsif_request *req;
     int64_t ret;
+
+    if (!import)
+        return -1;
 
     /* Prepare request for the backend */
     back_req_id = reserve_fsif_request(import);
@@ -776,6 +812,9 @@
     RING_IDX back_req_id; 
     struct fsif_request *req;
     int ret;
+
+    if (!import)
+        return -1;
 
     /* Prepare request for the backend */
     back_req_id = reserve_fsif_request(import);
@@ -1231,19 +1270,19 @@
 {
     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");
extras/mini-os/main.c +0 -5
diff -r be056dcaceb4 extras/mini-os/main.c
@@ -69,11 +69,6 @@
 #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) {