Commit 1d746ee9 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/famz/tags/block-and-testing-pull-request' into staging



Block and testing patches for 3.1

- aio fixes by me
- nvme fixes by Paolo and me
- test improvements by Peter, Phil and me

# gpg: Signature made Wed 15 Aug 2018 04:11:43 BST
# gpg:                using RSA key CA35624C6A9171C6
# gpg: Good signature from "Fam Zheng <famz@redhat.com>"
# Primary key fingerprint: 5003 7CB7 9706 0F76 F021  AD56 CA35 624C 6A91 71C6

* remotes/famz/tags/block-and-testing-pull-request:
  aio-posix: Improve comment around marking node deleted
  tests/vm: Add vm-build-all/vm-clean-all in help text
  tests/vm: Use make's --output-sync option
  tests/vm: Bump guest RAM up from 2G to 4G
  tests/vm: Propagate V=1 down into the make inside the VM
  tests/vm: Pass the jobs parallelism setting to 'make check'
  tests: vm: Add vm-clean-all
  tests: Add centos VM testing
  tests: Allow overriding archive path with SRC_ARCHIVE
  tests: Add an option for snapshot (default: off)
  docker: Install more packages in centos7
  aio: Do aio_notify_accept only during blocking aio_poll
  aio-posix: Don't count ctx->notifier as progress when polling
  nvme: simplify plug/unplug
  nvme: Fix nvme_init error handling
  tests/vm: Add flex and bison to the vm image
  tests/vm: Only use -cpu 'host' if KVM is available

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 48a539df 37a81812
Loading
Loading
Loading
Loading
+22 −35
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ typedef struct {
    uint64_t nsze; /* Namespace size reported by identify command */
    int nsid;      /* The namespace id to read/write data. */
    uint64_t max_transfer;
    int plugged;
    bool plugged;

    CoMutex dma_map_lock;
    CoQueue dma_flush_queue;
@@ -569,13 +569,13 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
    s->vfio = qemu_vfio_open_pci(device, errp);
    if (!s->vfio) {
        ret = -EINVAL;
        goto fail;
        goto out;
    }

    s->regs = qemu_vfio_pci_map_bar(s->vfio, 0, 0, NVME_BAR_SIZE, errp);
    if (!s->regs) {
        ret = -EINVAL;
        goto fail;
        goto out;
    }

    /* Perform initialize sequence as described in NVMe spec "7.6.1
@@ -585,7 +585,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
    if (!(cap & (1ULL << 37))) {
        error_setg(errp, "Device doesn't support NVMe command set");
        ret = -EINVAL;
        goto fail;
        goto out;
    }

    s->page_size = MAX(4096, 1 << (12 + ((cap >> 48) & 0xF)));
@@ -603,7 +603,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
                             PRId64 " ms)",
                       timeout_ms);
            ret = -ETIMEDOUT;
            goto fail;
            goto out;
        }
    }

@@ -613,7 +613,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
    s->queues[0] = nvme_create_queue_pair(bs, 0, NVME_QUEUE_SIZE, errp);
    if (!s->queues[0]) {
        ret = -EINVAL;
        goto fail;
        goto out;
    }
    QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
    s->regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE);
@@ -633,14 +633,14 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
                             PRId64 " ms)",
                       timeout_ms);
            ret = -ETIMEDOUT;
            goto fail_queue;
            goto out;
        }
    }

    ret = qemu_vfio_pci_init_irq(s->vfio, &s->irq_notifier,
                                 VFIO_PCI_MSIX_IRQ_INDEX, errp);
    if (ret) {
        goto fail_queue;
        goto out;
    }
    aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
                           false, nvme_handle_event, nvme_poll_cb);
@@ -649,30 +649,15 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
    if (local_err) {
        error_propagate(errp, local_err);
        ret = -EIO;
        goto fail_handler;
        goto out;
    }

    /* Set up command queues. */
    if (!nvme_add_io_queue(bs, errp)) {
        ret = -EIO;
        goto fail_handler;
    }
    return 0;

fail_handler:
    aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
                           false, NULL, NULL);
fail_queue:
    nvme_free_queue_pair(bs, s->queues[0]);
fail:
    g_free(s->queues);
    if (s->regs) {
        qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);
    }
    if (s->vfio) {
        qemu_vfio_close(s->vfio);
    }
    event_notifier_cleanup(&s->irq_notifier);
out:
    /* Cleaning up is done in nvme_file_open() upon error. */
    return ret;
}

@@ -739,8 +724,10 @@ static void nvme_close(BlockDriverState *bs)
    for (i = 0; i < s->nr_queues; ++i) {
        nvme_free_queue_pair(bs, s->queues[i]);
    }
    g_free(s->queues);
    aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
                           false, NULL, NULL);
    event_notifier_cleanup(&s->irq_notifier);
    qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);
    qemu_vfio_close(s->vfio);
}
@@ -1114,7 +1101,8 @@ static void nvme_attach_aio_context(BlockDriverState *bs,
static void nvme_aio_plug(BlockDriverState *bs)
{
    BDRVNVMeState *s = bs->opaque;
    s->plugged++;
    assert(!s->plugged);
    s->plugged = true;
}

static void nvme_aio_unplug(BlockDriverState *bs)
@@ -1122,7 +1110,7 @@ static void nvme_aio_unplug(BlockDriverState *bs)
    int i;
    BDRVNVMeState *s = bs->opaque;
    assert(s->plugged);
    if (!--s->plugged) {
    s->plugged = false;
    for (i = 1; i < s->nr_queues; i++) {
        NVMeQueuePair *q = s->queues[i];
        qemu_mutex_lock(&q->lock);
@@ -1131,7 +1119,6 @@ static void nvme_aio_unplug(BlockDriverState *bs)
        qemu_mutex_unlock(&q->lock);
    }
}
}

static void nvme_register_buf(BlockDriverState *bs, void *host, size_t size)
{
+1 −0
Original line number Diff line number Diff line
@@ -434,6 +434,7 @@ Debugging

Add ``DEBUG=1`` and/or ``V=1`` to the make command to allow interactive
debugging and verbose output. If this is not enough, see the next section.
``V=1`` will be propagated down into the make jobs in the guest.

Manual invocation
-----------------
+5 −2
Original line number Diff line number Diff line
@@ -27,8 +27,11 @@ DOCKER_SRC_COPY := $(BUILD_DIR)/docker-src.$(CUR_TIME)

$(DOCKER_SRC_COPY):
	@mkdir $@
	$(if $(SRC_ARCHIVE), \
		$(call quiet-command, cp "$(SRC_ARCHIVE)" $@/qemu.tar, \
			"CP", "$@/qemu.tar"), \
		$(call quiet-command, cd $(SRC_PATH) && scripts/archive-source.sh $@/qemu.tar, \
		"GEN", "$@/qemu.tar")
			"GEN", "$@/qemu.tar"))
	$(call quiet-command, cp $(SRC_PATH)/tests/docker/run $@/run, \
		"COPY","RUNNER")

+3 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ RUN yum install -y epel-release centos-release-xen
RUN yum -y update
ENV PACKAGES \
    bison \
    bzip2 \
    bzip2-devel \
    ccache \
    csnappy-devel \
@@ -12,10 +13,12 @@ ENV PACKAGES \
    gettext \
    git \
    glib2-devel \
    libaio-devel \
    libepoxy-devel \
    libfdt-devel \
    librdmacm-devel \
    lzo-devel \
    nettle-devel \
    make \
    mesa-libEGL-devel \
    mesa-libgbm-devel \
+10 −2
Original line number Diff line number Diff line
# Makefile for VM tests

.PHONY: vm-build-all
.PHONY: vm-build-all vm-clean-all

IMAGES := ubuntu.i386 freebsd netbsd openbsd
IMAGES := ubuntu.i386 freebsd netbsd openbsd centos
IMAGE_FILES := $(patsubst %, tests/vm/%.img, $(IMAGES))

.PRECIOUS: $(IMAGE_FILES)
@@ -14,9 +14,16 @@ vm-test:
	@echo "  vm-build-freebsd                - Build QEMU in FreeBSD VM"
	@echo "  vm-build-netbsd                 - Build QEMU in NetBSD VM"
	@echo "  vm-build-openbsd                - Build QEMU in OpenBSD VM"
	@echo "  vm-build-centos                 - Build QEMU in CentOS VM, with Docker"
	@echo ""
	@echo "  vm-build-all                    - Build QEMU in all VMs"
	@echo "  vm-clean-all                    - Clean up VM images"

vm-build-all: $(addprefix vm-build-, $(IMAGES))

vm-clean-all:
	rm -f $(IMAGE_FILES)

tests/vm/%.img: $(SRC_PATH)/tests/vm/% \
		$(SRC_PATH)/tests/vm/basevm.py \
		$(SRC_PATH)/tests/vm/Makefile.include
@@ -36,6 +43,7 @@ vm-build-%: tests/vm/%.img
		$(if $(V)$(DEBUG), --debug) \
		$(if $(DEBUG), --interactive) \
		$(if $(J),--jobs $(J)) \
		$(if $(V),--verbose) \
		--image "$<" \
		--build-qemu $(SRC_PATH), \
		"  VM-BUILD $*")
Loading