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-devel

RE: [Xen-devel] Race condition in /etc/xen/scripts/block

To: "Bastian de Groot" <degroot@xxxxxxxxxxxxx>
Subject: RE: [Xen-devel] Race condition in /etc/xen/scripts/block
From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
Date: Fri, 16 Jul 2010 21:35:03 +1000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 16 Jul 2010 04:36:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <201007161328.39953.degroot@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <201007161159.10982.degroot@xxxxxxxxxxxxx> <AEC6C66638C05B468B556EA548C1A77D01A0A84D@trantor> <201007161328.39953.degroot@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acsk2iJsplt57mYFRe+gwsAuDxnOKQAAI0+Q
Thread-topic: [Xen-devel] Race condition in /etc/xen/scripts/block
> 
> Hi James,
> 
> thank you for your fast reply. The VMs are not PV domains, so the
problem
> seems to be pretty much the same as yours. I would be very glad if you
could
> publish the patch, so that I can test if it works for me.
> 

This is the patch I'm using for drbd. You can probably remove the drbd
bit if it doesn't interest you. If line wrapping makes the patch
unusable let me know and I'll attach it as a file. It's against 3.4.x
but is simple enough that you should be able to re-invent it for a later
or earlier version. Obviously if qemu isn't the thing that's having
problems then this patch won't help.

James


diff --git a/xenstore.c b/xenstore.c
index 9360771..bd0b5e0 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -317,6 +317,7 @@ void xenstore_parse_domain_config(int hvm_domid)
     unsigned int len, num, hd_index, pci_devid = 0;
     BlockDriverState *bs;
     BlockDriver *format;
+    int retry_count;

     /* paths controlled by untrustworthy guest, and values read from
them */
     char *danger_path;
@@ -428,6 +429,14 @@ void xenstore_parse_domain_config(int hvm_domid)
             params = newparams;
            format = &bdrv_raw;
         }
+        /* handle drbd mapping */
+        if (!strcmp(drv, "drbd")) {
+            char *newparams = malloc(17 + strlen(params) + 1);
+            sprintf(newparams, "/dev/drbd/by-res/%s", params);
+            free(params);
+            params = newparams;
+           format = &bdrv_raw;
+        }

 #if 0
        /* Phantom VBDs are disabled because the use of paths
@@ -500,8 +509,15 @@ void xenstore_parse_domain_config(int hvm_domid)
                }
            }
             pstrcpy(bs->filename, sizeof(bs->filename), params);
-            if (bdrv_open2(bs, params, BDRV_O_CACHE_WB /* snapshot and
write-back */, format) < 0)
-                fprintf(stderr, "qemu: could not open vbd '%s' or hard
disk image '%s' (drv '%s' format '%s')\n", buf, params, drv ? drv : "?",
format ? format->format_name : "0");
+            retry_count = 0;
+            while ((ret = bdrv_open2(bs, params, BDRV_O_CACHE_WB /*
snapshot and write-back */, format)) < 0)
+            {
+               if (retry_count++ > 10)
+                  break;
+               sleep(1);
+            }
+            if (ret < 0)
+               fprintf(stderr, "qemu: could not open vbd '%s' or hard
disk image '%s' (drv '%s' format '%s')\n", buf, params, drv ? drv : "?",
format ? format->format_name : "0");
         }

        drives_table[nb_drives].bdrv = bs;

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