Skip to content

Commit 3b26876

Browse files
committed
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - enhance handling of size-related BlockConf properties - nvme: small fixes, refactoring and cleanups - virtio-blk: On restart, process queued requests in the proper context - icount: make dma reads deterministic - iotests: Some fixes for rarely run cases - .gitignore: Ignore storage-daemon files - Minor code cleanups # gpg: Signature made Wed 17 Jun 2020 15:47:19 BST # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "[email protected]" # gpg: Good signature from "Kevin Wolf <[email protected]>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (43 commits) iotests: Add copyright line in qcow2.py iotests/{190,291}: compat=0.10 is unsupported iotests/229: data_file is unsupported iotests/292: data_file is unsupported iotests/041: Skip test_small_target for qed iotests.py: Add skip_for_formats() decorator block: lift blocksize property limit to 2 MiB qdev-properties: add getter for size32 and blocksize block: make BlockConf size props 32bit and accept size suffixes qdev-properties: make blocksize accept size suffixes qdev-properties: add size32 property type qdev-properties: blocksize: use same limits in code and description block: consolidate blocksize properties consistency checks virtio-blk: store opt_io_size with correct size .gitignore: Ignore storage-daemon files hw/block/nvme: verify msix_init_exclusive_bar() return value hw/block/nvme: add msix_qsize parameter hw/block/nvme: Verify msix_vector_use() returned value hw/block/nvme: factor out controller identify setup hw/block/nvme: do cmb/pmr init as part of pci init ... Signed-off-by: Peter Maydell <[email protected]>
2 parents 3f429a3 + 3419ec7 commit 3b26876

37 files changed

+1005
-698
lines changed

.gitignore

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@
3434
/qapi/qapi-builtin-types.[ch]
3535
/qapi/qapi-builtin-visit.[ch]
3636
/qapi/qapi-commands-*.[ch]
37-
/qapi/qapi-commands.[ch]
38-
/qapi/qapi-emit-events.[ch]
37+
**/qapi/qapi-commands.[ch]
38+
**/qapi/qapi-emit-events.[ch]
3939
/qapi/qapi-events-*.[ch]
40-
/qapi/qapi-events.[ch]
41-
/qapi/qapi-init-commands.[ch]
42-
/qapi/qapi-introspect.[ch]
40+
**/qapi/qapi-events.[ch]
41+
**/qapi/qapi-init-commands.[ch]
42+
**/qapi/qapi-introspect.[ch]
4343
/qapi/qapi-types-*.[ch]
44-
/qapi/qapi-types.[ch]
44+
**/qapi/qapi-types.[ch]
4545
/qapi/qapi-visit-*.[ch]
4646
!/qapi/qapi-visit-core.c
47-
/qapi/qapi-visit.[ch]
48-
/qapi/qapi-doc.texi
47+
**/qapi/qapi-visit.[ch]
48+
**/qapi/qapi-doc.texi
4949
/qemu-edid
5050
/qemu-img
5151
/qemu-nbd
@@ -59,6 +59,7 @@
5959
/qemu-keymap
6060
/qemu-monitor.texi
6161
/qemu-monitor-info.texi
62+
/qemu-storage-daemon
6263
/qemu-version.h
6364
/qemu-version.h.tmp
6465
/module_block.h

Makefile.objs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ chardev-obj-y = chardev/
1313

1414
authz-obj-y = authz/
1515

16-
block-obj-y = block/ block/monitor/ nbd/ scsi/
16+
block-obj-y = block/ nbd/ scsi/
1717
block-obj-y += block.o blockjob.o job.o
1818
block-obj-y += qemu-io-cmds.o
1919
block-obj-$(CONFIG_REPLICATION) += replication.o

block/Makefile.objs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ block-obj-y += aio_task.o
4646
block-obj-y += backup-top.o
4747
block-obj-y += filter-compress.o
4848
common-obj-y += monitor/
49+
block-obj-y += monitor/
4950

5051
block-obj-y += stream.o
5152

block/qcow2-bitmap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,19 +1757,20 @@ bool qcow2_supports_persistent_dirty_bitmap(BlockDriverState *bs)
17571757
}
17581758

17591759
/*
1760-
* Compute the space required for bitmaps in @bs.
1760+
* Compute the space required to copy bitmaps from @in_bs.
17611761
*
17621762
* The computation is based as if copying to a new image with the
1763-
* given @cluster_size, which may differ from the cluster size in @bs.
1763+
* given @cluster_size, which may differ from the cluster size in
1764+
* @in_bs; in fact, @in_bs might be something other than qcow2.
17641765
*/
1765-
uint64_t qcow2_get_persistent_dirty_bitmap_size(BlockDriverState *bs,
1766+
uint64_t qcow2_get_persistent_dirty_bitmap_size(BlockDriverState *in_bs,
17661767
uint32_t cluster_size)
17671768
{
17681769
uint64_t bitmaps_size = 0;
17691770
BdrvDirtyBitmap *bm;
17701771
size_t bitmap_dir_size = 0;
17711772

1772-
FOR_EACH_DIRTY_BITMAP(bs, bm) {
1773+
FOR_EACH_DIRTY_BITMAP(in_bs, bm) {
17731774
if (bdrv_dirty_bitmap_get_persistence(bm)) {
17741775
const char *name = bdrv_dirty_bitmap_name(bm);
17751776
uint32_t granularity = bdrv_dirty_bitmap_granularity(bm);

dma-helpers.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "trace-root.h"
1414
#include "qemu/thread.h"
1515
#include "qemu/main-loop.h"
16+
#include "sysemu/cpus.h"
17+
#include "qemu/range.h"
1618

1719
/* #define DEBUG_IOMMU */
1820

@@ -142,6 +144,26 @@ static void dma_blk_cb(void *opaque, int ret)
142144
cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
143145
cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;
144146
mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir);
147+
/*
148+
* Make reads deterministic in icount mode. Windows sometimes issues
149+
* disk read requests with overlapping SGs. It leads
150+
* to non-determinism, because resulting buffer contents may be mixed
151+
* from several sectors. This code splits all SGs into several
152+
* groups. SGs in every group do not overlap.
153+
*/
154+
if (mem && use_icount && dbs->dir == DMA_DIRECTION_FROM_DEVICE) {
155+
int i;
156+
for (i = 0 ; i < dbs->iov.niov ; ++i) {
157+
if (ranges_overlap((intptr_t)dbs->iov.iov[i].iov_base,
158+
dbs->iov.iov[i].iov_len, (intptr_t)mem,
159+
cur_len)) {
160+
dma_memory_unmap(dbs->sg->as, mem, cur_len,
161+
dbs->dir, cur_len);
162+
mem = NULL;
163+
break;
164+
}
165+
}
166+
}
145167
if (!mem)
146168
break;
147169
qemu_iovec_add(&dbs->iov, mem, cur_len);

hw/block/block.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
6161
return true;
6262
}
6363

64-
void blkconf_blocksizes(BlockConf *conf)
64+
bool blkconf_blocksizes(BlockConf *conf, Error **errp)
6565
{
6666
BlockBackend *blk = conf->blk;
6767
BlockSizes blocksizes;
@@ -83,6 +83,44 @@ void blkconf_blocksizes(BlockConf *conf)
8383
conf->logical_block_size = BDRV_SECTOR_SIZE;
8484
}
8585
}
86+
87+
if (conf->logical_block_size > conf->physical_block_size) {
88+
error_setg(errp,
89+
"logical_block_size > physical_block_size not supported");
90+
return false;
91+
}
92+
93+
if (!QEMU_IS_ALIGNED(conf->min_io_size, conf->logical_block_size)) {
94+
error_setg(errp,
95+
"min_io_size must be a multiple of logical_block_size");
96+
return false;
97+
}
98+
99+
/*
100+
* all devices which support min_io_size (scsi and virtio-blk) expose it to
101+
* the guest as a uint16_t in units of logical blocks
102+
*/
103+
if (conf->min_io_size / conf->logical_block_size > UINT16_MAX) {
104+
error_setg(errp, "min_io_size must not exceed %u logical blocks",
105+
UINT16_MAX);
106+
return false;
107+
}
108+
109+
if (!QEMU_IS_ALIGNED(conf->opt_io_size, conf->logical_block_size)) {
110+
error_setg(errp,
111+
"opt_io_size must be a multiple of logical_block_size");
112+
return false;
113+
}
114+
115+
if (conf->discard_granularity != -1 &&
116+
!QEMU_IS_ALIGNED(conf->discard_granularity,
117+
conf->logical_block_size)) {
118+
error_setg(errp, "discard_granularity must be "
119+
"a multiple of logical_block_size");
120+
return false;
121+
}
122+
123+
return true;
86124
}
87125

88126
bool blkconf_apply_backend_options(BlockConf *conf, bool readonly,

hw/block/dataplane/virtio-blk.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
220220
goto fail_guest_notifiers;
221221
}
222222

223+
/* Process queued requests before the ones in vring */
224+
virtio_blk_process_queued_requests(vblk, false);
225+
223226
/* Kick right away to begin processing requests already in vring */
224227
for (i = 0; i < nvqs; i++) {
225228
VirtQueue *vq = virtio_get_queue(s->vdev, i);
@@ -239,6 +242,11 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
239242
return 0;
240243

241244
fail_guest_notifiers:
245+
/*
246+
* If we failed to set up the guest notifiers queued requests will be
247+
* processed on the main context.
248+
*/
249+
virtio_blk_process_queued_requests(vblk, false);
242250
vblk->dataplane_disabled = true;
243251
s->starting = false;
244252
vblk->dataplane_started = true;

hw/block/fdc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,10 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
554554
read_only = !blk_bs(dev->conf.blk) || blk_is_read_only(dev->conf.blk);
555555
}
556556

557-
blkconf_blocksizes(&dev->conf);
557+
if (!blkconf_blocksizes(&dev->conf, errp)) {
558+
return;
559+
}
560+
558561
if (dev->conf.logical_block_size != 512 ||
559562
dev->conf.physical_block_size != 512)
560563
{

0 commit comments

Comments
 (0)