Revision be028adc

b/block.c
668 668
        open_flags |= BDRV_O_RDWR;
669 669
    }
670 670

  
671
    bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR);
671
    bs->read_only = !(open_flags & BDRV_O_RDWR);
672 672

  
673 673
    /* Open the image, either directly or using a protocol */
674 674
    if (drv->bdrv_file_open) {
......
808 808
        goto unlink_and_fail;
809 809
    }
810 810

  
811
    if (flags & BDRV_O_RDWR) {
812
        flags |= BDRV_O_ALLOW_RDWR;
813
    }
814

  
815
    bs->keep_read_only = !(flags & BDRV_O_ALLOW_RDWR);
816

  
811 817
    /* Open the image */
812 818
    ret = bdrv_open_common(bs, filename, flags, drv);
813 819
    if (ret < 0) {
......
837 843
            bdrv_close(bs);
838 844
            return ret;
839 845
        }
840
        if (bs->is_temporary) {
841
            bs->backing_hd->keep_read_only = !(flags & BDRV_O_RDWR);
842
        } else {
843
            /* base image inherits from "parent" */
844
            bs->backing_hd->keep_read_only = bs->keep_read_only;
845
        }
846 846
    }
847 847

  
848 848
    if (!bdrv_key_required(bs)) {
b/block.h
80 80
#define BDRV_O_COPY_ON_READ 0x0400 /* copy read backing sectors into image */
81 81
#define BDRV_O_INCOMING    0x0800  /* consistency hint for incoming migration */
82 82
#define BDRV_O_CHECK       0x1000  /* open solely for consistency check */
83
#define BDRV_O_ALLOW_RDWR  0x2000  /* allow reopen to change from r/o to r/w */
83 84

  
84 85
#define BDRV_O_CACHE_MASK  (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH)
85 86

  

Also available in: Unified diff