|
|
|
|
|
|
|
|
|
|
xen-devel
Re: [Xen-devel] [PATCH] make qemu handle drbd properly
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>
|
- Re: [Xen-devel] [PATCH] make qemu handle drbd properly,
Shriram Rajagopalan <=
|
|
|
|
|