diff mbox

[v2,7/7] block: after creating a live snapshot, make old image read-only

Message ID 0a92f2462c53f5da2c4038c6c5cbf2000b3ef14c.1348589526.git.jcody@redhat.com
State New
Headers show

Commit Message

Jeff Cody Sept. 25, 2012, 4:29 p.m. UTC
Currently, after a live snapshot of a drive, the image that has
been 'demoted' to be below the new active layer remains r/w.
This patch reopens it read-only.

Note that we do not check for error on the reopen(), because we
will not abort the snapshots if the reopen fails.

This patch depends on the bdrv_reopen() series.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 blockdev.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kevin Wolf Sept. 26, 2012, 2:20 p.m. UTC | #1
Am 25.09.2012 18:29, schrieb Jeff Cody:
> Currently, after a live snapshot of a drive, the image that has
> been 'demoted' to be below the new active layer remains r/w.
> This patch reopens it read-only.
> 
> Note that we do not check for error on the reopen(), because we
> will not abort the snapshots if the reopen fails.
> 
> This patch depends on the bdrv_reopen() series.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>

This should be independent from the live commit patches, so I already
applied this one to the block branch.

Kevin
Jeff Cody Sept. 26, 2012, 2:21 p.m. UTC | #2
On 09/26/2012 10:20 AM, Kevin Wolf wrote:
> Am 25.09.2012 18:29, schrieb Jeff Cody:
>> Currently, after a live snapshot of a drive, the image that has
>> been 'demoted' to be below the new active layer remains r/w.
>> This patch reopens it read-only.
>>
>> Note that we do not check for error on the reopen(), because we
>> will not abort the snapshots if the reopen fails.
>>
>> This patch depends on the bdrv_reopen() series.
>>
>> Signed-off-by: Jeff Cody <jcody@redhat.com>
> 
> This should be independent from the live commit patches, so I already
> applied this one to the block branch.
> 
> Kevin
> 

Thanks
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 6f1080c..fa7efae 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -803,6 +803,11 @@  void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
     QSIMPLEQ_FOREACH(states, &snap_bdrv_states, entry) {
         /* This removes our old bs from the bdrv_states, and adds the new bs */
         bdrv_append(states->new_bs, states->old_bs);
+        /* We don't need (or want) to use the transactional
+         * bdrv_reopen_multiple() across all the entries at once, because we
+         * don't want to abort all of them if one of them fails the reopen */
+        bdrv_reopen(states->new_bs, states->new_bs->open_flags & ~BDRV_O_RDWR,
+                    NULL);
     }
 
     /* success */