debuggers.hg

changeset 20015:5719af68e43e

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>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jul 23 08:57:02 2009 +0100 (2009-07-23)
parents e7c6a258be0d
children 83e6b0198569
files extras/mini-os/fs-front.c extras/mini-os/main.c
line diff
     1.1 --- a/extras/mini-os/fs-front.c	Thu Jul 23 08:56:15 2009 +0100
     1.2 +++ b/extras/mini-os/fs-front.c	Thu Jul 23 08:57:02 2009 +0100
     1.3 @@ -193,6 +193,9 @@ int fs_open(struct fs_import *import, ch
     1.4      struct fsif_request *req;
     1.5      int fd;
     1.6  
     1.7 +    if (!import)
     1.8 +        return -1;
     1.9 +
    1.10      /* Prepare request for the backend */
    1.11      back_req_id = reserve_fsif_request(import);
    1.12      DEBUG("Backend request id=%d\n", back_req_id);
    1.13 @@ -234,6 +237,9 @@ int fs_close(struct fs_import *import, i
    1.14      struct fsif_request *req;
    1.15      int ret;
    1.16  
    1.17 +    if (!import)
    1.18 +        return -1;
    1.19 +
    1.20      /* Prepare request for the backend */
    1.21      back_req_id = reserve_fsif_request(import);
    1.22      DEBUG("Backend request id=%d\n", back_req_id);
    1.23 @@ -274,6 +280,9 @@ ssize_t fs_read(struct fs_import *import
    1.24      ssize_t ret;
    1.25      int i;
    1.26  
    1.27 +    if (!import)
    1.28 +        return -1;
    1.29 +
    1.30      BUG_ON(len > PAGE_SIZE * FSIF_NR_READ_GNTS);
    1.31  
    1.32      /* Prepare request for the backend */
    1.33 @@ -345,6 +354,9 @@ ssize_t fs_write(struct fs_import *impor
    1.34      ssize_t ret, to_copy;
    1.35      int i;
    1.36  
    1.37 +    if (!import)
    1.38 +        return -1;
    1.39 +
    1.40      BUG_ON(len > PAGE_SIZE * FSIF_NR_WRITE_GNTS);
    1.41  
    1.42      /* Prepare request for the backend */
    1.43 @@ -413,6 +425,9 @@ int fs_stat(struct fs_import *import,
    1.44      struct fsif_request *req;
    1.45      int ret;
    1.46  
    1.47 +    if (!import)
    1.48 +        return -1;
    1.49 +
    1.50      /* Prepare request for the backend */
    1.51      back_req_id = reserve_fsif_request(import);
    1.52      DEBUG("Backend request id=%d\n", back_req_id);
    1.53 @@ -455,6 +470,9 @@ int fs_truncate(struct fs_import *import
    1.54      struct fsif_request *req;
    1.55      int ret;
    1.56  
    1.57 +    if (!import)
    1.58 +        return -1;
    1.59 +
    1.60      /* Prepare request for the backend */
    1.61      back_req_id = reserve_fsif_request(import);
    1.62      DEBUG("Backend request id=%d\n", back_req_id);
    1.63 @@ -495,6 +513,9 @@ int fs_remove(struct fs_import *import, 
    1.64      struct fsif_request *req;
    1.65      int ret;
    1.66  
    1.67 +    if (!import)
    1.68 +        return -1;
    1.69 +
    1.70      /* Prepare request for the backend */
    1.71      back_req_id = reserve_fsif_request(import);
    1.72      DEBUG("Backend request id=%d\n", back_req_id);
    1.73 @@ -543,6 +564,9 @@ int fs_rename(struct fs_import *import,
    1.74      char old_header[] = "old: ";
    1.75      char new_header[] = "new: ";
    1.76  
    1.77 +    if (!import)
    1.78 +        return -1;
    1.79 +
    1.80      /* Prepare request for the backend */
    1.81      back_req_id = reserve_fsif_request(import);
    1.82      DEBUG("Backend request id=%d\n", back_req_id);
    1.83 @@ -594,6 +618,9 @@ int fs_create(struct fs_import *import, 
    1.84      struct fsif_request *req;
    1.85      int ret;
    1.86  
    1.87 +    if (!import)
    1.88 +        return -1;
    1.89 +
    1.90      /* Prepare request for the backend */
    1.91      back_req_id = reserve_fsif_request(import);
    1.92      DEBUG("Backend request id=%d\n", back_req_id);
    1.93 @@ -641,6 +668,9 @@ char** fs_list(struct fs_import *import,
    1.94      char **files, *current_file;
    1.95      int i;
    1.96  
    1.97 +    if (!import)
    1.98 +        return NULL;
    1.99 +
   1.100      DEBUG("Different masks: NR_FILES=(%llx, %d), ERROR=(%llx, %d), HAS_MORE(%llx, %d)\n",
   1.101              NR_FILES_MASK, NR_FILES_SHIFT, ERROR_MASK, ERROR_SHIFT, HAS_MORE_FLAG, HAS_MORE_SHIFT);
   1.102  
   1.103 @@ -696,6 +726,9 @@ int fs_chmod(struct fs_import *import, i
   1.104      struct fsif_request *req;
   1.105      int ret;
   1.106  
   1.107 +    if (!import)
   1.108 +        return -1;
   1.109 +
   1.110      /* Prepare request for the backend */
   1.111      back_req_id = reserve_fsif_request(import);
   1.112      DEBUG("Backend request id=%d\n", back_req_id);
   1.113 @@ -736,6 +769,9 @@ int64_t fs_space(struct fs_import *impor
   1.114      struct fsif_request *req;
   1.115      int64_t ret;
   1.116  
   1.117 +    if (!import)
   1.118 +        return -1;
   1.119 +
   1.120      /* Prepare request for the backend */
   1.121      back_req_id = reserve_fsif_request(import);
   1.122      DEBUG("Backend request id=%d\n", back_req_id);
   1.123 @@ -777,6 +813,9 @@ int fs_sync(struct fs_import *import, in
   1.124      struct fsif_request *req;
   1.125      int ret;
   1.126  
   1.127 +    if (!import)
   1.128 +        return -1;
   1.129 +
   1.130      /* Prepare request for the backend */
   1.131      back_req_id = reserve_fsif_request(import);
   1.132      DEBUG("Backend request id=%d\n", back_req_id);
   1.133 @@ -1231,20 +1270,20 @@ void init_fs_frontend(void)
   1.134  {
   1.135      struct minios_list_head *entry;
   1.136      struct fs_import *import = NULL;
   1.137 -    printk("Initing FS fronend(s).\n");
   1.138 +    printk("Initing FS frontend(s).\n");
   1.139  
   1.140 -    //exports = probe_exports();
   1.141      add_export(&exports, 0);
   1.142      minios_list_for_each(entry, &exports)
   1.143      {
   1.144          import = minios_list_entry(entry, struct fs_import, list);
   1.145          printk("FS export [dom=%d, id=%d] found\n", 
   1.146                  import->dom_id, import->export_id);
   1.147 -        init_fs_import(import);
   1.148 +        if (init_fs_import(import) != 0) {
   1.149 +            fs_import = import;
   1.150 +            break;
   1.151 +        }
   1.152      }
   1.153  
   1.154 -    fs_import = import;
   1.155 -
   1.156      if (!fs_import)
   1.157  	printk("No FS import\n");
   1.158  }
     2.1 --- a/extras/mini-os/main.c	Thu Jul 23 08:56:15 2009 +0100
     2.2 +++ b/extras/mini-os/main.c	Thu Jul 23 08:57:02 2009 +0100
     2.3 @@ -69,11 +69,6 @@ static void call_main(void *p)
     2.4  #endif
     2.5  
     2.6  #ifdef CONFIG_QEMU
     2.7 -    if (!fs_import) {
     2.8 -        printk("No FS backend found, is it running?\n");
     2.9 -        do_exit();
    2.10 -    }
    2.11 -
    2.12      /* Fetch argc, argv from XenStore */
    2.13      domid = xenbus_read_integer("target");
    2.14      if (domid == -1) {