Revision 7b272452 block.c

b/block.c
634 634
    bs->copy_on_read--;
635 635
}
636 636

  
637
static int bdrv_open_flags(BlockDriverState *bs, int flags)
638
{
639
    int open_flags = flags | BDRV_O_CACHE_WB;
640

  
641
    /*
642
     * Clear flags that are internal to the block layer before opening the
643
     * image.
644
     */
645
    open_flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
646

  
647
    /*
648
     * Snapshots should be writable.
649
     */
650
    if (bs->is_temporary) {
651
        open_flags |= BDRV_O_RDWR;
652
    }
653

  
654
    return open_flags;
655
}
656

  
637 657
/*
638 658
 * Common part for opening disk images and files
639 659
 */
......
665 685
    bs->opaque = g_malloc0(drv->instance_size);
666 686

  
667 687
    bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
668
    open_flags = flags | BDRV_O_CACHE_WB;
669

  
670
    /*
671
     * Clear flags that are internal to the block layer before opening the
672
     * image.
673
     */
674
    open_flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
675

  
676
    /*
677
     * Snapshots should be writable.
678
     */
679
    if (bs->is_temporary) {
680
        open_flags |= BDRV_O_RDWR;
681
    }
688
    open_flags = bdrv_open_flags(bs, flags);
682 689

  
683 690
    bs->read_only = !(open_flags & BDRV_O_RDWR);
684 691

  

Also available in: Unified diff