stream.c (a170a91fd3eab6155da39e740381867e80bcc93e) | stream.c (12fa4af61fb2a08b156134c3b6717534c637c995) |
---|---|
1/* 2 * Image streaming 3 * 4 * Copyright IBM, Corp. 2011 5 * 6 * Authors: 7 * Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> 8 * --- 54 unchanged lines hidden (view full) --- 63} StreamCompleteData; 64 65static void stream_complete(BlockJob *job, void *opaque) 66{ 67 StreamBlockJob *s = container_of(job, StreamBlockJob, common); 68 StreamCompleteData *data = opaque; 69 BlockDriverState *bs = blk_bs(job->blk); 70 BlockDriverState *base = s->base; | 1/* 2 * Image streaming 3 * 4 * Copyright IBM, Corp. 2011 5 * 6 * Authors: 7 * Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> 8 * --- 54 unchanged lines hidden (view full) --- 63} StreamCompleteData; 64 65static void stream_complete(BlockJob *job, void *opaque) 66{ 67 StreamBlockJob *s = container_of(job, StreamBlockJob, common); 68 StreamCompleteData *data = opaque; 69 BlockDriverState *bs = blk_bs(job->blk); 70 BlockDriverState *base = s->base; |
71 Error *local_err = NULL; |
|
71 72 if (!block_job_is_cancelled(&s->common) && data->reached_end && 73 data->ret == 0) { 74 const char *base_id = NULL, *base_fmt = NULL; 75 if (base) { 76 base_id = s->backing_file_str; 77 if (base->drv) { 78 base_fmt = base->drv->format_name; 79 } 80 } 81 data->ret = bdrv_change_backing_file(bs, base_id, base_fmt); | 72 73 if (!block_job_is_cancelled(&s->common) && data->reached_end && 74 data->ret == 0) { 75 const char *base_id = NULL, *base_fmt = NULL; 76 if (base) { 77 base_id = s->backing_file_str; 78 if (base->drv) { 79 base_fmt = base->drv->format_name; 80 } 81 } 82 data->ret = bdrv_change_backing_file(bs, base_id, base_fmt); |
82 bdrv_set_backing_hd(bs, base); | 83 bdrv_set_backing_hd(bs, base, &local_err); 84 if (local_err) { 85 error_report_err(local_err); 86 data->ret = -EPERM; 87 goto out; 88 } |
83 } 84 | 89 } 90 |
91out: |
|
85 /* Reopen the image back in read-only mode if necessary */ 86 if (s->bs_flags != bdrv_get_flags(bs)) { 87 /* Give up write permissions before making it read-only */ 88 blk_set_perm(job->blk, 0, BLK_PERM_ALL, &error_abort); 89 bdrv_reopen(bs, s->bs_flags, NULL); 90 } 91 92 g_free(s->backing_file_str); --- 186 unchanged lines hidden --- | 92 /* Reopen the image back in read-only mode if necessary */ 93 if (s->bs_flags != bdrv_get_flags(bs)) { 94 /* Give up write permissions before making it read-only */ 95 blk_set_perm(job->blk, 0, BLK_PERM_ALL, &error_abort); 96 bdrv_reopen(bs, s->bs_flags, NULL); 97 } 98 99 g_free(s->backing_file_str); --- 186 unchanged lines hidden --- |