Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into s…
Browse files Browse the repository at this point in the history
…taging

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 "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [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 <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jun 18, 2020
2 parents 3f429a3 + 3419ec7 commit 3b26876
Show file tree
Hide file tree
Showing 37 changed files with 1,005 additions and 698 deletions.
17 changes: 9 additions & 8 deletions .gitignore
Expand Up @@ -34,18 +34,18 @@
/qapi/qapi-builtin-types.[ch]
/qapi/qapi-builtin-visit.[ch]
/qapi/qapi-commands-*.[ch]
/qapi/qapi-commands.[ch]
/qapi/qapi-emit-events.[ch]
**/qapi/qapi-commands.[ch]
**/qapi/qapi-emit-events.[ch]
/qapi/qapi-events-*.[ch]
/qapi/qapi-events.[ch]
/qapi/qapi-init-commands.[ch]
/qapi/qapi-introspect.[ch]
**/qapi/qapi-events.[ch]
**/qapi/qapi-init-commands.[ch]
**/qapi/qapi-introspect.[ch]
/qapi/qapi-types-*.[ch]
/qapi/qapi-types.[ch]
**/qapi/qapi-types.[ch]
/qapi/qapi-visit-*.[ch]
!/qapi/qapi-visit-core.c
/qapi/qapi-visit.[ch]
/qapi/qapi-doc.texi
**/qapi/qapi-visit.[ch]
**/qapi/qapi-doc.texi
/qemu-edid
/qemu-img
/qemu-nbd
Expand All @@ -59,6 +59,7 @@
/qemu-keymap
/qemu-monitor.texi
/qemu-monitor-info.texi
/qemu-storage-daemon
/qemu-version.h
/qemu-version.h.tmp
/module_block.h
Expand Down
2 changes: 1 addition & 1 deletion Makefile.objs
Expand Up @@ -13,7 +13,7 @@ chardev-obj-y = chardev/

authz-obj-y = authz/

block-obj-y = block/ block/monitor/ nbd/ scsi/
block-obj-y = block/ nbd/ scsi/
block-obj-y += block.o blockjob.o job.o
block-obj-y += qemu-io-cmds.o
block-obj-$(CONFIG_REPLICATION) += replication.o
Expand Down
1 change: 1 addition & 0 deletions block/Makefile.objs
Expand Up @@ -46,6 +46,7 @@ block-obj-y += aio_task.o
block-obj-y += backup-top.o
block-obj-y += filter-compress.o
common-obj-y += monitor/
block-obj-y += monitor/

block-obj-y += stream.o

Expand Down
9 changes: 5 additions & 4 deletions block/qcow2-bitmap.c
Expand Up @@ -1757,19 +1757,20 @@ bool qcow2_supports_persistent_dirty_bitmap(BlockDriverState *bs)
}

/*
* Compute the space required for bitmaps in @bs.
* Compute the space required to copy bitmaps from @in_bs.
*
* The computation is based as if copying to a new image with the
* given @cluster_size, which may differ from the cluster size in @bs.
* given @cluster_size, which may differ from the cluster size in
* @in_bs; in fact, @in_bs might be something other than qcow2.
*/
uint64_t qcow2_get_persistent_dirty_bitmap_size(BlockDriverState *bs,
uint64_t qcow2_get_persistent_dirty_bitmap_size(BlockDriverState *in_bs,
uint32_t cluster_size)
{
uint64_t bitmaps_size = 0;
BdrvDirtyBitmap *bm;
size_t bitmap_dir_size = 0;

FOR_EACH_DIRTY_BITMAP(bs, bm) {
FOR_EACH_DIRTY_BITMAP(in_bs, bm) {
if (bdrv_dirty_bitmap_get_persistence(bm)) {
const char *name = bdrv_dirty_bitmap_name(bm);
uint32_t granularity = bdrv_dirty_bitmap_granularity(bm);
Expand Down
22 changes: 22 additions & 0 deletions dma-helpers.c
Expand Up @@ -13,6 +13,8 @@
#include "trace-root.h"
#include "qemu/thread.h"
#include "qemu/main-loop.h"
#include "sysemu/cpus.h"
#include "qemu/range.h"

/* #define DEBUG_IOMMU */

Expand Down Expand Up @@ -142,6 +144,26 @@ static void dma_blk_cb(void *opaque, int ret)
cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;
mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir);
/*
* Make reads deterministic in icount mode. Windows sometimes issues
* disk read requests with overlapping SGs. It leads
* to non-determinism, because resulting buffer contents may be mixed
* from several sectors. This code splits all SGs into several
* groups. SGs in every group do not overlap.
*/
if (mem && use_icount && dbs->dir == DMA_DIRECTION_FROM_DEVICE) {
int i;
for (i = 0 ; i < dbs->iov.niov ; ++i) {
if (ranges_overlap((intptr_t)dbs->iov.iov[i].iov_base,
dbs->iov.iov[i].iov_len, (intptr_t)mem,
cur_len)) {
dma_memory_unmap(dbs->sg->as, mem, cur_len,
dbs->dir, cur_len);
mem = NULL;
break;
}
}
}
if (!mem)
break;
qemu_iovec_add(&dbs->iov, mem, cur_len);
Expand Down
40 changes: 39 additions & 1 deletion hw/block/block.c
Expand Up @@ -61,7 +61,7 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
return true;
}

void blkconf_blocksizes(BlockConf *conf)
bool blkconf_blocksizes(BlockConf *conf, Error **errp)
{
BlockBackend *blk = conf->blk;
BlockSizes blocksizes;
Expand All @@ -83,6 +83,44 @@ void blkconf_blocksizes(BlockConf *conf)
conf->logical_block_size = BDRV_SECTOR_SIZE;
}
}

if (conf->logical_block_size > conf->physical_block_size) {
error_setg(errp,
"logical_block_size > physical_block_size not supported");
return false;
}

if (!QEMU_IS_ALIGNED(conf->min_io_size, conf->logical_block_size)) {
error_setg(errp,
"min_io_size must be a multiple of logical_block_size");
return false;
}

/*
* all devices which support min_io_size (scsi and virtio-blk) expose it to
* the guest as a uint16_t in units of logical blocks
*/
if (conf->min_io_size / conf->logical_block_size > UINT16_MAX) {
error_setg(errp, "min_io_size must not exceed %u logical blocks",
UINT16_MAX);
return false;
}

if (!QEMU_IS_ALIGNED(conf->opt_io_size, conf->logical_block_size)) {
error_setg(errp,
"opt_io_size must be a multiple of logical_block_size");
return false;
}

if (conf->discard_granularity != -1 &&
!QEMU_IS_ALIGNED(conf->discard_granularity,
conf->logical_block_size)) {
error_setg(errp, "discard_granularity must be "
"a multiple of logical_block_size");
return false;
}

return true;
}

bool blkconf_apply_backend_options(BlockConf *conf, bool readonly,
Expand Down
8 changes: 8 additions & 0 deletions hw/block/dataplane/virtio-blk.c
Expand Up @@ -220,6 +220,9 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
goto fail_guest_notifiers;
}

/* Process queued requests before the ones in vring */
virtio_blk_process_queued_requests(vblk, false);

/* Kick right away to begin processing requests already in vring */
for (i = 0; i < nvqs; i++) {
VirtQueue *vq = virtio_get_queue(s->vdev, i);
Expand All @@ -239,6 +242,11 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
return 0;

fail_guest_notifiers:
/*
* If we failed to set up the guest notifiers queued requests will be
* processed on the main context.
*/
virtio_blk_process_queued_requests(vblk, false);
vblk->dataplane_disabled = true;
s->starting = false;
vblk->dataplane_started = true;
Expand Down
5 changes: 4 additions & 1 deletion hw/block/fdc.c
Expand Up @@ -554,7 +554,10 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
read_only = !blk_bs(dev->conf.blk) || blk_is_read_only(dev->conf.blk);
}

blkconf_blocksizes(&dev->conf);
if (!blkconf_blocksizes(&dev->conf, errp)) {
return;
}

if (dev->conf.logical_block_size != 512 ||
dev->conf.physical_block_size != 512)
{
Expand Down

0 comments on commit 3b26876

Please sign in to comment.