[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: James Harper <james.harper@xxxxxxxxxxxxxxxx>
  • 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
  • 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=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.