xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bastian de Groot <degroot@univention.de>
To: James Harper <james.harper@bendigoit.com.au>
Cc: xen-devel@lists.xensource.com
Subject: Re: Race condition in /etc/xen/scripts/block
Date: Tue, 20 Jul 2010 13:56:22 +0200	[thread overview]
Message-ID: <201007201356.22713.degroot@univention.de> (raw)
In-Reply-To: <AEC6C66638C05B468B556EA548C1A77D01A0A84E@trantor>

Hi James,

thanks again for the fast reply. I've tested the patch over the last few days 
and it seems to work just fine. 

As you said, it's not the most elegant way, but it looks like there is no 
other simple way around this problem.

Does anyone know whether xen 4.x also has this bug?

Bastian

Am Freitag 16 Juli 2010 13:35:03 schrieben Sie:
> 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;

      reply	other threads:[~2010-07-20 11:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16  9:59 Race condition in /etc/xen/scripts/block Bastian de Groot
2010-07-16 10:07 ` James Harper
2010-07-16 11:28   ` Bastian de Groot
2010-07-16 11:35     ` James Harper
2010-07-20 11:56       ` Bastian de Groot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201007201356.22713.degroot@univention.de \
    --to=degroot@univention.de \
    --cc=james.harper@bendigoit.com.au \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).