diff options
-rw-r--r-- | MAINTAINERS | 1 | ||||
-rw-r--r-- | block.c | 31 | ||||
-rw-r--r-- | block/linux-aio.c | 96 | ||||
-rw-r--r-- | block/mirror.c | 4 | ||||
-rw-r--r-- | block/raw-aio.h | 2 | ||||
-rw-r--r-- | block/raw-posix.c | 73 | ||||
-rw-r--r-- | hw/acpi/memory_hotplug.c | 2 | ||||
-rw-r--r-- | hw/block/dataplane/virtio-blk.c | 2 | ||||
-rw-r--r-- | hw/core/qdev-properties-system.c | 3 | ||||
-rw-r--r-- | hw/core/qdev.c | 8 | ||||
-rw-r--r-- | hw/ide/ahci.c | 32 | ||||
-rw-r--r-- | hw/ide/ahci.h | 2 | ||||
-rw-r--r-- | hw/mem/pc-dimm.c | 8 | ||||
-rw-r--r-- | hw/pci/pci.c | 2 | ||||
-rw-r--r-- | hw/s390x/s390-virtio-bus.c | 2 | ||||
-rw-r--r-- | hw/s390x/virtio-ccw.c | 11 | ||||
-rw-r--r-- | hw/virtio/virtio-mmio.c | 6 | ||||
-rw-r--r-- | hw/virtio/virtio-pci.c | 16 | ||||
-rw-r--r-- | include/block/block.h | 4 | ||||
-rw-r--r-- | include/block/block_int.h | 5 | ||||
-rw-r--r-- | include/hw/virtio/virtio-blk.h | 3 | ||||
-rw-r--r-- | include/hw/virtio/virtio-net.h | 1 | ||||
-rw-r--r-- | include/hw/virtio/virtio-scsi.h | 1 | ||||
-rw-r--r-- | include/sysemu/char.h | 1 | ||||
-rw-r--r-- | numa.c | 8 | ||||
-rw-r--r-- | qemu-char.c | 36 | ||||
-rw-r--r-- | qemu-doc.texi | 4 | ||||
-rw-r--r-- | qemu-img.texi | 4 | ||||
-rw-r--r-- | qmp.c | 99 | ||||
-rw-r--r-- | tests/Makefile | 8 | ||||
-rwxr-xr-x | tests/qemu-iotests/041 | 46 | ||||
-rw-r--r-- | tests/qemu-iotests/041.out | 4 |
32 files changed, 424 insertions, 101 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index e7dc90782e..906f252477 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -563,6 +563,7 @@ Devices ------- IDE M: Kevin Wolf <kwolf@redhat.com> +M: Stefan Hajnoczi <stefanha@redhat.com> S: Odd Fixes F: include/hw/ide.h F: hw/ide/ @@ -1905,6 +1905,7 @@ void bdrv_drain_all(void) bool bs_busy; aio_context_acquire(aio_context); + bdrv_flush_io_queue(bs); bdrv_start_throttled_reqs(bs); bs_busy = bdrv_requests_pending(bs); bs_busy |= aio_poll(aio_context, bs_busy); @@ -5782,3 +5783,33 @@ BlockDriverState *check_to_replace_node(const char *node_name, Error **errp) return to_replace_bs; } + +void bdrv_io_plug(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (drv && drv->bdrv_io_plug) { + drv->bdrv_io_plug(bs); + } else if (bs->file) { + bdrv_io_plug(bs->file); + } +} + +void bdrv_io_unplug(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (drv && drv->bdrv_io_unplug) { + drv->bdrv_io_unplug(bs); + } else if (bs->file) { + bdrv_io_unplug(bs->file); + } +} + +void bdrv_flush_io_queue(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (drv && drv->bdrv_flush_io_queue) { + drv->bdrv_flush_io_queue(bs); + } else if (bs->file) { + bdrv_flush_io_queue(bs->file); + } +} diff --git a/block/linux-aio.c b/block/linux-aio.c index f0a2c087b2..48673690ac 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -25,6 +25,8 @@ */ #define MAX_EVENTS 128 +#define MAX_QUEUED_IO 128 + struct qemu_laiocb { BlockDriverAIOCB common; struct qemu_laio_state *ctx; @@ -36,9 +38,19 @@ struct qemu_laiocb { QLIST_ENTRY(qemu_laiocb) node; }; +typedef struct { + struct iocb *iocbs[MAX_QUEUED_IO]; + int plugged; + unsigned int size; + unsigned int idx; +} LaioQueue; + struct qemu_laio_state { io_context_t ctx; EventNotifier e; + + /* io queue for submit at batch */ + LaioQueue io_q; }; static inline ssize_t io_event_ret(struct io_event *ev) @@ -135,6 +147,79 @@ static const AIOCBInfo laio_aiocb_info = { .cancel = laio_cancel, }; +static void ioq_init(LaioQueue *io_q) +{ + io_q->size = MAX_QUEUED_IO; + io_q->idx = 0; + io_q->plugged = 0; +} + +static int ioq_submit(struct qemu_laio_state *s) +{ + int ret, i = 0; + int len = s->io_q.idx; + + do { + ret = io_submit(s->ctx, len, s->io_q.iocbs); + } while (i++ < 3 && ret == -EAGAIN); + + /* empty io queue */ + s->io_q.idx = 0; + + if (ret < 0) { + i = 0; + } else { + i = ret; + } + + for (; i < len; i++) { + struct qemu_laiocb *laiocb = + container_of(s->io_q.iocbs[i], struct qemu_laiocb, iocb); + + laiocb->ret = (ret < 0) ? ret : -EIO; + qemu_laio_process_completion(s, laiocb); + } + return ret; +} + +static void ioq_enqueue(struct qemu_laio_state *s, struct iocb *iocb) +{ + unsigned int idx = s->io_q.idx; + + s->io_q.iocbs[idx++] = iocb; + s->io_q.idx = idx; + + /* submit immediately if queue is full */ + if (idx == s->io_q.size) { + ioq_submit(s); + } +} + +void laio_io_plug(BlockDriverState *bs, void *aio_ctx) +{ + struct qemu_laio_state *s = aio_ctx; + + s->io_q.plugged++; +} + +int laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug) +{ + struct qemu_laio_state *s = aio_ctx; + int ret = 0; + + assert(s->io_q.plugged > 0 || !unplug); + + if (unplug && --s->io_q.plugged > 0) { + return 0; + } + + if (s->io_q.idx > 0) { + ret = ioq_submit(s); + } + + return ret; +} + BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int type) @@ -168,8 +253,13 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd, } io_set_eventfd(&laiocb->iocb, event_notifier_get_fd(&s->e)); - if (io_submit(s->ctx, 1, &iocbs) < 0) - goto out_free_aiocb; + if (!s->io_q.plugged) { + if (io_submit(s->ctx, 1, &iocbs) < 0) { + goto out_free_aiocb; + } + } else { + ioq_enqueue(s, iocbs); + } return &laiocb->common; out_free_aiocb: @@ -204,6 +294,8 @@ void *laio_init(void) goto out_close_efd; } + ioq_init(&s->io_q); + return s; out_close_efd: diff --git a/block/mirror.c b/block/mirror.c index 6c3ee7041c..c7a655fc58 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -265,9 +265,11 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) next_sector = sector_num; while (nb_chunks-- > 0) { MirrorBuffer *buf = QSIMPLEQ_FIRST(&s->buf_free); + size_t remaining = (nb_sectors * BDRV_SECTOR_SIZE) - op->qiov.size; + QSIMPLEQ_REMOVE_HEAD(&s->buf_free, next); s->buf_free_count--; - qemu_iovec_add(&op->qiov, buf, s->granularity); + qemu_iovec_add(&op->qiov, buf, MIN(s->granularity, remaining)); /* Advance the HBitmapIter in parallel, so that we do not examine * the same sector twice. diff --git a/block/raw-aio.h b/block/raw-aio.h index 8cf084eeb5..e18c97509a 100644 --- a/block/raw-aio.h +++ b/block/raw-aio.h @@ -40,6 +40,8 @@ BlockDriverAIOCB *laio_submit(BlockDriverState *bs, void *aio_ctx, int fd, BlockDriverCompletionFunc *cb, void *opaque, int type); void laio_detach_aio_context(void *s, AioContext *old_context); void laio_attach_aio_context(void *s, AioContext *new_context); +void laio_io_plug(BlockDriverState *bs, void *aio_ctx); +int laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug); #endif #ifdef _WIN32 diff --git a/block/raw-posix.c b/block/raw-posix.c index 825a0c878f..a857def671 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1057,6 +1057,36 @@ static BlockDriverAIOCB *raw_aio_submit(BlockDriverState *bs, cb, opaque, type); } +static void raw_aio_plug(BlockDriverState *bs) +{ +#ifdef CONFIG_LINUX_AIO + BDRVRawState *s = bs->opaque; + if (s->use_aio) { + laio_io_plug(bs, s->aio_ctx); + } +#endif +} + +static void raw_aio_unplug(BlockDriverState *bs) +{ +#ifdef CONFIG_LINUX_AIO + BDRVRawState *s = bs->opaque; + if (s->use_aio) { + laio_io_unplug(bs, s->aio_ctx, true); + } +#endif +} + +static void raw_aio_flush_io_queue(BlockDriverState *bs) +{ +#ifdef CONFIG_LINUX_AIO + BDRVRawState *s = bs->opaque; + if (s->use_aio) { + laio_io_unplug(bs, s->aio_ctx, false); + } +#endif +} + static BlockDriverAIOCB *raw_aio_readv(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque) @@ -1133,12 +1163,12 @@ static int64_t raw_getlength(BlockDriverState *bs) struct stat st; if (fstat(fd, &st)) - return -1; + return -errno; if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { struct disklabel dl; if (ioctl(fd, DIOCGDINFO, &dl)) - return -1; + return -errno; return (uint64_t)dl.d_secsize * dl.d_partitions[DISKPART(st.st_rdev)].p_size; } else @@ -1152,7 +1182,7 @@ static int64_t raw_getlength(BlockDriverState *bs) struct stat st; if (fstat(fd, &st)) - return -1; + return -errno; if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { struct dkwedge_info dkw; @@ -1162,7 +1192,7 @@ static int64_t raw_getlength(BlockDriverState *bs) struct disklabel dl; if (ioctl(fd, DIOCGDINFO, &dl)) - return -1; + return -errno; return (uint64_t)dl.d_secsize * dl.d_partitions[DISKPART(st.st_rdev)].p_size; } @@ -1175,6 +1205,7 @@ static int64_t raw_getlength(BlockDriverState *bs) BDRVRawState *s = bs->opaque; struct dk_minfo minfo; int ret; + int64_t size; ret = fd_open(bs); if (ret < 0) { @@ -1193,7 +1224,11 @@ static int64_t raw_getlength(BlockDriverState *bs) * There are reports that lseek on some devices fails, but * irc discussion said that contingency on contingency was overkill. */ - return lseek(s->fd, 0, SEEK_END); + size = lseek(s->fd, 0, SEEK_END); + if (size < 0) { + return -errno; + } + return size; } #elif defined(CONFIG_BSD) static int64_t raw_getlength(BlockDriverState *bs) @@ -1231,6 +1266,9 @@ again: size = LLONG_MAX; #else size = lseek(fd, 0LL, SEEK_END); + if (size < 0) { + return -errno; + } #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) switch(s->type) { @@ -1247,6 +1285,9 @@ again: #endif } else { size = lseek(fd, 0, SEEK_END); + if (size < 0) { + return -errno; + } } return size; } @@ -1255,13 +1296,18 @@ static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; int ret; + int64_t size; ret = fd_open(bs); if (ret < 0) { return ret; } - return lseek(s->fd, 0, SEEK_END); + size = lseek(s->fd, 0, SEEK_END); + if (size < 0) { + return -errno; + } + return size; } #endif @@ -1528,6 +1574,9 @@ static BlockDriver bdrv_file = { .bdrv_aio_flush = raw_aio_flush, .bdrv_aio_discard = raw_aio_discard, .bdrv_refresh_limits = raw_refresh_limits, + .bdrv_io_plug = raw_aio_plug, + .bdrv_io_unplug = raw_aio_unplug, + .bdrv_flush_io_queue = raw_aio_flush_io_queue, .bdrv_truncate = raw_truncate, .bdrv_getlength = raw_getlength, @@ -1927,6 +1976,9 @@ static BlockDriver bdrv_host_device = { .bdrv_aio_flush = raw_aio_flush, .bdrv_aio_discard = hdev_aio_discard, .bdrv_refresh_limits = raw_refresh_limits, + .bdrv_io_plug = raw_aio_plug, + .bdrv_io_unplug = raw_aio_unplug, + .bdrv_flush_io_queue = raw_aio_flush_io_queue, .bdrv_truncate = raw_truncate, .bdrv_getlength = raw_getlength, @@ -2072,6 +2124,9 @@ static BlockDriver bdrv_host_floppy = { .bdrv_aio_writev = raw_aio_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_refresh_limits = raw_refresh_limits, + .bdrv_io_plug = raw_aio_plug, + .bdrv_io_unplug = raw_aio_unplug, + .bdrv_flush_io_queue = raw_aio_flush_io_queue, .bdrv_truncate = raw_truncate, .bdrv_getlength = raw_getlength, @@ -2200,6 +2255,9 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_aio_writev = raw_aio_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_refresh_limits = raw_refresh_limits, + .bdrv_io_plug = raw_aio_plug, + .bdrv_io_unplug = raw_aio_unplug, + .bdrv_flush_io_queue = raw_aio_flush_io_queue, .bdrv_truncate = raw_truncate, .bdrv_getlength = raw_getlength, @@ -2334,6 +2392,9 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_aio_writev = raw_aio_writev, .bdrv_aio_flush = raw_aio_flush, .bdrv_refresh_limits = raw_refresh_limits, + .bdrv_io_plug = raw_aio_plug, + .bdrv_io_unplug = raw_aio_unplug, + .bdrv_flush_io_queue = raw_aio_flush_io_queue, .bdrv_truncate = raw_truncate, .bdrv_getlength = raw_getlength, diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 38ca415f64..ed3924126f 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -159,7 +159,7 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count); memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state, - "apci-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN); + "acpi-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN); memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io); } diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 4c5ba18122..4bc0729bf7 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -84,6 +84,7 @@ static void handle_notify(EventNotifier *e) }; event_notifier_test_and_clear(&s->host_notifier); + bdrv_io_plug(s->blk->conf.bs); for (;;) { /* Disable guest->host notifies to avoid unnecessary vmexits */ vring_disable_notification(s->vdev, &s->vring); @@ -117,6 +118,7 @@ static void handle_notify(EventNotifier *e) break; } } + bdrv_io_unplug(s->blk->conf.bs); } /* Context: QEMU global mutex held */ diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 8e140af46f..ae0900f651 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -394,7 +394,8 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque) g->driver = qemu_opt_get(opts, "driver"); g->property = qemu_opt_get(opts, "property"); g->value = qemu_opt_get(opts, "value"); - oc = object_class_by_name(g->driver); + oc = object_class_dynamic_cast(object_class_by_name(g->driver), + TYPE_DEVICE); if (oc) { DeviceClass *dc = DEVICE_CLASS(oc); diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 3bdda8ef66..da1ba48c99 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -957,7 +957,13 @@ static void device_initfn(Object *obj) static void device_post_init(Object *obj) { - qdev_prop_set_globals(DEVICE(obj), &error_abort); + Error *err = NULL; + qdev_prop_set_globals(DEVICE(obj), &err); + if (err) { + qerror_report_err(err); + error_free(err); + exit(EXIT_FAILURE); + } } /* Unlink device from bus and free the structure. */ diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 9bae22ecb1..604152a823 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -175,17 +175,18 @@ static void ahci_trigger_irq(AHCIState *s, AHCIDevice *d, ahci_check_irq(s); } -static void map_page(uint8_t **ptr, uint64_t addr, uint32_t wanted) +static void map_page(AddressSpace *as, uint8_t **ptr, uint64_t addr, + uint32_t wanted) { hwaddr len = wanted; if (*ptr) { - cpu_physical_memory_unmap(*ptr, len, 1, len); + dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len); } - *ptr = cpu_physical_memory_map(addr, &len, 1); + *ptr = dma_memory_map(as, addr, &len, DMA_DIRECTION_FROM_DEVICE); if (len < wanted) { - cpu_physical_memory_unmap(*ptr, len, 1, len); + dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len); *ptr = NULL; } } @@ -198,24 +199,24 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val) switch (offset) { case PORT_LST_ADDR: pr->lst_addr = val; - map_page(&s->dev[port].lst, + map_page(s->as, &s->dev[port].lst, ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); s->dev[port].cur_cmd = NULL; break; case PORT_LST_ADDR_HI: pr->lst_addr_hi = val; - map_page(&s->dev[port].lst, + map_page(s->as, &s->dev[port].lst, ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); s->dev[port].cur_cmd = NULL; break; case PORT_FIS_ADDR: pr->fis_addr = val; - map_page(&s->dev[port].res_fis, + map_page(s->as, &s->dev[port].res_fis, ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); break; case PORT_FIS_ADDR_HI: pr->fis_addr_hi = val; - map_page(&s->dev[port].res_fis, + map_page(s->as, &s->dev[port].res_fis, ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); break; case PORT_IRQ_STAT: @@ -639,6 +640,11 @@ static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis) } } +static int prdt_tbl_entry_size(const AHCI_SG *tbl) +{ + return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1; +} + static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset) { AHCICmdHdr *cmd = ad->cur_cmd; @@ -681,7 +687,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset) sum = 0; for (i = 0; i < sglist_alloc_hint; i++) { /* flags_size is zero-based */ - tbl_entry_size = (le32_to_cpu(tbl[i].flags_size) + 1); + tbl_entry_size = prdt_tbl_entry_size(&tbl[i]); if (offset <= (sum + tbl_entry_size)) { off_idx = i; off_pos = offset - sum; @@ -700,12 +706,12 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset) qemu_sglist_init(sglist, qbus->parent, (sglist_alloc_hint - off_idx), ad->hba->as); qemu_sglist_add(sglist, le64_to_cpu(tbl[off_idx].addr + off_pos), - le32_to_cpu(tbl[off_idx].flags_size) + 1 - off_pos); + prdt_tbl_entry_size(&tbl[off_idx]) - off_pos); for (i = off_idx + 1; i < sglist_alloc_hint; i++) { /* flags_size is zero-based */ qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr), - le32_to_cpu(tbl[i].flags_size) + 1); + prdt_tbl_entry_size(&tbl[i])); } } @@ -1260,9 +1266,9 @@ static int ahci_state_post_load(void *opaque, int version_id) ad = &s->dev[i]; AHCIPortRegs *pr = &ad->port_regs; - map_page(&ad->lst, + map_page(s->as, &ad->lst, ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); - map_page(&ad->res_fis, + map_page(s->as, &ad->res_fis, ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); /* * All pending i/o should be flushed out on a migrate. However, diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h index 9a4064f892..f418b30ce7 100644 --- a/hw/ide/ahci.h +++ b/hw/ide/ahci.h @@ -201,6 +201,8 @@ #define AHCI_COMMAND_TABLE_ACMD 0x40 +#define AHCI_PRDT_SIZE_MASK 0x3fffff + #define IDE_FEATURE_DMA 1 #define READ_FPDMA_QUEUED 0x60 diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index ad176b700b..08f49ed53b 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -146,7 +146,13 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t new_addr, ret = 0; uint64_t address_space_end = address_space_start + address_space_size; - assert(address_space_end > address_space_size); + if (!address_space_size) { + error_setg(errp, "memory hotplug is not enabled, " + "please add maxmem option"); + goto out; + } + + assert(address_space_end > address_space_start); object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); if (hint) { diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 17ed5107ad..351d320470 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -827,6 +827,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, } pci_dev->bus = bus; + pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, @@ -836,7 +837,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); - pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index c0dc3658c7..6b6fb61c47 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -494,6 +494,7 @@ static unsigned virtio_s390_get_features(DeviceState *d) static Property s390_virtio_net_properties[] = { DEFINE_NIC_PROPERTIES(VirtIONetS390, vdev.nic_conf), + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features), DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features), DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetS390, vdev.net_conf), DEFINE_PROP_END_OF_LIST(), @@ -614,6 +615,7 @@ static const TypeInfo virtio_s390_device_info = { static Property s390_virtio_scsi_properties[] = { DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSIS390, vdev.parent_obj.conf), + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features), DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index c2799685f2..33a1d863b1 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1402,7 +1402,6 @@ static const TypeInfo virtio_ccw_net = { static Property virtio_ccw_blk_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_BLK_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), @@ -1430,7 +1429,6 @@ static const TypeInfo virtio_ccw_blk = { static Property virtio_ccw_serial_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtioSerialCcw, vdev.serial), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), @@ -1457,7 +1455,6 @@ static const TypeInfo virtio_ccw_serial = { static Property virtio_ccw_balloon_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), @@ -1514,7 +1511,6 @@ static const TypeInfo virtio_ccw_scsi = { static Property vhost_ccw_scsi_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), DEFINE_VHOST_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.parent_obj.conf), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_END_OF_LIST(), }; @@ -1551,7 +1547,6 @@ static void virtio_ccw_rng_instance_init(Object *obj) static Property virtio_ccw_rng_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORNGCcw, vdev.conf), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), @@ -1617,10 +1612,16 @@ static int virtio_ccw_busdev_unplug(DeviceState *dev) return 0; } +static Property virtio_ccw_properties[] = { + DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->props = virtio_ccw_properties; dc->init = virtio_ccw_busdev_init; dc->exit = virtio_ccw_busdev_exit; dc->unplug = virtio_ccw_busdev_unplug; diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 8829eb0e26..18c6e5b55c 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -369,10 +369,16 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp) sysbus_init_mmio(sbd, &proxy->iomem); } +static Property virtio_mmio_properties[] = { + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOMMIOProxy, host_features), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_mmio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->props = virtio_mmio_properties; dc->realize = virtio_mmio_realizefn; dc->reset = virtio_mmio_reset; set_bit(DEVICE_CATEGORY_MISC, dc->categories); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 3c42cda82b..3007319740 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -914,7 +914,6 @@ static Property virtio_9p_pci_properties[] = { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VIRTIO_9P_PROPERTIES(V9fsPCIState, vdev.fsconf), DEFINE_PROP_END_OF_LIST(), }; @@ -1003,11 +1002,9 @@ static void virtio_pci_device_plugged(DeviceState *d) static void virtio_pci_device_unplugged(DeviceState *d) { - PCIDevice *pci_dev = PCI_DEVICE(d); VirtIOPCIProxy *proxy = VIRTIO_PCI(d); virtio_pci_stop_ioeventfd(proxy); - msix_uninit_exclusive_bar(pci_dev); } static int virtio_pci_init(PCIDevice *pci_dev) @@ -1024,6 +1021,8 @@ static int virtio_pci_init(PCIDevice *pci_dev) static void virtio_pci_exit(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); + + msix_uninit_exclusive_bar(pci_dev); memory_region_destroy(&proxy->bar); } @@ -1037,11 +1036,17 @@ static void virtio_pci_reset(DeviceState *qdev) proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } +static Property virtio_pci_properties[] = { + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + dc->props = virtio_pci_properties; k->init = virtio_pci_init; k->exit = virtio_pci_exit; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; @@ -1066,7 +1071,6 @@ static Property virtio_blk_pci_properties[] = { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), - DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features), DEFINE_PROP_END_OF_LIST(), }; @@ -1191,7 +1195,6 @@ static const TypeInfo virtio_scsi_pci_info = { static Property vhost_scsi_pci_properties[] = { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSIPCI, vdev.parent_obj.conf), DEFINE_PROP_END_OF_LIST(), }; @@ -1272,7 +1275,6 @@ static void balloon_pci_stats_set_poll_interval(Object *obj, struct Visitor *v, } static Property virtio_balloon_pci_properties[] = { - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -1375,7 +1377,6 @@ static Property virtio_serial_pci_properties[] = { VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerialPCI, vdev.serial), DEFINE_PROP_END_OF_LIST(), }; @@ -1471,7 +1472,6 @@ static const TypeInfo virtio_net_pci_info = { /* virtio-rng-pci */ static Property virtio_rng_pci_properties[] = { - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORngPCI, vdev.conf), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/block/block.h b/include/block/block.h index baecc26dfc..32d36760fd 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -584,4 +584,8 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs); */ void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context); +void bdrv_io_plug(BlockDriverState *bs); +void bdrv_io_unplug(BlockDriverState *bs); +void bdrv_flush_io_queue(BlockDriverState *bs); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 8f8e65e763..f6c3befed8 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -261,6 +261,11 @@ struct BlockDriver { void (*bdrv_attach_aio_context)(BlockDriverState *bs, AioContext *new_context); + /* io queue for linux-aio */ + void (*bdrv_io_plug)(BlockDriverState *bs); + void (*bdrv_io_unplug)(BlockDriverState *bs); + void (*bdrv_flush_io_queue)(BlockDriverState *bs); + QLIST_ENTRY(BlockDriver) list; }; diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 223530e18a..b3080a2144 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -152,9 +152,6 @@ typedef struct VirtIOBlockReq { BlockAcctCookie acct; } VirtIOBlockReq; -#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \ - DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) - int virtio_blk_handle_scsi_req(VirtIOBlock *blk, VirtQueueElement *elem); diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index f7fccc08a4..6ceb5aa92e 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -258,7 +258,6 @@ struct virtio_net_ctrl_mq { #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 #define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \ - DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \ DEFINE_PROP_BIT("any_layout", _state, _field, VIRTIO_F_ANY_LAYOUT, true), \ DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \ DEFINE_PROP_BIT("guest_csum", _state, _field, VIRTIO_NET_F_GUEST_CSUM, true), \ diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index a8f618578b..0419ee4252 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -178,7 +178,6 @@ typedef struct { DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128) #define DEFINE_VIRTIO_SCSI_FEATURES(_state, _feature_field) \ - DEFINE_VIRTIO_COMMON_FEATURES(_state, _feature_field), \ DEFINE_PROP_BIT("hotplug", _state, _feature_field, VIRTIO_SCSI_F_HOTPLUG, \ true), \ DEFINE_PROP_BIT("param_change", _state, _feature_field, \ diff --git a/include/sysemu/char.h b/include/sysemu/char.h index c8b15f9729..0bbd631e72 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -84,7 +84,6 @@ struct CharDriverState { int avail_connections; int is_mux; guint fd_in_tag; - guint fd_hup_tag; QemuOpts *opts; QTAILQ_ENTRY(CharDriverState) next; }; @@ -301,6 +301,14 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, exit(1); } + if (memory_region_is_mapped(seg)) { + char *path = object_get_canonical_path_component(OBJECT(backend)); + error_report("memory backend %s is used multiple times. Each " + "-numa option must use a different memdev value.", + path); + exit(1); + } + memory_region_add_subregion(mr, addr, seg); vmstate_register_ram_global(seg); addr += size; diff --git a/qemu-char.c b/qemu-char.c index 51917de462..55e372cf32 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -581,6 +581,12 @@ static Notifier muxes_realize_notify = { .notify = muxes_realize_done, }; +static GSource *mux_chr_add_watch(CharDriverState *s, GIOCondition cond) +{ + MuxDriver *d = s->opaque; + return d->drv->chr_add_watch(d->drv, cond); +} + static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) { CharDriverState *chr; @@ -597,6 +603,9 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) chr->chr_accept_input = mux_chr_accept_input; /* Frontend guest-open / -close notification is not support with muxes */ chr->chr_set_fe_open = NULL; + if (drv->chr_add_watch) { + chr->chr_add_watch = mux_chr_add_watch; + } /* only default to opened state if we've realized the initial * set of muxes */ @@ -2673,6 +2682,12 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) uint8_t buf[READ_BUF_LEN]; int len, size; + if (cond & G_IO_HUP) { + /* connection closed */ + tcp_chr_disconnect(chr); + return TRUE; + } + if (!s->connected || s->max_size <= 0) { return TRUE; } @@ -2724,25 +2739,6 @@ CharDriverState *qemu_chr_open_eventfd(int eventfd) } #endif -static gboolean tcp_chr_chan_close(GIOChannel *channel, GIOCondition cond, - void *opaque) -{ - CharDriverState *chr = opaque; - - if (cond != G_IO_HUP) { - return FALSE; - } - - /* connection closed */ - tcp_chr_disconnect(chr); - if (chr->fd_hup_tag) { - g_source_remove(chr->fd_hup_tag); - chr->fd_hup_tag = 0; - } - - return TRUE; -} - static void tcp_chr_connect(void *opaque) { CharDriverState *chr = opaque; @@ -2752,8 +2748,6 @@ static void tcp_chr_connect(void *opaque) if (s->chan) { chr->fd_in_tag = io_add_watch_poll(s->chan, tcp_chr_read_poll, tcp_chr_read, chr); - chr->fd_hup_tag = g_io_add_watch(s->chan, G_IO_HUP, tcp_chr_chan_close, - chr); } qemu_chr_be_generic_open(chr); } diff --git a/qemu-doc.texi b/qemu-doc.texi index ad92c85cba..551619abd7 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -590,7 +590,7 @@ check -r all} is required, which may take some time. This option can only be enabled if @code{compat=1.1} is specified. @item nocow -If this option is set to @code{on}, it will trun off COW of the file. It's only +If this option is set to @code{on}, it will turn off COW of the file. It's only valid on btrfs, no effect on other file systems. Btrfs has low performance when hosting a VM image file, even more when the guest @@ -603,7 +603,7 @@ does. Note: this option is only valid to new or empty files. If there is an existing file which is COW and has data blocks already, it couldn't be changed to NOCOW by setting @code{nocow=on}. One can issue @code{lsattr filename} to check if -the NOCOW flag is set or not (Capitabl 'C' is NOCOW flag). +the NOCOW flag is set or not (Capital 'C' is NOCOW flag). @end table diff --git a/qemu-img.texi b/qemu-img.texi index 8496f3b8dc..514be90f7d 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -475,7 +475,7 @@ check -r all} is required, which may take some time. This option can only be enabled if @code{compat=1.1} is specified. @item nocow -If this option is set to @code{on}, it will trun off COW of the file. It's only +If this option is set to @code{on}, it will turn off COW of the file. It's only valid on btrfs, no effect on other file systems. Btrfs has low performance when hosting a VM image file, even more when the guest @@ -488,7 +488,7 @@ does. Note: this option is only valid to new or empty files. If there is an existing file which is COW and has data blocks already, it couldn't be changed to NOCOW by setting @code{nocow=on}. One can issue @code{lsattr filename} to check if -the NOCOW flag is set or not (Capitabl 'C' is NOCOW flag). +the NOCOW flag is set or not (Capital 'C' is NOCOW flag). @end table @@ -433,11 +433,57 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements, return ret; } +/* Return a DevicePropertyInfo for a qdev property. + * + * If a qdev property with the given name does not exist, use the given default + * type. If the qdev property info should not be shown, return NULL. + * + * The caller must free the return value. + */ +static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, + const char *name, + const char *default_type) +{ + DevicePropertyInfo *info; + Property *prop; + + do { + for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { + if (strcmp(name, prop->name) != 0) { + continue; + } + + /* + * TODO Properties without a parser are just for dirty hacks. + * qdev_prop_ptr is the only such PropertyInfo. It's marked + * for removal. This conditional should be removed along with + * it. + */ + if (!prop->info->set) { + return NULL; /* no way to set it, don't show */ + } + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(prop->name); + info->type = g_strdup(prop->info->legacy_name ?: prop->info->name); + return info; + } + klass = object_class_get_parent(klass); + } while (klass != object_class_by_name(TYPE_DEVICE)); + + /* Not a qdev property, use the default type */ + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(name); + info->type = g_strdup(default_type); + return info; +} + DevicePropertyInfoList *qmp_device_list_properties(const char *typename, Error **errp) { ObjectClass *klass; - Property *prop; + Object *obj; + ObjectProperty *prop; DevicePropertyInfoList *prop_list = NULL; klass = object_class_by_name(typename); @@ -453,32 +499,39 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, return NULL; } - do { - for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { - DevicePropertyInfoList *entry; - DevicePropertyInfo *info; + obj = object_new(typename); - /* - * TODO Properties without a parser are just for dirty hacks. - * qdev_prop_ptr is the only such PropertyInfo. It's marked - * for removal. This conditional should be removed along with - * it. - */ - if (!prop->info->set) { - continue; /* no way to set it, don't show */ - } + QTAILQ_FOREACH(prop, &obj->properties, node) { + DevicePropertyInfo *info; + DevicePropertyInfoList *entry; + + /* Skip Object and DeviceState properties */ + if (strcmp(prop->name, "type") == 0 || + strcmp(prop->name, "realized") == 0 || + strcmp(prop->name, "hotpluggable") == 0 || + strcmp(prop->name, "parent_bus") == 0) { + continue; + } - info = g_malloc0(sizeof(*info)); - info->name = g_strdup(prop->name); - info->type = g_strdup(prop->info->legacy_name ?: prop->info->name); + /* Skip legacy properties since they are just string versions of + * properties that we already list. + */ + if (strstart(prop->name, "legacy-", NULL)) { + continue; + } - entry = g_malloc0(sizeof(*entry)); - entry->value = info; - entry->next = prop_list; - prop_list = entry; + info = make_device_property_info(klass, prop->name, prop->type); + if (!info) { + continue; } - klass = object_class_get_parent(klass); - } while (klass != object_class_by_name(TYPE_DEVICE)); + + entry = g_malloc0(sizeof(*entry)); + entry->value = info; + entry->next = prop_list; + prop_list = entry; + } + + object_unref(obj); return prop_list; } diff --git a/tests/Makefile b/tests/Makefile index 7e53d0d618..1fcd633871 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -158,7 +158,7 @@ gcov-files-i386-y += hw/usb/hcd-ehci.c gcov-files-i386-y += hw/usb/hcd-uhci.c gcov-files-i386-y += hw/usb/dev-hid.c gcov-files-i386-y += hw/usb/dev-storage.c -#check-qtest-i386-y += tests/vhost-user-test$(EXESUF) +check-qtest-i386-$(CONFIG_POSIX) += tests/vhost-user-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y)) @@ -333,11 +333,13 @@ tests/es1370-test$(EXESUF): tests/es1370-test.o tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y) -tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a +tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a -#LIBS+= -lutil +ifeq ($(CONFIG_POSIX),y) +LIBS += -lutil +endif # QTest rules diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 0815e19274..5dbd4ee91b 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -217,6 +217,11 @@ class TestSingleDriveZeroLength(TestSingleDrive): test_small_buffer2 = None test_large_cluster = None +class TestSingleDriveUnalignedLength(TestSingleDrive): + image_len = 1025 * 1024 + test_small_buffer2 = None + test_large_cluster = None + class TestMirrorNoBacking(ImageMirroringTestCase): image_len = 2 * 1024 * 1024 # MB @@ -735,6 +740,9 @@ class TestRepairQuorum(ImageMirroringTestCase): image_len = 1 * 1024 * 1024 # MB IMAGES = [ quorum_img1, quorum_img2, quorum_img3 ] + def has_quorum(self): + return 'quorum' in iotests.qemu_img_pipe('--help') + def setUp(self): self.vm = iotests.VM() @@ -752,8 +760,9 @@ class TestRepairQuorum(ImageMirroringTestCase): #assemble the quorum block device from the individual files args = { "options" : { "driver": "quorum", "id": "quorum0", "vote-threshold": 2, "children": [ "img0", "img1", "img2" ] } } - result = self.vm.qmp("blockdev-add", **args) - self.assert_qmp(result, 'return', {}) + if self.has_quorum(): + result = self.vm.qmp("blockdev-add", **args) + self.assert_qmp(result, 'return', {}) def tearDown(self): @@ -766,6 +775,9 @@ class TestRepairQuorum(ImageMirroringTestCase): pass def test_complete(self): + if not self.has_quorum(): + return + self.assert_no_active_block_jobs() result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', @@ -784,6 +796,9 @@ class TestRepairQuorum(ImageMirroringTestCase): 'target image does not match source after mirroring') def test_cancel(self): + if not self.has_quorum(): + return + self.assert_no_active_block_jobs() result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', @@ -800,6 +815,9 @@ class TestRepairQuorum(ImageMirroringTestCase): self.vm.shutdown() def test_cancel_after_ready(self): + if not self.has_quorum(): + return + self.assert_no_active_block_jobs() result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', @@ -818,6 +836,9 @@ class TestRepairQuorum(ImageMirroringTestCase): 'target image does not match source after mirroring') def test_pause(self): + if not self.has_quorum(): + return + self.assert_no_active_block_jobs() result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', @@ -846,6 +867,9 @@ class TestRepairQuorum(ImageMirroringTestCase): 'target image does not match source after mirroring') def test_medium_not_found(self): + if not self.has_quorum(): + return + result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', node_name='repair0', replaces='img1', @@ -853,6 +877,9 @@ class TestRepairQuorum(ImageMirroringTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_image_not_found(self): + if not self.has_quorum(): + return + result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', node_name='repair0', replaces='img1', @@ -861,6 +888,9 @@ class TestRepairQuorum(ImageMirroringTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_device_not_found(self): + if not self.has_quorum(): + return + result = self.vm.qmp('drive-mirror', device='nonexistent', sync='full', node_name='repair0', replaces='img1', @@ -868,6 +898,9 @@ class TestRepairQuorum(ImageMirroringTestCase): self.assert_qmp(result, 'error/class', 'DeviceNotFound') def test_wrong_sync_mode(self): + if not self.has_quorum(): + return + result = self.vm.qmp('drive-mirror', device='quorum0', node_name='repair0', replaces='img1', @@ -875,12 +908,18 @@ class TestRepairQuorum(ImageMirroringTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_no_node_name(self): + if not self.has_quorum(): + return + result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', replaces='img1', target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'error/class', 'GenericError') def test_unexistant_replaces(self): + if not self.has_quorum(): + return + result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', node_name='repair0', replaces='img77', @@ -888,6 +927,9 @@ class TestRepairQuorum(ImageMirroringTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_after_a_quorum_snapshot(self): + if not self.has_quorum(): + return + result = self.vm.qmp('blockdev-snapshot-sync', node_name='img1', snapshot_file=quorum_snapshot_file, snapshot_node_name="snap1"); diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index 42147c0b58..24093bc631 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -.............................................. +...................................................... ---------------------------------------------------------------------- -Ran 46 tests +Ran 54 tests OK |