Revision be028adc block.c

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)) {

Also available in: Unified diff