WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [qemu-xen-unstable] stubdom: fix cdrom changing

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [qemu-xen-unstable] stubdom: fix cdrom changing
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Mon, 4 Jan 2010 10:05:07 -0800
Delivery-date: Mon, 04 Jan 2010 10:05:05 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
commit 662c50f50338fa3abe68da95b45b6ef42dcdecc8
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Date:   Mon Jan 4 16:21:02 2010 +0000

    stubdom: fix cdrom changing
    
    Hi all,
    the current code to change a cdrom doesn't work with stubdoms:
    
    - media_filename set at boot time doesn't have the proper
    value (that in the stubdom case is the frontend path and not the
    filename);
    
    - when a cdrom watch event is triggered, the code to decide whether the
    new cdrom is valid and different from the current cdrom doesn't work for
    stubdoms;
    
    both issues are fixed by this patch, in particular now media_filename
    consistently holds the frontend path for stubdoms while bs->filename
    holds the filename (like in the normal qemu case) to allow comparisons
    with the old cdrom filename.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 xenstore.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/xenstore.c b/xenstore.c
index 8ac478b..5064719 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -108,7 +108,23 @@ static void insert_media(void *opaque)
                 format = &bdrv_raw;
 
             bdrv_open2(bs, media_filename[i], 0, format);
+#ifdef CONFIG_STUBDOM
+            {
+                char *buf, *backend, *params_path, *params;
+                unsigned int len;
+                asprintf(&buf, "%s/backend", media_filename[i]);
+                backend = xs_read(xsh, XBT_NULL, buf, &len);
+                asprintf(&params_path, "%s/params", backend);
+                params = xs_read(xsh, XBT_NULL, params_path, &len);
+                pstrcpy(bs->filename, sizeof(bs->filename), params);
+                free(buf);
+                free(backend);
+                free(params_path);
+                free(params);
+            }
+#else
             pstrcpy(bs->filename, sizeof(bs->filename), media_filename[i]);
+#endif
             free(media_filename[i]);
             media_filename[i] = NULL;
         }
@@ -555,6 +571,11 @@ void xenstore_parse_domain_config(int hvm_domid)
 
        drives_table[nb_drives].bdrv = bs;
        drives_table[nb_drives].used = 1;
+#ifdef CONFIG_STUBDOM
+    media_filename[nb_drives] = strdup(danger_buf);
+#else
+    media_filename[nb_drives] = strdup(bs->filename);
+#endif
        nb_drives++;
 
     }
@@ -931,6 +952,7 @@ void xenstore_process_event(void *opaque)
     fprintf(stderr,"medium change watch on `%s' (index: %d): %s\n",
            vec[XS_WATCH_TOKEN], hd_index, image ? image : "<none>");
 
+#ifndef CONFIG_STUBDOM
     if (image != NULL) {
         /* Strip off blktap sub-type prefix */
         bpath = strdup(vec[XS_WATCH_PATH]); 
@@ -947,6 +969,30 @@ void xenstore_process_event(void *opaque)
         if (!strcmp(image, drives_table[hd_index].bdrv->filename))
             goto out;  /* identical */
     }
+#else
+    {
+        char path[strlen(vec[XS_WATCH_PATH]) - 6 + 8];
+        char *state;
+        path[0] = '\0';
+        strncat(path, vec[XS_WATCH_PATH], strlen(vec[XS_WATCH_PATH]) - 6);
+        strcat(path, "state");
+        state = xs_read(xsh, XBT_NULL, path, &len);
+        if (image && image[0] && state && atoi(state) <= 4) {
+            if (!strcmp(image, drives_table[hd_index].bdrv->filename))
+                goto out;  /* identical */
+            path[0] = '\0';
+            strncat(path, vec[XS_WATCH_PATH], strlen(vec[XS_WATCH_PATH]) - 6);
+            strcat(path, "frontend");
+            free(image);
+            image = NULL;
+            image = xs_read(xsh, XBT_NULL, path, &len);
+        } else {
+            free(image);
+            image = NULL;
+        }
+        free(state);
+    }
+#endif
 
     drives_table[hd_index].bdrv->filename[0] = '\0';
     bdrv_close(drives_table[hd_index].bdrv);
@@ -956,15 +1002,7 @@ void xenstore_process_event(void *opaque)
     }
 
     if (image && image[0]) {
-#ifdef CONFIG_STUBDOM
-        char path[strlen(vec[XS_WATCH_PATH]) - 6 + 8];
-        path[0] = '\0';
-        strncat(path, vec[XS_WATCH_PATH], strlen(vec[XS_WATCH_PATH]) - 6);
-        strcat(path, "frontend");
-        media_filename[hd_index] = xs_read(xsh, XBT_NULL, path, &len);
-#else
         media_filename[hd_index] = strdup(image);
-#endif
         xenstore_check_new_media_present(5000);
     }
 
--
generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [qemu-xen-unstable] stubdom: fix cdrom changing, Ian Jackson <=