Skip to contentSkip to conversation

strip tap subtype prefix from image name

PATCH In review Pat Campbell 3 participants 3 messages Jan 30, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 strip tap subtype prefix from image name

Currently I am not able to mount or boot from an HVM CDROM when it is configured for 'tap:aio' instead of 'file'.

disk=[ 'tap:aio:/var/lib/xen/images/sles10-sp2-fv/disk0,hda,w', '

       tap:aio:/home/iso/sles/SLES10.iso,hdc:cdrom,r', ]

With the attached patch I am able to boot from the CDROM and or mount it.

Patch changes xenstore.c:xenstore_process_event() to strip the tap subtype prefix from the image name.

Please apply to xen-unstable tip.

tools/ioemu/xenstore.c +28 -3
diff -r 1c826ea72a80 tools/ioemu/xenstore.c
@@ -418,7 +418,7 @@ void xenstore_record_dm_state(char *stat
 
 void xenstore_process_event(void *opaque)
 {
-    char **vec, *image = NULL;
+    char **vec, *bpath, *buf, *image = NULL;
     unsigned int len, num, hd_index;
 
     vec = xs_read_watch(xsh, &num);
@@ -440,8 +440,33 @@ void xenstore_process_event(void *opaque
         goto out;
     hd_index = vec[XS_WATCH_TOKEN][2] - 'a';
     image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len);
-    if (image == NULL || !strcmp(image, bs_table[hd_index]->filename))
-        goto out;  /* gone or identical */
+    if (image == NULL)
+        goto out;  /* gone */
+
+    /* Strip off blktap sub-type prefix */
+    bpath = strdup(vec[XS_WATCH_PATH]); 
+    if (bpath) {
+        char * offset = strrchr(bpath, '/');
+        if (offset) {
+            *offset = '\0';
+            if (pasprintf(&buf, "%s/type", bpath) == 0) {
+                char * drv = xs_read(xsh, XBT_NULL, buf, &len);
+                if (drv != NULL) {
+                    if (!strcmp(drv, "tap")) {
+                        offset = strchr(image, ':'); 
+                        if (offset) 
+                            memmove(image, offset+1, strlen(offset+1)+1 );
+                    }
+                    free(drv);
+                }
+                free(buf);
+            }
+        }
+        free(bpath);
+    }
+
+    if (!strcmp(image, bs_table[hd_index]->filename))
+        goto out;  /* identical */
 
     do_eject(0, vec[XS_WATCH_TOKEN]);
     bs_table[hd_index]->filename[0] = 0;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 6 lines · On Wednesday 30 January 2008 13:57:24 Pat Campbell wrote:

Currently I am not able to mount or boot from an HVM CDROM when it is configured for 'tap:aio' instead of 'file'.

disk=[ 'tap:aio:/var/lib/xen/images/sles10-sp2-fv/disk0,hda,w', '

       tap:aio:/home/iso/sles/SLES10.iso,hdc:cdrom,r', ]
Quoted 8 lines

With the attached patch I am able to boot from the CDROM and or mount it.

Patch changes xenstore.c:xenstore_process_event() to strip the tap subtype prefix from the image name.

Please apply to xen-unstable tip.

Please use a more readable coding style.

What you did is this:

if (a) {
        if (b) {
                if (c) {
                        /* do it */
                } else {
                        /* Alternative C */
                } 
        } else {
                /* Alternative B */
        }
} else {
        /* Alternative A */
}

return;

I suggest you to use this style:

if (!a) {
    /* Alternative A */
    return;
}
if (!b) {
    /* Alternative B */
    return;
}
if (!c) {
    /* Alternative C */
    return;
}

/* do it */
return;

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy