Commit 87a5debd authored by Thibaut LAURENT's avatar Thibaut LAURENT Committed by Kevin Wolf
Browse files

block: Disable BDRV_O_COPY_ON_READ for the backing file



Since commit 0ebd24e0,
bdrv_open_common will throw an error when trying to open a file
read-only with the BDRV_O_COPY_ON_READ flag set.
Although BDRV_O_RDWR is unset for the backing files,
BDRV_O_COPY_ON_READ is still passed on if copy-on-read was requested
for the drive. Let's unset this flag too before opening the backing
file, or bdrv_open_common will fail.

Signed-off-by: default avatarThibaut LAURENT <thibaut.laurent@gmail.com>
Reviewed-by: default avatarBenoit Canet <benoit@irqsave.net>
Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 8464b273
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -999,7 +999,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
    }

    /* backing files always opened read-only */
    back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
    back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT |
                                    BDRV_O_COPY_ON_READ);

    ret = bdrv_open(bs->backing_hd,
                    *backing_filename ? backing_filename : NULL, options,