Skip to content

Commit 97629cc

Browse files
committed
Merge in changes from QEMU v2.1.3 (that happened since v2.1.2).
Merge from master v2.1.3 tag.
2 parents d5e92d3 + c2b0926 commit 97629cc

Some content is hidden

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

100 files changed

+1211
-270
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.2
1+
2.1.3

audio/audio_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
191191
audio_detach_capture (hw);
192192
#endif
193193
QLIST_REMOVE (hw, entries);
194+
glue (hw->pcm_ops->fini_, TYPE) (hw);
194195
glue (s->nb_hw_voices_, TYPE) += 1;
195196
glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
196-
glue (hw->pcm_ops->fini_, TYPE) (hw);
197197
g_free (hw);
198198
*hwp = NULL;
199199
}

block-migration.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
652652
{
653653
int ret;
654654
int64_t last_ftell = qemu_ftell(f);
655+
int64_t delta_ftell;
655656

656657
DPRINTF("Enter save live iterate submitted %d transferred %d\n",
657658
block_mig_state.submitted, block_mig_state.transferred);
@@ -701,7 +702,14 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
701702
}
702703

703704
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
704-
return qemu_ftell(f) - last_ftell;
705+
delta_ftell = qemu_ftell(f) - last_ftell;
706+
if (delta_ftell > 0) {
707+
return 1;
708+
} else if (delta_ftell < 0) {
709+
return -1;
710+
} else {
711+
return 0;
712+
}
705713
}
706714

707715
/* Called with iothread lock taken. */
@@ -756,8 +764,8 @@ static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
756764
block_mig_state.read_done * BLOCK_SIZE;
757765

758766
/* Report at least one block pending during bulk phase */
759-
if (pending == 0 && !block_mig_state.bulk_completed) {
760-
pending = BLOCK_SIZE;
767+
if (pending <= max_size && !block_mig_state.bulk_completed) {
768+
pending = max_size + BLOCK_SIZE;
761769
}
762770
blk_mig_unlock();
763771
qemu_mutex_unlock_iothread();

block.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ BlockDriver *bdrv_find_protocol(const char *filename,
633633
}
634634

635635
if (!path_has_protocol(filename) || !allow_protocol_prefix) {
636-
return bdrv_find_format("file");
636+
return &bdrv_file;
637637
}
638638

639639
p = strchr(filename, ':');
@@ -662,12 +662,7 @@ static int find_image_format(BlockDriverState *bs, const char *filename,
662662

663663
/* Return the raw BlockDriver * to scsi-generic devices or empty drives */
664664
if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
665-
drv = bdrv_find_format("raw");
666-
if (!drv) {
667-
error_setg(errp, "Could not find raw image format");
668-
ret = -ENOENT;
669-
}
670-
*pdrv = drv;
665+
*pdrv = &bdrv_raw;
671666
return ret;
672667
}
673668

@@ -1182,7 +1177,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
11821177
{
11831178
char *backing_filename = g_malloc0(PATH_MAX);
11841179
int ret = 0;
1185-
BlockDriver *back_drv = NULL;
11861180
BlockDriverState *backing_hd;
11871181
Error *local_err = NULL;
11881182

@@ -1215,14 +1209,14 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
12151209

12161210
backing_hd = bdrv_new("", errp);
12171211

1218-
if (bs->backing_format[0] != '\0') {
1219-
back_drv = bdrv_find_format(bs->backing_format);
1212+
if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) {
1213+
qdict_put(options, "driver", qstring_from_str(bs->backing_format));
12201214
}
12211215

12221216
assert(bs->backing_hd == NULL);
12231217
ret = bdrv_open(&backing_hd,
12241218
*backing_filename ? backing_filename : NULL, NULL, options,
1225-
bdrv_backing_flags(bs->open_flags), back_drv, &local_err);
1219+
bdrv_backing_flags(bs->open_flags), NULL, &local_err);
12261220
if (ret < 0) {
12271221
bdrv_unref(backing_hd);
12281222
backing_hd = NULL;
@@ -1296,7 +1290,6 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
12961290
/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */
12971291
char *tmp_filename = g_malloc0(PATH_MAX + 1);
12981292
int64_t total_size;
1299-
BlockDriver *bdrv_qcow2;
13001293
QemuOpts *opts = NULL;
13011294
QDict *snapshot_options;
13021295
BlockDriverState *bs_snapshot;
@@ -1322,11 +1315,10 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
13221315
goto out;
13231316
}
13241317

1325-
bdrv_qcow2 = bdrv_find_format("qcow2");
1326-
opts = qemu_opts_create(bdrv_qcow2->create_opts, NULL, 0,
1318+
opts = qemu_opts_create(bdrv_qcow2.create_opts, NULL, 0,
13271319
&error_abort);
13281320
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, total_size);
1329-
ret = bdrv_create(bdrv_qcow2, tmp_filename, opts, &local_err);
1321+
ret = bdrv_create(&bdrv_qcow2, tmp_filename, opts, &local_err);
13301322
qemu_opts_del(opts);
13311323
if (ret < 0) {
13321324
error_setg_errno(errp, -ret, "Could not create temporary overlay "
@@ -1346,7 +1338,7 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
13461338
bs_snapshot = bdrv_new("", &error_abort);
13471339

13481340
ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options,
1349-
flags, bdrv_qcow2, &local_err);
1341+
flags, &bdrv_qcow2, &local_err);
13501342
if (ret < 0) {
13511343
error_propagate(errp, local_err);
13521344
goto out;
@@ -5535,6 +5527,18 @@ void bdrv_img_create(const char *filename, const char *fmt,
55355527
return;
55365528
}
55375529

5530+
if (!drv->create_opts) {
5531+
error_setg(errp, "Format driver '%s' does not support image creation",
5532+
drv->format_name);
5533+
return;
5534+
}
5535+
5536+
if (!proto_drv->create_opts) {
5537+
error_setg(errp, "Protocol driver '%s' does not support image creation",
5538+
proto_drv->format_name);
5539+
return;
5540+
}
5541+
55385542
create_opts = qemu_opts_append(create_opts, drv->create_opts);
55395543
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
55405544

block/blkdebug.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,25 @@ static BlockDriverAIOCB *blkdebug_aio_writev(BlockDriverState *bs,
526526
return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
527527
}
528528

529+
static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
530+
BlockDriverCompletionFunc *cb, void *opaque)
531+
{
532+
BDRVBlkdebugState *s = bs->opaque;
533+
BlkdebugRule *rule = NULL;
534+
535+
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
536+
if (rule->options.inject.sector == -1) {
537+
break;
538+
}
539+
}
540+
541+
if (rule && rule->options.inject.error) {
542+
return inject_error(bs, cb, opaque, rule);
543+
}
544+
545+
return bdrv_aio_flush(bs->file, cb, opaque);
546+
}
547+
529548

530549
static void blkdebug_close(BlockDriverState *bs)
531550
{
@@ -703,6 +722,7 @@ static BlockDriver bdrv_blkdebug = {
703722

704723
.bdrv_aio_readv = blkdebug_aio_readv,
705724
.bdrv_aio_writev = blkdebug_aio_writev,
725+
.bdrv_aio_flush = blkdebug_aio_flush,
706726

707727
.bdrv_debug_event = blkdebug_debug_event,
708728
.bdrv_debug_breakpoint = blkdebug_debug_breakpoint,

block/nfs.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,19 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
401401
return 0;
402402
}
403403

404+
static QemuOptsList nfs_create_opts = {
405+
.name = "nfs-create-opts",
406+
.head = QTAILQ_HEAD_INITIALIZER(nfs_create_opts.head),
407+
.desc = {
408+
{
409+
.name = BLOCK_OPT_SIZE,
410+
.type = QEMU_OPT_SIZE,
411+
.help = "Virtual disk size"
412+
},
413+
{ /* end of list */ }
414+
}
415+
};
416+
404417
static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)
405418
{
406419
int ret = 0;
@@ -461,6 +474,8 @@ static BlockDriver bdrv_nfs = {
461474

462475
.instance_size = sizeof(NFSClient),
463476
.bdrv_needs_filename = true,
477+
.create_opts = &nfs_create_opts,
478+
464479
.bdrv_has_zero_init = nfs_has_zero_init,
465480
.bdrv_get_allocated_file_size = nfs_get_allocated_file_size,
466481
.bdrv_truncate = nfs_file_truncate,

block/qcow2-cluster.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,14 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
158158
int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index)
159159
{
160160
BDRVQcowState *s = bs->opaque;
161-
uint64_t buf[L1_ENTRIES_PER_SECTOR];
161+
uint64_t buf[L1_ENTRIES_PER_SECTOR] = { 0 };
162162
int l1_start_index;
163163
int i, ret;
164164

165165
l1_start_index = l1_index & ~(L1_ENTRIES_PER_SECTOR - 1);
166-
for (i = 0; i < L1_ENTRIES_PER_SECTOR; i++) {
166+
for (i = 0; i < L1_ENTRIES_PER_SECTOR && l1_start_index + i < s->l1_size;
167+
i++)
168+
{
167169
buf[i] = cpu_to_be64(s->l1_table[l1_start_index + i]);
168170
}
169171

@@ -1200,7 +1202,7 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
12001202

12011203
again:
12021204
start = offset;
1203-
remaining = *num << BDRV_SECTOR_BITS;
1205+
remaining = (uint64_t)*num << BDRV_SECTOR_BITS;
12041206
cluster_offset = 0;
12051207
*host_offset = 0;
12061208
cur_bytes = 0;

block/qcow2.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
114114
#ifdef DEBUG_EXT
115115
printf("ext.magic = 0x%x\n", ext.magic);
116116
#endif
117-
if (ext.len > end_offset - offset) {
117+
if (offset > end_offset || ext.len > end_offset - offset) {
118118
error_setg(errp, "Header extension too large");
119119
return -EINVAL;
120120
}
@@ -1275,10 +1275,23 @@ static void qcow2_close(BlockDriverState *bs)
12751275
s->l1_table = NULL;
12761276

12771277
if (!(bs->open_flags & BDRV_O_INCOMING)) {
1278-
qcow2_cache_flush(bs, s->l2_table_cache);
1279-
qcow2_cache_flush(bs, s->refcount_block_cache);
1278+
int ret1, ret2;
12801279

1281-
qcow2_mark_clean(bs);
1280+
ret1 = qcow2_cache_flush(bs, s->l2_table_cache);
1281+
ret2 = qcow2_cache_flush(bs, s->refcount_block_cache);
1282+
1283+
if (ret1) {
1284+
error_report("Failed to flush the L2 table cache: %s",
1285+
strerror(-ret1));
1286+
}
1287+
if (ret2) {
1288+
error_report("Failed to flush the refcount block cache: %s",
1289+
strerror(-ret2));
1290+
}
1291+
1292+
if (!ret1 && !ret2) {
1293+
qcow2_mark_clean(bs);
1294+
}
12821295
}
12831296

12841297
qcow2_cache_destroy(bs, s->l2_table_cache);
@@ -1712,10 +1725,9 @@ static int qcow2_create2(const char *filename, int64_t total_size,
17121725
* refcount of the cluster that is occupied by the header and the refcount
17131726
* table)
17141727
*/
1715-
BlockDriver* drv = bdrv_find_format("qcow2");
1716-
assert(drv != NULL);
17171728
ret = bdrv_open(&bs, filename, NULL, NULL,
1718-
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv, &local_err);
1729+
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,
1730+
&bdrv_qcow2, &local_err);
17191731
if (ret < 0) {
17201732
error_propagate(errp, local_err);
17211733
goto out;
@@ -1767,7 +1779,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
17671779
/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
17681780
ret = bdrv_open(&bs, filename, NULL, NULL,
17691781
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING,
1770-
drv, &local_err);
1782+
&bdrv_qcow2, &local_err);
17711783
if (local_err) {
17721784
error_propagate(errp, local_err);
17731785
goto out;
@@ -1948,8 +1960,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num,
19481960
sector based I/Os */
19491961
cluster_offset = bdrv_getlength(bs->file);
19501962
cluster_offset = (cluster_offset + 511) & ~511;
1951-
bdrv_truncate(bs->file, cluster_offset);
1952-
return 0;
1963+
return bdrv_truncate(bs->file, cluster_offset);
19531964
}
19541965

19551966
if (nb_sectors != s->cluster_sectors) {
@@ -2404,7 +2415,7 @@ static QemuOptsList qcow2_create_opts = {
24042415
}
24052416
};
24062417

2407-
static BlockDriver bdrv_qcow2 = {
2418+
BlockDriver bdrv_qcow2 = {
24082419
.format_name = "qcow2",
24092420
.instance_size = sizeof(BDRVQcowState),
24102421
.bdrv_probe = qcow2_probe,

block/raw-posix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
447447
s->has_write_zeroes = true;
448448

449449
if (fstat(s->fd, &st) < 0) {
450+
ret = -errno;
450451
error_setg_errno(errp, errno, "Could not stat file");
451452
goto fail;
452453
}
@@ -1585,7 +1586,7 @@ static QemuOptsList raw_create_opts = {
15851586
}
15861587
};
15871588

1588-
static BlockDriver bdrv_file = {
1589+
BlockDriver bdrv_file = {
15891590
.format_name = "file",
15901591
.protocol_name = "file",
15911592
.instance_size = sizeof(BDRVRawState),

block/raw-win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static QemuOptsList raw_create_opts = {
540540
}
541541
};
542542

543-
static BlockDriver bdrv_file = {
543+
BlockDriver bdrv_file = {
544544
.format_name = "file",
545545
.protocol_name = "file",
546546
.instance_size = sizeof(BDRVRawState),

0 commit comments

Comments
 (0)