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] [PATCH] make qemu handle drbd properly

To: James Harper <james.harper@xxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] make qemu handle drbd properly
From: Shriram Rajagopalan <rshriram@xxxxxxxxx>
Date: Sat, 25 Jun 2011 12:47:09 -0400
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sat, 25 Jun 2011 09:48:52 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=v79xIPKtLDSMEVl+fnmFyRk6xrurn376Jd0BHe8AO6w=; b=glNd0gFCreMtrAWXDBuRByceHLyqoOMd/T6FlkmQg2ZCDeLgmtj3P82KUUpOJg6iZL 4BFnvvLEyM5PfQDImhhfZQnWEVHTOzoD1VOdpSJsw1alng7ml4kcSOdOASJXuRWLLaz+ AE214xHUnwAnP8MY5jp9TQsp1kfiuMf4avKFo=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=u9DLKIl/6HK2CI98slUEkNnLj7WBvJqxLkIPqrY1nLgu6nuSWYHJBxOwaZ268mpR1H IOF8kWECMKnd1JxisIabN1oIFNQCGNLOLcF5bIgkpFHr0eCgtPSICfWQKKqvXAJg9SpO DAkeQ+QDkc8XWXsdWkJXjar9nOCAHKDl/LPyk=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <AEC6C66638C05B468B556EA548C1A77D01BB92B8@trantor>
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: <Acu93M69hrwjXAfcQG+0NjGopOq6NQ==> <AEC6C66638C05B468B556EA548C1A77D01BB92B8@trantor>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Wed, Jan 26, 2011 at 11:43 PM, James Harper <james.harper@xxxxxxxxxxxxxxxx> wrote:
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

Sorry to dig up an old thread. This patch doesnt seem to be in any of the
qemu-xen-*, xen-*-testing or xen-unstable trees. Any reason why?

shriram

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>