On Fri, Jul 1, 2011 at 5:55 AM, Fam Zheng <famc...@gmail.com> wrote: > + /* save to extents array */ > + if (!strcmp(type, "FLAT")) { > + /* FLAT extent */ > + char extent_path[PATH_MAX]; > + BlockDriverState *extent_file; > + BlockDriver *drv; > + VmdkExtent *extent; > + > + extent_file = bdrv_new(""); > + drv = bdrv_find_format("file"); > + if (!drv) { > + bdrv_delete(extent_file); > + return -EINVAL; > + } > + path_combine(extent_path, sizeof(extent_path), > + desc_file_path, fname); > + ret = bdrv_open(extent_file, extent_path, > + bs->open_flags | BDRV_O_RDWR | BDRV_O_NO_BACKING, drv);
Why are you forcing BDRV_O_RDWR and BDRV_O_NO_BACKING? It should be possible to open a vmdk file readonly. By the way, you can shortcut the bdrv_find_format()/bdrv_open() using bdrv_open_file(). That will simplify things a little. BDRV_O_NO_BACKING is not needed with the "file" driver (which doesn't support backing files). Stefan