diff options
-rw-r--r-- | block.c | 21 | ||||
-rw-r--r-- | block/curl.c | 2 | ||||
-rw-r--r-- | block/file-posix.c | 5 | ||||
-rw-r--r-- | block/mirror.c | 6 | ||||
-rw-r--r-- | block/replication.c | 14 | ||||
-rw-r--r-- | blockdev.c | 4 | ||||
-rw-r--r-- | hw/intc/nios2_iic.c | 13 | ||||
-rw-r--r-- | hw/nios2/10m50_devboard.c | 3 | ||||
-rw-r--r-- | hw/xtensa/xtfpga.c | 9 | ||||
-rw-r--r-- | include/block/block_int.h | 4 | ||||
-rw-r--r-- | target/xtensa/xtensa-semi.c | 49 | ||||
-rw-r--r-- | util/oslib-posix.c | 2 | ||||
-rw-r--r-- | util/thread-pool.c | 7 |
13 files changed, 101 insertions, 38 deletions
@@ -1393,6 +1393,11 @@ static int bdrv_fill_options(QDict **options, const char *filename, return 0; } +static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared, + GSList *ignore_children, Error **errp); +static void bdrv_child_abort_perm_update(BdrvChild *c); +static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared); + /* * Check whether permissions on this node can be changed in a way that * @cumulative_perms and @cumulative_shared_perms are the new cumulative @@ -1615,8 +1620,8 @@ static int bdrv_check_update_perm(BlockDriverState *bs, uint64_t new_used_perm, /* Needs to be followed by a call to either bdrv_child_set_perm() or * bdrv_child_abort_perm_update(). */ -int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared, - GSList *ignore_children, Error **errp) +static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared, + GSList *ignore_children, Error **errp) { int ret; @@ -1627,7 +1632,7 @@ int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared, return ret; } -void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared) +static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared) { uint64_t cumulative_perms, cumulative_shared_perms; @@ -1639,7 +1644,7 @@ void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared) bdrv_set_perm(c->bs, cumulative_perms, cumulative_shared_perms); } -void bdrv_child_abort_perm_update(BdrvChild *c) +static void bdrv_child_abort_perm_update(BdrvChild *c) { bdrv_abort_perm_update(c->bs); } @@ -2025,6 +2030,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, bdrv_set_backing_hd(bs, backing_hd, &local_err); bdrv_unref(backing_hd); if (local_err) { + error_propagate(errp, local_err); ret = -EINVAL; goto free_exit; } @@ -4344,8 +4350,15 @@ void bdrv_attach_aio_context(BlockDriverState *bs, void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context) { + AioContext *ctx; + bdrv_drain(bs); /* ensure there are no in-flight requests */ + ctx = bdrv_get_aio_context(bs); + while (aio_poll(ctx, false)) { + /* wait for all bottom halves to execute */ + } + bdrv_detach_aio_context(bs); /* This function executes in the old AioContext so acquire the new one in diff --git a/block/curl.c b/block/curl.c index e83dcd8f50..34dbd335f4 100644 --- a/block/curl.c +++ b/block/curl.c @@ -377,7 +377,7 @@ static void curl_multi_check_completion(BDRVCURLState *s) } qemu_mutex_unlock(&s->mutex); - acb->common.cb(acb->common.opaque, -EPROTO); + acb->common.cb(acb->common.opaque, -EIO); qemu_mutex_lock(&s->mutex); qemu_aio_unref(acb); state->acb[i] = NULL; diff --git a/block/file-posix.c b/block/file-posix.c index c4c06637ef..53febd3767 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -686,7 +686,7 @@ static int hdev_get_max_segments(const struct stat *st) goto out; } do { - ret = read(fd, buf, sizeof(buf)); + ret = read(fd, buf, sizeof(buf) - 1); } while (ret == -1 && errno == EINTR); if (ret < 0) { ret = -errno; @@ -703,6 +703,9 @@ static int hdev_get_max_segments(const struct stat *st) } out: + if (fd != -1) { + close(fd); + } g_free(sysfspath); return ret; #else diff --git a/block/mirror.c b/block/mirror.c index 4f3a5cb310..ca4baa510a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -574,7 +574,8 @@ static void mirror_exit(BlockJob *job, void *opaque) * valid. Also give up permissions on mirror_top_bs->backing, which might * block the removal. */ block_job_remove_all_bdrv(job); - bdrv_child_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL); + bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL, + &error_abort); bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort); /* We just changed the BDS the job BB refers to (with either or both of the @@ -1245,7 +1246,8 @@ fail: block_job_unref(&s->common); } - bdrv_child_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL); + bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL, + &error_abort); bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort); } diff --git a/block/replication.c b/block/replication.c index 22f170fd33..bf3c395eb4 100644 --- a/block/replication.c +++ b/block/replication.c @@ -155,6 +155,18 @@ static void replication_close(BlockDriverState *bs) replication_remove(s->rs); } +static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, + const BdrvChildRole *role, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + *nperm = *nshared = BLK_PERM_CONSISTENT_READ \ + | BLK_PERM_WRITE \ + | BLK_PERM_WRITE_UNCHANGED; + + return; +} + static int64_t replication_getlength(BlockDriverState *bs) { return bdrv_getlength(bs->file->bs); @@ -660,7 +672,7 @@ BlockDriver bdrv_replication = { .bdrv_open = replication_open, .bdrv_close = replication_close, - .bdrv_child_perm = bdrv_filter_default_perms, + .bdrv_child_perm = replication_child_perm, .bdrv_getlength = replication_getlength, .bdrv_co_readv = replication_co_readv, diff --git a/blockdev.c b/blockdev.c index f1f49bd3ca..c5b2c2c209 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2047,7 +2047,9 @@ static void block_dirty_bitmap_clear_abort(BlkActionState *common) BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState, common, common); - bdrv_undo_clear_dirty_bitmap(state->bitmap, state->backup); + if (state->backup) { + bdrv_undo_clear_dirty_bitmap(state->bitmap, state->backup); + } } static void block_dirty_bitmap_clear_commit(BlkActionState *common) diff --git a/hw/intc/nios2_iic.c b/hw/intc/nios2_iic.c index 818ab1b315..190b6fdbf3 100644 --- a/hw/intc/nios2_iic.c +++ b/hw/intc/nios2_iic.c @@ -62,17 +62,15 @@ static void altera_iic_init(Object *obj) sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq); } -static Property altera_iic_properties[] = { - DEFINE_PROP_PTR("cpu", AlteraIIC, cpu), - DEFINE_PROP_END_OF_LIST(), -}; - static void altera_iic_realize(DeviceState *dev, Error **errp) { struct AlteraIIC *pv = ALTERA_IIC(dev); + Error *err = NULL; + pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &err); if (!pv->cpu) { - error_setg(errp, "altera,iic: CPU not connected"); + error_setg(errp, "altera,iic: CPU link not found: %s", + error_get_pretty(err)); return; } } @@ -81,8 +79,7 @@ static void altera_iic_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - dc->props = altera_iic_properties; - /* Reason: pointer property "cpu" */ + /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */ dc->cannot_instantiate_with_device_add_yet = true; dc->realize = altera_iic_realize; } diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c index 62e5738b65..051be73e9a 100644 --- a/hw/nios2/10m50_devboard.c +++ b/hw/nios2/10m50_devboard.c @@ -82,7 +82,8 @@ static void nios2_10m50_ghrd_init(MachineState *machine) /* Register: Internal Interrupt Controller (IIC) */ dev = qdev_create(NULL, "altera,iic"); - qdev_prop_set_ptr(dev, "cpu", cpu); + object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu), + &error_abort); qdev_init_nofail(dev); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]); for (i = 0; i < 32; i++) { diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index dc6fdcc266..11176e26bd 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -317,6 +317,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) cur_tagptr = put_tag(cur_tagptr, BP_TAG_COMMAND_LINE, strlen(kernel_cmdline) + 1, kernel_cmdline); } +#ifdef CONFIG_FDT if (dtb_filename) { int fdt_size; void *fdt = load_device_tree(dtb_filename, &fdt_size); @@ -332,6 +333,14 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) sizeof(dtb_addr), &dtb_addr); cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4096); } +#else + if (dtb_filename) { + error_report("could not load DTB '%s': " + "FDT support is not configured in QEMU", + dtb_filename); + exit(EXIT_FAILURE); + } +#endif if (initrd_filename) { BpMemInfo initrd_location = { 0 }; int initrd_size = load_ramdisk(initrd_filename, cur_lowmem, diff --git a/include/block/block_int.h b/include/block/block_int.h index 6c699ac9c3..59400bd848 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -889,10 +889,6 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, void *opaque, Error **errp); void bdrv_root_unref_child(BdrvChild *child); -int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared, - GSList *ignore_children, Error **errp); -void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared); -void bdrv_child_abort_perm_update(BdrvChild *c); int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared, Error **errp); diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index 370e365c65..a888a9dc7b 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -28,6 +28,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/helper-proto.h" +#include "exec/semihost.h" #include "qemu/log.h" enum { @@ -261,28 +262,50 @@ void HELPER(simcall)(CPUXtensaState *env) break; case TARGET_SYS_argc: - regs[2] = 1; + regs[2] = semihosting_get_argc(); regs[3] = 0; break; case TARGET_SYS_argv_sz: - regs[2] = 128; - regs[3] = 0; + { + int argc = semihosting_get_argc(); + int sz = (argc + 1) * sizeof(uint32_t); + int i; + + for (i = 0; i < argc; ++i) { + sz += 1 + strlen(semihosting_get_arg(i)); + } + regs[2] = sz; + regs[3] = 0; + } break; case TARGET_SYS_argv: { - struct Argv { - uint32_t argptr[2]; - char text[120]; - } argv = { - {0, 0}, - "test" - }; - - argv.argptr[0] = tswap32(regs[3] + offsetof(struct Argv, text)); + int argc = semihosting_get_argc(); + int str_offset = (argc + 1) * sizeof(uint32_t); + int i; + uint32_t argptr; + + for (i = 0; i < argc; ++i) { + const char *str = semihosting_get_arg(i); + int str_size = strlen(str) + 1; + + argptr = tswap32(regs[3] + str_offset); + + cpu_memory_rw_debug(cs, + regs[3] + i * sizeof(uint32_t), + (uint8_t *)&argptr, sizeof(argptr), 1); + cpu_memory_rw_debug(cs, + regs[3] + str_offset, + (uint8_t *)str, str_size, 1); + str_offset += str_size; + } + argptr = 0; cpu_memory_rw_debug(cs, - regs[3], (uint8_t *)&argv, sizeof(argv), 1); + regs[3] + i * sizeof(uint32_t), + (uint8_t *)&argptr, sizeof(argptr), 1); + regs[3] = 0; } break; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 94d81b9ec0..3fe6089c3e 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -709,8 +709,6 @@ void sigaction_invoke(struct sigaction *action, si.si_pid = info->ssi_pid; si.si_status = info->ssi_status; si.si_uid = info->ssi_uid; - } else if (info->ssi_signo == SIGIO) { - si.si_band = info->ssi_band; } action->sa_sigaction(info->ssi_signo, &si, NULL); } diff --git a/util/thread-pool.c b/util/thread-pool.c index ce6cd30193..610646d131 100644 --- a/util/thread-pool.c +++ b/util/thread-pool.c @@ -188,6 +188,13 @@ restart: aio_context_release(pool->ctx); elem->common.cb(elem->common.opaque, elem->ret); aio_context_acquire(pool->ctx); + + /* We can safely cancel the completion_bh here regardless of someone + * else having scheduled it meanwhile because we reenter the + * completion function anyway (goto restart). + */ + qemu_bh_cancel(pool->completion_bh); + qemu_aio_unref(elem); goto restart; } else { |