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

[Xen-devel] [PATCH] make qemu handle drbd properly

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] make qemu handle drbd properly
From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
Date: Thu, 27 Jan 2011 15:43:56 +1100
Delivery-date: Wed, 26 Jan 2011 20:44:41 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acu93M69hrwjXAfcQG+0NjGopOq6NQ==
Thread-topic: [PATCH] make qemu handle drbd properly
This attached patch allows qemu to accept a drbd: prefix and interpret
it as a drbd resource. It then searches for it in /dev/drbd/by-res/
(which must be mapped via udev). It's against 4.0-testing.

Also, the block scripts make the drbd resource primary but don't want
for it to actually become available. A secondary drbd resource returns
EMEDIUMTYPE so if we get that result, wait half a second and retry, up
to a total of 5 retries. Fixing this in the block scripts might be
better but I can't see how to do it cleanly. 

James


diff --git a/xenstore.c b/xenstore.c
index 13b8d57..f6e2170 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -413,6 +413,9 @@ void xenstore_parse_domain_config(int hvm_domid)
     char *danger_buf = NULL;
     char *danger_type = NULL;

+    int retries = 1; /* number of attempts to open the block device -
drbd can take a second to become available */
+    int status;
+
     for(i = 0; i < MAX_DRIVES + 1; i++)
         media_filename[i] = NULL;

@@ -519,6 +522,14 @@ void xenstore_parse_domain_config(int hvm_domid)
            format = &bdrv_raw;
         }

+        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;
+            retries = 5;
+        }
 #if 0
        /* Phantom VBDs are disabled because the use of paths
         * from guest-controlled areas in xenstore is unsafe.
@@ -617,7 +628,14 @@ void xenstore_parse_domain_config(int hvm_domid)

             fprintf(stderr, "Using file %s in read-%s mode\n",
bs->filename, is_readonly ? "only" : "write");

-            if (bdrv_open2(bs, params, flags, format) < 0)
+            do {
+                int status = bdrv_open2(bs, params, flags, format);
+                if (status != -EMEDIUMTYPE)
+                    break;
+                usleep(500000); /* 500ms */
+                retries--;
+            } while (retries);
+            if (status < 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 : "
         }


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

<Prev in Thread] Current Thread [Next in Thread>