Skip to content

Commit 33c6cae

Browse files
author
Anthony Liguori
committed
Merge remote-tracking branch 'kwolf/for-anthony' into staging
# By Max Reitz (30) and others # Via Kevin Wolf * kwolf/for-anthony: (61 commits) qemu-iotests: Add test for inactive L2 overlap qemu-io: Let "open" pass options to block driver vmdk: Fix vmdk_parse_extents blockdev: blockdev_init() error conversion blockdev: Don't disable COR automatically with blockdev-add blockdev: Remove 'media' parameter from blockdev_init() qemu-iotests: Check autodel behaviour for device_del blockdev: Remove IF_* check for read-only blockdev_init blockdev: Move virtio-blk device creation to drive_init blockdev: Move bus/unit/index processing to drive_init blockdev: Move parsing of 'boot' option to drive_init blockdev: Moving parsing of geometry options to drive_init blockdev: Move parsing of 'if' option to drive_init blockdev: Move parsing of 'media' option to drive_init blockdev: Pass QDict to blockdev_init() blockdev: Separate ID generation from DriveInfo creation blockdev: 'blockdev-add' QMP command blockdev: Introduce DriveInfo.enable_auto_del qapi-types/visit.py: Inheritance for structs qapi-types/visit.py: Pass whole expr dict for structs ... Message-id: [email protected] Signed-off-by: Anthony Liguori <[email protected]>
2 parents 39c153b + 34eeb82 commit 33c6cae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2109
-516
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ clean:
246246
rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp)
247247
rm -rf qapi-generated
248248
rm -rf qga/qapi-generated
249-
$(MAKE) -C tests/tcg clean
250249
for d in $(ALL_SUBDIRS); do \
251250
if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
252251
rm -f $$d/qemu-options.def; \

block.c

+48-5
Original file line numberDiff line numberDiff line change
@@ -769,13 +769,22 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
769769
bs->read_only = !(open_flags & BDRV_O_RDWR);
770770

771771
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
772-
error_setg(errp, "Driver '%s' is not whitelisted", drv->format_name);
772+
error_setg(errp,
773+
!bs->read_only && bdrv_is_whitelisted(drv, true)
774+
? "Driver '%s' can only be used for read-only devices"
775+
: "Driver '%s' is not whitelisted",
776+
drv->format_name);
773777
return -ENOTSUP;
774778
}
775779

776780
assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
777-
if (!bs->read_only && (flags & BDRV_O_COPY_ON_READ)) {
778-
bdrv_enable_copy_on_read(bs);
781+
if (flags & BDRV_O_COPY_ON_READ) {
782+
if (!bs->read_only) {
783+
bdrv_enable_copy_on_read(bs);
784+
} else {
785+
error_setg(errp, "Can't use copy-on-read on read-only device");
786+
return -EINVAL;
787+
}
779788
}
780789

781790
if (filename != NULL) {
@@ -881,7 +890,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
881890
/* Find the right block driver */
882891
drvname = qdict_get_try_str(options, "driver");
883892
if (drvname) {
884-
drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR));
893+
drv = bdrv_find_format(drvname);
885894
if (!drv) {
886895
error_setg(errp, "Unknown driver '%s'", drvname);
887896
}
@@ -1123,7 +1132,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
11231132
/* Find the right image format driver */
11241133
drvname = qdict_get_try_str(options, "driver");
11251134
if (drvname) {
1126-
drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR));
1135+
drv = bdrv_find_format(drvname);
11271136
qdict_del(options, "driver");
11281137
}
11291138

@@ -3147,6 +3156,12 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
31473156
return ret;
31483157
}
31493158

3159+
if (ret & BDRV_BLOCK_RAW) {
3160+
assert(ret & BDRV_BLOCK_OFFSET_VALID);
3161+
return bdrv_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
3162+
*pnum, pnum);
3163+
}
3164+
31503165
if (!(ret & BDRV_BLOCK_DATA)) {
31513166
if (bdrv_has_zero_init(bs)) {
31523167
ret |= BDRV_BLOCK_ZERO;
@@ -3322,6 +3337,15 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
33223337
return drv->bdrv_get_info(bs, bdi);
33233338
}
33243339

3340+
ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs)
3341+
{
3342+
BlockDriver *drv = bs->drv;
3343+
if (drv && drv->bdrv_get_specific_info) {
3344+
return drv->bdrv_get_specific_info(bs);
3345+
}
3346+
return NULL;
3347+
}
3348+
33253349
int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
33263350
int64_t pos, int size)
33273351
{
@@ -4632,3 +4656,22 @@ int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *options)
46324656
}
46334657
return bs->drv->bdrv_amend_options(bs, options);
46344658
}
4659+
4660+
ExtSnapshotPerm bdrv_check_ext_snapshot(BlockDriverState *bs)
4661+
{
4662+
if (bs->drv->bdrv_check_ext_snapshot) {
4663+
return bs->drv->bdrv_check_ext_snapshot(bs);
4664+
}
4665+
4666+
if (bs->file && bs->file->drv && bs->file->drv->bdrv_check_ext_snapshot) {
4667+
return bs->file->drv->bdrv_check_ext_snapshot(bs);
4668+
}
4669+
4670+
/* external snapshots are allowed by default */
4671+
return EXT_SNAPSHOT_ALLOWED;
4672+
}
4673+
4674+
ExtSnapshotPerm bdrv_check_ext_snapshot_forbidden(BlockDriverState *bs)
4675+
{
4676+
return EXT_SNAPSHOT_FORBIDDEN;
4677+
}

block/backup.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ static void backup_iostatus_reset(BlockJob *job)
202202
bdrv_iostatus_reset(s->target);
203203
}
204204

205-
static const BlockJobType backup_job_type = {
205+
static const BlockJobDriver backup_job_driver = {
206206
.instance_size = sizeof(BackupBlockJob),
207-
.job_type = "backup",
207+
.job_type = BLOCK_JOB_TYPE_BACKUP,
208208
.set_speed = backup_set_speed,
209209
.iostatus_reset = backup_iostatus_reset,
210210
};
@@ -370,7 +370,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
370370
return;
371371
}
372372

373-
BackupBlockJob *job = block_job_create(&backup_job_type, bs, speed,
373+
BackupBlockJob *job = block_job_create(&backup_job_driver, bs, speed,
374374
cb, opaque, errp);
375375
if (!job) {
376376
return;

block/blkdebug.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
362362
opts = qemu_opts_create_nofail(&runtime_opts);
363363
qemu_opts_absorb_qdict(opts, options, &local_err);
364364
if (error_is_set(&local_err)) {
365-
qerror_report_err(local_err);
366-
error_free(local_err);
365+
error_propagate(errp, local_err);
367366
ret = -EINVAL;
368367
goto fail;
369368
}
@@ -373,6 +372,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
373372
if (config) {
374373
ret = read_config(s, config);
375374
if (ret < 0) {
375+
error_setg_errno(errp, -ret, "Could not read blkdebug config file");
376376
goto fail;
377377
}
378378
}
@@ -383,14 +383,14 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
383383
/* Open the backing file */
384384
filename = qemu_opt_get(opts, "x-image");
385385
if (filename == NULL) {
386+
error_setg(errp, "Could not retrieve image file name");
386387
ret = -EINVAL;
387388
goto fail;
388389
}
389390

390391
ret = bdrv_file_open(&bs->file, filename, NULL, flags, &local_err);
391392
if (ret < 0) {
392-
qerror_report_err(local_err);
393-
error_free(local_err);
393+
error_propagate(errp, local_err);
394394
goto fail;
395395
}
396396

block/blkverify.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -128,38 +128,37 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
128128
opts = qemu_opts_create_nofail(&runtime_opts);
129129
qemu_opts_absorb_qdict(opts, options, &local_err);
130130
if (error_is_set(&local_err)) {
131-
qerror_report_err(local_err);
132-
error_free(local_err);
131+
error_propagate(errp, local_err);
133132
ret = -EINVAL;
134133
goto fail;
135134
}
136135

137136
/* Parse the raw image filename */
138137
raw = qemu_opt_get(opts, "x-raw");
139138
if (raw == NULL) {
139+
error_setg(errp, "Could not retrieve raw image filename");
140140
ret = -EINVAL;
141141
goto fail;
142142
}
143143

144144
ret = bdrv_file_open(&bs->file, raw, NULL, flags, &local_err);
145145
if (ret < 0) {
146-
qerror_report_err(local_err);
147-
error_free(local_err);
146+
error_propagate(errp, local_err);
148147
goto fail;
149148
}
150149

151150
/* Open the test file */
152151
filename = qemu_opt_get(opts, "x-image");
153152
if (filename == NULL) {
153+
error_setg(errp, "Could not retrieve test image filename");
154154
ret = -EINVAL;
155155
goto fail;
156156
}
157157

158158
s->test_file = bdrv_new("");
159159
ret = bdrv_open(s->test_file, filename, NULL, flags, NULL, &local_err);
160160
if (ret < 0) {
161-
qerror_report_err(local_err);
162-
error_free(local_err);
161+
error_propagate(errp, local_err);
163162
bdrv_unref(s->test_file);
164163
s->test_file = NULL;
165164
goto fail;
@@ -417,6 +416,8 @@ static BlockDriver bdrv_blkverify = {
417416
.bdrv_aio_readv = blkverify_aio_readv,
418417
.bdrv_aio_writev = blkverify_aio_writev,
419418
.bdrv_aio_flush = blkverify_aio_flush,
419+
420+
.bdrv_check_ext_snapshot = bdrv_check_ext_snapshot_forbidden,
420421
};
421422

422423
static void bdrv_blkverify_init(void)

block/commit.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp)
173173
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
174174
}
175175

176-
static const BlockJobType commit_job_type = {
176+
static const BlockJobDriver commit_job_driver = {
177177
.instance_size = sizeof(CommitBlockJob),
178-
.job_type = "commit",
178+
.job_type = BLOCK_JOB_TYPE_COMMIT,
179179
.set_speed = commit_set_speed,
180180
};
181181

@@ -238,7 +238,7 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
238238
}
239239

240240

241-
s = block_job_create(&commit_job_type, bs, speed, cb, opaque, errp);
241+
s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
242242
if (!s) {
243243
return;
244244
}

block/mirror.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ static void mirror_complete(BlockJob *job, Error **errp)
525525
block_job_resume(job);
526526
}
527527

528-
static const BlockJobType mirror_job_type = {
528+
static const BlockJobDriver mirror_job_driver = {
529529
.instance_size = sizeof(MirrorBlockJob),
530-
.job_type = "mirror",
530+
.job_type = BLOCK_JOB_TYPE_MIRROR,
531531
.set_speed = mirror_set_speed,
532532
.iostatus_reset= mirror_iostatus_reset,
533533
.complete = mirror_complete,
@@ -563,7 +563,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
563563
return;
564564
}
565565

566-
s = block_job_create(&mirror_job_type, bs, speed, cb, opaque, errp);
566+
s = block_job_create(&mirror_job_driver, bs, speed, cb, opaque, errp);
567567
if (!s) {
568568
return;
569569
}

0 commit comments

Comments
 (0)