ia64/xen-unstable

changeset 17665:e3b13e1ecf6c

ioemu: Do not try to guess backing file format when using qcow vbds.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 15 15:10:05 2008 +0100 (2008-05-15)
parents 8d18e52a1b23
children f12724194ec6
files tools/ioemu/block.c tools/ioemu/xenstore.c
line diff
     1.1 --- a/tools/ioemu/block.c	Thu May 15 11:09:16 2008 +0100
     1.2 +++ b/tools/ioemu/block.c	Thu May 15 15:10:05 2008 +0100
     1.3 @@ -240,8 +240,28 @@ static int is_windows_drive(const char *
     1.4  }
     1.5  #endif
     1.6  
     1.7 +static int bdrv_invalid_protocol_open(BlockDriverState *bs,
     1.8 +				      const char *filename, int flags) {
     1.9 +    return -ENOENT;
    1.10 +}
    1.11 +
    1.12 +static BlockDriver bdrv_invalid_protocol = {
    1.13 +    "invalid_protocol",
    1.14 +    .bdrv_open = bdrv_invalid_protocol_open,
    1.15 +};
    1.16 +
    1.17  static BlockDriver *find_protocol(const char *filename)
    1.18  {
    1.19 +    /* Return values:
    1.20 +     *   &bdrv_xxx
    1.21 +     *      filename specifies protocol xxx
    1.22 +     *      caller should use that
    1.23 +     *   NULL                    filename does not specify any protocol
    1.24 +     *       caller may apply their own default
    1.25 +     *   &bdrv_invalid_protocol  filename speciies an unknown protocol
    1.26 +     *       caller should return -ENOENT; or may just try to open with
    1.27 +     *       that bdrv, which always fails that way.
    1.28 +     */
    1.29      BlockDriver *drv1;
    1.30      char protocol[128];
    1.31      int len;
    1.32 @@ -254,7 +274,7 @@ static BlockDriver *find_protocol(const 
    1.33  #endif
    1.34      p = strchr(filename, ':');
    1.35      if (!p)
    1.36 -        return NULL; /* do not ever guess raw, it is a security problem! */
    1.37 +        return NULL;
    1.38      len = p - filename;
    1.39      if (len > sizeof(protocol) - 1)
    1.40          len = sizeof(protocol) - 1;
    1.41 @@ -265,7 +285,7 @@ static BlockDriver *find_protocol(const 
    1.42              !strcmp(drv1->protocol_name, protocol))
    1.43              return drv1;
    1.44      }
    1.45 -    return NULL;
    1.46 +    return &bdrv_invalid_protocol;
    1.47  }
    1.48  
    1.49  /* XXX: force raw format if block or character device ? It would
    1.50 @@ -295,8 +315,8 @@ static BlockDriver *find_image_format(co
    1.51  #endif
    1.52      
    1.53      drv = find_protocol(filename);
    1.54 -    /* no need to test disk image formats for vvfat */
    1.55 -    if (drv == &bdrv_vvfat)
    1.56 +    /* no need to test disk image format if the filename told us */
    1.57 +    if (drv != NULL)
    1.58          return drv;
    1.59  
    1.60      ret = bdrv_file_open(&bs, filename, BDRV_O_RDONLY);
    1.61 @@ -390,7 +410,7 @@ int bdrv_open2(BlockDriverState *bs, con
    1.62      if (flags & BDRV_O_FILE) {
    1.63          drv = find_protocol(filename);
    1.64          if (!drv)
    1.65 -            return -ENOENT;
    1.66 +	    drv = &bdrv_raw;
    1.67      } else {
    1.68          if (!drv) {
    1.69              drv = find_image_format(filename);
    1.70 @@ -438,7 +458,7 @@ int bdrv_open2(BlockDriverState *bs, con
    1.71          }
    1.72          path_combine(backing_filename, sizeof(backing_filename),
    1.73                       filename, bs->backing_file);
    1.74 -        if (bdrv_open(bs->backing_hd, backing_filename, 0) < 0)
    1.75 +        if (bdrv_open2(bs->backing_hd, backing_filename, 0, &bdrv_raw) < 0)
    1.76              goto fail;
    1.77      }
    1.78  
     2.1 --- a/tools/ioemu/xenstore.c	Thu May 15 11:09:16 2008 +0100
     2.2 +++ b/tools/ioemu/xenstore.c	Thu May 15 15:10:05 2008 +0100
     2.3 @@ -260,6 +260,8 @@ void xenstore_parse_domain_config(int hv
     2.4  		    /* autoguess qcow vs qcow2 */
     2.5  		} else if (!strcmp(drv,"file") || !strcmp(drv,"phy")) {
     2.6  		    format = &bdrv_raw;
     2.7 +		} else if (!strcmp(drv,"phy")) {
     2.8 +		    format = &bdrv_raw;
     2.9  		} else {
    2.10  		    format = bdrv_find_format(drv);
    2.11  		    if (!format) {
    2.12 @@ -269,7 +271,7 @@ void xenstore_parse_domain_config(int hv
    2.13  		}
    2.14  	    }
    2.15              if (bdrv_open2(bs, params, 0 /* snapshot */, format) < 0)
    2.16 -                fprintf(stderr, "qemu: could not open vbd '%s' or hard disk image '%s' (drv '%s')\n", buf, params, drv ? drv : "?");
    2.17 +                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");
    2.18          }
    2.19      }
    2.20