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] [xen-unstable] [ioemu] Cleanup media change code.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [ioemu] Cleanup media change code.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Mar 2007 09:50:16 -0700
Delivery-date: Tue, 20 Mar 2007 09:50:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Christian Limpach <Christian.Limpach@xxxxxxxxxxxxx>
# Date 1174302928 0
# Node ID 4b9150e9ecfd41dfc2e85822effc49d0206b617b
# Parent  066b66ce1f98eb8248b8fde66a9d29afbde307ca
[ioemu] Cleanup media change code.

Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxxx>
---
 tools/ioemu/xenstore.c |   52 +++++++++++++++++++------------------------------
 1 files changed, 21 insertions(+), 31 deletions(-)

diff -r 066b66ce1f98 -r 4b9150e9ecfd tools/ioemu/xenstore.c
--- a/tools/ioemu/xenstore.c    Mon Mar 19 11:09:57 2007 +0000
+++ b/tools/ioemu/xenstore.c    Mon Mar 19 11:15:28 2007 +0000
@@ -18,7 +18,7 @@
 #include <fcntl.h>
 
 static struct xs_handle *xsh = NULL;
-static char *hd_filename[MAX_DISKS];
+static char *media_filename[MAX_DISKS];
 static QEMUTimer *insert_timer = NULL;
 
 #define UWAIT_MAX (30*1000000) /* thirty seconds */
@@ -45,10 +45,10 @@ static void insert_media(void *opaque)
     int i;
 
     for (i = 0; i < MAX_DISKS; i++) {
-       if (hd_filename[i]) {
-           do_change(bs_table[i]->device_name, hd_filename[i]);
-           free(hd_filename[i]);
-           hd_filename[i] = NULL;
+       if (media_filename[i] && bs_table[i]) {
+           do_change(bs_table[i]->device_name, media_filename[i]);
+           free(media_filename[i]);
+           media_filename[i] = NULL;
        }
     }
 }
@@ -87,7 +87,7 @@ void xenstore_parse_domain_config(int do
     unsigned int len, num, hd_index;
 
     for(i = 0; i < MAX_DISKS; i++)
-        hd_filename[i] = NULL;
+        media_filename[i] = NULL;
 
     xsh = xs_daemon_open();
     if (xsh == NULL) {
@@ -133,19 +133,12 @@ void xenstore_parse_domain_config(int do
            continue;
        free(type);
        type = xs_read(xsh, XBT_NULL, buf, &len);
-       /* read params to get the patch of the image -- read it last
-        * so that we have its path in buf when setting up the
-        * watch */
        if (pasprintf(&buf, "%s/params", bpath) == -1)
            continue;
        free(params);
        params = xs_read(xsh, XBT_NULL, buf, &len);
        if (params == NULL)
            continue;
-       if (params[0]) {
-           hd_filename[hd_index] = params;     /* strdup() */
-           params = NULL;              /* don't free params on re-use */
-       }
         /* 
          * check if device has a phantom vbd; the phantom is hooked
          * to the frontend device (for ease of cleanup), so lookup 
@@ -156,35 +149,32 @@ void xenstore_parse_domain_config(int do
            continue;
        free(fpath);
         fpath = xs_read(xsh, XBT_NULL, buf, &len);
-       if (fpath != NULL) {
+       if (fpath) {
            if (pasprintf(&buf, "%s/dev", fpath) == -1)
                continue;
+           free(params);
             params = xs_read(xsh, XBT_NULL, buf , &len);
-           if (params != NULL) {
-                free(hd_filename[hd_index]);
-                hd_filename[hd_index] = params;
-                params = NULL;              /* don't free params on re-use */
+           if (params) {
                 /* 
                  * wait for device, on timeout silently fail because we will 
                  * fail to open below
                  */
-                waitForDevice(hd_filename[hd_index]);
+                waitForDevice(params);
             }
         }
+
        bs_table[hd_index] = bdrv_new(dev);
-        /* re-establish buf */
-       if (pasprintf(&buf, "%s/params", bpath) == -1)
-           continue;
        /* check if it is a cdrom */
        if (type && !strcmp(type, "cdrom")) {
            bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM);
-           xs_watch(xsh, buf, dev);
+           if (pasprintf(&buf, "%s/params", bpath) != -1)
+               xs_watch(xsh, buf, dev);
        }
-       if (hd_filename[hd_index]) {
-            if (bdrv_open(bs_table[hd_index], hd_filename[hd_index],
-                         0 /* snapshot */) < 0)
+       /* open device now if media present */
+       if (params[0]) {
+            if (bdrv_open(bs_table[hd_index], params, 0 /* snapshot */) < 0)
                 fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
-                        hd_filename[hd_index]);
+                        params);
        }
     }
 
@@ -347,13 +337,13 @@ void xenstore_process_event(void *opaque
 
     do_eject(0, vec[XS_WATCH_TOKEN]);
     bs_table[hd_index]->filename[0] = 0;
-    if (hd_filename[hd_index]) {
-       free(hd_filename[hd_index]);
-       hd_filename[hd_index] = NULL;
+    if (media_filename[hd_index]) {
+       free(media_filename[hd_index]);
+       media_filename[hd_index] = NULL;
     }
 
     if (image[0]) {
-       hd_filename[hd_index] = strdup(image);
+       media_filename[hd_index] = strdup(image);
        xenstore_check_new_media_present(5000);
     }
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [ioemu] Cleanup media change code., Xen patchbot-unstable <=