aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS6
-rw-r--r--Makefile20
-rw-r--r--audio/spiceaudio.c1
-rw-r--r--audio/wavcapture.c1
-rw-r--r--backends/hostmem.c1
-rw-r--r--backends/rng-egd.c11
-rw-r--r--backends/rng-random.c6
-rw-r--r--backends/rng.c2
-rw-r--r--backends/tpm.c2
-rw-r--r--balloon.c5
-rw-r--r--block.c12
-rw-r--r--block/backup.c5
-rw-r--r--block/block-backend.c5
-rw-r--r--block/commit.c3
-rw-r--r--block/curl.c1
-rw-r--r--block/dmg.c1
-rw-r--r--block/io.c46
-rw-r--r--block/iscsi.c5
-rw-r--r--block/mirror.c9
-rw-r--r--block/qapi.c8
-rw-r--r--block/qcow.c5
-rw-r--r--block/qcow2-snapshot.c1
-rw-r--r--block/qcow2.c4
-rw-r--r--block/qed.c4
-rw-r--r--block/quorum.c9
-rw-r--r--block/raw-posix.c93
-rw-r--r--block/raw-win32.c1
-rw-r--r--block/snapshot.c5
-rw-r--r--block/ssh.c2
-rw-r--r--block/stream.c5
-rw-r--r--block/throttle-groups.c9
-rw-r--r--block/vhdx-log.c1
-rw-r--r--block/vmdk.c14
-rw-r--r--block/vvfat.c30
-rw-r--r--blockdev-nbd.c6
-rw-r--r--blockdev.c80
-rw-r--r--blockjob.c9
-rwxr-xr-xconfigure201
-rw-r--r--cpus.c9
-rw-r--r--disas.c14
-rw-r--r--dump.c13
-rw-r--r--hmp.c64
-rw-r--r--hw/9pfs/virtio-9p.c1
-rw-r--r--hw/arm/virt-acpi-build.c22
-rw-r--r--hw/arm/virt.c2
-rw-r--r--hw/block/nvme.c1
-rw-r--r--hw/block/virtio-blk.c18
-rw-r--r--hw/char/serial-pci.c1
-rw-r--r--hw/char/virtio-serial-bus.c1
-rw-r--r--hw/core/nmi.c2
-rw-r--r--hw/core/platform-bus.c1
-rw-r--r--hw/core/qdev-properties-system.c46
-rw-r--r--hw/core/qdev-properties.c13
-rw-r--r--hw/core/qdev.c9
-rw-r--r--hw/display/cg3.c1
-rw-r--r--hw/display/g364fb.c1
-rw-r--r--hw/display/qxl-logger.c16
-rw-r--r--hw/display/qxl.c1
-rw-r--r--hw/display/tcx.c2
-rw-r--r--hw/dma/xilinx_axidma.c1
-rw-r--r--hw/i386/kvm/pci-assign.c39
-rw-r--r--hw/i386/pc.c2
-rw-r--r--hw/ide/ahci.c2
-rw-r--r--hw/input/Makefile.objs1
-rw-r--r--hw/input/virtio-input-host.c188
-rw-r--r--hw/input/virtio-input.c8
-rw-r--r--hw/intc/openpic.c6
-rw-r--r--hw/isa/piix4.c8
-rw-r--r--hw/isa/vt82c686.c47
-rw-r--r--hw/mips/mips_malta.c11
-rw-r--r--hw/misc/ivshmem.c2
-rw-r--r--hw/net/rocker/qmp-norocker.c8
-rw-r--r--hw/net/xilinx_axienet.c1
-rw-r--r--hw/pci-host/piix.c57
-rw-r--r--hw/pci/pci-stub.c3
-rw-r--r--hw/pci/pci.c5
-rw-r--r--hw/pci/pcie.c1
-rw-r--r--hw/pci/pcie_aer.c4
-rw-r--r--hw/pci/shpc.c1
-rw-r--r--hw/ppc/spapr_pci.c8
-rw-r--r--hw/ppc/spapr_vio.c1
-rw-r--r--hw/ppc/virtex_ml507.c2
-rw-r--r--hw/s390x/event-facility.c1
-rw-r--r--hw/s390x/s390-virtio-bus.c1
-rw-r--r--hw/s390x/s390-virtio.c4
-rw-r--r--hw/s390x/virtio-ccw.c2
-rw-r--r--hw/scsi/vhost-scsi.c1
-rw-r--r--hw/timer/hpet.c1
-rw-r--r--hw/tpm/tpm_passthrough.c1
-rw-r--r--hw/usb/bus.c1
-rw-r--r--hw/usb/ccid-card-emulated.c1
-rw-r--r--hw/usb/ccid-card-passthru.c2
-rw-r--r--hw/usb/dev-network.c2
-rw-r--r--hw/usb/dev-serial.c2
-rw-r--r--hw/usb/dev-smartcard-reader.c1
-rw-r--r--hw/usb/dev-storage.c1
-rw-r--r--hw/usb/hcd-ehci.h1
-rw-r--r--hw/usb/host-libusb.c1
-rw-r--r--hw/usb/redirect.c9
-rw-r--r--hw/virtio/virtio-pci.c43
-rw-r--r--hw/virtio/virtio-pci.h10
-rw-r--r--hw/virtio/virtio-rng.c1
-rw-r--r--hw/watchdog/wdt_i6300esb.c14
-rw-r--r--hw/xen/xen_pt.c61
-rw-r--r--hw/xen/xen_pt.h12
-rw-r--r--hw/xen/xen_pt_config_init.c7
-rw-r--r--hw/xen/xen_pt_msi.c24
-rw-r--r--include/block/block_int.h2
-rw-r--r--include/disas/disas.h4
-rw-r--r--include/exec/softmmu-semi.h13
-rw-r--r--include/hw/acpi/acpi-defs.h12
-rw-r--r--include/hw/virtio/virtio-input.h20
-rw-r--r--include/monitor/monitor.h9
-rw-r--r--include/monitor/qdev.h7
-rw-r--r--include/net/net.h2
-rw-r--r--include/qapi/qmp/qbool.h8
-rw-r--r--include/qapi/qmp/qdict.h4
-rw-r--r--include/qapi/qmp/qerror.h88
-rw-r--r--include/qapi/qmp/qobject.h1
-rw-r--r--include/qemu/hbitmap.h8
-rw-r--r--include/qemu/iov.h2
-rw-r--r--include/qemu/log.h4
-rw-r--r--include/qemu/option.h5
-rw-r--r--include/qemu/sockets.h1
-rw-r--r--include/sysemu/balloon.h1
-rw-r--r--include/sysemu/block-backend.h1
-rw-r--r--include/ui/console.h4
-rw-r--r--include/ui/qemu-spice.h2
-rw-r--r--libcacard/libcacard.pc.in2
-rw-r--r--libdecnumber/dpd/decimal128Local.h42
-rw-r--r--migration/migration.c38
-rw-r--r--migration/qemu-file-buf.c1
-rw-r--r--migration/qemu-file.c1
-rw-r--r--migration/rdma.c1
-rw-r--r--migration/savevm.c4
-rw-r--r--monitor.c301
-rw-r--r--net/l2tpv3.c1
-rw-r--r--net/net.c126
-rw-r--r--net/slirp.c1
-rw-r--r--numa.c1
-rw-r--r--qapi/block-core.json8
-rw-r--r--qapi/opts-visitor.c24
-rw-r--r--qapi/qapi-visit-core.c28
-rw-r--r--qapi/qmp-dispatch.c12
-rw-r--r--qapi/qmp-input-visitor.c30
-rw-r--r--qapi/qmp-output-visitor.c3
-rw-r--r--qapi/string-input-visitor.c24
-rw-r--r--qapi/string-output-visitor.c1
-rw-r--r--qdev-monitor.c172
-rw-r--r--qemu-char.c1
-rw-r--r--qemu-img.c6
-rw-r--r--qemu-io-cmds.c1
-rw-r--r--qemu-io.c4
-rw-r--r--qemu-nbd.c4
-rw-r--r--qemu-options.hx67
-rw-r--r--qga/commands-posix.c40
-rw-r--r--qga/commands-win32.c66
-rw-r--r--qga/main.c4
-rw-r--r--qmp-commands.hx6
-rw-r--r--qmp.c97
-rw-r--r--qobject/Makefile.objs1
-rw-r--r--qobject/json-parser.c7
-rw-r--r--qobject/qbool.c8
-rw-r--r--qobject/qdict.c8
-rw-r--r--qobject/qerror.c148
-rw-r--r--qobject/qjson.c5
-rw-r--r--qom/object.c22
-rw-r--r--scripts/qapi-commands.py42
-rw-r--r--slirp/misc.c1
-rw-r--r--stubs/Makefile.objs1
-rw-r--r--stubs/arch-query-cpu-def.c2
-rw-r--r--stubs/dump.c1
-rw-r--r--stubs/mon-is-qmp.c2
-rw-r--r--stubs/mon-set-error.c8
-rw-r--r--target-alpha/translate.c2
-rw-r--r--target-arm/arm-semi.c11
-rw-r--r--target-arm/cpu.c1
-rw-r--r--target-arm/helper-a64.c2
-rw-r--r--target-arm/translate-a64.c2
-rw-r--r--target-arm/translate.c2
-rw-r--r--target-cris/translate.c2
-rw-r--r--target-i386/cpu.c20
-rw-r--r--target-i386/kvm.c1
-rw-r--r--target-i386/translate.c2
-rw-r--r--target-lm32/translate.c2
-rw-r--r--target-m68k/translate.c2
-rw-r--r--target-microblaze/translate.c2
-rw-r--r--target-mips/Makefile.objs2
-rw-r--r--target-mips/helper.h2
-rw-r--r--target-mips/mips-semi.c358
-rw-r--r--target-mips/translate.c1751
-rw-r--r--target-mips/translate_init.c37
-rw-r--r--target-openrisc/translate.c2
-rw-r--r--target-ppc/translate.c2
-rw-r--r--target-s390x/kvm.c2
-rw-r--r--target-s390x/translate.c2
-rw-r--r--target-sh4/translate.c2
-rw-r--r--target-sparc/translate.c2
-rw-r--r--target-tricore/translate.c2
-rw-r--r--target-unicore32/translate.c2
-rw-r--r--target-xtensa/translate.c2
-rw-r--r--tests/check-qjson.c11
-rw-r--r--tests/qemu-iotests/051.out8
-rw-r--r--tests/test-hbitmap.c38
-rw-r--r--tests/test-opts-visitor.c3
-rw-r--r--tests/test-qemu-opts.c2
-rw-r--r--tests/test-qmp-event.c4
-rw-r--r--tests/test-qmp-output-visitor.c6
-rw-r--r--tpm.c12
-rw-r--r--ui/input-legacy.c1
-rw-r--r--ui/input.c4
-rw-r--r--ui/spice-core.c1
-rw-r--r--ui/spice-display.c1
-rw-r--r--ui/vnc-jobs.c1
-rw-r--r--ui/vnc.c10
-rw-r--r--util/hbitmap.c13
-rw-r--r--util/iov.c14
-rw-r--r--util/osdep.c1
-rw-r--r--util/qemu-config.c1
-rw-r--r--util/qemu-error.c5
-rw-r--r--util/qemu-option.c49
-rw-r--r--util/qemu-sockets.c9
-rw-r--r--vl.c150
-rw-r--r--xen-hvm.c24
224 files changed, 3492 insertions, 2143 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 5b4c30788f..3d48a6bd65 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -740,6 +740,12 @@ S: Supported
F: hw/s390x/virtio-ccw.[hc]
T: git git://github.com/cohuck/qemu virtio-ccw-upstr
+virtio-input
+M: Gerd Hoffmann <kraxel@redhat.com>
+S: Maintained
+F: hw/input/virtio-input*.c
+F: include/hw/virtio/virtio-input.h
+
virtio-serial
M: Amit Shah <amit.shah@redhat.com>
S: Supported
diff --git a/Makefile b/Makefile
index e7c5c3af6f..c9be643ae3 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,11 @@
# Always point to the root of the build tree (needs GNU make).
BUILD_DIR=$(CURDIR)
+# Before including a proper config-host.mak, assume we are in the source tree
+SRC_PATH=.
+
+UNCHECKED_GOALS := %clean TAGS cscope ctags
+
# All following code might depend on configuration variables
ifneq ($(wildcard config-host.mak),)
# Put the all: rule here so that config-host.mak can contain dependencies.
@@ -38,7 +43,7 @@ config-host.mak: $(SRC_PATH)/configure
fi
else
config-host.mak:
-ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
@echo "Please call configure before running make!"
@exit 1
endif
@@ -449,15 +454,20 @@ endif
test speed: all
$(MAKE) -C tests/tcg $@
+.PHONY: ctags
+ctags:
+ rm -f $@
+ find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
+
.PHONY: TAGS
TAGS:
rm -f $@
find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
cscope:
- rm -f ./cscope.*
- find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files
- cscope -b
+ rm -f "$(SRC_PATH)"/cscope.*
+ find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
+ cscope -b -i"$(SRC_PATH)/cscope.files"
# opengl shader programs
ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
@@ -600,7 +610,7 @@ endif # CONFIG_WIN
# Add a dependency on the generated files, so that they are always
# rebuilt before other object files
-ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
Makefile: $(GENERATED_HEADERS)
endif
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index 5c6f726757..42ae4a45f7 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -18,6 +18,7 @@
*/
#include "hw/hw.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "ui/qemu-spice.h"
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 6f6d792691..86e905627a 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -1,5 +1,6 @@
#include "hw/hw.h"
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "audio.h"
typedef struct {
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 7d74be04c3..61c1ac0843 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -13,7 +13,6 @@
#include "qapi/visitor.h"
#include "qapi-types.h"
#include "qapi-visit.h"
-#include "qapi/qmp/qerror.h"
#include "qemu/config-file.h"
#include "qom/object_interfaces.h"
diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 2962795a8f..6c13409632 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -140,19 +140,20 @@ static void rng_egd_opened(RngBackend *b, Error **errp)
RngEgd *s = RNG_EGD(b);
if (s->chr_name == NULL) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- "chardev", "a valid character device");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "chardev", "a valid character device");
return;
}
s->chr = qemu_chr_find(s->chr_name);
if (s->chr == NULL) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, s->chr_name);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", s->chr_name);
return;
}
if (qemu_chr_fe_claim(s->chr) != 0) {
- error_set(errp, QERR_DEVICE_IN_USE, s->chr_name);
+ error_setg(errp, QERR_DEVICE_IN_USE, s->chr_name);
return;
}
@@ -167,7 +168,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
RngEgd *s = RNG_EGD(b);
if (b->opened) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_setg(errp, QERR_PERMISSION_DENIED);
} else {
g_free(s->chr_name);
s->chr_name = g_strdup(value);
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 4f85a8ea49..4e51f4609b 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -74,8 +74,8 @@ static void rng_random_opened(RngBackend *b, Error **errp)
RndRandom *s = RNG_RANDOM(b);
if (s->filename == NULL) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- "filename", "a valid filename");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "filename", "a valid filename");
} else {
s->fd = qemu_open(s->filename, O_RDONLY | O_NONBLOCK);
if (s->fd == -1) {
@@ -98,7 +98,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
RndRandom *s = RNG_RANDOM(obj);
if (b->opened) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_setg(errp, QERR_PERMISSION_DENIED);
return;
}
diff --git a/backends/rng.c b/backends/rng.c
index 0f2fc11dd8..5065fdc155 100644
--- a/backends/rng.c
+++ b/backends/rng.c
@@ -57,7 +57,7 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp)
}
if (!value && s->opened) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_setg(errp, QERR_PERMISSION_DENIED);
return;
}
diff --git a/backends/tpm.c b/backends/tpm.c
index f3ab3b30bd..a512693b15 100644
--- a/backends/tpm.c
+++ b/backends/tpm.c
@@ -133,7 +133,7 @@ static void tpm_backend_prop_set_opened(Object *obj, bool value, Error **errp)
}
if (!value && s->opened) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_setg(errp, QERR_PERMISSION_DENIED);
return;
}
diff --git a/balloon.c b/balloon.c
index c7033e3dc3..5d69e8a00b 100644
--- a/balloon.c
+++ b/balloon.c
@@ -24,12 +24,13 @@
* THE SOFTWARE.
*/
-#include "monitor/monitor.h"
+#include "qemu-common.h"
#include "exec/cpu-common.h"
#include "sysemu/kvm.h"
#include "sysemu/balloon.h"
#include "trace.h"
#include "qmp-commands.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h"
static QEMUBalloonEvent *balloon_event_fn;
@@ -96,7 +97,7 @@ void qmp_balloon(int64_t target, Error **errp)
}
if (target <= 0) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
return;
}
diff --git a/block.c b/block.c
index dd4f58d6cb..81233beaab 100644
--- a/block.c
+++ b/block.c
@@ -26,7 +26,9 @@
#include "trace.h"
#include "block/block_int.h"
#include "block/blockjob.h"
+#include "qemu/error-report.h"
#include "qemu/module.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h"
#include "sysemu/block-backend.h"
#include "sysemu/sysemu.h"
@@ -583,7 +585,7 @@ static int find_image_format(BlockDriverState *bs, const char *filename,
int ret = 0;
/* Return the raw BlockDriver * to scsi-generic devices or empty drives */
- if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
+ if (bdrv_is_sg(bs) || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
*pdrv = &bdrv_raw;
return ret;
}
@@ -615,7 +617,7 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint)
BlockDriver *drv = bs->drv;
/* Do not attempt drv->bdrv_getlength() on scsi-generic devices */
- if (bs->sg)
+ if (bdrv_is_sg(bs))
return 0;
/* query actual device if possible, otherwise just trust the hint */
@@ -946,7 +948,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
assert(bdrv_opt_mem_align(bs) != 0);
assert(bdrv_min_mem_align(bs) != 0);
- assert((bs->request_alignment != 0) || bs->sg);
+ assert((bs->request_alignment != 0) || bdrv_is_sg(bs));
qemu_opts_del(opts);
return 0;
@@ -2698,7 +2700,7 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp)
error_setg(errp, "Node '%s' is not encrypted",
bdrv_get_device_or_node_name(bs));
} else if (bdrv_set_key(bs, key) < 0) {
- error_set(errp, QERR_INVALID_PASSWORD);
+ error_setg(errp, QERR_INVALID_PASSWORD);
}
} else {
if (bdrv_key_required(bs)) {
@@ -3511,7 +3513,7 @@ void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap)
{
assert(bdrv_dirty_bitmap_enabled(bitmap));
- hbitmap_reset(bitmap->bitmap, 0, bitmap->size);
+ hbitmap_reset_all(bitmap->bitmap);
}
void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
diff --git a/block/backup.c b/block/backup.c
index d3f648ddd7..4a1af68c32 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -19,6 +19,7 @@
#include "block/block.h"
#include "block/block_int.h"
#include "block/blockjob.h"
+#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h"
#define BACKUP_CLUSTER_BITS 16
@@ -197,7 +198,7 @@ static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp)
BackupBlockJob *s = container_of(job, BackupBlockJob, common);
if (speed < 0) {
- error_set(errp, QERR_INVALID_PARAMETER, "speed");
+ error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -472,7 +473,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
- error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");
+ error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error");
return;
}
diff --git a/block/block-backend.c b/block/block-backend.c
index 93e46f376a..aee8a12023 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -700,6 +700,11 @@ int blk_flush_all(void)
return bdrv_flush_all();
}
+void blk_drain(BlockBackend *blk)
+{
+ bdrv_drain(blk->bs);
+}
+
void blk_drain_all(void)
{
bdrv_drain_all();
diff --git a/block/commit.c b/block/commit.c
index cfa2bbebc2..7312a5bdc0 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -15,6 +15,7 @@
#include "trace.h"
#include "block/block_int.h"
#include "block/blockjob.h"
+#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h"
enum {
@@ -186,7 +187,7 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp)
CommitBlockJob *s = container_of(job, CommitBlockJob, common);
if (speed < 0) {
- error_set(errp, QERR_INVALID_PARAMETER, "speed");
+ error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
diff --git a/block/curl.c b/block/curl.c
index bbee3ca179..3a2b63e16e 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "block/block_int.h"
#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qstring.h"
#include <curl/curl.h>
// #define DEBUG_CURL
diff --git a/block/dmg.c b/block/dmg.c
index 825c49d59a..9f2528169c 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "block/block_int.h"
#include "qemu/bswap.h"
+#include "qemu/error-report.h"
#include "qemu/module.h"
#include <zlib.h>
#ifdef CONFIG_BZIP2
diff --git a/block/io.c b/block/io.c
index bb4f78784e..e2959920b8 100644
--- a/block/io.c
+++ b/block/io.c
@@ -26,6 +26,7 @@
#include "block/blockjob.h"
#include "block/block_int.h"
#include "block/throttle-groups.h"
+#include "qemu/error-report.h"
#define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
@@ -232,17 +233,6 @@ static bool bdrv_requests_pending(BlockDriverState *bs)
return false;
}
-static bool bdrv_drain_one(BlockDriverState *bs)
-{
- bool bs_busy;
-
- bdrv_flush_io_queue(bs);
- bdrv_start_throttled_reqs(bs);
- bs_busy = bdrv_requests_pending(bs);
- bs_busy |= aio_poll(bdrv_get_aio_context(bs), bs_busy);
- return bs_busy;
-}
-
/*
* Wait for pending requests to complete on a single BlockDriverState subtree
*
@@ -255,8 +245,13 @@ static bool bdrv_drain_one(BlockDriverState *bs)
*/
void bdrv_drain(BlockDriverState *bs)
{
- while (bdrv_drain_one(bs)) {
+ bool busy = true;
+
+ while (busy) {
/* Keep iterating */
+ bdrv_flush_io_queue(bs);
+ busy = bdrv_requests_pending(bs);
+ busy |= aio_poll(bdrv_get_aio_context(bs), busy);
}
}
@@ -277,6 +272,7 @@ void bdrv_drain_all(void)
/* Always run first iteration so any pending completion BHs run */
bool busy = true;
BlockDriverState *bs = NULL;
+ GSList *aio_ctxs = NULL, *ctx;
while ((bs = bdrv_next(bs))) {
AioContext *aio_context = bdrv_get_aio_context(bs);
@@ -286,17 +282,30 @@ void bdrv_drain_all(void)
block_job_pause(bs->job);
}
aio_context_release(aio_context);
+
+ if (!aio_ctxs || !g_slist_find(aio_ctxs, aio_context)) {
+ aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
+ }
}
while (busy) {
busy = false;
- bs = NULL;
- while ((bs = bdrv_next(bs))) {
- AioContext *aio_context = bdrv_get_aio_context(bs);
+ for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {
+ AioContext *aio_context = ctx->data;
+ bs = NULL;
aio_context_acquire(aio_context);
- busy |= bdrv_drain_one(bs);
+ while ((bs = bdrv_next(bs))) {
+ if (aio_context == bdrv_get_aio_context(bs)) {
+ bdrv_flush_io_queue(bs);
+ if (bdrv_requests_pending(bs)) {
+ busy = true;
+ aio_poll(aio_context, busy);
+ }
+ }
+ }
+ busy |= aio_poll(aio_context, false);
aio_context_release(aio_context);
}
}
@@ -311,6 +320,7 @@ void bdrv_drain_all(void)
}
aio_context_release(aio_context);
}
+ g_slist_free(aio_ctxs);
}
/**
@@ -2255,7 +2265,8 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
{
int ret;
- if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
+ if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) ||
+ bdrv_is_sg(bs)) {
return 0;
}
@@ -2561,4 +2572,5 @@ void bdrv_flush_io_queue(BlockDriverState *bs)
} else if (bs->file) {
bdrv_flush_io_queue(bs->file);
}
+ bdrv_start_throttled_reqs(bs);
}
diff --git a/block/iscsi.c b/block/iscsi.c
index 14e97a6b48..49cee4dda9 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -38,6 +38,7 @@
#include "qemu/iov.h"
#include "sysemu/sysemu.h"
#include "qmp-commands.h"
+#include "qapi/qmp/qstring.h"
#include <iscsi/iscsi.h>
#include <iscsi/scsi-lowlevel.h>
@@ -627,10 +628,6 @@ static int coroutine_fn iscsi_co_flush(BlockDriverState *bs)
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
- if (bs->sg) {
- return 0;
- }
-
if (!iscsilun->force_next_flush) {
return 0;
}
diff --git a/block/mirror.c b/block/mirror.c
index 58f391a6d6..048e452d17 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -14,6 +14,7 @@
#include "trace.h"
#include "block/blockjob.h"
#include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h"
#include "qemu/bitmap.h"
@@ -573,7 +574,7 @@ static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp)
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
if (speed < 0) {
- error_set(errp, QERR_INVALID_PARAMETER, "speed");
+ error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -598,8 +599,8 @@ static void mirror_complete(BlockJob *job, Error **errp)
return;
}
if (!s->synced) {
- error_set(errp, QERR_BLOCK_JOB_NOT_READY,
- bdrv_get_device_name(job->bs));
+ error_setg(errp, QERR_BLOCK_JOB_NOT_READY,
+ bdrv_get_device_name(job->bs));
return;
}
@@ -667,7 +668,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
if ((on_source_error == BLOCKDEV_ON_ERROR_STOP ||
on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
- error_set(errp, QERR_INVALID_PARAMETER, "on-source-error");
+ error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error");
return;
}
diff --git a/block/qapi.c b/block/qapi.c
index a738148bce..2ce509711d 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -520,13 +520,7 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
}
case QTYPE_QBOOL: {
QBool *value = qobject_to_qbool(obj);
- func_fprintf(f, "%s", qbool_get_int(value) ? "true" : "false");
- break;
- }
- case QTYPE_QERROR: {
- QString *value = qerror_human((QError *)obj);
- func_fprintf(f, "%s", qstring_get_str(value));
- QDECREF(value);
+ func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
break;
}
default:
diff --git a/block/qcow.c b/block/qcow.c
index 911e59fd0b..733627fbf2 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -25,6 +25,7 @@
#include "block/block_int.h"
#include "qemu/module.h"
#include <zlib.h>
+#include "qapi/qmp/qerror.h"
#include "qemu/aes.h"
#include "migration/migration.h"
@@ -123,8 +124,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
char version[64];
snprintf(version, sizeof(version), "QCOW version %" PRIu32,
header.version);
- error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
- bdrv_get_device_or_node_name(bs), "qcow", version);
+ error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ bdrv_get_device_or_node_name(bs), "qcow", version);
ret = -ENOTSUP;
goto fail;
}
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 17bb2119b2..b6f58c13e2 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -25,6 +25,7 @@
#include "qemu-common.h"
#include "block/block_int.h"
#include "block/qcow2.h"
+#include "qemu/error-report.h"
void qcow2_free_snapshots(BlockDriverState *bs)
{
diff --git a/block/qcow2.c b/block/qcow2.c
index c4f6938a36..d522ec7d14 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -207,8 +207,8 @@ static void GCC_FMT_ATTR(3, 4) report_unsupported(BlockDriverState *bs,
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
- error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
- bdrv_get_device_or_node_name(bs), "qcow2", msg);
+ error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ bdrv_get_device_or_node_name(bs), "qcow2", msg);
}
static void report_unsupported_feature(BlockDriverState *bs,
diff --git a/block/qed.c b/block/qed.c
index 5bbe069ce9..954ed007c0 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -407,8 +407,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
char buf[64];
snprintf(buf, sizeof(buf), "%" PRIx64,
s->header.features & ~QED_FEATURE_MASK);
- error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
- bdrv_get_device_or_node_name(bs), "QED", buf);
+ error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ bdrv_get_device_or_node_name(bs), "QED", buf);
return -ENOTSUP;
}
if (!qed_is_cluster_size_valid(s->header.cluster_size)) {
diff --git a/block/quorum.c b/block/quorum.c
index 77e55b2775..a7df17c185 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -18,6 +18,7 @@
#include "block/block_int.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qint.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlist.h"
@@ -800,8 +801,8 @@ static int quorum_valid_threshold(int threshold, int num_children, Error **errp)
{
if (threshold < 1) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- "vote-threshold", "value >= 1");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "vote-threshold", "value >= 1");
return -ERANGE;
}
@@ -1024,9 +1025,9 @@ static void quorum_refresh_filename(BlockDriverState *bs)
qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD,
QOBJECT(qint_from_int(s->threshold)));
qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY,
- QOBJECT(qbool_from_int(s->is_blkverify)));
+ QOBJECT(qbool_from_bool(s->is_blkverify)));
qdict_put_obj(opts, QUORUM_OPT_REWRITE,
- QOBJECT(qbool_from_int(s->rewrite_corrupted)));
+ QOBJECT(qbool_from_bool(s->rewrite_corrupted)));
qdict_put_obj(opts, "children", QOBJECT(children));
bs->full_open_options = opts;
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 44ade8cf4e..cbe6574bf4 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "qemu/log.h"
#include "block/block_int.h"
@@ -31,6 +32,7 @@
#include "qemu/iov.h"
#include "raw-aio.h"
#include "qapi/util.h"
+#include "qapi/qmp/qstring.h"
#if defined(__APPLE__) && (__MACH__)
#include <paths.h>
@@ -57,6 +59,7 @@
#include <linux/fd.h>
#include <linux/fs.h>
#include <linux/hdreg.h>
+#include <scsi/sg.h>
#ifdef __s390__
#include <asm/dasd.h>
#endif
@@ -94,15 +97,19 @@
#include <xfs/xfs.h>
#endif
-//#define DEBUG_FLOPPY
-
//#define DEBUG_BLOCK
-#if defined(DEBUG_BLOCK)
-#define DEBUG_BLOCK_PRINT(formatCstr, ...) do { if (qemu_log_enabled()) \
- { qemu_log(formatCstr, ## __VA_ARGS__); qemu_log_flush(); } } while (0)
+
+#ifdef DEBUG_BLOCK
+# define DEBUG_BLOCK_PRINT 1
#else
-#define DEBUG_BLOCK_PRINT(formatCstr, ...)
+# define DEBUG_BLOCK_PRINT 0
#endif
+#define DPRINTF(fmt, ...) \
+do { \
+ if (DEBUG_BLOCK_PRINT) { \
+ printf(fmt, ## __VA_ARGS__); \
+ } \
+} while (0)
/* OS X does not have O_DSYNC */
#ifndef O_DSYNC
@@ -303,9 +310,9 @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
char *buf;
size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize());
- /* For /dev/sg devices the alignment is not really used.
+ /* For SCSI generic devices the alignment is not really used.
With buffered I/O, we don't have any restrictions. */
- if (bs->sg || !s->needs_alignment) {
+ if (bdrv_is_sg(bs) || !s->needs_alignment) {
bs->request_alignment = 1;
s->buf_align = 1;
return;
@@ -1018,6 +1025,7 @@ static ssize_t handle_aiocb_rw(RawPosixAIOData *aiocb)
static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes)
{
struct xfs_flock64 fl;
+ int err;
memset(&fl, 0, sizeof(fl));
fl.l_whence = SEEK_SET;
@@ -1025,8 +1033,9 @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes)
fl.l_len = bytes;
if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) {
- DEBUG_BLOCK_PRINT("cannot write zero range (%s)\n", strerror(errno));
- return -errno;
+ err = errno;
+ DPRINTF("cannot write zero range (%s)\n", strerror(errno));
+ return -err;
}
return 0;
@@ -1035,6 +1044,7 @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes)
static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes)
{
struct xfs_flock64 fl;
+ int err;
memset(&fl, 0, sizeof(fl));
fl.l_whence = SEEK_SET;
@@ -1042,8 +1052,9 @@ static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes)
fl.l_len = bytes;
if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) {
- DEBUG_BLOCK_PRINT("cannot punch hole (%s)\n", strerror(errno));
- return -errno;
+ err = errno;
+ DPRINTF("cannot punch hole (%s)\n", strerror(errno));
+ return -err;
}
return 0;
@@ -2076,15 +2087,38 @@ static void hdev_parse_filename(const char *filename, QDict *options,
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
}
+static bool hdev_is_sg(BlockDriverState *bs)
+{
+
+#if defined(__linux__)
+
+ struct stat st;
+ struct sg_scsi_id scsiid;
+ int sg_version;
+
+ if (stat(bs->filename, &st) >= 0 && S_ISCHR(st.st_mode) &&
+ !bdrv_ioctl(bs, SG_GET_VERSION_NUM, &sg_version) &&
+ !bdrv_ioctl(bs, SG_GET_SCSI_ID, &scsiid)) {
+ DPRINTF("SG device found: type=%d, version=%d\n",
+ scsiid.scsi_type, sg_version);
+ return true;
+ }
+
+#endif
+
+ return false;
+}
+
static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRawState *s = bs->opaque;
Error *local_err = NULL;
int ret;
- const char *filename = qdict_get_str(options, "filename");
#if defined(__APPLE__) && defined(__MACH__)
+ const char *filename = qdict_get_str(options, "filename");
+
if (strstart(filename, "/dev/cdrom", NULL)) {
kern_return_t kernResult;
io_iterator_t mediaIterator;
@@ -2113,16 +2147,6 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
#endif
s->type = FTYPE_FILE;
-#if defined(__linux__)
- {
- char resolved_path[ MAXPATHLEN ], *temp;
-
- temp = realpath(filename, resolved_path);
- if (temp && strstart(temp, "/dev/sg", NULL)) {
- bs->sg = 1;
- }
- }
-#endif
ret = raw_open_common(bs, options, flags, 0, &local_err);
if (ret < 0) {
@@ -2132,6 +2156,9 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
return ret;
}
+ /* Since this does ioctl the device must be already opened */
+ bs->sg = hdev_is_sg(bs);
+
if (flags & BDRV_O_RDWR) {
ret = check_hdev_writable(s);
if (ret < 0) {
@@ -2160,16 +2187,12 @@ static int fd_open(BlockDriverState *bs)
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
qemu_close(s->fd);
s->fd = -1;
-#ifdef DEBUG_FLOPPY
- printf("Floppy closed\n");
-#endif
+ DPRINTF("Floppy closed\n");
}
if (s->fd < 0) {
if (s->fd_got_error &&
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
-#ifdef DEBUG_FLOPPY
- printf("No floppy (open delayed)\n");
-#endif
+ DPRINTF("No floppy (open delayed)\n");
return -EIO;
}
s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK);
@@ -2178,14 +2201,10 @@ static int fd_open(BlockDriverState *bs)
s->fd_got_error = 1;
if (last_media_present)
s->fd_media_changed = 1;
-#ifdef DEBUG_FLOPPY
- printf("No floppy\n");
-#endif
+ DPRINTF("No floppy\n");
return -EIO;
}
-#ifdef DEBUG_FLOPPY
- printf("Floppy opened\n");
-#endif
+ DPRINTF("Floppy opened\n");
}
if (!last_media_present)
s->fd_media_changed = 1;
@@ -2453,9 +2472,7 @@ static int floppy_media_changed(BlockDriverState *bs)
fd_open(bs);
ret = s->fd_media_changed;
s->fd_media_changed = 0;
-#ifdef DEBUG_FLOPPY
- printf("Floppy changed=%d\n", ret);
-#endif
+ DPRINTF("Floppy changed=%d\n", ret);
return ret;
}
diff --git a/block/raw-win32.c b/block/raw-win32.c
index dae5d2fee9..68f2338acc 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -29,6 +29,7 @@
#include "trace.h"
#include "block/thread-pool.h"
#include "qemu/iov.h"
+#include "qapi/qmp/qstring.h"
#include <windows.h>
#include <winioctl.h>
diff --git a/block/snapshot.c b/block/snapshot.c
index 50ae610139..19395ae014 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -24,6 +24,7 @@
#include "block/snapshot.h"
#include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
QemuOptsList internal_snapshot_opts = {
.name = "snapshot",
@@ -229,7 +230,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
{
BlockDriver *drv = bs->drv;
if (!drv) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
return -ENOMEDIUM;
}
if (!snapshot_id && !name) {
@@ -315,7 +316,7 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs,
BlockDriver *drv = bs->drv;
if (!drv) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, bdrv_get_device_name(bs));
return -ENOMEDIUM;
}
if (!snapshot_id && !name) {
diff --git a/block/ssh.c b/block/ssh.c
index f466cbf396..aebb18cc8f 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -30,9 +30,11 @@
#include <libssh2_sftp.h>
#include "block/block_int.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "qemu/uri.h"
#include "qapi/qmp/qint.h"
+#include "qapi/qmp/qstring.h"
/* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in
* this block driver code.
diff --git a/block/stream.c b/block/stream.c
index a628901f69..ab0bd057f7 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -14,6 +14,7 @@
#include "trace.h"
#include "block/block_int.h"
#include "block/blockjob.h"
+#include "qapi/qmp/qerror.h"
#include "qemu/ratelimit.h"
enum {
@@ -227,7 +228,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
StreamBlockJob *s = container_of(job, StreamBlockJob, common);
if (speed < 0) {
- error_set(errp, QERR_INVALID_PARAMETER, "speed");
+ error_setg(errp, QERR_INVALID_PARAMETER, "speed");
return;
}
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
@@ -250,7 +251,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base,
if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
- error_set(errp, QERR_INVALID_PARAMETER, "on-error");
+ error_setg(errp, QERR_INVALID_PARAMETER, "on-error");
return;
}
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index efc462fbc5..1abc6fcaea 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -324,9 +324,14 @@ void throttle_group_config(BlockDriverState *bs, ThrottleConfig *cfg)
ThrottleState *ts = bs->throttle_state;
ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
qemu_mutex_lock(&tg->lock);
- throttle_config(ts, tt, cfg);
/* throttle_config() cancels the timers */
- tg->any_timer_armed[0] = tg->any_timer_armed[1] = false;
+ if (timer_pending(tt->timers[0])) {
+ tg->any_timer_armed[0] = false;
+ }
+ if (timer_pending(tt->timers[1])) {
+ tg->any_timer_armed[1] = false;
+ }
+ throttle_config(ts, tt, cfg);
qemu_mutex_unlock(&tg->lock);
}
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 6547bec404..47fec63c61 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -19,6 +19,7 @@
*/
#include "qemu-common.h"
#include "block/block_int.h"
+#include "qemu/error-report.h"
#include "qemu/module.h"
#include "block/vhdx.h"
diff --git a/block/vmdk.c b/block/vmdk.c
index be9263a34e..fbaab67c8f 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -25,6 +25,8 @@
#include "qemu-common.h"
#include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "qemu/module.h"
#include "migration/migration.h"
#include <zlib.h>
@@ -645,8 +647,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
char buf[64];
snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
le32_to_cpu(header.version));
- error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
- bdrv_get_device_or_node_name(bs), "vmdk", buf);
+ error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ bdrv_get_device_or_node_name(bs), "vmdk", buf);
return -ENOTSUP;
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
/* VMware KB 2064959 explains that version 3 added support for
@@ -1688,12 +1690,12 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
/* write all the data */
ret = bdrv_pwrite(bs, 0, &magic, sizeof(magic));
if (ret < 0) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
goto exit;
}
ret = bdrv_pwrite(bs, sizeof(magic), &header, sizeof(header));
if (ret < 0) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
goto exit;
}
@@ -1713,7 +1715,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
ret = bdrv_pwrite(bs, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
gd_buf, gd_buf_size);
if (ret < 0) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
goto exit;
}
@@ -1725,7 +1727,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
ret = bdrv_pwrite(bs, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
gd_buf, gd_buf_size);
if (ret < 0) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
goto exit;
}
diff --git a/block/vvfat.c b/block/vvfat.c
index e803589675..206869712e 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -30,6 +30,7 @@
#include "migration/migration.h"
#include "qapi/qmp/qint.h"
#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qstring.h"
#ifndef S_IWGRP
#define S_IWGRP 0
@@ -322,6 +323,7 @@ typedef struct BDRVVVFATState {
int fat_type; /* 16 or 32 */
array_t fat,directory,mapping;
+ char volume_label[11];
unsigned int cluster_size;
unsigned int sectors_per_cluster;
@@ -859,7 +861,7 @@ static int init_directories(BDRVVVFATState* s,
{
direntry_t* entry=array_get_next(&(s->directory));
entry->attributes=0x28; /* archive | volume label */
- memcpy(entry->name, "QEMU VVFAT ", sizeof(entry->name));
+ memcpy(entry->name, s->volume_label, sizeof(entry->name));
}
/* Now build FAT, and write back information into directory */
@@ -968,7 +970,8 @@ static int init_directories(BDRVVVFATState* s,
bootsector->u.fat16.signature=0x29;
bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
- memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11);
+ memcpy(bootsector->u.fat16.volume_label, s->volume_label,
+ sizeof(bootsector->u.fat16.volume_label));
memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8);
bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
@@ -1008,6 +1011,11 @@ static QemuOptsList runtime_opts = {
.help = "Create a floppy rather than a hard disk image",
},
{
+ .name = "label",
+ .type = QEMU_OPT_STRING,
+ .help = "Use a volume label other than QEMU VVFAT",
+ },
+ {
.name = "rw",
.type = QEMU_OPT_BOOL,
.help = "Make the image writable",
@@ -1059,8 +1067,8 @@ static void vvfat_parse_filename(const char *filename, QDict *options,
/* Fill in the options QDict */
qdict_put(options, "dir", qstring_from_str(filename));
qdict_put(options, "fat-type", qint_from_int(fat_type));
- qdict_put(options, "floppy", qbool_from_int(floppy));
- qdict_put(options, "rw", qbool_from_int(rw));
+ qdict_put(options, "floppy", qbool_from_bool(floppy));
+ qdict_put(options, "rw", qbool_from_bool(rw));
}
static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
@@ -1069,7 +1077,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
BDRVVVFATState *s = bs->opaque;
int cyls, heads, secs;
bool floppy;
- const char *dirname;
+ const char *dirname, *label;
QemuOpts *opts;
Error *local_err = NULL;
int ret;
@@ -1096,6 +1104,18 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
s->fat_type = qemu_opt_get_number(opts, "fat-type", 0);
floppy = qemu_opt_get_bool(opts, "floppy", false);
+ memset(s->volume_label, ' ', sizeof(s->volume_label));
+ label = qemu_opt_get(opts, "label");
+ if (label) {
+ size_t label_length = strlen(label);
+ if (label_length > 11) {
+ error_setg(errp, "vvfat label cannot be longer than 11 bytes");
+ ret = -EINVAL;
+ goto fail;
+ }
+ memcpy(s->volume_label, label, label_length);
+ }
+
if (floppy) {
/* 1.44MB or 2.88MB floppy. 2.88MB can be FAT12 (default) or FAT16. */
if (!s->fat_type) {
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 0d9df47ce4..bcdd18b3f6 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -12,7 +12,6 @@
#include "sysemu/blockdev.h"
#include "sysemu/block-backend.h"
#include "hw/block/block.h"
-#include "monitor/monitor.h"
#include "qapi/qmp/qerror.h"
#include "sysemu/sysemu.h"
#include "qmp-commands.h"
@@ -91,11 +90,12 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
if (!blk_is_inserted(blk)) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
diff --git a/blockdev.c b/blockdev.c
index 41d7e0fe54..b35467646e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -36,10 +36,12 @@
#include "block/blockjob.h"
#include "block/throttle-groups.h"
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/qmp/types.h"
#include "qapi-visit.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp-output-visitor.h"
#include "qapi/util.h"
#include "sysemu/sysemu.h"
@@ -174,7 +176,7 @@ static int drive_index_to_unit_id(BlockInterfaceType type, int index)
QemuOpts *drive_def(const char *optstr)
{
- return qemu_opts_parse(qemu_find_opts("drive"), optstr, 0);
+ return qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, false);
}
QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
@@ -1111,7 +1113,8 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return NULL;
}
bs = blk_bs(blk);
@@ -1300,7 +1303,8 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
/* 2. check for validation */
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -1310,7 +1314,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common,
aio_context_acquire(state->aio_context);
if (!bdrv_is_inserted(bs)) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
@@ -1451,7 +1455,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
/* start processing */
drv = bdrv_find_format(format);
if (!drv) {
- error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+ error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
@@ -1478,7 +1482,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
aio_context_acquire(state->aio_context);
if (!bdrv_is_inserted(state->old_bs)) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
@@ -1489,13 +1493,13 @@ static void external_snapshot_prepare(BlkTransactionState *common,
if (!bdrv_is_read_only(state->old_bs)) {
if (bdrv_flush(state->old_bs)) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
return;
}
}
if (!bdrv_is_first_non_filter(state->old_bs)) {
- error_set(errp, QERR_FEATURE_DISABLED, "snapshot");
+ error_setg(errp, QERR_FEATURE_DISABLED, "snapshot");
return;
}
@@ -1580,7 +1584,8 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp)
blk = blk_by_name(backup->device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, backup->device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", backup->device);
return;
}
bs = blk_bs(blk);
@@ -1850,7 +1855,8 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
@@ -1910,7 +1916,8 @@ void qmp_change_blockdev(const char *device, const char *filename,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -1921,7 +1928,7 @@ void qmp_change_blockdev(const char *device, const char *filename,
if (format) {
drv = bdrv_find_whitelisted_format(format, bs->read_only);
if (!drv) {
- error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+ error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out;
}
}
@@ -1971,7 +1978,8 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -2202,17 +2210,17 @@ void qmp_block_resize(bool has_device, const char *device,
aio_context_acquire(aio_context);
if (!bdrv_is_first_non_filter(bs)) {
- error_set(errp, QERR_FEATURE_DISABLED, "resize");
+ error_setg(errp, QERR_FEATURE_DISABLED, "resize");
goto out;
}
if (size < 0) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
goto out;
}
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
- error_set(errp, QERR_DEVICE_IN_USE, device);
+ error_setg(errp, QERR_DEVICE_IN_USE, device);
goto out;
}
@@ -2224,16 +2232,16 @@ void qmp_block_resize(bool has_device, const char *device,
case 0:
break;
case -ENOMEDIUM:
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
break;
case -ENOTSUP:
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
break;
case -EACCES:
error_setg(errp, "Device '%s' is read only", device);
break;
case -EBUSY:
- error_set(errp, QERR_DEVICE_IN_USE, device);
+ error_setg(errp, QERR_DEVICE_IN_USE, device);
break;
default:
error_setg_errno(errp, -ret, "Could not resize");
@@ -2291,7 +2299,8 @@ void qmp_block_stream(const char *device,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -2306,7 +2315,7 @@ void qmp_block_stream(const char *device,
if (has_base) {
base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) {
- error_set(errp, QERR_BASE_NOT_FOUND, base);
+ error_setg(errp, QERR_BASE_NOT_FOUND, base);
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
@@ -2365,7 +2374,8 @@ void qmp_block_commit(const char *device,
* scenario in which all optional arguments are omitted. */
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -2403,7 +2413,7 @@ void qmp_block_commit(const char *device,
}
if (base_bs == NULL) {
- error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
+ error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
goto out;
}
@@ -2477,7 +2487,8 @@ void qmp_drive_backup(const char *device, const char *target,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -2488,7 +2499,7 @@ void qmp_drive_backup(const char *device, const char *target,
/* Although backup_run has this check too, we need to use bs->drv below, so
* do an early check redundantly. */
if (!bdrv_is_inserted(bs)) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto out;
}
@@ -2498,7 +2509,7 @@ void qmp_drive_backup(const char *device, const char *target,
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
- error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+ error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out;
}
}
@@ -2680,18 +2691,20 @@ void qmp_drive_mirror(const char *device, const char *target,
}
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
- "a value in range [512B, 64MB]");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
+ "a value in range [512B, 64MB]");
return;
}
if (granularity & (granularity - 1)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
+ "power of 2");
return;
}
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
@@ -2700,7 +2713,7 @@ void qmp_drive_mirror(const char *device, const char *target,
aio_context_acquire(aio_context);
if (!bdrv_is_inserted(bs)) {
- error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto out;
}
@@ -2710,7 +2723,7 @@ void qmp_drive_mirror(const char *device, const char *target,
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
- error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
+ error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format);
goto out;
}
}
@@ -2957,7 +2970,8 @@ void qmp_change_backing_file(const char *device,
blk = blk_by_name(device);
if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
diff --git a/blockjob.c b/blockjob.c
index 2755465259..ec46fad2f1 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -29,6 +29,7 @@
#include "block/block.h"
#include "block/blockjob.h"
#include "block/block_int.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h"
#include "block/coroutine.h"
#include "qmp-commands.h"
@@ -42,7 +43,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
BlockJob *job;
if (bs->job) {
- error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
+ error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
return NULL;
}
bdrv_ref(bs);
@@ -93,7 +94,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
Error *local_err = NULL;
if (!job->driver->set_speed) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return;
}
job->driver->set_speed(job, speed, &local_err);
@@ -108,8 +109,8 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
void block_job_complete(BlockJob *job, Error **errp)
{
if (job->pause_count || job->cancelled || !job->driver->complete) {
- error_set(errp, QERR_BLOCK_JOB_NOT_READY,
- bdrv_get_device_name(job->bs));
+ error_setg(errp, QERR_BLOCK_JOB_NOT_READY,
+ bdrv_get_device_name(job->bs));
return;
}
diff --git a/configure b/configure
index fe3440f349..3063739a5e 100755
--- a/configure
+++ b/configure
@@ -355,7 +355,7 @@ for opt do
--extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
EXTRA_CFLAGS="$optarg"
;;
- --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
+ --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
EXTRA_LDFLAGS="$optarg"
;;
--enable-debug-info) debug_info="yes"
@@ -1282,29 +1282,10 @@ Advanced options (experts only):
--sysconfdir=PATH install config in PATH$confsuffix
--localstatedir=PATH install local state in PATH (set at runtime on win32)
--with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
- --enable-modules enable modules support
- --enable-debug-tcg enable TCG debugging
- --disable-debug-tcg disable TCG debugging (default)
- --enable-debug-info enable debugging information (default)
- --disable-debug-info disable debugging information
--enable-debug enable common debug build options
- --enable-sparse enable sparse checker
- --disable-sparse disable sparse checker (default)
--disable-strip disable stripping binaries
--disable-werror disable compilation abort on warning
--disable-stack-protector disable compiler-provided stack protection
- --disable-sdl disable SDL
- --enable-sdl enable SDL
- --with-sdlabi select preferred SDL ABI 1.2 or 2.0
- --disable-gtk disable gtk UI
- --enable-gtk enable gtk UI
- --with-gtkabi select preferred GTK ABI 2.0 or 3.0
- --disable-virtfs disable VirtFS
- --enable-virtfs enable VirtFS
- --disable-vnc disable VNC
- --enable-vnc enable VNC
- --disable-cocoa disable Cocoa (Mac OS X only)
- --enable-cocoa enable Cocoa (default on Mac OS X)
--audio-drv-list=LIST set audio drivers list:
Available drivers: $audio_possible_drivers
--block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
@@ -1314,119 +1295,89 @@ Advanced options (experts only):
--block-drv-ro-whitelist=L
set block driver read-only whitelist
(affects only QEMU, not qemu-img)
- --disable-xen disable xen backend driver support
- --enable-xen enable xen backend driver support
- --disable-xen-pci-passthrough
- --enable-xen-pci-passthrough
- --disable-brlapi disable BrlAPI
- --enable-brlapi enable BrlAPI
- --disable-vnc-tls disable TLS encryption for VNC server
- --enable-vnc-tls enable TLS encryption for VNC server
- --disable-vnc-sasl disable SASL encryption for VNC server
- --enable-vnc-sasl enable SASL encryption for VNC server
- --disable-vnc-jpeg disable JPEG lossy compression for VNC server
- --enable-vnc-jpeg enable JPEG lossy compression for VNC server
- --disable-vnc-png disable PNG compression for VNC server (default)
- --enable-vnc-png enable PNG compression for VNC server
- --disable-vnc-ws disable Websockets support for VNC server
- --enable-vnc-ws enable Websockets support for VNC server
- --disable-curses disable curses output
- --enable-curses enable curses output
- --disable-curl disable curl connectivity
- --enable-curl enable curl connectivity
- --disable-fdt disable fdt device tree
- --enable-fdt enable fdt device tree
- --disable-bluez disable bluez stack connectivity
- --enable-bluez enable bluez stack connectivity
- --disable-slirp disable SLIRP userspace network connectivity
- --disable-kvm disable KVM acceleration support
- --enable-kvm enable KVM acceleration support
- --disable-rdma disable RDMA-based migration support
- --enable-rdma enable RDMA-based migration support
- --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
- --enable-system enable all system emulation targets
- --disable-system disable all system emulation targets
- --enable-user enable supported user emulation targets
- --disable-user disable all user emulation targets
- --enable-linux-user enable all linux usermode emulation targets
- --disable-linux-user disable all linux usermode emulation targets
- --enable-bsd-user enable all BSD usermode emulation targets
- --disable-bsd-user disable all BSD usermode emulation targets
- --enable-guest-base enable GUEST_BASE support for usermode
- emulation targets
- --disable-guest-base disable GUEST_BASE support
- --enable-pie build Position Independent Executables
- --disable-pie do not build Position Independent Executables
- --oss-lib path to OSS library
- --cpu=CPU Build for host CPU [$cpu]
- --disable-uuid disable uuid support
- --enable-uuid enable uuid support
- --disable-vde disable support for vde network
- --enable-vde enable support for vde network
- --disable-netmap disable support for netmap network
- --enable-netmap enable support for netmap network
- --disable-linux-aio disable Linux AIO support
- --enable-linux-aio enable Linux AIO support
- --disable-cap-ng disable libcap-ng support
- --enable-cap-ng enable libcap-ng support
- --disable-attr disable attr and xattr support
- --enable-attr enable attr and xattr support
- --disable-blobs disable installing provided firmware blobs
- --enable-docs enable documentation build
- --disable-docs disable documentation build
- --disable-vhost-net disable vhost-net acceleration support
- --enable-vhost-net enable vhost-net acceleration support
--enable-trace-backends=B Set trace backend
Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
--with-trace-file=NAME Full PATH,NAME of file to store traces
Default:trace-<pid>
- --disable-spice disable spice
- --enable-spice enable spice
- --enable-rbd enable building the rados block device (rbd)
- --disable-libiscsi disable iscsi support
- --enable-libiscsi enable iscsi support
- --disable-libnfs disable nfs support
- --enable-libnfs enable nfs support
- --disable-smartcard-nss disable smartcard nss support
- --enable-smartcard-nss enable smartcard nss support
- --disable-libusb disable libusb (for usb passthrough)
- --enable-libusb enable libusb (for usb passthrough)
- --disable-usb-redir disable usb network redirection support
- --enable-usb-redir enable usb network redirection support
- --enable-lzo enable the support of lzo compression library
- --enable-snappy enable the support of snappy compression library
- --enable-bzip2 enable the support of bzip2 compression library (for
- reading bzip2-compressed dmg images)
- --disable-guest-agent disable building of the QEMU Guest Agent
- --enable-guest-agent enable building of the QEMU Guest Agent
- --enable-guest-agent-msi enable building guest agent Windows MSI installation package
- --disable-guest-agent-msi disable building guest agent Windows MSI installation
- --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
- --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
- --disable-seccomp disable seccomp support
- --enable-seccomp enable seccomp support
+ --disable-slirp disable SLIRP userspace network connectivity
+ --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
+ --oss-lib path to OSS library
+ --cpu=CPU Build for host CPU [$cpu]
--with-coroutine=BACKEND coroutine backend. Supported options:
gthread, ucontext, sigaltstack, windows
- --disable-coroutine-pool disable coroutine freelist (worse performance)
- --enable-coroutine-pool enable coroutine freelist (better performance)
- --enable-glusterfs enable GlusterFS backend
- --disable-glusterfs disable GlusterFS backend
- --enable-archipelago enable Archipelago backend
- --disable-archipelago disable Archipelago backend
--enable-gcov enable test coverage analysis with gcov
--gcov=GCOV use specified gcov [$gcov_tool]
- --disable-tpm disable TPM support
- --enable-tpm enable TPM support
- --disable-libssh2 disable ssh block device support
- --enable-libssh2 enable ssh block device support
- --disable-vhdx disable support for the Microsoft VHDX image format
- --enable-vhdx enable support for the Microsoft VHDX image format
- --disable-quorum disable quorum block filter support
- --enable-quorum enable quorum block filter support
- --disable-numa disable libnuma support
- --enable-numa enable libnuma support
- --disable-tcmalloc disable tcmalloc support
- --enable-tcmalloc enable tcmalloc support
+ --disable-blobs disable installing provided firmware blobs
+ --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
+ --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
+
+Optional features, enabled with --enable-FEATURE and
+disabled with --disable-FEATURE, default is enabled if available:
+
+ system all system emulation targets
+ user supported user emulation targets
+ linux-user all linux usermode emulation targets
+ bsd-user all BSD usermode emulation targets
+ guest-base GUEST_BASE support for usermode emulation targets
+ docs build documentation
+ guest-agent build the QEMU Guest Agent
+ guest-agent-msi build guest agent Windows MSI installation package
+ pie Position Independent Executables
+ modules modules support
+ debug-tcg TCG debugging (default is disabled)
+ debug-info debugging information
+ sparse sparse checker
+
+ sdl SDL UI
+ --with-sdlabi select preferred SDL ABI 1.2 or 2.0
+ gtk gtk UI
+ --with-gtkabi select preferred GTK ABI 2.0 or 3.0
+ vte vte support for the gtk UI
+ curses curses UI
+ vnc VNC UI support
+ vnc-tls TLS encryption for VNC server
+ vnc-sasl SASL encryption for VNC server
+ vnc-jpeg JPEG lossy compression for VNC server
+ vnc-png PNG compression for VNC server
+ vnc-ws Websockets support for VNC server
+ cocoa Cocoa UI (Mac OS X only)
+ virtfs VirtFS
+ xen xen backend driver support
+ xen-pci-passthrough
+ brlapi BrlAPI (Braile)
+ curl curl connectivity
+ fdt fdt device tree
+ bluez bluez stack connectivity
+ kvm KVM acceleration support
+ rdma RDMA-based migration support
+ uuid uuid support
+ vde support for vde network
+ netmap support for netmap network
+ linux-aio Linux AIO support
+ cap-ng libcap-ng support
+ attr attr and xattr support
+ vhost-net vhost-net acceleration support
+ spice spice
+ rbd rados block device (rbd)
+ libiscsi iscsi support
+ libnfs nfs support
+ smartcard-nss smartcard nss support
+ libusb libusb (for usb passthrough)
+ usb-redir usb network redirection support
+ lzo support of lzo compression library
+ snappy support of snappy compression library
+ bzip2 support of bzip2 compression library
+ (for reading bzip2-compressed dmg images)
+ seccomp seccomp support
+ coroutine-pool coroutine freelist (better performance)
+ glusterfs GlusterFS backend
+ archipelago Archipelago backend
+ tpm TPM support
+ libssh2 ssh block device support
+ vhdx support for the Microsoft VHDX image format
+ quorum quorum block filter support
+ numa libnuma support
+ tcmalloc tcmalloc support
NOTE: The object files are built at the place where configure is launched
EOF
diff --git a/cpus.c b/cpus.c
index b85fb5f03f..4f0e54d53c 100644
--- a/cpus.c
+++ b/cpus.c
@@ -27,6 +27,7 @@
#include "monitor/monitor.h"
#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
#include "exec/gdbstub.h"
#include "sysemu/dma.h"
@@ -1512,8 +1513,8 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
- "a CPU number");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+ "a CPU number");
return;
}
@@ -1533,7 +1534,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename,
goto exit;
}
if (fwrite(buf, 1, l, f) != l) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
goto exit;
}
addr += l;
@@ -1563,7 +1564,7 @@ void qmp_pmemsave(int64_t addr, int64_t size, const char *filename,
l = size;
cpu_physical_memory_read(addr, buf, l);
if (fwrite(buf, 1, l, f) != l) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
goto exit;
}
addr += l;
diff --git a/disas.c b/disas.c
index 44a019a2e7..576c6a437b 100644
--- a/disas.c
+++ b/disas.c
@@ -9,7 +9,7 @@
typedef struct CPUDebug {
struct disassemble_info info;
- CPUArchState *env;
+ CPUState *cpu;
} CPUDebug;
/* Filled in by elfload.c. Simplistic, but will do for now. */
@@ -39,7 +39,7 @@ target_read_memory (bfd_vma memaddr,
{
CPUDebug *s = container_of(info, CPUDebug, info);
- cpu_memory_rw_debug(ENV_GET_CPU(s->env), memaddr, myaddr, length, 0);
+ cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);
return 0;
}
@@ -195,7 +195,7 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info)
bit 16 indicates little endian.
other targets - unused
*/
-void target_disas(FILE *out, CPUArchState *env, target_ulong code,
+void target_disas(FILE *out, CPUState *cpu, target_ulong code,
target_ulong size, int flags)
{
target_ulong pc;
@@ -205,7 +205,7 @@ void target_disas(FILE *out, CPUArchState *env, target_ulong code,
INIT_DISASSEMBLE_INFO(s.info, out, fprintf);
- s.env = env;
+ s.cpu = cpu;
s.info.read_memory_func = target_read_memory;
s.info.buffer_vma = code;
s.info.buffer_length = size;
@@ -430,7 +430,7 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,
if (monitor_disas_is_physical) {
cpu_physical_memory_read(memaddr, myaddr, length);
} else {
- cpu_memory_rw_debug(ENV_GET_CPU(s->env), memaddr, myaddr, length, 0);
+ cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);
}
return 0;
}
@@ -447,7 +447,7 @@ monitor_fprintf(FILE *stream, const char *fmt, ...)
/* Disassembler for the monitor.
See target_disas for a description of flags. */
-void monitor_disas(Monitor *mon, CPUArchState *env,
+void monitor_disas(Monitor *mon, CPUState *cpu,
target_ulong pc, int nb_insn, int is_physical, int flags)
{
int count, i;
@@ -456,7 +456,7 @@ void monitor_disas(Monitor *mon, CPUArchState *env,
INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);
- s.env = env;
+ s.cpu = cpu;
monitor_disas_is_physical = is_physical;
s.info.read_memory_func = monitor_read_memory;
s.info.print_address_func = generic_print_target_address;
diff --git a/dump.c b/dump.c
index 9c7dad8f86..78b7d843ce 100644
--- a/dump.c
+++ b/dump.c
@@ -23,6 +23,7 @@
#include "sysemu/memory_mapping.h"
#include "sysemu/cpus.h"
#include "qapi/error.h"
+#include "qapi/qmp/qerror.h"
#include "qmp-commands.h"
#include <zlib.h>
@@ -1474,7 +1475,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
s->start = get_start_block(s);
if (s->start == -1) {
- error_set(errp, QERR_INVALID_PARAMETER, "begin");
+ error_setg(errp, QERR_INVALID_PARAMETER, "begin");
goto cleanup;
}
@@ -1484,14 +1485,14 @@ static void dump_init(DumpState *s, int fd, bool has_format,
*/
ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
if (ret < 0) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
goto cleanup;
}
s->note_size = cpu_get_note_size(s->dump_info.d_class,
s->dump_info.d_machine, nr_cpus);
if (s->note_size < 0) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
goto cleanup;
}
@@ -1615,11 +1616,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
return;
}
if (has_begin && !has_length) {
- error_set(errp, QERR_MISSING_PARAMETER, "length");
+ error_setg(errp, QERR_MISSING_PARAMETER, "length");
return;
}
if (!has_begin && has_length) {
- error_set(errp, QERR_MISSING_PARAMETER, "begin");
+ error_setg(errp, QERR_MISSING_PARAMETER, "begin");
return;
}
@@ -1656,7 +1657,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
}
if (fd == -1) {
- error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+ error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
return;
}
diff --git a/hmp.c b/hmp.c
index 23abc7d9f1..070aaf814f 100644
--- a/hmp.c
+++ b/hmp.c
@@ -25,6 +25,7 @@
#include "monitor/monitor.h"
#include "monitor/qdev.h"
#include "qapi/opts-visitor.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/string-output-visitor.h"
#include "qapi-visit.h"
#include "ui/console.h"
@@ -438,8 +439,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
BlockInfoList *block_list, *info;
BlockDeviceInfoList *blockdev_list, *blockdev;
const char *device = qdict_get_try_str(qdict, "device");
- bool verbose = qdict_get_try_bool(qdict, "verbose", 0);
- bool nodes = qdict_get_try_bool(qdict, "nodes", 0);
+ bool verbose = qdict_get_try_bool(qdict, "verbose", false);
+ bool nodes = qdict_get_try_bool(qdict, "nodes", false);
bool printed = false;
/* Print BlockBackend information */
@@ -995,7 +996,7 @@ void hmp_nmi(Monitor *mon, const QDict *qdict)
void hmp_set_link(Monitor *mon, const QDict *qdict)
{
const char *name = qdict_get_str(qdict, "name");
- int up = qdict_get_bool(qdict, "up");
+ bool up = qdict_get_bool(qdict, "up");
Error *err = NULL;
qmp_set_link(name, up, &err);
@@ -1039,13 +1040,13 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_str(qdict, "target");
const char *format = qdict_get_try_str(qdict, "format");
- int reuse = qdict_get_try_bool(qdict, "reuse", 0);
- int full = qdict_get_try_bool(qdict, "full", 0);
+ bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+ bool full = qdict_get_try_bool(qdict, "full", false);
enum NewImageMode mode;
Error *err = NULL;
if (!filename) {
- error_set(&err, QERR_MISSING_PARAMETER, "target");
+ error_setg(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &err);
return;
}
@@ -1069,13 +1070,13 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_str(qdict, "target");
const char *format = qdict_get_try_str(qdict, "format");
- int reuse = qdict_get_try_bool(qdict, "reuse", 0);
- int full = qdict_get_try_bool(qdict, "full", 0);
+ bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+ bool full = qdict_get_try_bool(qdict, "full", false);
enum NewImageMode mode;
Error *err = NULL;
if (!filename) {
- error_set(&err, QERR_MISSING_PARAMETER, "target");
+ error_setg(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &err);
return;
}
@@ -1098,14 +1099,14 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device");
const char *filename = qdict_get_try_str(qdict, "snapshot-file");
const char *format = qdict_get_try_str(qdict, "format");
- int reuse = qdict_get_try_bool(qdict, "reuse", 0);
+ bool reuse = qdict_get_try_bool(qdict, "reuse", false);
enum NewImageMode mode;
Error *err = NULL;
if (!filename) {
/* In the future, if 'snapshot-file' is not specified, the snapshot
will be taken internally. Today it's actually required. */
- error_set(&err, QERR_MISSING_PARAMETER, "snapshot-file");
+ error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
hmp_handle_error(mon, &err);
return;
}
@@ -1200,7 +1201,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
}
if (i == MIGRATION_CAPABILITY_MAX) {
- error_set(&err, QERR_INVALID_PARAMETER, cap);
+ error_setg(&err, QERR_INVALID_PARAMETER, cap);
}
qapi_free_MigrationCapabilityStatusList(caps);
@@ -1244,7 +1245,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
}
if (i == MIGRATION_PARAMETER_MAX) {
- error_set(&err, QERR_INVALID_PARAMETER, param);
+ error_setg(&err, QERR_INVALID_PARAMETER, param);
}
if (err) {
@@ -1294,7 +1295,7 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
void hmp_eject(Monitor *mon, const QDict *qdict)
{
- int force = qdict_get_try_bool(qdict, "force", 0);
+ bool force = qdict_get_try_bool(qdict, "force", false);
const char *device = qdict_get_str(qdict, "device");
Error *err = NULL;
@@ -1394,7 +1395,7 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict)
{
Error *error = NULL;
const char *device = qdict_get_str(qdict, "device");
- bool force = qdict_get_try_bool(qdict, "force", 0);
+ bool force = qdict_get_try_bool(qdict, "force", false);
qmp_block_job_cancel(device, true, force, &error);
@@ -1474,9 +1475,9 @@ static void hmp_migrate_status_cb(void *opaque)
void hmp_migrate(Monitor *mon, const QDict *qdict)
{
- int detach = qdict_get_try_bool(qdict, "detach", 0);
- int blk = qdict_get_try_bool(qdict, "blk", 0);
- int inc = qdict_get_try_bool(qdict, "inc", 0);
+ bool detach = qdict_get_try_bool(qdict, "detach", false);
+ bool blk = qdict_get_try_bool(qdict, "blk", false);
+ bool inc = qdict_get_try_bool(qdict, "inc", false);
const char *uri = qdict_get_str(qdict, "uri");
Error *err = NULL;
@@ -1507,7 +1508,10 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
void hmp_device_add(Monitor *mon, const QDict *qdict)
{
- do_device_add(mon, qdict, NULL);
+ Error *err = NULL;
+
+ qmp_device_add((QDict *)qdict, NULL, &err);
+ hmp_handle_error(mon, &err);
}
void hmp_device_del(Monitor *mon, const QDict *qdict)
@@ -1522,10 +1526,10 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
- int paging = qdict_get_try_bool(qdict, "paging", 0);
- int zlib = qdict_get_try_bool(qdict, "zlib", 0);
- int lzo = qdict_get_try_bool(qdict, "lzo", 0);
- int snappy = qdict_get_try_bool(qdict, "snappy", 0);
+ bool paging = qdict_get_try_bool(qdict, "paging", false);
+ bool zlib = qdict_get_try_bool(qdict, "zlib", false);
+ bool lzo = qdict_get_try_bool(qdict, "lzo", false);
+ bool snappy = qdict_get_try_bool(qdict, "snappy", false);
const char *file = qdict_get_str(qdict, "filename");
bool has_begin = qdict_haskey(qdict, "begin");
bool has_length = qdict_haskey(qdict, "length");
@@ -1751,8 +1755,8 @@ void hmp_screendump(Monitor *mon, const QDict *qdict)
void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
{
const char *uri = qdict_get_str(qdict, "uri");
- int writable = qdict_get_try_bool(qdict, "writable", 0);
- int all = qdict_get_try_bool(qdict, "all", 0);
+ bool writable = qdict_get_try_bool(qdict, "writable", false);
+ bool all = qdict_get_try_bool(qdict, "all", false);
Error *local_err = NULL;
BlockInfoList *block_list, *info;
SocketAddress *addr;
@@ -1805,7 +1809,7 @@ exit:
void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
- int writable = qdict_get_try_bool(qdict, "writable", 0);
+ bool writable = qdict_get_try_bool(qdict, "writable", false);
Error *local_err = NULL;
qmp_nbd_server_add(device, true, writable, &local_err);
@@ -1839,7 +1843,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)
Error *err = NULL;
QemuOpts *opts;
- opts = qemu_opts_parse(qemu_find_opts("chardev"), args, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true);
if (opts == NULL) {
error_setg(&err, "Parsing chardev args failed");
} else {
@@ -1867,7 +1871,8 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
if (blk) {
qemuio_command(blk, command);
} else {
- error_set(&err, QERR_DEVICE_NOT_FOUND, device);
+ error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device);
}
hmp_handle_error(mon, &err);
@@ -1995,7 +2000,8 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
obj = object_resolve_path(path, &ambiguous);
if (obj == NULL) {
- error_set(&err, QERR_DEVICE_NOT_FOUND, path);
+ error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", path);
} else {
if (ambiguous) {
monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path);
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 4964da0d7e..6ef8af3f64 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -13,6 +13,7 @@
#include "hw/virtio/virtio.h"
#include "hw/i386/pc.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "virtio-9p.h"
#include "fsdev/qemu-fsdev.h"
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index d5a8b9c017..f365140319 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -387,7 +387,7 @@ build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
mcfg->allocation[0].end_bus_number = (memmap[VIRT_PCIE_ECAM].size
/ PCIE_MMCFG_SIZE_MIN) - 1;
- build_header(linker, table_data, (void *)mcfg, "MCFG", len, 5);
+ build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1);
}
/* GTDT */
@@ -413,7 +413,7 @@ build_gtdt(GArray *table_data, GArray *linker)
build_header(linker, table_data,
(void *)(table_data->data + gtdt_start), "GTDT",
- table_data->len - gtdt_start, 5);
+ table_data->len - gtdt_start, 2);
}
/* MADT */
@@ -423,8 +423,10 @@ build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info,
{
int madt_start = table_data->len;
const MemMapEntry *memmap = guest_info->memmap;
+ const int *irqmap = guest_info->irqmap;
AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd;
+ AcpiMadtGenericMsiFrame *gic_msi;
int i;
madt = acpi_data_push(table_data, sizeof *madt);
@@ -448,9 +450,18 @@ build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info,
gicd->length = sizeof(*gicd);
gicd->base_address = memmap[VIRT_GIC_DIST].base;
+ gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
+ gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
+ gic_msi->length = sizeof(*gic_msi);
+ gic_msi->gic_msi_frame_id = 0;
+ gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base);
+ gic_msi->flags = cpu_to_le32(1);
+ gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
+ gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE);
+
build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC",
- table_data->len - madt_start, 5);
+ table_data->len - madt_start, 3);
}
/* FADT */
@@ -507,7 +518,7 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len),
- "DSDT", dsdt->buf->len, 5);
+ "DSDT", dsdt->buf->len, 2);
free_aml_allocator();
}
@@ -545,6 +556,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
* FADT
* GTDT
* MADT
+ * MCFG
* DSDT
*/
@@ -552,7 +564,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
dsdt = tables_blob->len;
build_dsdt(tables_blob, tables->linker, guest_info);
- /* FADT MADT GTDT SPCR pointed to by RSDT */
+ /* FADT MADT GTDT MCFG SPCR pointed to by RSDT */
acpi_add_table(table_offsets, tables_blob);
build_fadt(tables_blob, tables->linker, dsdt);
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 4e78083a9d..484689264c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -956,6 +956,8 @@ static void virt_class_init(ObjectClass *oc, void *data)
mc->init = machvirt_init;
mc->max_cpus = 8;
mc->has_dynamic_sysbus = true;
+ mc->block_default_type = IF_VIRTIO;
+ mc->no_cdrom = 1;
}
static const TypeInfo machvirt_info = {
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 4b6d5e6078..c6a6a0e49a 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -154,6 +154,7 @@ static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len,
qemu_sglist_destroy(&qsg);
return NVME_INVALID_FIELD | NVME_DNR;
}
+ qemu_sglist_destroy(&qsg);
return NVME_SUCCESS;
}
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index cd539aa11c..6aefda4bf2 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -499,8 +499,7 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
iov_discard_front(&iov, &out_num, sizeof(req->out));
- if (in_num < 1 ||
- in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
+ if (in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
error_report("virtio-blk request inhdr too short");
exit(1);
}
@@ -651,16 +650,21 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running,
static void virtio_blk_reset(VirtIODevice *vdev)
{
VirtIOBlock *s = VIRTIO_BLK(vdev);
-
- if (s->dataplane) {
- virtio_blk_data_plane_stop(s->dataplane);
- }
+ AioContext *ctx;
/*
* This should cancel pending requests, but can't do nicely until there
* are per-device request lists.
*/
- blk_drain_all();
+ ctx = blk_get_aio_context(s->blk);
+ aio_context_acquire(ctx);
+ blk_drain(s->blk);
+
+ if (s->dataplane) {
+ virtio_blk_data_plane_stop(s->dataplane);
+ }
+ aio_context_release(ctx);
+
blk_set_enable_write_cache(s->blk, s->original_wce);
}
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 653064fadf..1c8b9be5cc 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -27,7 +27,6 @@
#include "hw/char/serial.h"
#include "hw/pci/pci.h"
-#include "qapi/qmp/qerror.h"
#define PCI_SERIAL_MAX_PORTS 4
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index d451b22386..78c73e5abe 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -20,6 +20,7 @@
#include "qemu/iov.h"
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "qemu/queue.h"
#include "hw/sysbus.h"
#include "trace.h"
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 5260d6c1ec..de1d1f8cb1 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -67,7 +67,7 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
if (ns.handled) {
error_propagate(errp, ns.errp);
} else {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
}
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index 0f052b3338..70e0518901 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -20,7 +20,6 @@
*/
#include "hw/platform-bus.h"
-#include "monitor/monitor.h"
#include "exec/address-spaces.h"
#include "sysemu/sysemu.h"
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 0309fe5767..921e799dbb 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -35,15 +35,15 @@ static void get_pointer(Object *obj, Visitor *v, Property *prop,
}
static void set_pointer(Object *obj, Visitor *v, Property *prop,
- int (*parse)(DeviceState *dev, const char *str,
- void **ptr),
+ void (*parse)(DeviceState *dev, const char *str,
+ void **ptr, const char *propname,
+ Error **errp),
const char *name, Error **errp)
{
DeviceState *dev = DEVICE(obj);
Error *local_err = NULL;
void **ptr = qdev_get_prop_ptr(dev, prop);
char *str;
- int ret;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -60,26 +60,38 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
*ptr = NULL;
return;
}
- ret = parse(dev, str, ptr);
- error_set_from_qdev_prop_error(errp, ret, dev, prop, str);
+ parse(dev, str, ptr, prop->name, errp);
g_free(str);
}
/* --- drive --- */
-static int parse_drive(DeviceState *dev, const char *str, void **ptr)
+static void parse_drive(DeviceState *dev, const char *str, void **ptr,
+ const char *propname, Error **errp)
{
BlockBackend *blk;
blk = blk_by_name(str);
if (!blk) {
- return -ENOENT;
+ error_setg(errp, "Property '%s.%s' can't find value '%s'",
+ object_get_typename(OBJECT(dev)), propname, str);
+ return;
}
if (blk_attach_dev(blk, dev) < 0) {
- return -EEXIST;
+ DriveInfo *dinfo = blk_legacy_dinfo(blk);
+
+ if (dinfo->type != IF_NONE) {
+ error_setg(errp, "Drive '%s' is already in use because "
+ "it has been automatically connected to another "
+ "device (did you need 'if=none' in the drive options?)",
+ str);
+ } else {
+ error_setg(errp, "Drive '%s' is already in use by another device",
+ str);
+ }
+ return;
}
*ptr = blk;
- return 0;
}
static void release_drive(Object *obj, const char *name, void *opaque)
@@ -121,17 +133,21 @@ PropertyInfo qdev_prop_drive = {
/* --- character device --- */
-static int parse_chr(DeviceState *dev, const char *str, void **ptr)
+static void parse_chr(DeviceState *dev, const char *str, void **ptr,
+ const char *propname, Error **errp)
{
CharDriverState *chr = qemu_chr_find(str);
if (chr == NULL) {
- return -ENOENT;
+ error_setg(errp, "Property '%s.%s' can't find value '%s'",
+ object_get_typename(OBJECT(dev)), propname, str);
+ return;
}
if (qemu_chr_fe_claim(chr) != 0) {
- return -EEXIST;
+ error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
+ object_get_typename(OBJECT(dev)), propname, str);
+ return;
}
*ptr = chr;
- return 0;
}
static void release_chr(Object *obj, const char *name, void *opaque)
@@ -326,8 +342,8 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
hubport = net_hub_port_find(id);
if (!hubport) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- name, prop->info->name);
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name, prop->info->name);
return;
}
*ptr = hubport;
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index f78b335816..e9e686f260 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1,6 +1,7 @@
#include "net/net.h"
#include "hw/qdev.h"
#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "sysemu/block-backend.h"
#include "hw/block/block.h"
#include "net/hub.h"
@@ -570,8 +571,8 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
if (local_err) {
error_propagate(errp, local_err);
} else if (value < -1 || value > 255) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "pci_devfn");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "pci_devfn");
} else {
*ptr = value;
}
@@ -640,8 +641,8 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
}
/* value of 0 means "unset" */
if (value && (value < min || value > max)) {
- error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
- dev->id?:"", name, (int64_t)value, min, max);
+ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
+ dev->id ? : "", name, (int64_t)value, min, max);
return;
}
@@ -923,8 +924,8 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
break;
default:
case -EINVAL:
- error_set(errp, QERR_PROPERTY_VALUE_BAD,
- object_get_typename(OBJECT(dev)), prop->name, value);
+ error_setg(errp, QERR_PROPERTY_VALUE_BAD,
+ object_get_typename(OBJECT(dev)), prop->name, value);
break;
case -ENOENT:
error_setg(errp, "Property '%s.%s' can't find value '%s'",
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index a6353c177f..b2f404a765 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -32,6 +32,7 @@
#include "qapi/qmp/qerror.h"
#include "qapi/visitor.h"
#include "qapi/qmp/qjson.h"
+#include "qemu/error-report.h"
#include "hw/hotplug.h"
#include "hw/boards.h"
#include "qapi-event.h"
@@ -276,13 +277,13 @@ void qdev_unplug(DeviceState *dev, Error **errp)
HotplugHandlerClass *hdc;
if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
- error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
return;
}
if (!dc->hotpluggable) {
- error_set(errp, QERR_DEVICE_NO_HOTPLUG,
- object_get_typename(OBJECT(dev)));
+ error_setg(errp, QERR_DEVICE_NO_HOTPLUG,
+ object_get_typename(OBJECT(dev)));
return;
}
@@ -1026,7 +1027,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
Error *local_err = NULL;
if (dev->hotplugged && !dc->hotpluggable) {
- error_set(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
+ error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
return;
}
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index b94e5e0d78..34dcbc3119 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -303,6 +303,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
if (fcode_filename) {
ret = load_image_targphys(fcode_filename, s->prom_addr,
FCODE_MAX_ROM_SIZE);
+ g_free(fcode_filename);
if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
error_report("cg3: could not load prom '%s'", CG3_ROM_FILE);
}
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 52a9733bfd..7f83a007b7 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -18,6 +18,7 @@
*/
#include "hw/hw.h"
+#include "qemu/error-report.h"
#include "ui/console.h"
#include "ui/pixel_ops.h"
#include "trace.h"
diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c
index c900c2ca4f..d944d3fdb5 100644
--- a/hw/display/qxl-logger.c
+++ b/hw/display/qxl-logger.c
@@ -22,7 +22,7 @@
#include "qemu/timer.h"
#include "qxl.h"
-static const char *qxl_type[] = {
+static const char *const qxl_type[] = {
[ QXL_CMD_NOP ] = "nop",
[ QXL_CMD_DRAW ] = "draw",
[ QXL_CMD_UPDATE ] = "update",
@@ -31,7 +31,7 @@ static const char *qxl_type[] = {
[ QXL_CMD_SURFACE ] = "surface",
};
-static const char *qxl_draw_type[] = {
+static const char *const qxl_draw_type[] = {
[ QXL_DRAW_NOP ] = "nop",
[ QXL_DRAW_FILL ] = "fill",
[ QXL_DRAW_OPAQUE ] = "opaque",
@@ -48,7 +48,7 @@ static const char *qxl_draw_type[] = {
[ QXL_DRAW_ALPHA_BLEND ] = "alpha-blend",
};
-static const char *qxl_draw_effect[] = {
+static const char *const qxl_draw_effect[] = {
[ QXL_EFFECT_BLEND ] = "blend",
[ QXL_EFFECT_OPAQUE ] = "opaque",
[ QXL_EFFECT_REVERT_ON_DUP ] = "revert-on-dup",
@@ -59,12 +59,12 @@ static const char *qxl_draw_effect[] = {
[ QXL_EFFECT_OPAQUE_BRUSH ] = "opaque-brush",
};
-static const char *qxl_surface_cmd[] = {
+static const char *const qxl_surface_cmd[] = {
[ QXL_SURFACE_CMD_CREATE ] = "create",
[ QXL_SURFACE_CMD_DESTROY ] = "destroy",
};
-static const char *spice_surface_fmt[] = {
+static const char *const spice_surface_fmt[] = {
[ SPICE_SURFACE_FMT_INVALID ] = "invalid",
[ SPICE_SURFACE_FMT_1_A ] = "alpha/1",
[ SPICE_SURFACE_FMT_8_A ] = "alpha/8",
@@ -74,14 +74,14 @@ static const char *spice_surface_fmt[] = {
[ SPICE_SURFACE_FMT_32_ARGB ] = "ARGB/32",
};
-static const char *qxl_cursor_cmd[] = {
+static const char *const qxl_cursor_cmd[] = {
[ QXL_CURSOR_SET ] = "set",
[ QXL_CURSOR_MOVE ] = "move",
[ QXL_CURSOR_HIDE ] = "hide",
[ QXL_CURSOR_TRAIL ] = "trail",
};
-static const char *spice_cursor_type[] = {
+static const char *const spice_cursor_type[] = {
[ SPICE_CURSOR_TYPE_ALPHA ] = "alpha",
[ SPICE_CURSOR_TYPE_MONO ] = "mono",
[ SPICE_CURSOR_TYPE_COLOR4 ] = "color4",
@@ -91,7 +91,7 @@ static const char *spice_cursor_type[] = {
[ SPICE_CURSOR_TYPE_COLOR32 ] = "color32",
};
-static const char *qxl_v2n(const char *n[], size_t l, int v)
+static const char *qxl_v2n(const char *const n[], size_t l, int v)
{
if (v >= l || !n[v]) {
return "???";
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 722146ec3a..f87a5ee602 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -25,7 +25,6 @@
#include "qemu/timer.h"
#include "qemu/queue.h"
#include "qemu/atomic.h"
-#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
#include "trace.h"
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index f3faf78bf8..6acdc2d282 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -27,6 +27,7 @@
#include "ui/pixel_ops.h"
#include "hw/loader.h"
#include "hw/sysbus.h"
+#include "qemu/error-report.h"
#define TCX_ROM_FILE "QEMU,tcx.bin"
#define FCODE_MAX_ROM_SIZE 0x10000
@@ -1017,6 +1018,7 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)
if (fcode_filename) {
ret = load_image_targphys(fcode_filename, s->prom_addr,
FCODE_MAX_ROM_SIZE);
+ g_free(fcode_filename);
if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
error_report("tcx: could not load prom '%s'", TCX_ROM_FILE);
}
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index d06002dde8..cf842a3cc7 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -26,7 +26,6 @@
#include "qemu/timer.h"
#include "hw/ptimer.h"
#include "qemu/log.h"
-#include "qapi/qmp/qerror.h"
#include "qemu/main-loop.h"
#include "hw/stream.h"
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index 9db7c77605..74d22f4fd2 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -141,6 +141,9 @@ typedef struct AssignedDevice {
int32_t bootindex;
} AssignedDevice;
+#define TYPE_PCI_ASSIGN "kvm-pci-assign"
+#define PCI_ASSIGN(obj) OBJECT_CHECK(AssignedDevice, (obj), TYPE_PCI_ASSIGN)
+
static void assigned_dev_update_irq_routing(PCIDevice *dev);
static void assigned_dev_load_option_rom(AssignedDevice *dev);
@@ -257,7 +260,7 @@ static const MemoryRegionOps slow_bar_ops = {
static void assigned_dev_iomem_setup(PCIDevice *pci_dev, int region_num,
pcibus_t e_size)
{
- AssignedDevice *r_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *r_dev = PCI_ASSIGN(pci_dev);
AssignedDevRegion *region = &r_dev->v_addrs[region_num];
PCIRegion *real_region = &r_dev->real_device.regions[region_num];
@@ -289,7 +292,7 @@ static const MemoryRegionOps assigned_dev_ioport_ops = {
static void assigned_dev_ioport_setup(PCIDevice *pci_dev, int region_num,
pcibus_t size)
{
- AssignedDevice *r_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *r_dev = PCI_ASSIGN(pci_dev);
AssignedDevRegion *region = &r_dev->v_addrs[region_num];
region->e_size = size;
@@ -303,7 +306,7 @@ static void assigned_dev_ioport_setup(PCIDevice *pci_dev, int region_num,
static uint32_t assigned_dev_pci_read(PCIDevice *d, int pos, int len)
{
- AssignedDevice *pci_dev = DO_UPCAST(AssignedDevice, dev, d);
+ AssignedDevice *pci_dev = PCI_ASSIGN(d);
uint32_t val;
ssize_t ret;
int fd = pci_dev->real_device.config_fd;
@@ -328,7 +331,7 @@ static uint8_t assigned_dev_pci_read_byte(PCIDevice *d, int pos)
static void assigned_dev_pci_write(PCIDevice *d, int pos, uint32_t val, int len)
{
- AssignedDevice *pci_dev = DO_UPCAST(AssignedDevice, dev, d);
+ AssignedDevice *pci_dev = PCI_ASSIGN(d);
ssize_t ret;
int fd = pci_dev->real_device.config_fd;
@@ -946,7 +949,7 @@ static void deassign_device(AssignedDevice *dev)
*/
static void assigned_dev_update_irq_routing(PCIDevice *dev)
{
- AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, dev);
+ AssignedDevice *assigned_dev = PCI_ASSIGN(dev);
Error *err = NULL;
int r;
@@ -961,7 +964,7 @@ static void assigned_dev_update_irq_routing(PCIDevice *dev)
static void assigned_dev_update_msi(PCIDevice *pci_dev)
{
- AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap +
PCI_MSI_FLAGS);
int r;
@@ -1015,7 +1018,7 @@ static void assigned_dev_update_msi(PCIDevice *pci_dev)
static void assigned_dev_update_msi_msg(PCIDevice *pci_dev)
{
- AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint8_t ctrl_byte = pci_get_byte(pci_dev->config + pci_dev->msi_cap +
PCI_MSI_FLAGS);
@@ -1048,7 +1051,7 @@ static bool assigned_dev_msix_skipped(MSIXTableEntry *entry)
static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
{
- AssignedDevice *adev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *adev = PCI_ASSIGN(pci_dev);
uint16_t entries_nr = 0;
int i, r = 0;
MSIXTableEntry *entry = adev->msix_table;
@@ -1113,7 +1116,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
static void assigned_dev_update_msix(PCIDevice *pci_dev)
{
- AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint16_t ctrl_word = pci_get_word(pci_dev->config + pci_dev->msix_cap +
PCI_MSIX_FLAGS);
int r;
@@ -1163,7 +1166,7 @@ static void assigned_dev_update_msix(PCIDevice *pci_dev)
static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev,
uint32_t address, int len)
{
- AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint32_t virt_val = pci_default_read_config(pci_dev, address, len);
uint32_t real_val, emulate_mask, full_emulation_mask;
@@ -1184,7 +1187,7 @@ static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev,
static void assigned_dev_pci_write_config(PCIDevice *pci_dev, uint32_t address,
uint32_t val, int len)
{
- AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *assigned_dev = PCI_ASSIGN(pci_dev);
uint16_t old_cmd = pci_get_word(pci_dev->config + PCI_COMMAND);
uint32_t emulate_mask, full_emulation_mask;
int ret;
@@ -1244,7 +1247,7 @@ static void assigned_dev_setup_cap_read(AssignedDevice *dev, uint32_t offset,
static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
{
- AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *dev = PCI_ASSIGN(pci_dev);
PCIRegion *pci_region = dev->real_device.regions;
int ret, pos;
Error *local_err = NULL;
@@ -1684,8 +1687,8 @@ static const VMStateDescription vmstate_assigned_device = {
static void reset_assigned_device(DeviceState *dev)
{
- PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
- AssignedDevice *adev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ PCIDevice *pci_dev = PCI_DEVICE(dev);
+ AssignedDevice *adev = PCI_ASSIGN(pci_dev);
char reset_file[64];
const char reset[] = "1";
int fd, ret;
@@ -1740,7 +1743,7 @@ static void reset_assigned_device(DeviceState *dev)
static void assigned_realize(struct PCIDevice *pci_dev, Error **errp)
{
- AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *dev = PCI_ASSIGN(pci_dev);
uint8_t e_intx;
int r;
Error *local_err = NULL;
@@ -1836,7 +1839,7 @@ exit_with_error:
static void assigned_exitfn(struct PCIDevice *pci_dev)
{
- AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
+ AssignedDevice *dev = PCI_ASSIGN(pci_dev);
deassign_device(dev);
free_assigned_device(dev);
@@ -1845,7 +1848,7 @@ static void assigned_exitfn(struct PCIDevice *pci_dev)
static void assigned_dev_instance_init(Object *obj)
{
PCIDevice *pci_dev = PCI_DEVICE(obj);
- AssignedDevice *d = DO_UPCAST(AssignedDevice, dev, PCI_DEVICE(obj));
+ AssignedDevice *d = PCI_ASSIGN(pci_dev);
device_add_bootindex_property(obj, &d->bootindex,
"bootindex", NULL,
@@ -1879,7 +1882,7 @@ static void assign_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo assign_info = {
- .name = "kvm-pci-assign",
+ .name = TYPE_PCI_ASSIGN,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(AssignedDevice),
.class_init = assign_class_init,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3f0d435da9..7072930cfc 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -31,7 +31,6 @@
#include "hw/ide.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_bus.h"
-#include "monitor/monitor.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/timer/hpet.h"
#include "hw/i386/smbios.h"
@@ -57,6 +56,7 @@
#include "sysemu/arch_init.h"
#include "qemu/bitmap.h"
#include "qemu/config-file.h"
+#include "qemu/error-report.h"
#include "hw/acpi/acpi.h"
#include "hw/acpi/cpu_hotplug.h"
#include "hw/cpu/icc_bus.h"
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 9e5d86297c..b4b65c100a 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -27,7 +27,7 @@
#include <hw/pci/pci.h>
#include <hw/sysbus.h>
-#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "sysemu/block-backend.h"
#include "sysemu/dma.h"
#include "internal.h"
diff --git a/hw/input/Makefile.objs b/hw/input/Makefile.objs
index 0dae71052d..624ba7ea40 100644
--- a/hw/input/Makefile.objs
+++ b/hw/input/Makefile.objs
@@ -11,6 +11,7 @@ common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
ifeq ($(CONFIG_LINUX),y)
common-obj-$(CONFIG_VIRTIO) += virtio-input.o
common-obj-$(CONFIG_VIRTIO) += virtio-input-hid.o
+common-obj-$(CONFIG_VIRTIO) += virtio-input-host.o
endif
obj-$(CONFIG_MILKYMIST) += milkymist-softusb.o
diff --git a/hw/input/virtio-input-host.c b/hw/input/virtio-input-host.c
new file mode 100644
index 0000000000..f7e3d844e6
--- /dev/null
+++ b/hw/input/virtio-input-host.c
@@ -0,0 +1,188 @@
+/*
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version. See the COPYING file in the
+ * top-level directory.
+ */
+
+#include "qemu-common.h"
+#include "qemu/sockets.h"
+
+#include "hw/qdev.h"
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/virtio-input.h"
+
+#include "standard-headers/linux/input.h"
+
+/* ----------------------------------------------------------------- */
+
+static struct virtio_input_config virtio_input_host_config[] = {
+ { /* empty list */ },
+};
+
+static void virtio_input_host_event(void *opaque)
+{
+ VirtIOInputHost *vih = opaque;
+ VirtIOInput *vinput = VIRTIO_INPUT(vih);
+ struct virtio_input_event virtio;
+ struct input_event evdev;
+ int rc;
+
+ for (;;) {
+ rc = read(vih->fd, &evdev, sizeof(evdev));
+ if (rc != sizeof(evdev)) {
+ break;
+ }
+
+ virtio.type = cpu_to_le16(evdev.type);
+ virtio.code = cpu_to_le16(evdev.code);
+ virtio.value = cpu_to_le32(evdev.value);
+ virtio_input_send(vinput, &virtio);
+ }
+}
+
+static void virtio_input_bits_config(VirtIOInputHost *vih,
+ int type, int count)
+{
+ virtio_input_config bits;
+ int rc, i, size = 0;
+
+ memset(&bits, 0, sizeof(bits));
+ rc = ioctl(vih->fd, EVIOCGBIT(type, count/8), bits.u.bitmap);
+ if (rc < 0) {
+ return;
+ }
+
+ for (i = 0; i < count/8; i++) {
+ if (bits.u.bitmap[i]) {
+ size = i+1;
+ }
+ }
+ if (size == 0) {
+ return;
+ }
+
+ bits.select = VIRTIO_INPUT_CFG_EV_BITS;
+ bits.subsel = type;
+ bits.size = size;
+ virtio_input_add_config(VIRTIO_INPUT(vih), &bits);
+}
+
+static void virtio_input_host_realize(DeviceState *dev, Error **errp)
+{
+ VirtIOInputHost *vih = VIRTIO_INPUT_HOST(dev);
+ VirtIOInput *vinput = VIRTIO_INPUT(dev);
+ virtio_input_config id;
+ struct input_id ids;
+ int rc, ver;
+
+ if (!vih->evdev) {
+ error_setg(errp, "evdev property is required");
+ return;
+ }
+
+ vih->fd = open(vih->evdev, O_RDWR);
+ if (vih->fd < 0) {
+ error_setg_file_open(errp, errno, vih->evdev);
+ return;
+ }
+ qemu_set_nonblock(vih->fd);
+
+ rc = ioctl(vih->fd, EVIOCGVERSION, &ver);
+ if (rc < 0) {
+ error_setg(errp, "%s: is not an evdev device", vih->evdev);
+ goto err_close;
+ }
+
+ rc = ioctl(vih->fd, EVIOCGRAB, 1);
+ if (rc < 0) {
+ error_setg_errno(errp, errno, "%s: failed to get exclusive access",
+ vih->evdev);
+ goto err_close;
+ }
+
+ memset(&id, 0, sizeof(id));
+ ioctl(vih->fd, EVIOCGNAME(sizeof(id.u.string)-1), id.u.string);
+ id.select = VIRTIO_INPUT_CFG_ID_NAME;
+ id.size = strlen(id.u.string);
+ virtio_input_add_config(vinput, &id);
+
+ if (ioctl(vih->fd, EVIOCGID, &ids) == 0) {
+ memset(&id, 0, sizeof(id));
+ id.select = VIRTIO_INPUT_CFG_ID_DEVIDS;
+ id.size = sizeof(struct virtio_input_devids);
+ id.u.ids.bustype = cpu_to_le16(ids.bustype);
+ id.u.ids.vendor = cpu_to_le16(ids.vendor);
+ id.u.ids.product = cpu_to_le16(ids.product);
+ id.u.ids.version = cpu_to_le16(ids.version);
+ virtio_input_add_config(vinput, &id);
+ }
+
+ virtio_input_bits_config(vih, EV_KEY, KEY_CNT);
+ virtio_input_bits_config(vih, EV_REL, REL_CNT);
+ virtio_input_bits_config(vih, EV_ABS, ABS_CNT);
+ virtio_input_bits_config(vih, EV_MSC, MSC_CNT);
+ virtio_input_bits_config(vih, EV_SW, SW_CNT);
+
+ qemu_set_fd_handler(vih->fd, virtio_input_host_event, NULL, vih);
+ return;
+
+err_close:
+ close(vih->fd);
+ vih->fd = -1;
+ return;
+}
+
+static void virtio_input_host_unrealize(DeviceState *dev, Error **errp)
+{
+ VirtIOInputHost *vih = VIRTIO_INPUT_HOST(dev);
+
+ if (vih->fd > 0) {
+ qemu_set_fd_handler(vih->fd, NULL, NULL, NULL);
+ close(vih->fd);
+ }
+}
+
+static const VMStateDescription vmstate_virtio_input_host = {
+ .name = "virtio-input-host",
+ .unmigratable = 1,
+};
+
+static Property virtio_input_host_properties[] = {
+ DEFINE_PROP_STRING("evdev", VirtIOInputHost, evdev),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_input_host_class_init(ObjectClass *klass, void *data)
+{
+ VirtIOInputClass *vic = VIRTIO_INPUT_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->vmsd = &vmstate_virtio_input_host;
+ dc->props = virtio_input_host_properties;
+ vic->realize = virtio_input_host_realize;
+ vic->unrealize = virtio_input_host_unrealize;
+}
+
+static void virtio_input_host_init(Object *obj)
+{
+ VirtIOInput *vinput = VIRTIO_INPUT(obj);
+
+ virtio_input_init_config(vinput, virtio_input_host_config);
+}
+
+static const TypeInfo virtio_input_host_info = {
+ .name = TYPE_VIRTIO_INPUT_HOST,
+ .parent = TYPE_VIRTIO_INPUT,
+ .instance_size = sizeof(VirtIOInputHost),
+ .instance_init = virtio_input_host_init,
+ .class_init = virtio_input_host_class_init,
+};
+
+/* ----------------------------------------------------------------- */
+
+static void virtio_register_types(void)
+{
+ type_register_static(&virtio_input_host_info);
+}
+
+type_init(virtio_register_types)
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index c4f4b3c150..7f5b8d6000 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -216,7 +216,7 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
}
virtio_input_idstr_config(vinput, VIRTIO_INPUT_CFG_ID_SERIAL,
- vinput->input.serial);
+ vinput->serial);
QTAILQ_FOREACH(cfg, &vinput->cfg_list, node) {
if (vinput->cfg_size < cfg->config.size) {
@@ -248,11 +248,17 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
virtio_cleanup(vdev);
}
+static Property virtio_input_properties[] = {
+ DEFINE_PROP_STRING("serial", VirtIOInput, serial),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void virtio_input_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+ dc->props = virtio_input_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
vdc->realize = virtio_input_device_realize;
vdc->unrealize = virtio_input_device_unrealize;
diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index 87fe2e865d..14ab0e31b8 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -1556,9 +1556,9 @@ static void openpic_realize(DeviceState *dev, Error **errp)
};
if (opp->nb_cpus > MAX_CPU) {
- error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
- TYPE_OPENPIC, "nb_cpus", (uint64_t)opp->nb_cpus,
- (uint64_t)0, (uint64_t)MAX_CPU);
+ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
+ TYPE_OPENPIC, "nb_cpus", (uint64_t)opp->nb_cpus,
+ (uint64_t)0, (uint64_t)MAX_CPU);
return;
}
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index d9522b1f45..2c59e91fff 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -34,6 +34,10 @@ typedef struct PIIX4State {
PCIDevice dev;
} PIIX4State;
+#define TYPE_PIIX4_PCI_DEVICE "PIIX4"
+#define PIIX4_PCI_DEVICE(obj) \
+ OBJECT_CHECK(PIIX4State, (obj), TYPE_PIIX4_PCI_DEVICE)
+
static void piix4_reset(void *opaque)
{
PIIX4State *d = opaque;
@@ -84,7 +88,7 @@ static const VMStateDescription vmstate_piix4 = {
static void piix4_realize(PCIDevice *dev, Error **errp)
{
- PIIX4State *d = DO_UPCAST(PIIX4State, dev, dev);
+ PIIX4State *d = PIIX4_PCI_DEVICE(dev);
isa_bus_new(DEVICE(d), pci_address_space(dev),
pci_address_space_io(dev));
@@ -121,7 +125,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo piix4_info = {
- .name = "PIIX4",
+ .name = TYPE_PIIX4_PCI_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PIIX4State),
.class_init = piix4_class_init,
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index b2ba870427..252e1d7145 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -47,6 +47,10 @@ typedef struct VT82C686BState {
SuperIOConfig superio_conf;
} VT82C686BState;
+#define TYPE_VT82C686B_DEVICE "VT82C686B"
+#define VT82C686B_DEVICE(obj) \
+ OBJECT_CHECK(VT82C686BState, (obj), TYPE_VT82C686B_DEVICE)
+
static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
unsigned size)
{
@@ -114,7 +118,7 @@ static void vt82c686b_reset(void * opaque)
{
PCIDevice *d = opaque;
uint8_t *pci_conf = d->config;
- VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d);
+ VT82C686BState *vt82c = VT82C686B_DEVICE(d);
pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0);
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
@@ -142,7 +146,7 @@ static void vt82c686b_reset(void * opaque)
static void vt82c686b_write_config(PCIDevice * d, uint32_t address,
uint32_t val, int len)
{
- VT82C686BState *vt686 = DO_UPCAST(VT82C686BState, dev, d);
+ VT82C686BState *vt686 = VT82C686B_DEVICE(d);
DPRINTF("vt82c686b_write_config address 0x%x val 0x%x len 0x%x\n",
address, val, len);
@@ -172,6 +176,18 @@ typedef struct VT686MC97State {
PCIDevice dev;
} VT686MC97State;
+#define TYPE_VT82C686B_PM_DEVICE "VT82C686B_PM"
+#define VT82C686B_PM_DEVICE(obj) \
+ OBJECT_CHECK(VT686PMState, (obj), TYPE_VT82C686B_PM_DEVICE)
+
+#define TYPE_VT82C686B_MC97_DEVICE "VT82C686B_MC97"
+#define VT82C686B_MC97_DEVICE(obj) \
+ OBJECT_CHECK(VT686MC97State, (obj), TYPE_VT82C686B_MC97_DEVICE)
+
+#define TYPE_VT82C686B_AC97_DEVICE "VT82C686B_AC97"
+#define VT82C686B_AC97_DEVICE(obj) \
+ OBJECT_CHECK(VT686AC97State, (obj), TYPE_VT82C686B_AC97_DEVICE)
+
static void pm_update_sci(VT686PMState *s)
{
int sci_level, pmsts;
@@ -247,7 +263,7 @@ static const VMStateDescription vmstate_acpi = {
static void vt82c686b_ac97_realize(PCIDevice *dev, Error **errp)
{
- VT686AC97State *s = DO_UPCAST(VT686AC97State, dev, dev);
+ VT686AC97State *s = VT82C686B_AC97_DEVICE(dev);
uint8_t *pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -261,7 +277,7 @@ void vt82c686b_ac97_init(PCIBus *bus, int devfn)
{
PCIDevice *dev;
- dev = pci_create(bus, devfn, "VT82C686B_AC97");
+ dev = pci_create(bus, devfn, TYPE_VT82C686B_AC97_DEVICE);
qdev_init_nofail(&dev->qdev);
}
@@ -280,7 +296,7 @@ static void via_ac97_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo via_ac97_info = {
- .name = "VT82C686B_AC97",
+ .name = TYPE_VT82C686B_AC97_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686AC97State),
.class_init = via_ac97_class_init,
@@ -288,7 +304,7 @@ static const TypeInfo via_ac97_info = {
static void vt82c686b_mc97_realize(PCIDevice *dev, Error **errp)
{
- VT686MC97State *s = DO_UPCAST(VT686MC97State, dev, dev);
+ VT686MC97State *s = VT82C686B_MC97_DEVICE(dev);
uint8_t *pci_conf = s->dev.config;
pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_INVALIDATE |
@@ -301,7 +317,7 @@ void vt82c686b_mc97_init(PCIBus *bus, int devfn)
{
PCIDevice *dev;
- dev = pci_create(bus, devfn, "VT82C686B_MC97");
+ dev = pci_create(bus, devfn, TYPE_VT82C686B_MC97_DEVICE);
qdev_init_nofail(&dev->qdev);
}
@@ -320,7 +336,7 @@ static void via_mc97_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo via_mc97_info = {
- .name = "VT82C686B_MC97",
+ .name = TYPE_VT82C686B_MC97_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686MC97State),
.class_init = via_mc97_class_init,
@@ -329,7 +345,7 @@ static const TypeInfo via_mc97_info = {
/* vt82c686 pm init */
static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
{
- VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev);
+ VT686PMState *s = VT82C686B_PM_DEVICE(dev);
uint8_t *pci_conf;
pci_conf = s->dev.config;
@@ -365,10 +381,10 @@ I2CBus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
PCIDevice *dev;
VT686PMState *s;
- dev = pci_create(bus, devfn, "VT82C686B_PM");
+ dev = pci_create(bus, devfn, TYPE_VT82C686B_PM_DEVICE);
qdev_prop_set_uint32(&dev->qdev, "smb_io_base", smb_io_base);
- s = DO_UPCAST(VT686PMState, dev, dev);
+ s = VT82C686B_PM_DEVICE(dev);
qdev_init_nofail(&dev->qdev);
@@ -398,7 +414,7 @@ static void via_pm_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo via_pm_info = {
- .name = "VT82C686B_PM",
+ .name = TYPE_VT82C686B_PM_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT686PMState),
.class_init = via_pm_class_init,
@@ -417,7 +433,7 @@ static const VMStateDescription vmstate_via = {
/* init the PCI-to-ISA bridge */
static void vt82c686b_realize(PCIDevice *d, Error **errp)
{
- VT82C686BState *vt82c = DO_UPCAST(VT82C686BState, dev, d);
+ VT82C686BState *vt82c = VT82C686B_DEVICE(d);
uint8_t *pci_conf;
ISABus *isa_bus;
uint8_t *wmask;
@@ -451,7 +467,8 @@ ISABus *vt82c686b_init(PCIBus *bus, int devfn)
{
PCIDevice *d;
- d = pci_create_simple_multifunction(bus, devfn, true, "VT82C686B");
+ d = pci_create_simple_multifunction(bus, devfn, true,
+ TYPE_VT82C686B_DEVICE);
return ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
}
@@ -477,7 +494,7 @@ static void via_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo via_info = {
- .name = "VT82C686B",
+ .name = TYPE_VT82C686B_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(VT82C686BState),
.class_init = via_class_init,
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 786a8f0638..3082e75340 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -53,6 +53,7 @@
#include "qemu/error-report.h"
#include "hw/empty_slot.h"
#include "sysemu/kvm.h"
+#include "exec/semihost.h"
//#define DEBUG_BOARD_INIT
@@ -634,7 +635,13 @@ static void write_bootloader (CPUMIPSState *env, uint8_t *base,
/* Second part of the bootloader */
p = (uint32_t *) (base + 0x580);
- stl_p(p++, 0x24040002); /* addiu a0, zero, 2 */
+
+ if (semihosting_get_argc()) {
+ /* Preserve a0 content as arguments have been passed */
+ stl_p(p++, 0x00000000); /* nop */
+ } else {
+ stl_p(p++, 0x24040002); /* addiu a0, zero, 2 */
+ }
stl_p(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); /* lui sp, high(ENVP_ADDR) */
stl_p(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff)); /* ori sp, sp, low(ENVP_ADDR) */
stl_p(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */
@@ -887,7 +894,7 @@ static void main_cpu_reset(void *opaque)
read only location. The kernel location and the arguments table
location does not change. */
if (loaderparams.kernel_filename) {
- env->CP0_Status &= ~((1 << CP0St_BEV) | (1 << CP0St_ERL));
+ env->CP0_Status &= ~(1 << CP0St_ERL);
}
malta_mips_config(cpu);
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 231c35fdef..cc76989a39 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -22,7 +22,7 @@
#include "hw/pci/msix.h"
#include "sysemu/kvm.h"
#include "migration/migration.h"
-#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "qemu/event_notifier.h"
#include "qemu/fifo8.h"
#include "sysemu/char.h"
diff --git a/hw/net/rocker/qmp-norocker.c b/hw/net/rocker/qmp-norocker.c
index f253747361..49b498b642 100644
--- a/hw/net/rocker/qmp-norocker.c
+++ b/hw/net/rocker/qmp-norocker.c
@@ -21,13 +21,13 @@
RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "rocker");
+ error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL;
};
RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "rocker");
+ error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL;
};
@@ -36,7 +36,7 @@ RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name,
uint32_t tbl_id,
Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "rocker");
+ error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL;
};
@@ -45,6 +45,6 @@ RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name,
uint8_t type,
Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "rocker");
+ error_setg(errp, QERR_FEATURE_DISABLED, "rocker");
return NULL;
};
diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index 21efedfc3e..92057707e0 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -26,7 +26,6 @@
#include "qemu/log.h"
#include "net/net.h"
#include "net/checksum.h"
-#include "qapi/qmp/qerror.h"
#include "hw/stream.h"
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index ed2424c4cd..ad55f99663 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -91,6 +91,10 @@ typedef struct PIIX3State {
MemoryRegion rcr_mem;
} PIIX3State;
+#define TYPE_PIIX3_PCI_DEVICE "pci-piix3"
+#define PIIX3_PCI_DEVICE(obj) \
+ OBJECT_CHECK(PIIX3State, (obj), TYPE_PIIX3_PCI_DEVICE)
+
#define TYPE_I440FX_PCI_DEVICE "i440FX"
#define I440FX_PCI_DEVICE(obj) \
OBJECT_CHECK(PCII440FXState, (obj), TYPE_I440FX_PCI_DEVICE)
@@ -368,13 +372,15 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state,
* connected to the IOAPIC directly.
* These additional routes can be discovered through ACPI. */
if (xen_enabled()) {
- piix3 = DO_UPCAST(PIIX3State, dev,
- pci_create_simple_multifunction(b, -1, true, "PIIX3-xen"));
+ PCIDevice *pci_dev = pci_create_simple_multifunction(b,
+ -1, true, "PIIX3-xen");
+ piix3 = PIIX3_PCI_DEVICE(pci_dev);
pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq,
piix3, XEN_PIIX_NUM_PIRQS);
} else {
- piix3 = DO_UPCAST(PIIX3State, dev,
- pci_create_simple_multifunction(b, -1, true, "PIIX3"));
+ PCIDevice *pci_dev = pci_create_simple_multifunction(b,
+ -1, true, "PIIX3");
+ piix3 = PIIX3_PCI_DEVICE(pci_dev);
pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3,
PIIX_NUM_PIRQS);
pci_bus_set_route_irq_fn(b, piix3_route_intx_pin_to_irq);
@@ -480,7 +486,7 @@ static void piix3_write_config(PCIDevice *dev,
{
pci_default_write_config(dev, address, val, len);
if (ranges_overlap(address, len, PIIX_PIRQC, 4)) {
- PIIX3State *piix3 = DO_UPCAST(PIIX3State, dev, dev);
+ PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev);
int pic_irq;
pci_bus_fire_intx_routing_notifier(piix3->dev.bus);
@@ -634,7 +640,7 @@ static const MemoryRegionOps rcr_ops = {
static void piix3_realize(PCIDevice *dev, Error **errp)
{
- PIIX3State *d = DO_UPCAST(PIIX3State, dev, dev);
+ PIIX3State *d = PIIX3_PCI_DEVICE(dev);
isa_bus_new(DEVICE(d), get_system_memory(),
pci_address_space_io(dev));
@@ -647,7 +653,7 @@ static void piix3_realize(PCIDevice *dev, Error **errp)
qemu_register_reset(piix3_reset, d);
}
-static void piix3_class_init(ObjectClass *klass, void *data)
+static void pci_piix3_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -656,7 +662,6 @@ static void piix3_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_piix3;
dc->hotpluggable = false;
k->realize = piix3_realize;
- k->config_write = piix3_write_config;
k->vendor_id = PCI_VENDOR_ID_INTEL;
/* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0;
@@ -668,38 +673,37 @@ static void piix3_class_init(ObjectClass *klass, void *data)
dc->cannot_instantiate_with_device_add_yet = true;
}
+static const TypeInfo piix3_pci_type_info = {
+ .name = TYPE_PIIX3_PCI_DEVICE,
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PIIX3State),
+ .abstract = true,
+ .class_init = pci_piix3_class_init,
+};
+
+static void piix3_class_init(ObjectClass *klass, void *data)
+{
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->config_write = piix3_write_config;
+}
+
static const TypeInfo piix3_info = {
.name = "PIIX3",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PIIX3State),
+ .parent = TYPE_PIIX3_PCI_DEVICE,
.class_init = piix3_class_init,
};
static void piix3_xen_class_init(ObjectClass *klass, void *data)
{
- DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- dc->desc = "ISA bridge";
- dc->vmsd = &vmstate_piix3;
- dc->hotpluggable = false;
- k->realize = piix3_realize;
k->config_write = piix3_write_config_xen;
- k->vendor_id = PCI_VENDOR_ID_INTEL;
- /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
- k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0;
- k->class_id = PCI_CLASS_BRIDGE_ISA;
- /*
- * Reason: part of PIIX3 southbridge, needs to be wired up by
- * pc_piix.c's pc_init1()
- */
- dc->cannot_instantiate_with_device_add_yet = true;
};
static const TypeInfo piix3_xen_info = {
.name = "PIIX3-xen",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PIIX3State),
+ .parent = TYPE_PIIX3_PCI_DEVICE,
.class_init = piix3_xen_class_init,
};
@@ -772,6 +776,7 @@ static const TypeInfo i440fx_pcihost_info = {
static void i440fx_register_types(void)
{
type_register_static(&i440fx_info);
+ type_register_static(&piix3_pci_type_info);
type_register_static(&piix3_info);
type_register_static(&piix3_xen_info);
type_register_static(&i440fx_pcihost_info);
diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c
index f8f237e823..063a7c2427 100644
--- a/hw/pci/pci-stub.c
+++ b/hw/pci/pci-stub.c
@@ -20,12 +20,13 @@
#include "sysemu/sysemu.h"
#include "monitor/monitor.h"
+#include "qapi/qmp/qerror.h"
#include "hw/pci/pci.h"
#include "qmp-commands.h"
PciInfoList *qmp_query_pci(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 21580433d4..442f822f42 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -30,6 +30,7 @@
#include "net/net.h"
#include "sysemu/sysemu.h"
#include "hw/loader.h"
+#include "qemu/error-report.h"
#include "qemu/range.h"
#include "qmp-commands.h"
#include "trace.h"
@@ -427,6 +428,10 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
for (i = 0; i < size; ++i) {
if ((config[i] ^ s->config[i]) &
s->cmask[i] & ~s->wmask[i] & ~s->w1cmask[i]) {
+ error_report("%s: Bad config data: i=0x%x read: %x device: %x "
+ "cmask: %x wmask: %x w1cmask:%x", __func__,
+ i, config[i], s->config[i],
+ s->cmask[i], s->wmask[i], s->w1cmask[i]);
g_free(config);
return -EINVAL;
}
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 1463e65b5d..14c77117f6 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -26,7 +26,6 @@
#include "hw/pci/pci_bus.h"
#include "hw/pci/pcie_regs.h"
#include "qemu/range.h"
-#include "qapi/qmp/qerror.h"
//#define DEBUG_PCIE
#ifdef DEBUG_PCIE
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index c8dea8ed9c..f1847ac210 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -975,7 +975,7 @@ static int do_pcie_aer_inject_error(Monitor *mon,
if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) {
char *e = NULL;
error_status = strtoul(error_name, &e, 0);
- correctable = qdict_get_try_bool(qdict, "correctable", 0);
+ correctable = qdict_get_try_bool(qdict, "correctable", false);
if (!e || *e != '\0') {
monitor_printf(mon, "invalid error status value. \"%s\"",
error_name);
@@ -989,7 +989,7 @@ static int do_pcie_aer_inject_error(Monitor *mon,
if (correctable) {
err.flags |= PCIE_AER_ERR_IS_CORRECTABLE;
}
- if (qdict_get_try_bool(qdict, "advisory_non_fatal", 0)) {
+ if (qdict_get_try_bool(qdict, "advisory_non_fatal", false)) {
err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY;
}
if (qdict_haskey(qdict, "header0")) {
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index a706486394..bfb4d31b62 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -7,7 +7,6 @@
#include "hw/pci/pci.h"
#include "hw/pci/pci_bus.h"
#include "hw/pci/msi.h"
-#include "qapi/qmp/qerror.h"
/* TODO: model power only and disabled slot states. */
/* TODO: handle SERR and wakeups */
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 4df3a33db4..d4a6150527 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1062,8 +1062,8 @@ static void spapr_phb_hot_plug_child(HotplugHandler *plug_handler,
* we need to let them know it's not enabled
*/
if (plugged_dev->hotplugged) {
- error_set(errp, QERR_BUS_NO_HOTPLUG,
- object_get_typename(OBJECT(phb)));
+ error_setg(errp, QERR_BUS_NO_HOTPLUG,
+ object_get_typename(OBJECT(phb)));
}
return;
}
@@ -1090,8 +1090,8 @@ static void spapr_phb_hot_unplug_child(HotplugHandler *plug_handler,
Error *local_err = NULL;
if (!phb->dr_enabled) {
- error_set(errp, QERR_BUS_NO_HOTPLUG,
- object_get_typename(OBJECT(phb)));
+ error_setg(errp, QERR_BUS_NO_HOTPLUG,
+ object_get_typename(OBJECT(phb)));
return;
}
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 174033dd41..8b59b64b7e 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -22,7 +22,6 @@
#include "hw/hw.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
-#include "monitor/monitor.h"
#include "hw/loader.h"
#include "elf.h"
#include "hw/sysbus.h"
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index 6ebd5bee8b..439732f7ab 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -32,6 +32,7 @@
#include "sysemu/device_tree.h"
#include "hw/loader.h"
#include "elf.h"
+#include "qemu/error-report.h"
#include "qemu/log.h"
#include "exec/address-spaces.h"
@@ -40,7 +41,6 @@
#include "ppc405.h"
#include "sysemu/block-backend.h"
-#include "qapi/qmp/qerror.h"
#define EPAPR_MAGIC (0x45504150)
#define FLASH_SIZE (16 * 1024 * 1024)
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 1cb116a297..0c700effb1 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -15,7 +15,6 @@
*
*/
-#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
#include "hw/s390x/sclp.h"
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 8a6e27eac1..77aec8a5bd 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -21,7 +21,6 @@
#include "sysemu/block-backend.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
-#include "monitor/monitor.h"
#include "hw/loader.h"
#include "elf.h"
#include "hw/virtio/virtio.h"
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 00ea793651..1284e77b22 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -22,12 +22,12 @@
*/
#include "hw/hw.h"
+#include "qapi/qmp/qerror.h"
#include "sysemu/block-backend.h"
#include "sysemu/blockdev.h"
#include "sysemu/sysemu.h"
#include "net/net.h"
#include "hw/boards.h"
-#include "monitor/monitor.h"
#include "hw/loader.h"
#include "hw/virtio/virtio.h"
#include "hw/sysbus.h"
@@ -324,7 +324,7 @@ void s390_nmi(NMIState *n, int cpu_index, Error **errp)
CPUState *cs = qemu_get_cpu(cpu_index);
if (s390_cpu_restart(S390_CPU(cs))) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
}
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index e32ada9bf1..9605bf40b9 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -15,12 +15,12 @@
#include "sysemu/blockdev.h"
#include "sysemu/sysemu.h"
#include "net/net.h"
-#include "monitor/monitor.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-serial.h"
#include "hw/virtio/virtio-net.h"
#include "hw/sysbus.h"
#include "qemu/bitops.h"
+#include "qemu/error-report.h"
#include "hw/virtio/virtio-bus.h"
#include "hw/s390x/adapter.h"
#include "hw/s390x/s390_flic.h"
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 1c389c4d7e..52549f8beb 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -16,6 +16,7 @@
#include <sys/ioctl.h>
#include "config.h"
+#include "qemu/error-report.h"
#include "qemu/queue.h"
#include "monitor/monitor.h"
#include "migration/migration.h"
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index b50071ef93..2bb62211c3 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -27,6 +27,7 @@
#include "hw/hw.h"
#include "hw/i386/pc.h"
#include "ui/console.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "hw/timer/hpet.h"
#include "hw/sysbus.h"
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 8d8523a535..79a8f98af0 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -26,6 +26,7 @@
#include "qemu-common.h"
#include "qapi/error.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "sysemu/tpm_backend.h"
#include "tpm_int.h"
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 375167573d..5f39e1e3ac 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -1,6 +1,7 @@
#include "hw/hw.h"
#include "hw/usb.h"
#include "hw/qdev.h"
+#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
#include "monitor/monitor.h"
#include "trace.h"
diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c
index aa1c37aabd..72329ed7d7 100644
--- a/hw/usb/ccid-card-emulated.c
+++ b/hw/usb/ccid-card-emulated.c
@@ -33,7 +33,6 @@
#include "qemu/thread.h"
#include "sysemu/char.h"
-#include "monitor/monitor.h"
#include "ccid.h"
#define DPRINTF(card, lvl, fmt, ...) \
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 10f1d309a6..85a4fc3e53 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -9,8 +9,8 @@
*/
#include "sysemu/char.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
-#include "monitor/monitor.h"
#include "ccid.h"
#include "libcacard/vscard_common.h"
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 743c231d6b..5eeb4c6b06 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1397,7 +1397,7 @@ static USBDevice *usb_net_init(USBBus *bus, const char *cmdline)
QemuOpts *opts;
int idx;
- opts = qemu_opts_parse(qemu_find_opts("net"), cmdline, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("net"), cmdline, false);
if (!opts) {
return NULL;
}
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 6ca3da9727..a6a66008ec 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -9,7 +9,7 @@
*/
#include "qemu-common.h"
-#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "hw/usb.h"
#include "hw/usb/desc.h"
#include "sysemu/char.h"
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 2d29367ae7..de534bab37 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -38,7 +38,6 @@
#include "qemu/error-report.h"
#include "hw/usb.h"
#include "hw/usb/desc.h"
-#include "monitor/monitor.h"
#include "ccid.h"
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index abe0e1d6a1..9a4e7dc0cb 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -8,6 +8,7 @@
*/
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "hw/usb.h"
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 87b240f70a..30218423c8 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -20,7 +20,6 @@
#include "hw/hw.h"
#include "qemu/timer.h"
#include "hw/usb.h"
-#include "monitor/monitor.h"
#include "sysemu/dma.h"
#include "sysemu/sysemu.h"
#include "hw/pci/pci.h"
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 10f4735ddf..bc2944c6b2 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -38,6 +38,7 @@
#include "qemu-common.h"
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
#include "trace.h"
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 6b4218c037..25df25fd0f 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -27,8 +27,9 @@
#include "qemu-common.h"
#include "qemu/timer.h"
-#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "qemu/iov.h"
#include "sysemu/char.h"
@@ -1369,7 +1370,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
int i;
if (dev->cs == NULL) {
- error_set(errp, QERR_MISSING_PARAMETER, "chardev");
+ error_setg(errp, QERR_MISSING_PARAMETER, "chardev");
return;
}
@@ -1378,8 +1379,8 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
&dev->filter_rules,
&dev->filter_rules_count);
if (i) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "filter",
- "a usb device filter string");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "filter",
+ "a usb device filter string");
return;
}
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index ce1c46e6e1..6a0174e9cc 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1900,8 +1900,7 @@ static const TypeInfo virtio_rng_pci_info = {
/* virtio-input-pci */
-static Property virtio_input_hid_pci_properties[] = {
- DEFINE_VIRTIO_INPUT_PROPERTIES(VirtIOInputPCI, vdev.input),
+static Property virtio_input_pci_properties[] = {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1924,19 +1923,13 @@ static void virtio_input_pci_class_init(ObjectClass *klass, void *data)
VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
+ dc->props = virtio_input_pci_properties;
k->realize = virtio_input_pci_realize;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
pcidev_k->class_id = PCI_CLASS_INPUT_OTHER;
}
-static void virtio_input_hid_pci_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
-
- dc->props = virtio_input_hid_pci_properties;
-}
-
static void virtio_input_hid_kbd_pci_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
@@ -1955,22 +1948,33 @@ static void virtio_input_hid_mouse_pci_class_init(ObjectClass *klass,
static void virtio_keyboard_initfn(Object *obj)
{
VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj);
- object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_KEYBOARD);
- object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VIRTIO_KEYBOARD);
}
static void virtio_mouse_initfn(Object *obj)
{
VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj);
- object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_MOUSE);
- object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VIRTIO_MOUSE);
}
static void virtio_tablet_initfn(Object *obj)
{
VirtIOInputHIDPCI *dev = VIRTIO_INPUT_HID_PCI(obj);
- object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_TABLET);
- object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VIRTIO_TABLET);
+}
+
+static void virtio_host_initfn(Object *obj)
+{
+ VirtIOInputHostPCI *dev = VIRTIO_INPUT_HOST_PCI(obj);
+
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VIRTIO_INPUT_HOST);
}
static const TypeInfo virtio_input_pci_info = {
@@ -1985,7 +1989,6 @@ static const TypeInfo virtio_input_hid_pci_info = {
.name = TYPE_VIRTIO_INPUT_HID_PCI,
.parent = TYPE_VIRTIO_INPUT_PCI,
.instance_size = sizeof(VirtIOInputHIDPCI),
- .class_init = virtio_input_hid_pci_class_init,
.abstract = true,
};
@@ -2012,6 +2015,13 @@ static const TypeInfo virtio_tablet_pci_info = {
.instance_init = virtio_tablet_initfn,
};
+static const TypeInfo virtio_host_pci_info = {
+ .name = TYPE_VIRTIO_INPUT_HOST_PCI,
+ .parent = TYPE_VIRTIO_INPUT_PCI,
+ .instance_size = sizeof(VirtIOInputHostPCI),
+ .instance_init = virtio_host_initfn,
+};
+
/* virtio-pci-bus */
static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
@@ -2058,6 +2068,7 @@ static void virtio_pci_register_types(void)
type_register_static(&virtio_keyboard_pci_info);
type_register_static(&virtio_mouse_pci_info);
type_register_static(&virtio_tablet_pci_info);
+ type_register_static(&virtio_host_pci_info);
type_register_static(&virtio_pci_bus_info);
type_register_static(&virtio_pci_info);
#ifdef CONFIG_VIRTFS
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index 96025ca205..05d9d243f6 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -43,6 +43,7 @@ typedef struct VHostSCSIPCI VHostSCSIPCI;
typedef struct VirtIORngPCI VirtIORngPCI;
typedef struct VirtIOInputPCI VirtIOInputPCI;
typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
+typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
typedef struct VirtIOGPUPCI VirtIOGPUPCI;
/* virtio-pci-bus */
@@ -263,6 +264,15 @@ struct VirtIOInputHIDPCI {
VirtIOInputHID vdev;
};
+#define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci"
+#define VIRTIO_INPUT_HOST_PCI(obj) \
+ OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
+
+struct VirtIOInputHostPCI {
+ VirtIOPCIProxy parent_obj;
+ VirtIOInputHost vdev;
+};
+
/*
* virtio-gpu-pci: This extends VirtioPCIProxy.
*/
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 22b1d87d0e..740ed3102b 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -11,7 +11,6 @@
#include "qemu/iov.h"
#include "hw/qdev.h"
-#include "qapi/qmp/qerror.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-rng.h"
#include "sysemu/rng.h"
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index 4ebdbb8586..cfa2b1be13 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -103,6 +103,10 @@ struct I6300State {
typedef struct I6300State I6300State;
+#define TYPE_WATCHDOG_I6300ESB_DEVICE "i6300esb"
+#define WATCHDOG_I6300ESB_DEVICE(obj) \
+ OBJECT_CHECK(I6300State, (obj), TYPE_WATCHDOG_I6300ESB_DEVICE)
+
/* This function is called when the watchdog has either been enabled
* (hence it starts counting down) or has been keep-alived.
*/
@@ -150,7 +154,7 @@ static void i6300esb_disable_timer(I6300State *d)
static void i6300esb_reset(DeviceState *dev)
{
PCIDevice *pdev = PCI_DEVICE(dev);
- I6300State *d = DO_UPCAST(I6300State, dev, pdev);
+ I6300State *d = WATCHDOG_I6300ESB_DEVICE(pdev);
i6300esb_debug("I6300State = %p\n", d);
@@ -213,7 +217,7 @@ static void i6300esb_timer_expired(void *vp)
static void i6300esb_config_write(PCIDevice *dev, uint32_t addr,
uint32_t data, int len)
{
- I6300State *d = DO_UPCAST(I6300State, dev, dev);
+ I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
int old;
i6300esb_debug("addr = %x, data = %x, len = %d\n", addr, data, len);
@@ -241,7 +245,7 @@ static void i6300esb_config_write(PCIDevice *dev, uint32_t addr,
static uint32_t i6300esb_config_read(PCIDevice *dev, uint32_t addr, int len)
{
- I6300State *d = DO_UPCAST(I6300State, dev, dev);
+ I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
uint32_t data;
i6300esb_debug ("addr = %x, len = %d\n", addr, len);
@@ -416,7 +420,7 @@ static const VMStateDescription vmstate_i6300esb = {
static void i6300esb_realize(PCIDevice *dev, Error **errp)
{
- I6300State *d = DO_UPCAST(I6300State, dev, dev);
+ I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
i6300esb_debug("I6300State = %p\n", d);
@@ -451,7 +455,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo i6300esb_info = {
- .name = "i6300esb",
+ .name = TYPE_WATCHDOG_I6300ESB_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(I6300State),
.class_init = i6300esb_class_init,
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index 9afcda8e21..ed5fcaec0d 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -125,7 +125,7 @@ int xen_pt_bar_offset_to_index(uint32_t offset)
static uint32_t xen_pt_pci_read_config(PCIDevice *d, uint32_t addr, int len)
{
- XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d);
+ XenPCIPassthroughState *s = XEN_PT_DEVICE(d);
uint32_t val = 0;
XenPTRegGroup *reg_grp_entry = NULL;
XenPTReg *reg_entry = NULL;
@@ -230,7 +230,7 @@ exit:
static void xen_pt_pci_write_config(PCIDevice *d, uint32_t addr,
uint32_t val, int len)
{
- XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d);
+ XenPCIPassthroughState *s = XEN_PT_DEVICE(d);
int index = 0;
XenPTRegGroup *reg_grp_entry = NULL;
int rc = 0;
@@ -249,10 +249,18 @@ static void xen_pt_pci_write_config(PCIDevice *d, uint32_t addr,
/* check unused BAR register */
index = xen_pt_bar_offset_to_index(addr);
- if ((index >= 0) && (val > 0 && val < XEN_PT_BAR_ALLF) &&
- (s->bases[index].bar_flag == XEN_PT_BAR_FLAG_UNUSED)) {
- XEN_PT_WARN(d, "Guest attempt to set address to unused Base Address "
- "Register. (addr: 0x%02x, len: %d)\n", addr, len);
+ if ((index >= 0) && (val != 0)) {
+ uint32_t chk = val;
+
+ if (index == PCI_ROM_SLOT)
+ chk |= (uint32_t)~PCI_ROM_ADDRESS_MASK;
+
+ if ((chk != XEN_PT_BAR_ALLF) &&
+ (s->bases[index].bar_flag == XEN_PT_BAR_FLAG_UNUSED)) {
+ XEN_PT_WARN(d, "Guest attempt to set address to unused "
+ "Base Address Register. (addr: 0x%02x, len: %d)\n",
+ addr, len);
+ }
}
/* find register group entry */
@@ -607,8 +615,8 @@ static void xen_pt_region_update(XenPCIPassthroughState *s,
guest_port, machine_port, size,
op);
if (rc) {
- XEN_PT_ERR(d, "%s ioport mapping failed! (rc: %i)\n",
- adding ? "create new" : "remove old", rc);
+ XEN_PT_ERR(d, "%s ioport mapping failed! (err: %i)\n",
+ adding ? "create new" : "remove old", errno);
}
} else {
pcibus_t guest_addr = sec->offset_within_address_space;
@@ -621,8 +629,8 @@ static void xen_pt_region_update(XenPCIPassthroughState *s,
XEN_PFN(size + XC_PAGE_SIZE - 1),
op);
if (rc) {
- XEN_PT_ERR(d, "%s mem mapping failed! (rc: %i)\n",
- adding ? "create new" : "remove old", rc);
+ XEN_PT_ERR(d, "%s mem mapping failed! (err: %i)\n",
+ adding ? "create new" : "remove old", errno);
}
}
}
@@ -679,7 +687,7 @@ static const MemoryListener xen_pt_io_listener = {
static int xen_pt_initfn(PCIDevice *d)
{
- XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d);
+ XenPCIPassthroughState *s = XEN_PT_DEVICE(d);
int rc = 0;
uint8_t machine_irq = 0;
uint16_t cmd = 0;
@@ -736,14 +744,11 @@ static int xen_pt_initfn(PCIDevice *d)
rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
if (rc < 0) {
- XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (rc: %d)\n",
- machine_irq, pirq, rc);
+ XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)\n",
+ machine_irq, pirq, errno);
/* Disable PCI intx assertion (turn on bit10 of devctl) */
- xen_host_pci_set_word(&s->real_device,
- PCI_COMMAND,
- pci_get_word(s->dev.config + PCI_COMMAND)
- | PCI_COMMAND_INTX_DISABLE);
+ cmd |= PCI_COMMAND_INTX_DISABLE;
machine_irq = 0;
s->machine_irq = 0;
} else {
@@ -761,19 +766,17 @@ static int xen_pt_initfn(PCIDevice *d)
PCI_SLOT(d->devfn),
e_intx);
if (rc < 0) {
- XEN_PT_ERR(d, "Binding of interrupt %i failed! (rc: %d)\n",
- e_intx, rc);
+ XEN_PT_ERR(d, "Binding of interrupt %i failed! (err: %d)\n",
+ e_intx, errno);
/* Disable PCI intx assertion (turn on bit10 of devctl) */
- xen_host_pci_set_word(&s->real_device, PCI_COMMAND,
- *(uint16_t *)(&s->dev.config[PCI_COMMAND])
- | PCI_COMMAND_INTX_DISABLE);
+ cmd |= PCI_COMMAND_INTX_DISABLE;
xen_pt_mapped_machine_irq[machine_irq]--;
if (xen_pt_mapped_machine_irq[machine_irq] == 0) {
if (xc_physdev_unmap_pirq(xen_xc, xen_domid, machine_irq)) {
XEN_PT_ERR(d, "Unmapping of machine interrupt %i failed!"
- " (rc: %d)\n", machine_irq, rc);
+ " (err: %d)\n", machine_irq, errno);
}
}
s->machine_irq = 0;
@@ -797,7 +800,7 @@ out:
static void xen_pt_unregister_device(PCIDevice *d)
{
- XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d);
+ XenPCIPassthroughState *s = XEN_PT_DEVICE(d);
uint8_t machine_irq = s->machine_irq;
uint8_t intx = xen_pt_pci_intx(s);
int rc;
@@ -811,9 +814,9 @@ static void xen_pt_unregister_device(PCIDevice *d)
0 /* isa_irq */);
if (rc < 0) {
XEN_PT_ERR(d, "unbinding of interrupt INT%c failed."
- " (machine irq: %i, rc: %d)"
+ " (machine irq: %i, err: %d)"
" But bravely continuing on..\n",
- 'a' + intx, machine_irq, rc);
+ 'a' + intx, machine_irq, errno);
}
}
@@ -831,9 +834,9 @@ static void xen_pt_unregister_device(PCIDevice *d)
rc = xc_physdev_unmap_pirq(xen_xc, xen_domid, machine_irq);
if (rc < 0) {
- XEN_PT_ERR(d, "unmapping of interrupt %i failed. (rc: %d)"
+ XEN_PT_ERR(d, "unmapping of interrupt %i failed. (err: %d)"
" But bravely continuing on..\n",
- machine_irq, rc);
+ machine_irq, errno);
}
}
}
@@ -868,7 +871,7 @@ static void xen_pci_passthrough_class_init(ObjectClass *klass, void *data)
};
static const TypeInfo xen_pci_passthrough_info = {
- .name = "xen-pci-passthrough",
+ .name = TYPE_XEN_PT_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(XenPCIPassthroughState),
.class_init = xen_pci_passthrough_class_init,
diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h
index 4bba559763..393f36ccbf 100644
--- a/hw/xen/xen_pt.h
+++ b/hw/xen/xen_pt.h
@@ -31,11 +31,15 @@ void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3);
/* Helper */
#define XEN_PFN(x) ((x) >> XC_PAGE_SHIFT)
-typedef struct XenPTRegInfo XenPTRegInfo;
+typedef const struct XenPTRegInfo XenPTRegInfo;
typedef struct XenPTReg XenPTReg;
typedef struct XenPCIPassthroughState XenPCIPassthroughState;
+#define TYPE_XEN_PT_DEVICE "xen-pci-passthrough"
+#define XEN_PT_DEVICE(obj) \
+ OBJECT_CHECK(XenPCIPassthroughState, (obj), TYPE_XEN_PT_DEVICE)
+
/* function type for config reg */
typedef int (*xen_pt_conf_reg_init)
(XenPCIPassthroughState *, XenPTRegInfo *, uint32_t real_offset,
@@ -133,11 +137,11 @@ struct XenPTReg {
uint32_t data; /* emulated value */
};
-typedef struct XenPTRegGroupInfo XenPTRegGroupInfo;
+typedef const struct XenPTRegGroupInfo XenPTRegGroupInfo;
/* emul reg group size initialize method */
typedef int (*xen_pt_reg_size_init_fn)
- (XenPCIPassthroughState *, const XenPTRegGroupInfo *,
+ (XenPCIPassthroughState *, XenPTRegGroupInfo *,
uint32_t base_offset, uint8_t *size);
/* emulated register group information */
@@ -152,7 +156,7 @@ struct XenPTRegGroupInfo {
/* emul register group management table */
typedef struct XenPTRegGroup {
QLIST_ENTRY(XenPTRegGroup) entries;
- const XenPTRegGroupInfo *reg_grp;
+ XenPTRegGroupInfo *reg_grp;
uint32_t base_offset;
uint8_t size;
QLIST_HEAD(, XenPTReg) reg_tbl_list;
diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index f3cf069b60..dd37be38a4 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -96,8 +96,7 @@ XenPTReg *xen_pt_find_reg(XenPTRegGroup *reg_grp, uint32_t address)
}
static uint32_t get_throughable_mask(const XenPCIPassthroughState *s,
- const XenPTRegInfo *reg,
- uint32_t valid_mask)
+ XenPTRegInfo *reg, uint32_t valid_mask)
{
uint32_t throughable_mask = ~(reg->emu_mask | reg->ro_mask);
@@ -729,8 +728,8 @@ static XenPTRegInfo xen_pt_emu_reg_header0[] = {
.offset = PCI_ROM_ADDRESS,
.size = 4,
.init_val = 0x00000000,
- .ro_mask = 0x000007FE,
- .emu_mask = 0xFFFFF800,
+ .ro_mask = ~PCI_ROM_ADDRESS_MASK & ~PCI_ROM_ADDRESS_ENABLE,
+ .emu_mask = (uint32_t)PCI_ROM_ADDRESS_MASK,
.init = xen_pt_bar_reg_init,
.u.dw.read = xen_pt_long_reg_read,
.u.dw.write = xen_pt_exp_rom_bar_reg_write,
diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c
index 68db6233dc..263e0514a2 100644
--- a/hw/xen/xen_pt_msi.c
+++ b/hw/xen/xen_pt_msi.c
@@ -132,8 +132,8 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
msix_entry, table_base);
if (rc) {
XEN_PT_ERR(&s->dev,
- "Mapping of MSI%s (rc: %i, vec: %#x, entry %#x)\n",
- is_msix ? "-X" : "", rc, gvec, msix_entry);
+ "Mapping of MSI%s (err: %i, vec: %#x, entry %#x)\n",
+ is_msix ? "-X" : "", errno, gvec, msix_entry);
return rc;
}
}
@@ -166,12 +166,12 @@ static int msi_msix_update(XenPCIPassthroughState *s,
pirq, gflags, table_addr);
if (rc) {
- XEN_PT_ERR(d, "Updating of MSI%s failed. (rc: %d)\n",
- is_msix ? "-X" : "", rc);
+ XEN_PT_ERR(d, "Updating of MSI%s failed. (err: %d)\n",
+ is_msix ? "-X" : "", errno);
if (xc_physdev_unmap_pirq(xen_xc, xen_domid, *old_pirq)) {
- XEN_PT_ERR(d, "Unmapping of MSI%s pirq %d failed.\n",
- is_msix ? "-X" : "", *old_pirq);
+ XEN_PT_ERR(d, "Unmapping of MSI%s pirq %d failed. (err: %d)\n",
+ is_msix ? "-X" : "", *old_pirq, errno);
}
*old_pirq = XEN_PT_UNASSIGNED_PIRQ;
}
@@ -199,8 +199,8 @@ static int msi_msix_disable(XenPCIPassthroughState *s,
is_msix ? "-X" : "", pirq, gvec);
rc = xc_domain_unbind_msi_irq(xen_xc, xen_domid, gvec, pirq, gflags);
if (rc) {
- XEN_PT_ERR(d, "Unbinding of MSI%s failed. (pirq: %d, gvec: %#x)\n",
- is_msix ? "-X" : "", pirq, gvec);
+ XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: %d, gvec: %#x)\n",
+ is_msix ? "-X" : "", errno, pirq, gvec);
return rc;
}
}
@@ -208,8 +208,8 @@ static int msi_msix_disable(XenPCIPassthroughState *s,
XEN_PT_LOG(d, "Unmap MSI%s pirq %d\n", is_msix ? "-X" : "", pirq);
rc = xc_physdev_unmap_pirq(xen_xc, xen_domid, pirq);
if (rc) {
- XEN_PT_ERR(d, "Unmapping of MSI%s pirq %d failed. (rc: %i)\n",
- is_msix ? "-X" : "", pirq, rc);
+ XEN_PT_ERR(d, "Unmapping of MSI%s pirq %d failed. (err: %i)\n",
+ is_msix ? "-X" : "", pirq, errno);
return rc;
}
@@ -385,8 +385,8 @@ int xen_pt_msix_update_remap(XenPCIPassthroughState *s, int bar_index)
ret = xc_domain_unbind_pt_irq(xen_xc, xen_domid, entry->pirq,
PT_IRQ_TYPE_MSI, 0, 0, 0, 0);
if (ret) {
- XEN_PT_ERR(&s->dev, "unbind MSI-X entry %d failed\n",
- entry->pirq);
+ XEN_PT_ERR(&s->dev, "unbind MSI-X entry %d failed (err: %d)\n",
+ entry->pirq, errno);
}
entry->updated = true;
}
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 888ec09e96..b0476fc36e 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -31,8 +31,6 @@
#include "block/coroutine.h"
#include "qemu/timer.h"
#include "qapi-types.h"
-#include "qapi/qmp/qerror.h"
-#include "monitor/monitor.h"
#include "qemu/hbitmap.h"
#include "block/snapshot.h"
#include "qemu/main-loop.h"
diff --git a/include/disas/disas.h b/include/disas/disas.h
index c13ca9a3a4..2b9293b62a 100644
--- a/include/disas/disas.h
+++ b/include/disas/disas.h
@@ -6,10 +6,10 @@
#ifdef NEED_CPU_H
/* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size);
-void target_disas(FILE *out, CPUArchState *env, target_ulong code,
+void target_disas(FILE *out, CPUState *cpu, target_ulong code,
target_ulong size, int flags);
-void monitor_disas(Monitor *mon, CPUArchState *env,
+void monitor_disas(Monitor *mon, CPUState *cpu,
target_ulong pc, int nb_insn, int is_physical, int flags);
/* Look up symbol for debugging purpose. Returns "" if unknown. */
diff --git a/include/exec/softmmu-semi.h b/include/exec/softmmu-semi.h
index 8401f7d587..1819cc2498 100644
--- a/include/exec/softmmu-semi.h
+++ b/include/exec/softmmu-semi.h
@@ -9,14 +9,14 @@
#ifndef SOFTMMU_SEMI_H
#define SOFTMMU_SEMI_H 1
-static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr)
+static inline uint32_t softmmu_tget32(CPUArchState *env, target_ulong addr)
{
uint32_t val;
cpu_memory_rw_debug(ENV_GET_CPU(env), addr, (uint8_t *)&val, 4, 0);
return tswap32(val);
}
-static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr)
+static inline uint32_t softmmu_tget8(CPUArchState *env, target_ulong addr)
{
uint8_t val;
@@ -28,7 +28,8 @@ static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr)
#define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; })
#define get_user_ual(arg, p) get_user_u32(arg, p)
-static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val)
+static inline void softmmu_tput32(CPUArchState *env,
+ target_ulong addr, uint32_t val)
{
val = tswap32(val);
cpu_memory_rw_debug(ENV_GET_CPU(env), addr, (uint8_t *)&val, 4, 1);
@@ -36,8 +37,8 @@ static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val
#define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })
#define put_user_ual(arg, p) put_user_u32(arg, p)
-static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,
- int copy)
+static void *softmmu_lock_user(CPUArchState *env,
+ target_ulong addr, target_ulong len, int copy)
{
uint8_t *p;
/* TODO: Make this something that isn't fixed size. */
@@ -48,7 +49,7 @@ static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,
return p;
}
#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
-static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr)
+static char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr)
{
char *p;
char *s;
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index 7b4bfb7494..2b431e6242 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -372,6 +372,18 @@ struct AcpiMadtGenericDistributor {
typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor;
+struct AcpiMadtGenericMsiFrame {
+ ACPI_SUB_HEADER_DEF
+ uint16_t reserved;
+ uint32_t gic_msi_frame_id;
+ uint64_t base_address;
+ uint32_t flags;
+ uint16_t spi_count;
+ uint16_t spi_base;
+} QEMU_PACKED;
+
+typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame;
+
/*
* Generic Timer Description Table (GTDT)
*/
diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h
index 8134178bcd..fd5417d1a3 100644
--- a/include/hw/virtio/virtio-input.h
+++ b/include/hw/virtio/virtio-input.h
@@ -50,17 +50,17 @@ typedef struct virtio_input_event virtio_input_event;
#define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
-#define DEFINE_VIRTIO_INPUT_PROPERTIES(_state, _field) \
- DEFINE_PROP_STRING("serial", _state, _field.serial)
+#define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
+#define VIRTIO_INPUT_HOST(obj) \
+ OBJECT_CHECK(VirtIOInputHost, (obj), TYPE_VIRTIO_INPUT_HOST)
+#define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
+ OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
typedef struct VirtIOInput VirtIOInput;
typedef struct VirtIOInputClass VirtIOInputClass;
typedef struct VirtIOInputConfig VirtIOInputConfig;
typedef struct VirtIOInputHID VirtIOInputHID;
-
-struct virtio_input_conf {
- char *serial;
-};
+typedef struct VirtIOInputHost VirtIOInputHost;
struct VirtIOInputConfig {
virtio_input_config config;
@@ -74,7 +74,7 @@ struct VirtIOInput {
uint32_t cfg_size;
QTAILQ_HEAD(, VirtIOInputConfig) cfg_list;
VirtQueue *evt, *sts;
- virtio_input_conf input;
+ char *serial;
virtio_input_event *queue;
uint32_t qindex, qsize;
@@ -100,6 +100,12 @@ struct VirtIOInputHID {
int ledstate;
};
+struct VirtIOInputHost {
+ VirtIOInput parent_obj;
+ char *evdev;
+ int fd;
+};
+
void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
void virtio_input_init_config(VirtIOInput *vinput,
virtio_input_config *config);
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 88644ceda7..9aff47e699 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -2,7 +2,6 @@
#define MONITOR_H
#include "qemu-common.h"
-#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qdict.h"
#include "block/block.h"
#include "qemu/readline.h"
@@ -39,15 +38,13 @@ void monitor_flush(Monitor *mon);
int monitor_set_cpu(int cpu_index);
int monitor_get_cpu_index(void);
-void monitor_set_error(Monitor *mon, QError *qerror);
void monitor_read_command(Monitor *mon, int show_prompt);
int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
void *opaque);
-int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
-
-int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
-int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret);
+void qmp_qom_set(QDict *qdict, QObject **ret, Error **errp);
+void qmp_qom_get(QDict *qdict, QObject **ret, Error **errp);
+void qmp_object_add(QDict *qdict, QObject **ret, Error **errp);
void object_add(const char *type, const char *id, const QDict *qdict,
Visitor *v, Error **errp);
diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
index 719075283c..50ec2ffc12 100644
--- a/include/monitor/qdev.h
+++ b/include/monitor/qdev.h
@@ -2,15 +2,16 @@
#define QEMU_QDEV_MONITOR_H
#include "hw/qdev-core.h"
-#include "monitor/monitor.h"
+#include "qemu/typedefs.h"
/*** monitor commands ***/
void hmp_info_qtree(Monitor *mon, const QDict *qdict);
void hmp_info_qdm(Monitor *mon, const QDict *qdict);
void hmp_info_qom_tree(Monitor *mon, const QDict *dict);
-int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
+void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp);
+
int qdev_device_help(QemuOpts *opts);
-DeviceState *qdev_device_add(QemuOpts *opts);
+DeviceState *qdev_device_add(QemuOpts *opts, Error **errp);
#endif
diff --git a/include/net/net.h b/include/net/net.h
index 4306252b97..6a6cbef24a 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -197,7 +197,7 @@ void net_cleanup(void);
void hmp_host_net_add(Monitor *mon, const QDict *qdict);
void hmp_host_net_remove(Monitor *mon, const QDict *qdict);
void netdev_add(QemuOpts *opts, Error **errp);
-int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret);
+void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp);
int net_hub_id_for_client(NetClientState *nc, int *id);
NetClientState *net_hub_port_find(int hub_id);
diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h
index c4eaab9bb9..4aa6be3b33 100644
--- a/include/qapi/qmp/qbool.h
+++ b/include/qapi/qmp/qbool.h
@@ -14,16 +14,16 @@
#ifndef QBOOL_H
#define QBOOL_H
-#include <stdint.h>
+#include <stdbool.h>
#include "qapi/qmp/qobject.h"
typedef struct QBool {
QObject_HEAD;
- int value;
+ bool value;
} QBool;
-QBool *qbool_from_int(int value);
-int qbool_get_int(const QBool *qb);
+QBool *qbool_from_bool(bool value);
+bool qbool_get_bool(const QBool *qb);
QBool *qobject_to_qbool(const QObject *obj);
#endif /* QBOOL_H */
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 9fbf68ee0c..a37f4c1567 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -56,13 +56,13 @@ const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry);
/* High level helpers */
double qdict_get_double(const QDict *qdict, const char *key);
int64_t qdict_get_int(const QDict *qdict, const char *key);
-int qdict_get_bool(const QDict *qdict, const char *key);
+bool qdict_get_bool(const QDict *qdict, const char *key);
QList *qdict_get_qlist(const QDict *qdict, const char *key);
QDict *qdict_get_qdict(const QDict *qdict, const char *key);
const char *qdict_get_str(const QDict *qdict, const char *key);
int64_t qdict_get_try_int(const QDict *qdict, const char *key,
int64_t def_value);
-int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value);
+bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value);
const char *qdict_get_try_str(const QDict *qdict, const char *key);
void qdict_copy_default(QDict *dst, QDict *src, const char *key);
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index e5673394d3..842b27ae11 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -12,122 +12,98 @@
#ifndef QERROR_H
#define QERROR_H
-#include "qapi/qmp/qstring.h"
-#include "qemu/error-report.h"
-#include "qapi/error.h"
-#include "qapi-types.h"
-#include <stdarg.h>
-
-typedef struct QError {
- QObject_HEAD;
- Location loc;
- char *err_msg;
- ErrorClass err_class;
-} QError;
-
-QString *qerror_human(const QError *qerror);
-void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
-void qerror_report_err(Error *err);
-
/*
- * QError class list
- * Please keep the definitions in alphabetical order.
- * Use scripts/check-qerror.sh to check.
+ * These macros will go away, please don't use in new code, and do not
+ * add new ones!
*/
#define QERR_BASE_NOT_FOUND \
- ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
+ "Base '%s' not found"
#define QERR_BLOCK_JOB_NOT_READY \
- ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed"
+ "The active block job for device '%s' cannot be completed"
#define QERR_BUS_NO_HOTPLUG \
- ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
-
-#define QERR_BUS_NOT_FOUND \
- ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
+ "Bus '%s' does not support hotplugging"
#define QERR_DEVICE_HAS_NO_MEDIUM \
- ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
+ "Device '%s' has no medium"
#define QERR_DEVICE_INIT_FAILED \
- ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
+ "Device '%s' could not be initialized"
#define QERR_DEVICE_IN_USE \
- ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
+ "Device '%s' is in use"
#define QERR_DEVICE_NO_HOTPLUG \
- ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
-
-#define QERR_DEVICE_NOT_FOUND \
- ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
+ "Device '%s' does not support hotplugging"
#define QERR_FD_NOT_FOUND \
- ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
+ "File descriptor named '%s' not found"
#define QERR_FD_NOT_SUPPLIED \
- ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
+ "No file descriptor supplied via SCM_RIGHTS"
#define QERR_FEATURE_DISABLED \
- ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
+ "The feature '%s' is not enabled"
#define QERR_INVALID_BLOCK_FORMAT \
- ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
+ "Invalid block format '%s'"
#define QERR_INVALID_PARAMETER \
- ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
+ "Invalid parameter '%s'"
#define QERR_INVALID_PARAMETER_TYPE \
- ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
+ "Invalid parameter type for '%s', expected: %s"
#define QERR_INVALID_PARAMETER_VALUE \
- ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
+ "Parameter '%s' expects %s"
#define QERR_INVALID_PASSWORD \
- ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
+ "Password incorrect"
#define QERR_IO_ERROR \
- ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
+ "An IO error has occurred"
#define QERR_JSON_PARSING \
- ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
+ "Invalid JSON syntax"
#define QERR_MIGRATION_ACTIVE \
- ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
+ "There's a migration process in progress"
#define QERR_MISSING_PARAMETER \
- ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
+ "Parameter '%s' is missing"
#define QERR_PERMISSION_DENIED \
- ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
+ "Insufficient permission to perform this operation"
#define QERR_PROPERTY_VALUE_BAD \
- ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
+ "Property '%s.%s' doesn't take value '%s'"
#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
- ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
+ "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
#define QERR_QGA_COMMAND_FAILED \
- ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
+ "Guest agent command failed, error was '%s'"
#define QERR_QMP_BAD_INPUT_OBJECT \
- ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
+ "Expected '%s' in QMP input"
#define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
- ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
+ "QMP input object member '%s' expects '%s'"
#define QERR_QMP_EXTRA_MEMBER \
- ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
+ "QMP input object member '%s' is unexpected"
#define QERR_SET_PASSWD_FAILED \
- ERROR_CLASS_GENERIC_ERROR, "Could not set password"
+ "Could not set password"
#define QERR_UNDEFINED_ERROR \
- ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
+ "An undefined error has occurred"
#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
- ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
+ "'%s' uses a %s feature which is not supported by this qemu version: %s"
#define QERR_UNSUPPORTED \
- ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
+ "this feature or command is not currently supported"
#endif /* QERROR_H */
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index 84b2d9fef5..260d2ed3cc 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -44,7 +44,6 @@ typedef enum {
QTYPE_QLIST,
QTYPE_QFLOAT,
QTYPE_QBOOL,
- QTYPE_QERROR,
QTYPE_MAX,
} qtype_code;
diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index f0a85f8649..bb94a00c5f 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -132,6 +132,14 @@ void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t count);
void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count);
/**
+ * hbitmap_reset_all:
+ * @hb: HBitmap to operate on.
+ *
+ * Reset all bits in an HBitmap.
+ */
+void hbitmap_reset_all(HBitmap *hb);
+
+/**
* hbitmap_get:
* @hb: HBitmap to operate on.
* @item: Bit to query (0-based).
diff --git a/include/qemu/iov.h b/include/qemu/iov.h
index 68d25f29b7..569b2c2a23 100644
--- a/include/qemu/iov.h
+++ b/include/qemu/iov.h
@@ -75,7 +75,7 @@ size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
* For iov_send_recv() _whole_ area being sent or received
* should be within the iovec, not only beginning of it.
*/
-ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
+ssize_t iov_send_recv(int sockfd, const struct iovec *iov, unsigned iov_cnt,
size_t offset, size_t bytes, bool do_send);
#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \
iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false)
diff --git a/include/qemu/log.h b/include/qemu/log.h
index 195f665c4b..f880e66dbc 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -104,10 +104,10 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags)
#ifdef NEED_CPU_H
/* disas() and target_disas() to qemu_logfile: */
-static inline void log_target_disas(CPUArchState *env, target_ulong start,
+static inline void log_target_disas(CPUState *cpu, target_ulong start,
target_ulong len, int flags)
{
- target_disas(qemu_logfile, env, start, len, flags);
+ target_disas(qemu_logfile, cpu, start, len, flags);
}
static inline void log_disas(void *code, unsigned long size)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index ac0e43b7e5..57e51c9628 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -119,7 +119,10 @@ void qemu_opts_del(QemuOpts *opts);
void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp);
void qemu_opts_do_parse(QemuOpts *opts, const char *params,
const char *firstname, Error **errp);
-QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev);
+QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
+ bool permit_abbrev);
+QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
+ bool permit_abbrev, Error **errp);
void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
int permit_abbrev);
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 7992ece72a..c174b5cbdd 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -28,7 +28,6 @@ int inet_aton(const char *cp, struct in_addr *ia);
#include "qemu/option.h"
#include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
#include "qapi-types.h"
extern QemuOptsList socket_optslist;
diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h
index 0345e01efb..17fe30070d 100644
--- a/include/sysemu/balloon.h
+++ b/include/sysemu/balloon.h
@@ -14,7 +14,6 @@
#ifndef _QEMU_BALLOON_H
#define _QEMU_BALLOON_H
-#include "monitor/monitor.h"
#include "qapi-types.h"
typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index b4a4d5e0b9..8fc960fcbf 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -118,6 +118,7 @@ int blk_co_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors);
int blk_co_flush(BlockBackend *blk);
int blk_flush(BlockBackend *blk);
int blk_flush_all(void);
+void blk_drain(BlockBackend *blk);
void blk_drain_all(void);
BlockdevOnError blk_get_on_error(BlockBackend *blk, bool is_read);
BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
diff --git a/include/ui/console.h b/include/ui/console.h
index de92523bbb..047a2b4640 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -5,7 +5,7 @@
#include "qom/object.h"
#include "qapi/qmp/qdict.h"
#include "qemu/notify.h"
-#include "monitor/monitor.h"
+#include "qemu/typedefs.h"
#include "qapi-types.h"
#include "qapi/error.h"
@@ -369,7 +369,7 @@ char *vnc_display_local_addr(const char *id);
#ifdef CONFIG_VNC
int vnc_display_password(const char *id, const char *password);
int vnc_display_pw_expire(const char *id, time_t expires);
-QemuOpts *vnc_parse_func(const char *str);
+QemuOpts *vnc_parse(const char *str, Error **errp);
int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
#else
static inline int vnc_display_password(const char *id, const char *password)
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index 42db3c1645..0dff4229fc 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -26,7 +26,6 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
-#include "monitor/monitor.h"
extern int using_spice;
@@ -54,7 +53,6 @@ static inline CharDriverState *qemu_chr_open_spice_port(const char *name)
#endif
#else /* CONFIG_SPICE */
-#include "monitor/monitor.h"
#define using_spice 0
#define spice_displays 0
diff --git a/libcacard/libcacard.pc.in b/libcacard/libcacard.pc.in
index b6859b0c1f..4b60023ce9 100644
--- a/libcacard/libcacard.pc.in
+++ b/libcacard/libcacard.pc.in
@@ -7,7 +7,7 @@ Name: cacard
Description: CA Card library
Version: @VERSION@
-Requires: nss
+Requires.private: nss glib-2.0
Libs: -L${libdir} -lcacard
Libs.private:
Cflags: -I${includedir}
diff --git a/libdecnumber/dpd/decimal128Local.h b/libdecnumber/dpd/decimal128Local.h
deleted file mode 100644
index 1963678cdd..0000000000
--- a/libdecnumber/dpd/decimal128Local.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Local definitions for use with the decNumber C Library.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
-
- This file is part of GCC.
-
- GCC is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3, or (at your option) any later
- version.
-
- GCC is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
-Under Section 7 of GPL version 3, you are granted additional
-permissions described in the GCC Runtime Library Exception, version
-3.1, as published by the Free Software Foundation.
-
-You should have received a copy of the GNU General Public License and
-a copy of the GCC Runtime Library Exception along with this program;
-see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-<http://www.gnu.org/licenses/>. */
-
-#if !defined(DECIMAL128LOCAL)
-
-/* The compiler needs sign manipulation functions for decimal128 which
- are not part of the decNumber package. */
-
-/* Set sign; this assumes the sign was previously zero. */
-#define decimal128SetSign(d,b) \
- { (d)->bytes[WORDS_BIGENDIAN ? 0 : 15] |= ((unsigned) (b) << 7); }
-
-/* Clear sign. */
-#define decimal128ClearSign(d) \
- { (d)->bytes[WORDS_BIGENDIAN ? 0 : 15] &= ~0x80; }
-
-/* Flip sign. */
-#define decimal128FlipSign(d) \
- { (d)->bytes[WORDS_BIGENDIAN ? 0 : 15] ^= 0x80; }
-
-#endif
diff --git a/migration/migration.c b/migration/migration.c
index b04b4571a8..c6ac08a0cb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -14,12 +14,13 @@
*/
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "migration/migration.h"
-#include "monitor/monitor.h"
#include "migration/qemu-file.h"
#include "sysemu/sysemu.h"
#include "block/block.h"
+#include "qapi/qmp/qerror.h"
#include "qemu/sockets.h"
#include "migration/block.h"
#include "qemu/thread.h"
@@ -337,7 +338,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
if (s->state == MIGRATION_STATUS_ACTIVE ||
s->state == MIGRATION_STATUS_SETUP) {
- error_set(errp, QERR_MIGRATION_ACTIVE);
+ error_setg(errp, QERR_MIGRATION_ACTIVE);
return;
}
@@ -356,22 +357,22 @@ void qmp_migrate_set_parameters(bool has_compress_level,
MigrationState *s = migrate_get_current();
if (has_compress_level && (compress_level < 0 || compress_level > 9)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
- "is invalid, it should be in the range of 0 to 9");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level",
+ "is invalid, it should be in the range of 0 to 9");
return;
}
if (has_compress_threads &&
(compress_threads < 1 || compress_threads > 255)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- "compress_threads",
- "is invalid, it should be in the range of 1 to 255");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "compress_threads",
+ "is invalid, it should be in the range of 1 to 255");
return;
}
if (has_decompress_threads &&
(decompress_threads < 1 || decompress_threads > 255)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- "decompress_threads",
- "is invalid, it should be in the range of 1 to 255");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "decompress_threads",
+ "is invalid, it should be in the range of 1 to 255");
return;
}
@@ -573,7 +574,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
if (s->state == MIGRATION_STATUS_ACTIVE ||
s->state == MIGRATION_STATUS_SETUP ||
s->state == MIGRATION_STATUS_CANCELLING) {
- error_set(errp, QERR_MIGRATION_ACTIVE);
+ error_setg(errp, QERR_MIGRATION_ACTIVE);
return;
}
@@ -608,7 +609,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
fd_start_outgoing_migration(s, p, &local_err);
#endif
} else {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri",
+ "a valid migration protocol");
s->state = MIGRATION_STATUS_FAILED;
return;
}
@@ -632,22 +634,22 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp)
/* Check for truncation */
if (value != (size_t)value) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
- "exceeding address space");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+ "exceeding address space");
return;
}
/* Cache should not be larger than guest ram size */
if (value > ram_bytes_total()) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
- "exceeds guest ram size ");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+ "exceeds guest ram size ");
return;
}
new_size = xbzrle_cache_resize(value);
if (new_size < 0) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
- "is smaller than page size");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size",
+ "is smaller than page size");
return;
}
diff --git a/migration/qemu-file-buf.c b/migration/qemu-file-buf.c
index 16a51a1e17..2de9330ca5 100644
--- a/migration/qemu-file-buf.c
+++ b/migration/qemu-file-buf.c
@@ -26,6 +26,7 @@
* THE SOFTWARE.
*/
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/iov.h"
#include "qemu/sockets.h"
#include "block/coroutine.h"
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 965a757772..557c1c1a62 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -23,6 +23,7 @@
*/
#include <zlib.h>
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/iov.h"
#include "qemu/sockets.h"
#include "block/coroutine.h"
diff --git a/migration/rdma.c b/migration/rdma.c
index cf5de7e2ae..b777273b59 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -15,6 +15,7 @@
#include "migration/migration.h"
#include "migration/qemu-file.h"
#include "exec/cpu-common.h"
+#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/sockets.h"
#include "qemu/bitmap.h"
diff --git a/migration/savevm.c b/migration/savevm.c
index 2091882196..9e0e286797 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -37,6 +37,8 @@
#include "qemu/timer.h"
#include "audio/audio.h"
#include "migration/migration.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "qemu/queue.h"
#include "sysemu/cpus.h"
@@ -1307,7 +1309,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
ret = qemu_save_device_state(f);
qemu_fclose(f);
if (ret < 0) {
- error_set(errp, QERR_IO_ERROR);
+ error_setg(errp, QERR_IO_ERROR);
}
the_end:
diff --git a/monitor.c b/monitor.c
index 8e1a2e85b8..aeea2b5f9e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -49,6 +49,7 @@
#include "sysemu/kvm.h"
#include "qemu/acl.h"
#include "sysemu/tpm.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qint.h"
#include "qapi/qmp/qfloat.h"
#include "qapi/qmp/qlist.h"
@@ -81,9 +82,6 @@
#endif
#include "hw/lm32/lm32_pic.h"
-//#define DEBUG
-//#define DEBUG_COMPLETION
-
/*
* Supported types:
*
@@ -125,7 +123,7 @@ typedef struct mon_cmd_t {
const char *help;
union {
void (*cmd)(Monitor *mon, const QDict *qdict);
- int (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret_data);
+ void (*cmd_new)(QDict *params, QObject **ret_data, Error **errp);
} mhandler;
/* @sub_table is a list of 2nd level of commands. If it do not exist,
* mhandler should be used. If it exist, sub_table[?].mhandler should be
@@ -205,7 +203,6 @@ struct Monitor {
BlockCompletionFunc *password_completion_cb;
void *password_opaque;
mon_cmd_t *cmd_table;
- QError *error;
QLIST_HEAD(,mon_fd_t) fds;
QLIST_ENTRY(Monitor) entry;
};
@@ -566,11 +563,9 @@ static void monitor_qapi_event_init(void)
qmp_event_set_func_emit(monitor_qapi_event_queue);
}
-static int do_qmp_capabilities(Monitor *mon, const QDict *params,
- QObject **ret_data)
+static void qmp_capabilities(QDict *params, QObject **ret_data, Error **errp)
{
- mon->qmp.in_command_mode = true;
- return 0;
+ cur_mon->qmp.in_command_mode = true;
}
static void handle_hmp_command(Monitor *mon, const char *cmdline);
@@ -606,8 +601,8 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
int ret = monitor_set_cpu(cpu_index);
if (ret < 0) {
cur_mon = old_mon;
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
- "a CPU number");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+ "a CPU number");
goto out;
}
}
@@ -942,28 +937,28 @@ int monitor_set_cpu(int cpu_index)
return 0;
}
-static CPUArchState *mon_get_cpu(void)
+static CPUState *mon_get_cpu(void)
{
if (!cur_mon->mon_cpu) {
monitor_set_cpu(0);
}
cpu_synchronize_state(cur_mon->mon_cpu);
- return cur_mon->mon_cpu->env_ptr;
+ return cur_mon->mon_cpu;
+}
+
+static CPUArchState *mon_get_cpu_env(void)
+{
+ return mon_get_cpu()->env_ptr;
}
int monitor_get_cpu_index(void)
{
- CPUState *cpu = ENV_GET_CPU(mon_get_cpu());
- return cpu->cpu_index;
+ return mon_get_cpu()->cpu_index;
}
static void hmp_info_registers(Monitor *mon, const QDict *qdict)
{
- CPUState *cpu;
- CPUArchState *env;
- env = mon_get_cpu();
- cpu = ENV_GET_CPU(env);
- cpu_dump_state(cpu, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
+ cpu_dump_state(mon_get_cpu(), (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
}
static void hmp_info_jit(Monitor *mon, const QDict *qdict)
@@ -996,12 +991,7 @@ static void hmp_info_history(Monitor *mon, const QDict *qdict)
static void hmp_info_cpustats(Monitor *mon, const QDict *qdict)
{
- CPUState *cpu;
- CPUArchState *env;
-
- env = mon_get_cpu();
- cpu = ENV_GET_CPU(env);
- cpu_dump_statistics(cpu, (FILE *)mon, &monitor_fprintf, 0);
+ cpu_dump_statistics(mon_get_cpu(), (FILE *)mon, &monitor_fprintf, 0);
}
static void hmp_info_trace_events(Monitor *mon, const QDict *qdict)
@@ -1029,7 +1019,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
}
if (!has_port && !has_tls_port) {
- error_set(errp, QERR_MISSING_PARAMETER, "port/tls-port");
+ error_setg(errp, QERR_MISSING_PARAMETER, "port/tls-port");
return;
}
@@ -1037,13 +1027,13 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,
has_port ? port : -1,
has_tls_port ? tls_port : -1,
cert_subject)) {
- error_set(errp, QERR_UNDEFINED_ERROR);
+ error_setg(errp, QERR_UNDEFINED_ERROR);
return;
}
return;
}
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "spice");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "spice");
}
static void hmp_logfile(Monitor *mon, const QDict *qdict)
@@ -1134,16 +1124,14 @@ static void monitor_printc(Monitor *mon, int c)
static void memory_dump(Monitor *mon, int count, int format, int wsize,
hwaddr addr, int is_physical)
{
- CPUArchState *env;
int l, line_size, i, max_digits, len;
uint8_t buf[16];
uint64_t v;
if (format == 'i') {
- int flags;
- flags = 0;
- env = mon_get_cpu();
+ int flags = 0;
#ifdef TARGET_I386
+ CPUArchState *env = mon_get_cpu_env();
if (wsize == 2) {
flags = 1;
} else if (wsize == 4) {
@@ -1164,10 +1152,11 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
}
#endif
#ifdef TARGET_PPC
+ CPUArchState *env = mon_get_cpu_env();
flags = msr_le << 16;
flags |= env->bfd_mach;
#endif
- monitor_disas(mon, env, addr, count, is_physical, flags);
+ monitor_disas(mon, mon_get_cpu(), addr, count, is_physical, flags);
return;
}
@@ -1206,8 +1195,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
if (is_physical) {
cpu_physical_memory_read(addr, buf, l);
} else {
- env = mon_get_cpu();
- if (cpu_memory_rw_debug(ENV_GET_CPU(env), addr, buf, l, 0) < 0) {
+ if (cpu_memory_rw_debug(mon_get_cpu(), addr, buf, l, 0) < 0) {
monitor_printf(mon, " Cannot access memory\n");
break;
}
@@ -1586,7 +1574,7 @@ static void hmp_info_tlb(Monitor *mon, const QDict *qdict)
{
CPUArchState *env;
- env = mon_get_cpu();
+ env = mon_get_cpu_env();
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(mon, "PG disabled\n");
@@ -1809,7 +1797,7 @@ static void hmp_info_mem(Monitor *mon, const QDict *qdict)
{
CPUArchState *env;
- env = mon_get_cpu();
+ env = mon_get_cpu_env();
if (!(env->cr[0] & CR0_PG_MASK)) {
monitor_printf(mon, "PG disabled\n");
@@ -1846,7 +1834,7 @@ static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
static void hmp_info_tlb(Monitor *mon, const QDict *qdict)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
int i;
monitor_printf (mon, "ITLB:\n");
@@ -1862,7 +1850,7 @@ static void hmp_info_tlb(Monitor *mon, const QDict *qdict)
#if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENSA)
static void hmp_info_tlb(Monitor *mon, const QDict *qdict)
{
- CPUArchState *env1 = mon_get_cpu();
+ CPUArchState *env1 = mon_get_cpu_env();
dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1);
}
@@ -2091,7 +2079,7 @@ static void hmp_mce(Monitor *mon, const QDict *qdict)
uint64_t misc = qdict_get_int(qdict, "misc");
int flags = MCE_INJECT_UNCOND_AO;
- if (qdict_get_try_bool(qdict, "broadcast", 0)) {
+ if (qdict_get_try_bool(qdict, "broadcast", false)) {
flags |= MCE_INJECT_BROADCAST;
}
cs = qemu_get_cpu(cpu_index);
@@ -2110,14 +2098,14 @@ void qmp_getfd(const char *fdname, Error **errp)
fd = qemu_chr_fe_get_msgfd(cur_mon->chr);
if (fd == -1) {
- error_set(errp, QERR_FD_NOT_SUPPLIED);
+ error_setg(errp, QERR_FD_NOT_SUPPLIED);
return;
}
if (qemu_isdigit(fdname[0])) {
close(fd);
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
- "a name not starting with a digit");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
+ "a name not starting with a digit");
return;
}
@@ -2154,7 +2142,7 @@ void qmp_closefd(const char *fdname, Error **errp)
return;
}
- error_set(errp, QERR_FD_NOT_FOUND, fdname);
+ error_setg(errp, QERR_FD_NOT_FOUND, fdname);
}
static void hmp_loadvm(Monitor *mon, const QDict *qdict)
@@ -2235,7 +2223,7 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque,
fd = qemu_chr_fe_get_msgfd(mon->chr);
if (fd == -1) {
- error_set(errp, QERR_FD_NOT_SUPPLIED);
+ error_setg(errp, QERR_FD_NOT_SUPPLIED);
goto error;
}
@@ -2287,7 +2275,7 @@ error:
} else {
snprintf(fd_str, sizeof(fd_str), "fdset-id:%" PRId64, fdset_id);
}
- error_set(errp, QERR_FD_NOT_FOUND, fd_str);
+ error_setg(errp, QERR_FD_NOT_FOUND, fd_str);
}
FdsetInfoList *qmp_query_fdsets(Error **errp)
@@ -2355,8 +2343,8 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
if (has_fdset_id) {
if (fdset_id < 0) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id",
- "a non-negative value");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id",
+ "a non-negative value");
return NULL;
}
/* Use specified fdset ID */
@@ -2923,7 +2911,7 @@ typedef struct MonitorDef {
#if defined(TARGET_I386)
static target_long monitor_get_pc (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return env->eip + env->segs[R_CS].base;
}
#endif
@@ -2931,7 +2919,7 @@ static target_long monitor_get_pc (const struct MonitorDef *md, int val)
#if defined(TARGET_PPC)
static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
unsigned int u;
int i;
@@ -2944,31 +2932,31 @@ static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
static target_long monitor_get_msr (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return env->msr;
}
static target_long monitor_get_xer (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return env->xer;
}
static target_long monitor_get_decr (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return cpu_ppc_load_decr(env);
}
static target_long monitor_get_tbu (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return cpu_ppc_load_tbu(env);
}
static target_long monitor_get_tbl (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return cpu_ppc_load_tbl(env);
}
#endif
@@ -2977,7 +2965,7 @@ static target_long monitor_get_tbl (const struct MonitorDef *md, int val)
#ifndef TARGET_SPARC64
static target_long monitor_get_psr (const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return cpu_get_psr(env);
}
@@ -2985,7 +2973,7 @@ static target_long monitor_get_psr (const struct MonitorDef *md, int val)
static target_long monitor_get_reg(const struct MonitorDef *md, int val)
{
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
return env->regwptr[val];
}
#endif
@@ -3321,7 +3309,7 @@ static int get_monitor_def(target_long *pval, const char *name)
if (md->get_value) {
*pval = md->get_value(md, md->offset);
} else {
- CPUArchState *env = mon_get_cpu();
+ CPUArchState *env = mon_get_cpu_env();
ptr = (uint8_t *)env + md->offset;
switch(md->type) {
case MD_I32:
@@ -3637,43 +3625,32 @@ static const mon_cmd_t *qmp_find_cmd(const char *cmdname)
}
/*
- * Parse @cmdline according to command table @table.
- * If @cmdline is blank, return NULL.
- * If it can't be parsed, report to @mon, and return NULL.
- * Else, insert command arguments into @qdict, and return the command.
- * If a sub-command table exists, and if @cmdline contains an additional string
- * for a sub-command, this function will try to search the sub-command table.
- * If no additional string for a sub-command is present, this function will
- * return the command found in @table.
- * Do not assume the returned command points into @table! It doesn't
- * when the command is a sub-command.
+ * Parse command name from @cmdp according to command table @table.
+ * If blank, return NULL.
+ * Else, if no valid command can be found, report to @mon, and return
+ * NULL.
+ * Else, change @cmdp to point right behind the name, and return its
+ * command table entry.
+ * Do not assume the return value points into @table! It doesn't when
+ * the command is found in a sub-command table.
*/
static const mon_cmd_t *monitor_parse_command(Monitor *mon,
- const char *cmdline,
- int start,
- mon_cmd_t *table,
- QDict *qdict)
+ const char **cmdp,
+ mon_cmd_t *table)
{
- const char *p, *typestr;
- int c;
+ const char *p;
const mon_cmd_t *cmd;
char cmdname[256];
- char buf[1024];
- char *key;
-
-#ifdef DEBUG
- monitor_printf(mon, "command='%s', start='%d'\n", cmdline, start);
-#endif
/* extract the command name */
- p = get_command_name(cmdline + start, cmdname, sizeof(cmdname));
+ p = get_command_name(*cmdp, cmdname, sizeof(cmdname));
if (!p)
return NULL;
cmd = search_dispatch_table(table, cmdname);
if (!cmd) {
monitor_printf(mon, "unknown command: '%.*s'\n",
- (int)(p - cmdline), cmdline);
+ (int)(p - *cmdp), *cmdp);
return NULL;
}
@@ -3681,16 +3658,34 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
while (qemu_isspace(*p)) {
p++;
}
+
+ *cmdp = p;
/* search sub command */
- if (cmd->sub_table != NULL) {
- /* check if user set additional command */
- if (*p == '\0') {
- return cmd;
- }
- return monitor_parse_command(mon, cmdline, p - cmdline,
- cmd->sub_table, qdict);
+ if (cmd->sub_table != NULL && *p != '\0') {
+ return monitor_parse_command(mon, cmdp, cmd->sub_table);
}
+ return cmd;
+}
+
+/*
+ * Parse arguments for @cmd.
+ * If it can't be parsed, report to @mon, and return NULL.
+ * Else, insert command arguments into a QDict, and return it.
+ * Note: On success, caller has to free the QDict structure.
+ */
+
+static QDict *monitor_parse_arguments(Monitor *mon,
+ const char **endp,
+ const mon_cmd_t *cmd)
+{
+ const char *typestr;
+ char *key;
+ int c;
+ const char *p = *endp;
+ char buf[1024];
+ QDict *qdict = qdict_new();
+
/* parse the parameters */
typestr = cmd->args_type;
for(;;) {
@@ -3720,14 +3715,14 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
switch(c) {
case 'F':
monitor_printf(mon, "%s: filename expected\n",
- cmdname);
+ cmd->name);
break;
case 'B':
monitor_printf(mon, "%s: block device name expected\n",
- cmdname);
+ cmd->name);
break;
default:
- monitor_printf(mon, "%s: string expected\n", cmdname);
+ monitor_printf(mon, "%s: string expected\n", cmd->name);
break;
}
goto fail;
@@ -3752,7 +3747,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
if (get_str(buf, sizeof(buf), &p) < 0) {
goto fail;
}
- opts = qemu_opts_parse(opts_list, buf, 1);
+ opts = qemu_opts_parse_noisily(opts_list, buf, true);
if (!opts) {
goto fail;
}
@@ -3869,7 +3864,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
goto fail;
/* Check if 'i' is greater than 32-bit */
if ((c == 'i') && ((val >> 32) & 0xffffffff)) {
- monitor_printf(mon, "\'%s\' has failed: ", cmdname);
+ monitor_printf(mon, "\'%s\' has failed: ", cmd->name);
monitor_printf(mon, "integer is for 32-bit values\n");
goto fail;
} else if (c == 'M') {
@@ -3940,7 +3935,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
case 'b':
{
const char *beg;
- int val;
+ bool val;
while (qemu_isspace(*p)) {
p++;
@@ -3950,14 +3945,14 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
p++;
}
if (p - beg == 2 && !memcmp(beg, "on", p - beg)) {
- val = 1;
+ val = true;
} else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) {
- val = 0;
+ val = false;
} else {
monitor_printf(mon, "Expected 'on' or 'off'\n");
goto fail;
}
- qdict_put(qdict, key, qbool_from_int(val));
+ qdict_put(qdict, key, qbool_from_bool(val));
}
break;
case '-':
@@ -3977,7 +3972,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
if(!is_valid_option(p, typestr)) {
monitor_printf(mon, "%s: unsupported option -%c\n",
- cmdname, *p);
+ cmd->name, *p);
goto fail;
} else {
skip_key = 1;
@@ -3988,7 +3983,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
} else {
/* has option */
p++;
- qdict_put(qdict, key, qbool_from_int(1));
+ qdict_put(qdict, key, qbool_from_bool(true));
}
}
}
@@ -4011,8 +4006,8 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
len = strlen(p);
if (len <= 0) {
monitor_printf(mon, "%s: string expected\n",
- cmdname);
- break;
+ cmd->name);
+ goto fail;
}
qdict_put(qdict, key, qstring_from_str(p));
p += len;
@@ -4020,7 +4015,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
break;
default:
bad_type:
- monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
+ monitor_printf(mon, "%s: unknown type '%c'\n", cmd->name, c);
goto fail;
}
g_free(key);
@@ -4031,39 +4026,36 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
p++;
if (*p != '\0') {
monitor_printf(mon, "%s: extraneous characters at the end of line\n",
- cmdname);
+ cmd->name);
goto fail;
}
- return cmd;
+ return qdict;
fail:
+ QDECREF(qdict);
g_free(key);
return NULL;
}
-void monitor_set_error(Monitor *mon, QError *qerror)
-{
- /* report only the first error */
- if (!mon->error) {
- mon->error = qerror;
- } else {
- QDECREF(qerror);
- }
-}
-
static void handle_hmp_command(Monitor *mon, const char *cmdline)
{
QDict *qdict;
const mon_cmd_t *cmd;
- qdict = qdict_new();
+ cmd = monitor_parse_command(mon, &cmdline, mon->cmd_table);
+ if (!cmd) {
+ return;
+ }
- cmd = monitor_parse_command(mon, cmdline, 0, mon->cmd_table, qdict);
- if (cmd) {
- cmd->mhandler.cmd(mon, qdict);
+ qdict = monitor_parse_arguments(mon, &cmdline, cmd);
+ if (!qdict) {
+ monitor_printf(mon, "Try \"help %s\" for more information\n",
+ cmd->name);
+ return;
}
+ cmd->mhandler.cmd(mon, qdict);
QDECREF(qdict);
}
@@ -4115,10 +4107,7 @@ static void file_completion(Monitor *mon, const char *input)
path[input_path_len] = '\0';
pstrcpy(file_prefix, sizeof(file_prefix), p + 1);
}
-#ifdef DEBUG_COMPLETION
- monitor_printf(mon, "input='%s' path='%s' prefix='%s'\n",
- input, path, file_prefix);
-#endif
+
ffs = opendir(path);
if (!ffs)
return;
@@ -4696,14 +4685,6 @@ static void monitor_find_completion(void *opaque,
if (parse_cmdline(cmdline, &nb_args, args) < 0) {
return;
}
-#ifdef DEBUG_COMPLETION
- {
- int i;
- for (i = 0; i < nb_args; i++) {
- monitor_printf(mon, "arg%d = '%s'\n", i, args[i]);
- }
- }
-#endif
/* if the line ends with a space, it means we want to complete the
next arg */
@@ -4732,7 +4713,7 @@ static int monitor_can_read(void *opaque)
static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
Error **errp)
{
- bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
+ bool is_cap = cmd->mhandler.cmd_new == qmp_capabilities;
if (is_cap && mon->qmp.in_command_mode) {
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
@@ -4778,7 +4759,7 @@ static void check_client_args_type(const QDict *client_args,
continue;
}
/* client arg doesn't exist */
- error_set(errp, QERR_INVALID_PARAMETER, client_arg_name);
+ error_setg(errp, QERR_INVALID_PARAMETER, client_arg_name);
return;
}
@@ -4791,8 +4772,8 @@ static void check_client_args_type(const QDict *client_args,
case 'B':
case 's':
if (qobject_type(client_arg) != QTYPE_QSTRING) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE,
- client_arg_name, "string");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+ client_arg_name, "string");
return;
}
break;
@@ -4801,24 +4782,24 @@ static void check_client_args_type(const QDict *client_args,
case 'M':
case 'o':
if (qobject_type(client_arg) != QTYPE_QINT) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE,
- client_arg_name, "int");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+ client_arg_name, "int");
return;
}
break;
case 'T':
if (qobject_type(client_arg) != QTYPE_QINT &&
qobject_type(client_arg) != QTYPE_QFLOAT) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE,
- client_arg_name, "number");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+ client_arg_name, "number");
return;
}
break;
case 'b':
case '-':
if (qobject_type(client_arg) != QTYPE_QBOOL) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE,
- client_arg_name, "bool");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+ client_arg_name, "bool");
return;
}
break;
@@ -4861,7 +4842,7 @@ static void check_mandatory_args(const QDict *cmd_args,
} else if (qstring_get_str(type)[0] != '-' &&
qstring_get_str(type)[1] != '?' &&
!qdict_haskey(client_args, cmd_arg_name)) {
- error_set(errp, QERR_MISSING_PARAMETER, cmd_arg_name);
+ error_setg(errp, QERR_MISSING_PARAMETER, cmd_arg_name);
return;
}
}
@@ -4959,7 +4940,7 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
QDict *input_dict;
if (qobject_type(input_obj) != QTYPE_QDICT) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "object");
return NULL;
}
@@ -4971,27 +4952,27 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
- "execute", "string");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
+ "execute", "string");
return NULL;
}
has_exec_key = 1;
} else if (!strcmp(arg_name, "arguments")) {
if (qobject_type(arg_obj) != QTYPE_QDICT) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
- "arguments", "object");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
+ "arguments", "object");
return NULL;
}
} else if (!strcmp(arg_name, "id")) {
/* Any string is acceptable as "id", so nothing to check */
} else {
- error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
+ error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!has_exec_key) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
@@ -5013,7 +4994,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
obj = json_parser_parse(tokens, NULL);
if (!obj) {
// FIXME: should be triggered in json_parser_parse()
- error_set(&local_err, QERR_JSON_PARSING);
+ error_setg(&local_err, QERR_JSON_PARSING);
goto err_out;
}
@@ -5051,23 +5032,11 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
goto err_out;
}
- if (cmd->mhandler.cmd_new(mon, args, &data)) {
- /* Command failed... */
- if (!mon->error) {
- /* ... without setting an error, so make one up */
- error_set(&local_err, QERR_UNDEFINED_ERROR);
- }
- }
- if (mon->error) {
- error_set(&local_err, mon->error->err_class, "%s",
- mon->error->err_msg);
- }
+ cmd->mhandler.cmd_new(args, &data, &local_err);
err_out:
monitor_protocol_emitter(mon, data, local_err);
qobject_decref(data);
- QDECREF(mon->error);
- mon->error = NULL;
QDECREF(input);
QDECREF(args);
}
@@ -5133,7 +5102,7 @@ static QObject *get_qmp_greeting(void)
{
QObject *ver = NULL;
- qmp_marshal_input_query_version(NULL, NULL, &ver);
+ qmp_marshal_input_query_version(NULL, &ver, NULL);
return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
}
@@ -5389,6 +5358,6 @@ QemuOptsList qemu_mon_opts = {
#ifndef TARGET_I386
void qmp_rtc_reset_reinjection(Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
+ error_setg(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
}
#endif
diff --git a/net/l2tpv3.c b/net/l2tpv3.c
index 356dae2b72..4f9bceecc9 100644
--- a/net/l2tpv3.c
+++ b/net/l2tpv3.c
@@ -28,7 +28,6 @@
#include "config-host.h"
#include "net/net.h"
#include "clients.h"
-#include "monitor/monitor.h"
#include "qemu-common.h"
#include "qemu/error-report.h"
#include "qemu/option.h"
diff --git a/net/net.c b/net/net.c
index 6dbd61a8f2..6ff7fec1bb 100644
--- a/net/net.c
+++ b/net/net.c
@@ -32,6 +32,8 @@
#include "monitor/monitor.h"
#include "qemu-common.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "qemu/config-file.h"
#include "qmp-commands.h"
@@ -58,6 +60,9 @@ const char *host_net_devices[] = {
#ifdef CONFIG_NET_BRIDGE
"bridge",
#endif
+#ifdef CONFIG_NETMAP
+ "netmap",
+#endif
#ifdef CONFIG_SLIRP
"user",
#endif
@@ -908,78 +913,58 @@ static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])(
static int net_client_init1(const void *object, int is_netdev, Error **errp)
{
- union {
- const Netdev *netdev;
- const NetLegacy *net;
- } u;
const NetClientOptions *opts;
const char *name;
+ NetClientState *peer = NULL;
if (is_netdev) {
- u.netdev = object;
- opts = u.netdev->opts;
- name = u.netdev->id;
-
- switch (opts->kind) {
-#ifdef CONFIG_SLIRP
- case NET_CLIENT_OPTIONS_KIND_USER:
-#endif
- case NET_CLIENT_OPTIONS_KIND_TAP:
- case NET_CLIENT_OPTIONS_KIND_SOCKET:
-#ifdef CONFIG_VDE
- case NET_CLIENT_OPTIONS_KIND_VDE:
-#endif
-#ifdef CONFIG_NETMAP
- case NET_CLIENT_OPTIONS_KIND_NETMAP:
-#endif
-#ifdef CONFIG_NET_BRIDGE
- case NET_CLIENT_OPTIONS_KIND_BRIDGE:
-#endif
- case NET_CLIENT_OPTIONS_KIND_HUBPORT:
-#ifdef CONFIG_VHOST_NET_USED
- case NET_CLIENT_OPTIONS_KIND_VHOST_USER:
-#endif
-#ifdef CONFIG_L2TPV3
- case NET_CLIENT_OPTIONS_KIND_L2TPV3:
-#endif
- break;
-
- default:
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
- "a netdev backend type");
+ const Netdev *netdev = object;
+ opts = netdev->opts;
+ name = netdev->id;
+
+ if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP ||
+ opts->kind == NET_CLIENT_OPTIONS_KIND_NIC ||
+ !net_client_init_fun[opts->kind]) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
+ "a netdev backend type");
return -1;
}
} else {
- u.net = object;
- opts = u.net->opts;
+ const NetLegacy *net = object;
+ opts = net->opts;
+ /* missing optional values have been initialized to "all bits zero" */
+ name = net->has_id ? net->id : net->name;
+
+ if (opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) {
+ return 0; /* nothing to do */
+ }
if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",
- "a net type");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
+ "a net type");
return -1;
}
- /* missing optional values have been initialized to "all bits zero" */
- name = u.net->has_id ? u.net->id : u.net->name;
- }
- if (net_client_init_fun[opts->kind]) {
- NetClientState *peer = NULL;
+ if (!net_client_init_fun[opts->kind]) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type",
+ "a net backend type (maybe it is not compiled "
+ "into this binary)");
+ return -1;
+ }
- /* Do not add to a vlan if it's a -netdev or a nic with a netdev=
- * parameter. */
- if (!is_netdev &&
- (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
- !opts->nic->has_netdev)) {
- peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL);
+ /* Do not add to a vlan if it's a nic with a netdev= parameter. */
+ if (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
+ !opts->nic->has_netdev) {
+ peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL);
}
+ }
- if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) {
- /* FIXME drop when all init functions store an Error */
- if (errp && !*errp) {
- error_set(errp, QERR_DEVICE_INIT_FAILED,
- NetClientOptionsKind_lookup[opts->kind]);
- }
- return -1;
+ if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) {
+ /* FIXME drop when all init functions store an Error */
+ if (errp && !*errp) {
+ error_setg(errp, QERR_DEVICE_INIT_FAILED,
+ NetClientOptionsKind_lookup[opts->kind]);
}
+ return -1;
}
return 0;
}
@@ -1049,7 +1034,8 @@ void hmp_host_net_add(Monitor *mon, const QDict *qdict)
return;
}
- opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("net"),
+ opts_str ? opts_str : "", false);
if (!opts) {
return;
}
@@ -1089,7 +1075,7 @@ void netdev_add(QemuOpts *opts, Error **errp)
net_client_init(opts, 1, errp);
}
-int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_netdev_add(QDict *qdict, QObject **ret, Error **errp)
{
Error *local_err = NULL;
QemuOptsList *opts_list;
@@ -1097,26 +1083,22 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret)
opts_list = qemu_find_opts_err("netdev", &local_err);
if (local_err) {
- goto exit_err;
+ goto out;
}
opts = qemu_opts_from_qdict(opts_list, qdict, &local_err);
if (local_err) {
- goto exit_err;
+ goto out;
}
netdev_add(opts, &local_err);
if (local_err) {
qemu_opts_del(opts);
- goto exit_err;
+ goto out;
}
- return 0;
-
-exit_err:
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
+out:
+ error_propagate(errp, local_err);
}
void qmp_netdev_del(const char *id, Error **errp)
@@ -1126,7 +1108,8 @@ void qmp_netdev_del(const char *id, Error **errp)
nc = qemu_find_netdev(id);
if (!nc) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, id);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", id);
return;
}
@@ -1237,7 +1220,8 @@ void qmp_set_link(const char *name, bool up, Error **errp)
MAX_QUEUE_NUM);
if (queues == 0) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, name);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", name);
return;
}
nc = ncs[0];
@@ -1412,7 +1396,7 @@ int net_client_parse(QemuOptsList *opts_list, const char *optarg)
}
#endif
- if (!qemu_opts_parse(opts_list, optarg, 1)) {
+ if (!qemu_opts_parse_noisily(opts_list, optarg, true)) {
return -1;
}
diff --git a/net/slirp.c b/net/slirp.c
index 35338376f7..7657b38fdf 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -33,6 +33,7 @@
#include "clients.h"
#include "hub.h"
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "slirp/libslirp.h"
#include "sysemu/char.h"
diff --git a/numa.c b/numa.c
index 28c857c66a..91fc6c1d93 100644
--- a/numa.c
+++ b/numa.c
@@ -31,7 +31,6 @@
#include "qapi-visit.h"
#include "qapi/opts-visitor.h"
#include "qapi/dealloc-visitor.h"
-#include "qapi/qmp/qerror.h"
#include "hw/boards.h"
#include "sysemu/hostmem.h"
#include "qmp-commands.h"
diff --git a/qapi/block-core.json b/qapi/block-core.json
index afa9d3d1f3..5a368f6e19 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1083,7 +1083,7 @@
#
# I/O limits can be disabled by setting all of them to 0. In this case
# the device will be removed from its group and the rest of its
-# members will no be affected. The 'group' parameter is ignored.
+# members will not be affected. The 'group' parameter is ignored.
#
# @device: The name of the device
#
@@ -1453,13 +1453,17 @@
# @fat-type: #optional FAT type: 12, 16 or 32
# @floppy: #optional whether to export a floppy image (true) or
# partitioned hard disk (false; default)
+# @label: #optional set the volume label, limited to 11 bytes. FAT16 and
+# FAT32 traditionally have some restrictions on labels, which are
+# ignored by most operating systems. Defaults to "QEMU VVFAT".
+# (since 2.4)
# @rw: #optional whether to allow write operations (default: false)
#
# Since: 1.7
##
{ 'struct': 'BlockdevOptionsVVFAT',
'data': { 'dir': 'str', '*fat-type': 'int', '*floppy': 'bool',
- '*rw': 'bool' } }
+ '*label': 'str', '*rw': 'bool' } }
##
# @BlockdevOptionsGenericFormat
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index f2ad6d729a..7ae33b311e 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -173,7 +173,7 @@ opts_end_struct(Visitor *v, Error **errp)
const QemuOpt *first;
first = g_queue_peek_head(any);
- error_set(errp, QERR_INVALID_PARAMETER, first->name);
+ error_setg(errp, QERR_INVALID_PARAMETER, first->name);
}
g_hash_table_destroy(ov->unprocessed_opts);
ov->unprocessed_opts = NULL;
@@ -193,7 +193,7 @@ lookup_distinct(const OptsVisitor *ov, const char *name, Error **errp)
list = g_hash_table_lookup(ov->unprocessed_opts, name);
if (!list) {
- error_set(errp, QERR_MISSING_PARAMETER, name);
+ error_setg(errp, QERR_MISSING_PARAMETER, name);
}
return list;
}
@@ -341,8 +341,8 @@ opts_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
strcmp(opt->str, "n") == 0) {
*obj = false;
} else {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
- "on|yes|y|off|no|n");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+ "on|yes|y|off|no|n");
return;
}
} else {
@@ -403,9 +403,9 @@ opts_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
}
}
}
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
- (ov->list_mode == LM_NONE) ? "an int64 value" :
- "an int64 value or range");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+ (ov->list_mode == LM_NONE) ? "an int64 value" :
+ "an int64 value or range");
}
@@ -455,9 +455,9 @@ opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
}
}
}
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
- (ov->list_mode == LM_NONE) ? "a uint64 value" :
- "a uint64 value or range");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+ (ov->list_mode == LM_NONE) ? "a uint64 value" :
+ "a uint64 value or range");
}
@@ -477,8 +477,8 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
STRTOSZ_DEFSUFFIX_B);
if (val < 0 || *endptr) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
- "a size value representible as a non-negative int64");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, opt->name,
+ "a size value representible as a non-negative int64");
return;
}
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index a18ba1670f..5a7c900504 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -110,8 +110,8 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < 0 || value > UINT8_MAX) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "uint8_t");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "uint8_t");
return;
}
*obj = value;
@@ -128,8 +128,8 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp
value = *obj;
v->type_int(v, &value, name, errp);
if (value < 0 || value > UINT16_MAX) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "uint16_t");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "uint16_t");
return;
}
*obj = value;
@@ -146,8 +146,8 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp
value = *obj;
v->type_int(v, &value, name, errp);
if (value < 0 || value > UINT32_MAX) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "uint32_t");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "uint32_t");
return;
}
*obj = value;
@@ -177,8 +177,8 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT8_MIN || value > INT8_MAX) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "int8_t");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "int8_t");
return;
}
*obj = value;
@@ -195,8 +195,8 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT16_MIN || value > INT16_MAX) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "int16_t");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "int16_t");
return;
}
*obj = value;
@@ -213,8 +213,8 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
value = *obj;
v->type_int(v, &value, name, errp);
if (value < INT32_MIN || value > INT32_MAX) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
- "int32_t");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name ? name : "null", "int32_t");
return;
}
*obj = value;
@@ -271,7 +271,7 @@ void output_type_enum(Visitor *v, int *obj, const char * const strings[],
assert(strings);
while (strings[i++] != NULL);
if (value < 0 || value >= i - 1) {
- error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
+ error_setg(errp, QERR_INVALID_PARAMETER, name ? name : "null");
return;
}
@@ -303,7 +303,7 @@ void input_type_enum(Visitor *v, int *obj, const char * const strings[],
}
if (strings[value] == NULL) {
- error_set(errp, QERR_INVALID_PARAMETER, enum_str);
+ error_setg(errp, QERR_INVALID_PARAMETER, enum_str);
g_free(enum_str);
return;
}
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 222742013f..7bcc86080e 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -27,8 +27,8 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)
QDict *dict = NULL;
if (qobject_type(request) != QTYPE_QDICT) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT,
- "request is not a dictionary");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT,
+ "request is not a dictionary");
return NULL;
}
@@ -41,19 +41,19 @@ static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp)
if (!strcmp(arg_name, "execute")) {
if (qobject_type(arg_obj) != QTYPE_QSTRING) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
- "string");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute",
+ "string");
return NULL;
}
has_exec_key = true;
} else if (strcmp(arg_name, "arguments")) {
- error_set(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
+ error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name);
return NULL;
}
}
if (!has_exec_key) {
- error_set(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
+ error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute");
return NULL;
}
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index d8612062f1..e97b8a4282 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -105,7 +105,7 @@ static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
if (g_hash_table_size(top_ht)) {
const char *key;
g_hash_table_find(top_ht, always_true, &key);
- error_set(errp, QERR_QMP_EXTRA_MEMBER, key);
+ error_setg(errp, QERR_QMP_EXTRA_MEMBER, key);
}
g_hash_table_unref(top_ht);
}
@@ -122,8 +122,8 @@ static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
Error *err = NULL;
if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "QDict");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "QDict");
return;
}
@@ -163,8 +163,8 @@ static void qmp_input_start_list(Visitor *v, const char *name, Error **errp)
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QLIST) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "list");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "list");
return;
}
@@ -215,7 +215,7 @@ static void qmp_input_get_next_type(Visitor *v, int *kind, const int *qobjects,
QObject *qobj = qmp_input_get_object(qiv, name, false);
if (!qobj) {
- error_set(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+ error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
return;
}
*kind = qobjects[qobject_type(qobj)];
@@ -228,8 +228,8 @@ static void qmp_input_type_int(Visitor *v, int64_t *obj, const char *name,
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QINT) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "integer");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "integer");
return;
}
@@ -243,12 +243,12 @@ static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QBOOL) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "boolean");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "boolean");
return;
}
- *obj = qbool_get_int(qobject_to_qbool(qobj));
+ *obj = qbool_get_bool(qobject_to_qbool(qobj));
}
static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
@@ -258,8 +258,8 @@ static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
QObject *qobj = qmp_input_get_object(qiv, name, true);
if (!qobj || qobject_type(qobj) != QTYPE_QSTRING) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "string");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "string");
return;
}
@@ -274,8 +274,8 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT &&
qobject_type(qobj) != QTYPE_QINT)) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "number");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "number");
return;
}
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index 96b338463e..efc19d5841 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -16,7 +16,6 @@
#include "qemu/queue.h"
#include "qemu-common.h"
#include "qapi/qmp/types.h"
-#include "qapi/qmp/qerror.h"
typedef struct QStackEntry
{
@@ -166,7 +165,7 @@ static void qmp_output_type_bool(Visitor *v, bool *obj, const char *name,
Error **errp)
{
QmpOutputVisitor *qov = to_qov(v);
- qmp_output_add(qov, name, qbool_from_int(*obj));
+ qmp_output_add(qov, name, qbool_from_bool(*obj));
}
static void qmp_output_type_str(Visitor *v, char **obj, const char *name,
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index d8a8db02ed..bbd6a5456c 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -185,8 +185,8 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name,
StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v);
if (!siv->string) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "integer");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "integer");
return;
}
@@ -217,8 +217,8 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name,
return;
error:
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name,
- "an int64 value or range");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
+ "an int64 value or range");
}
static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
@@ -231,8 +231,8 @@ static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
if (siv->string) {
parse_option_size(name, siv->string, &val, &err);
} else {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "size");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "size");
return;
}
if (err) {
@@ -263,8 +263,8 @@ static void parse_type_bool(Visitor *v, bool *obj, const char *name,
}
}
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "boolean");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "boolean");
}
static void parse_type_str(Visitor *v, char **obj, const char *name,
@@ -274,8 +274,8 @@ static void parse_type_str(Visitor *v, char **obj, const char *name,
if (siv->string) {
*obj = g_strdup(siv->string);
} else {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "string");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "string");
}
}
@@ -291,8 +291,8 @@ static void parse_type_number(Visitor *v, double *obj, const char *name,
val = strtod(siv->string, &endp);
}
if (!siv->string || errno || endp == siv->string || *endp) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
- "number");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "number");
return;
}
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 1ab8574585..b86ce2cd07 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -13,7 +13,6 @@
#include "qemu-common.h"
#include "qapi/string-output-visitor.h"
#include "qapi/visitor-impl.h"
-#include "qapi/qmp/qerror.h"
#include "qemu/host-utils.h"
#include <math.h>
#include "qemu/range.h"
diff --git a/qdev-monitor.c b/qdev-monitor.c
index d71d1ee520..f9e2d6258d 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -23,7 +23,9 @@
#include "monitor/qdev.h"
#include "qmp-commands.h"
#include "sysemu/arch_init.h"
+#include "qapi/qmp/qerror.h"
#include "qemu/config-file.h"
+#include "qemu/error-report.h"
/*
* Aliases were a bad idea from the start. Let's keep them
@@ -156,8 +158,7 @@ static int set_property(void *opaque, const char *name, const char *value,
object_property_parse(obj, value, name, &err);
if (err != NULL) {
- qerror_report_err(err);
- error_free(err);
+ error_propagate(errp, err);
return -1;
}
return 0;
@@ -202,16 +203,16 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
}
if (object_class_is_abstract(oc)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
- "non-abstract device type");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
+ "non-abstract device type");
return NULL;
}
dc = DEVICE_CLASS(oc);
if (dc->cannot_instantiate_with_device_add_yet ||
(qdev_hotplug && !dc->hotpluggable)) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
- "pluggable device type");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
+ "pluggable device type");
return NULL;
}
@@ -288,12 +289,13 @@ static Object *qdev_get_peripheral_anon(void)
return dev;
}
+#if 0 /* conversion from qerror_report() to error_set() broke their use */
static void qbus_list_bus(DeviceState *dev)
{
BusState *child;
const char *sep = " ";
- error_printf("child busses at \"%s\":",
+ error_printf("child buses at \"%s\":",
dev->id ? dev->id : object_get_typename(OBJECT(dev)));
QLIST_FOREACH(child, &dev->child_bus, sibling) {
error_printf("%s\"%s\"", sep, child->name);
@@ -317,6 +319,7 @@ static void qbus_list_dev(BusState *bus)
}
error_printf("\n");
}
+#endif
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
{
@@ -364,46 +367,58 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)
return NULL;
}
+static inline bool qbus_is_full(BusState *bus)
+{
+ BusClass *bus_class = BUS_GET_CLASS(bus);
+ return bus_class->max_dev && bus->max_index >= bus_class->max_dev;
+}
+
+/*
+ * Search the tree rooted at @bus for a bus.
+ * If @name, search for a bus with that name. Note that bus names
+ * need not be unique. Yes, that's screwed up.
+ * Else search for a bus that is a subtype of @bus_typename.
+ * If more than one exists, prefer one that can take another device.
+ * Return the bus if found, else %NULL.
+ */
static BusState *qbus_find_recursive(BusState *bus, const char *name,
const char *bus_typename)
{
- BusClass *bus_class = BUS_GET_CLASS(bus);
BusChild *kid;
- BusState *child, *ret;
- int match = 1;
-
- if (name && (strcmp(bus->name, name) != 0)) {
- match = 0;
- } else if (bus_typename && !object_dynamic_cast(OBJECT(bus), bus_typename)) {
- match = 0;
- } else if ((bus_class->max_dev != 0) && (bus_class->max_dev <= bus->max_index)) {
- if (name != NULL) {
- /* bus was explicitly specified: return an error. */
- qerror_report(ERROR_CLASS_GENERIC_ERROR, "Bus '%s' is full",
- bus->name);
- return NULL;
- } else {
- /* bus was not specified: try to find another one. */
- match = 0;
- }
+ BusState *pick, *child, *ret;
+ bool match;
+
+ assert(name || bus_typename);
+ if (name) {
+ match = !strcmp(bus->name, name);
+ } else {
+ match = !!object_dynamic_cast(OBJECT(bus), bus_typename);
}
- if (match) {
- return bus;
+
+ if (match && !qbus_is_full(bus)) {
+ return bus; /* root matches and isn't full */
}
+ pick = match ? bus : NULL;
+
QTAILQ_FOREACH(kid, &bus->children, sibling) {
DeviceState *dev = kid->child;
QLIST_FOREACH(child, &dev->child_bus, sibling) {
ret = qbus_find_recursive(child, name, bus_typename);
- if (ret) {
- return ret;
+ if (ret && !qbus_is_full(ret)) {
+ return ret; /* a descendant matches and isn't full */
+ }
+ if (ret && !pick) {
+ pick = ret;
}
}
}
- return NULL;
+
+ /* root or a descendant matches, but is full */
+ return pick;
}
-static BusState *qbus_find(const char *path)
+static BusState *qbus_find(const char *path, Error **errp)
{
DeviceState *dev;
BusState *bus;
@@ -421,7 +436,7 @@ static BusState *qbus_find(const char *path)
}
bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
if (!bus) {
- qerror_report(QERR_BUS_NOT_FOUND, elem);
+ error_setg(errp, "Bus '%s' not found", elem);
return NULL;
}
pos = len;
@@ -433,7 +448,7 @@ static BusState *qbus_find(const char *path)
pos++;
}
if (path[pos] == '\0') {
- return bus;
+ break;
}
/* find device */
@@ -444,10 +459,13 @@ static BusState *qbus_find(const char *path)
pos += len;
dev = qbus_find_dev(bus, elem);
if (!dev) {
- qerror_report(QERR_DEVICE_NOT_FOUND, elem);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", elem);
+#if 0 /* conversion from qerror_report() to error_set() broke this: */
if (!monitor_cur_is_qmp()) {
qbus_list_dev(bus);
}
+#endif
return NULL;
}
@@ -458,21 +476,22 @@ static BusState *qbus_find(const char *path)
if (path[pos] == '\0') {
/* last specified element is a device. If it has exactly
* one child bus accept it nevertheless */
- switch (dev->num_child_bus) {
- case 0:
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "Device '%s' has no child bus", elem);
- return NULL;
- case 1:
- return QLIST_FIRST(&dev->child_bus);
- default:
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "Device '%s' has multiple child busses", elem);
+ if (dev->num_child_bus == 1) {
+ bus = QLIST_FIRST(&dev->child_bus);
+ break;
+ }
+ if (dev->num_child_bus) {
+ error_setg(errp, "Device '%s' has multiple child buses",
+ elem);
+#if 0 /* conversion from qerror_report() to error_set() broke this: */
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
- return NULL;
+#endif
+ } else {
+ error_setg(errp, "Device '%s' has no child bus", elem);
}
+ return NULL;
}
/* find bus */
@@ -483,16 +502,24 @@ static BusState *qbus_find(const char *path)
pos += len;
bus = qbus_find_bus(dev, elem);
if (!bus) {
- qerror_report(QERR_BUS_NOT_FOUND, elem);
+ error_setg(errp, "Bus '%s' not found", elem);
+#if 0 /* conversion from qerror_report() to error_set() broke this: */
if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev);
}
+#endif
return NULL;
}
}
+
+ if (qbus_is_full(bus)) {
+ error_setg(errp, "Bus '%s' is full", path);
+ return NULL;
+ }
+ return bus;
}
-DeviceState *qdev_device_add(QemuOpts *opts)
+DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
{
DeviceClass *dc;
const char *driver, *path, *id;
@@ -502,42 +529,38 @@ DeviceState *qdev_device_add(QemuOpts *opts)
driver = qemu_opt_get(opts, "driver");
if (!driver) {
- qerror_report(QERR_MISSING_PARAMETER, "driver");
+ error_setg(errp, QERR_MISSING_PARAMETER, "driver");
return NULL;
}
/* find driver */
- dc = qdev_get_device_class(&driver, &err);
- if (err) {
- qerror_report_err(err);
- error_free(err);
+ dc = qdev_get_device_class(&driver, errp);
+ if (!dc) {
return NULL;
}
/* find bus */
path = qemu_opt_get(opts, "bus");
if (path != NULL) {
- bus = qbus_find(path);
+ bus = qbus_find(path, errp);
if (!bus) {
return NULL;
}
if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "Device '%s' can't go on a %s bus",
- driver, object_get_typename(OBJECT(bus)));
+ error_setg(errp, "Device '%s' can't go on %s bus",
+ driver, object_get_typename(OBJECT(bus)));
return NULL;
}
} else if (dc->bus_type != NULL) {
bus = qbus_find_recursive(sysbus_get_default(), NULL, dc->bus_type);
- if (!bus) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "No '%s' bus found for device '%s'",
- dc->bus_type, driver);
+ if (!bus || qbus_is_full(bus)) {
+ error_setg(errp, "No '%s' bus found for device '%s'",
+ dc->bus_type, driver);
return NULL;
}
}
if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
- qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
return NULL;
}
@@ -565,7 +588,8 @@ DeviceState *qdev_device_add(QemuOpts *opts)
}
/* set properties */
- if (qemu_opt_foreach(opts, set_property, dev, NULL)) {
+ if (qemu_opt_foreach(opts, set_property, dev, &err)) {
+ error_propagate(errp, err);
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
return NULL;
@@ -574,12 +598,10 @@ DeviceState *qdev_device_add(QemuOpts *opts)
dev->opts = opts;
object_property_set_bool(OBJECT(dev), true, "realized", &err);
if (err != NULL) {
- qerror_report_err(err);
- error_free(err);
+ error_propagate(errp, err);
dev->opts = NULL;
object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
- qerror_report(QERR_DEVICE_INIT_FAILED, driver);
return NULL;
}
return dev;
@@ -736,7 +758,7 @@ void hmp_info_qom_tree(Monitor *mon, const QDict *dict)
print_qom_composition(mon, obj, 0);
}
-int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
{
Error *local_err = NULL;
QemuOpts *opts;
@@ -744,21 +766,20 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err);
if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
+ error_propagate(errp, local_err);
+ return;
}
if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
qemu_opts_del(opts);
- return 0;
+ return;
}
- dev = qdev_device_add(opts);
+ dev = qdev_device_add(opts, &local_err);
if (!dev) {
+ error_propagate(errp, local_err);
qemu_opts_del(opts);
- return -1;
+ return;
}
object_unref(OBJECT(dev));
- return 0;
}
void qmp_device_del(const char *id, Error **errp)
@@ -772,7 +793,8 @@ void qmp_device_del(const char *id, Error **errp)
g_free(path);
if (!obj) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, id);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", id);
return;
}
@@ -832,7 +854,7 @@ int qemu_global_option(const char *str)
return 0;
}
- opts = qemu_opts_parse(&qemu_global_opts, str, false);
+ opts = qemu_opts_parse_noisily(&qemu_global_opts, str, false);
if (!opts) {
return -1;
}
diff --git a/qemu-char.c b/qemu-char.c
index d0c1564306..617e034455 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "sysemu/char.h"
#include "hw/usb.h"
diff --git a/qemu-img.c b/qemu-img.c
index 60c820d002..75f4ee4421 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -23,6 +23,7 @@
*/
#include "qapi-visit.h"
#include "qapi/qmp-output-visitor.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qjson.h"
#include "qemu-common.h"
#include "qemu/option.h"
@@ -739,7 +740,7 @@ static int img_commit(int argc, char **argv)
if (base) {
base_bs = bdrv_find_backing_image(bs, base);
if (!base_bs) {
- error_set(&local_err, QERR_BASE_NOT_FOUND, base);
+ error_setg(&local_err, QERR_BASE_NOT_FOUND, base);
goto done;
}
} else {
@@ -1590,7 +1591,8 @@ static int img_convert(int argc, char **argv)
break;
case 'l':
if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
- sn_opts = qemu_opts_parse(&internal_snapshot_opts, optarg, 0);
+ sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
+ optarg, false);
if (!sn_opts) {
error_report("Failed in parsing snapshot param '%s'",
optarg);
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 52dc6111bf..53477e1e17 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -13,6 +13,7 @@
#include "block/block.h"
#include "block/block_int.h" /* for info_f() */
#include "block/qapi.h"
+#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/timer.h"
#include "sysemu/block-backend.h"
diff --git a/qemu-io.c b/qemu-io.c
index 9bc83c6ec1..f1e3a67135 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -15,10 +15,12 @@
#include <libgen.h>
#include "qemu-io.h"
+#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu/readline.h"
+#include "qapi/qmp/qstring.h"
#include "sysemu/block-backend.h"
#include "block/block_int.h"
#include "trace/control.h"
@@ -153,7 +155,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
readonly = 1;
break;
case 'o':
- if (!qemu_opts_parse(&empty_opts, optarg, 0)) {
+ if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) {
printf("could not parse option list -- %s\n", optarg);
qemu_opts_reset(&empty_opts);
return 0;
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 5af6d11e33..5106b802e6 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -25,6 +25,7 @@
#include "qemu/error-report.h"
#include "block/snapshot.h"
#include "qapi/util.h"
+#include "qapi/qmp/qstring.h"
#include <stdarg.h>
#include <stdio.h>
@@ -549,7 +550,8 @@ int main(int argc, char **argv)
break;
case 'l':
if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
- sn_opts = qemu_opts_parse(&internal_snapshot_opts, optarg, 0);
+ sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
+ optarg, false);
if (!sn_opts) {
errx(EXIT_FAILURE, "Failed in parsing snapshot param `%s'",
optarg);
diff --git a/qemu-options.hx b/qemu-options.hx
index d1712f58af..e6e3895918 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -118,7 +118,7 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa,
"-numa node[,memdev=id][,cpus=cpu[-cpu]][,nodeid=node]\n", QEMU_ARCH_ALL)
STEXI
@item -numa node[,mem=@var{size}][,cpus=@var{cpu[-cpu]}][,nodeid=@var{node}]
-@item -numa node[,memdev=@var{id}][,cpus=@var{cpu[-cpu]}][,nodeid=@var{node}]
+@itemx -numa node[,memdev=@var{id}][,cpus=@var{cpu[-cpu]}][,nodeid=@var{node}]
@findex -numa
Simulate a multi node NUMA system. If @samp{mem}, @samp{memdev}
and @samp{cpus} are omitted, resources are split equally. Also, note
@@ -189,8 +189,9 @@ In particular, you can use this to set driver properties for devices which are
created automatically by the machine model. To create a device which is not
created automatically and set properties on it, use -@option{device}.
-The two syntaxes are equivalent. The longer one works for drivers whose name
-contains a dot.
+-global @var{driver}.@var{prop}=@var{value} is shorthand for -global
+driver=@var{driver},property=@var{prop},value=@var{value}. The
+longhand syntax works even when @var{driver} contains a dot.
ETEXI
DEF("boot", HAS_ARG, QEMU_OPTION_boot,
@@ -420,7 +421,7 @@ DEF("fda", HAS_ARG, QEMU_OPTION_fda,
DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
STEXI
@item -fda @var{file}
-@item -fdb @var{file}
+@itemx -fdb @var{file}
@findex -fda
@findex -fdb
Use @var{file} as floppy disk 0/1 image (@pxref{disk_images}).
@@ -434,9 +435,9 @@ DEF("hdc", HAS_ARG, QEMU_OPTION_hdc,
DEF("hdd", HAS_ARG, QEMU_OPTION_hdd, "", QEMU_ARCH_ALL)
STEXI
@item -hda @var{file}
-@item -hdb @var{file}
-@item -hdc @var{file}
-@item -hdd @var{file}
+@itemx -hdb @var{file}
+@itemx -hdc @var{file}
+@itemx -hdd @var{file}
@findex -hda
@findex -hdb
@findex -hdc
@@ -1008,8 +1009,8 @@ Set the TCP port spice is listening on for plaintext channels.
Set the IP address spice is listening on. Default is any address.
@item ipv4
-@item ipv6
-@item unix
+@itemx ipv6
+@itemx unix
Force using the specified IP version.
@item password=<secret>
@@ -1044,17 +1045,17 @@ Set the TCP port spice is listening on for encrypted channels.
Set the x509 file directory. Expects same filenames as -vnc $display,x509=$dir
@item x509-key-file=<file>
-@item x509-key-password=<file>
-@item x509-cert-file=<file>
-@item x509-cacert-file=<file>
-@item x509-dh-key-file=<file>
+@itemx x509-key-password=<file>
+@itemx x509-cert-file=<file>
+@itemx x509-cacert-file=<file>
+@itemx x509-dh-key-file=<file>
The x509 file names can also be configured individually.
@item tls-ciphers=<list>
Specify which ciphers to use.
@item tls-channel=[main|display|cursor|inputs|record|playback]
-@item plaintext-channel=[main|display|cursor|inputs|record|playback]
+@itemx plaintext-channel=[main|display|cursor|inputs|record|playback]
Force specific channel to be used with or without TLS encryption. The
options can be specified multiple times to configure multiple
channels. The special name "default" can be used to set the default
@@ -1066,7 +1067,7 @@ Configure image compression (lossless).
Default is auto_glz.
@item jpeg-wan-compression=[auto|never|always]
-@item zlib-glz-wan-compression=[auto|never|always]
+@itemx zlib-glz-wan-compression=[auto|never|always]
Configure wan image compression (lossy for slow links).
Default is auto.
@@ -1604,7 +1605,7 @@ privilege to run. Valid options are:
Connect user mode stack to VLAN @var{n} (@var{n} = 0 is the default).
@item id=@var{id}
-@item name=@var{name}
+@itemx name=@var{name}
Assign symbolic name for use in monitor commands.
@item net=@var{addr}[/@var{mask}]
@@ -1711,7 +1712,7 @@ Then when you use on the host @code{telnet localhost 5555}, you
connect to the guest telnet server.
@item guestfwd=[tcp]:@var{server}:@var{port}-@var{dev}
-@item guestfwd=[tcp]:@var{server}:@var{port}-@var{cmd:command}
+@itemx guestfwd=[tcp]:@var{server}:@var{port}-@var{cmd:command}
Forward guest TCP connections to the IP address @var{server} on port @var{port}
to the character device @var{dev} or to a program executed by @var{cmd:command}
which gets spawned for each connection. This option can be given multiple times.
@@ -1742,7 +1743,7 @@ syntax gives undefined results. Their use for new applications is discouraged
as they will be removed from future versions.
@item -netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,helper=@var{helper}]
-@item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,helper=@var{helper}]
+@itemx -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,helper=@var{helper}]
Connect the host TAP network interface @var{name} to VLAN @var{n}.
Use the network script @var{file} to configure it and the network script
@@ -1782,7 +1783,7 @@ qemu-system-i386 linux.img \
@end example
@item -netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}]
-@item -net bridge[,vlan=@var{n}][,name=@var{name}][,br=@var{bridge}][,helper=@var{helper}]
+@itemx -net bridge[,vlan=@var{n}][,name=@var{name}][,br=@var{bridge}][,helper=@var{helper}]
Connect a host TAP network interface to a host bridge device.
Use the network helper @var{helper} to configure the TAP interface and
@@ -1805,7 +1806,7 @@ qemu-system-i386 linux.img -net bridge,br=qemubr0 -net nic,model=virtio
@end example
@item -netdev socket,id=@var{id}[,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
-@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
+@itemx -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
machine using a TCP socket connection. If @option{listen} is
@@ -1828,7 +1829,7 @@ qemu-system-i386 linux.img \
@end example
@item -netdev socket,id=@var{id}[,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]
-@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]
+@itemx -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]
Create a VLAN @var{n} shared with another QEMU virtual
machines using a UDP multicast socket, effectively making a bus for
@@ -1880,7 +1881,7 @@ qemu-system-i386 linux.img \
@end example
@item -netdev l2tpv3,id=@var{id},src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]
-@item -net l2tpv3[,vlan=@var{n}][,name=@var{name}],src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]
+@itemx -net l2tpv3[,vlan=@var{n}][,name=@var{name}],src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]
Connect VLAN @var{n} to L2TPv3 pseudowire. L2TPv3 (RFC3391) is a popular
protocol to transport Ethernet (and other Layer 2) data frames between
two systems. It is present in routers, firewalls and the Linux kernel
@@ -1901,7 +1902,7 @@ This transport allows a VM to communicate to another VM, router or firewall dire
@item ipv6
force v6, otherwise defaults to v4.
@item rxcookie=@var{rxcookie}
-@item txcookie=@var{txcookie}
+@itemx txcookie=@var{txcookie}
Cookies are a weak form of security in the l2tpv3 specification.
Their function is mostly to prevent misconfiguration. By default they are 32
bit.
@@ -1939,7 +1940,7 @@ qemu-system-i386 linux.img -net nic -net l2tpv3,src=4.2.3.1,dst=1.2.3.4,udp,srcp
@end example
@item -netdev vde,id=@var{id}[,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
-@item -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}] [,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
+@itemx -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}] [,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
and MODE @var{octalmode} to change default ownership and permissions for
@@ -2238,7 +2239,7 @@ DragonFlyBSD hosts. It is an alias for @option{serial}.
@option{path} specifies the path to the tty. @option{path} is required.
@item -chardev parallel ,id=@var{id} ,path=@var{path}
-@item -chardev parport ,id=@var{id} ,path=@var{path}
+@itemx -chardev parport ,id=@var{id} ,path=@var{path}
@option{parallel} is only available on Linux, FreeBSD and DragonFlyBSD hosts.
@@ -3211,7 +3212,7 @@ Examples:
@table @code
@item -watchdog i6300esb -watchdog-action pause
-@item -watchdog ib700
+@itemx -watchdog ib700
@end table
ETEXI
@@ -3231,7 +3232,7 @@ instance you could use the either of the following to change the escape
character to Control-t.
@table @code
@item -echr 0x14
-@item -echr 20
+@itemx -echr 20
@end table
ETEXI
@@ -3279,7 +3280,7 @@ DEF("incoming", HAS_ARG, QEMU_OPTION_incoming, \
QEMU_ARCH_ALL)
STEXI
@item -incoming tcp:[@var{host}]:@var{port}[,to=@var{maxport}][,ipv4][,ipv6]
-@item -incoming rdma:@var{host}:@var{port}[,ipv4][,ipv6]
+@itemx -incoming rdma:@var{host}:@var{port}[,ipv4][,ipv6]
@findex -incoming
Prepare for incoming migration, listen on a given tcp port.
@@ -3344,20 +3345,22 @@ Set OpenBIOS nvram @var{variable} to given @var{value} (PPC, SPARC only).
ETEXI
DEF("semihosting", 0, QEMU_OPTION_semihosting,
"-semihosting semihosting mode\n",
- QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32)
+ QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 |
+ QEMU_ARCH_MIPS)
STEXI
@item -semihosting
@findex -semihosting
-Enable semihosting mode (ARM, M68K, Xtensa only).
+Enable semihosting mode (ARM, M68K, Xtensa, MIPS only).
ETEXI
DEF("semihosting-config", HAS_ARG, QEMU_OPTION_semihosting_config,
"-semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]\n" \
" semihosting configuration\n",
-QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32)
+QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 |
+QEMU_ARCH_MIPS)
STEXI
@item -semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]
@findex -semihosting-config
-Enable and configure semihosting (ARM, M68K, Xtensa only).
+Enable and configure semihosting (ARM, M68K, Xtensa, MIPS only).
@table @option
@item target=@code{native|gdb|auto}
Defines where the semihosting calls will be addressed, to QEMU (@code{native})
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index ba8de62436..befd00b00d 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -382,15 +382,15 @@ static int guest_file_toggle_flags(int fd, int flags, bool set, Error **err)
old_flags = fcntl(fd, F_GETFL);
if (old_flags == -1) {
- error_set_errno(err, errno, QERR_QGA_COMMAND_FAILED,
- "failed to fetch filehandle flags");
+ error_setg_errno(err, errno, QERR_QGA_COMMAND_FAILED,
+ "failed to fetch filehandle flags");
return -1;
}
ret = fcntl(fd, F_SETFL, set ? (old_flags | flags) : (old_flags & ~flags));
if (ret == -1) {
- error_set_errno(err, errno, QERR_QGA_COMMAND_FAILED,
- "failed to set filehandle flags");
+ error_setg_errno(err, errno, QERR_QGA_COMMAND_FAILED,
+ "failed to set filehandle flags");
return -1;
}
@@ -2302,34 +2302,34 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
void qmp_guest_suspend_disk(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
void qmp_guest_suspend_ram(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
void qmp_guest_suspend_hybrid(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return -1;
}
@@ -2338,25 +2338,25 @@ void qmp_guest_set_user_password(const char *username,
bool crypted,
Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
GuestMemoryBlockResponseList *
qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
@@ -2366,20 +2366,20 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
int64_t qmp_guest_fsfreeze_freeze(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
@@ -2388,14 +2388,14 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
strList *mountpoints,
Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
int64_t qmp_guest_fsfreeze_thaw(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
@@ -2404,7 +2404,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)
#if !defined(CONFIG_FSTRIM)
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
#endif
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index d0aaec70f3..fbddc8b1b2 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -182,8 +182,8 @@ static void acquire_privilege(const char *name, Error **errp)
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token))
{
if (!LookupPrivilegeValue(NULL, name, &priv.Privileges[0].Luid)) {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "no luid for requested privilege");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "no luid for requested privilege");
goto out;
}
@@ -191,14 +191,14 @@ static void acquire_privilege(const char *name, Error **errp)
priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &priv, 0, NULL, 0)) {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "unable to acquire requested privilege");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "unable to acquire requested privilege");
goto out;
}
} else {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "failed to open privilege token");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "failed to open privilege token");
}
out:
@@ -217,8 +217,8 @@ static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
HANDLE thread = CreateThread(NULL, 0, func, opaque, 0, NULL);
if (!thread) {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "failed to dispatch asynchronous command");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "failed to dispatch asynchronous command");
error_propagate(errp, local_err);
}
}
@@ -237,8 +237,8 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
} else if (strcmp(mode, "reboot") == 0) {
shutdown_flag |= EWX_REBOOT;
} else {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
- "halt|powerdown|reboot");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "mode",
+ "halt|powerdown|reboot");
return;
}
@@ -252,7 +252,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {
slog("guest-shutdown failed: %lu", GetLastError());
- error_set(errp, QERR_UNDEFINED_ERROR);
+ error_setg(errp, QERR_UNDEFINED_ERROR);
}
}
@@ -384,7 +384,7 @@ static void guest_file_init(void)
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
@@ -394,7 +394,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
{
if (!vss_initialized()) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
@@ -415,7 +415,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **errp)
Error *local_err = NULL;
if (!vss_initialized()) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
@@ -446,7 +446,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
strList *mountpoints,
Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
@@ -459,7 +459,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)
int i;
if (!vss_initialized()) {
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return 0;
}
@@ -495,7 +495,7 @@ static void guest_fsfreeze_cleanup(void)
*/
void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
typedef enum {
@@ -510,27 +510,27 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **errp)
ZeroMemory(&sys_pwr_caps, sizeof(sys_pwr_caps));
if (!GetPwrCapabilities(&sys_pwr_caps)) {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "failed to determine guest suspend capabilities");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "failed to determine guest suspend capabilities");
goto out;
}
switch (mode) {
case GUEST_SUSPEND_MODE_DISK:
if (!sys_pwr_caps.SystemS4) {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "suspend-to-disk not supported by OS");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "suspend-to-disk not supported by OS");
}
break;
case GUEST_SUSPEND_MODE_RAM:
if (!sys_pwr_caps.SystemS3) {
- error_set(&local_err, QERR_QGA_COMMAND_FAILED,
- "suspend-to-ram not supported by OS");
+ error_setg(&local_err, QERR_QGA_COMMAND_FAILED,
+ "suspend-to-ram not supported by OS");
}
break;
default:
- error_set(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
- "GuestSuspendMode");
+ error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
+ "GuestSuspendMode");
}
out:
@@ -586,12 +586,12 @@ void qmp_guest_suspend_ram(Error **errp)
void qmp_guest_suspend_hybrid(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
@@ -666,13 +666,13 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return -1;
}
@@ -681,25 +681,25 @@ void qmp_guest_set_user_password(const char *username,
bool crypted,
Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
}
GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
GuestMemoryBlockResponseList *
qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
diff --git a/qga/main.c b/qga/main.c
index 7e1e438f67..23cde0104a 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -578,7 +578,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens)
qdict = qdict_new();
if (!err) {
g_warning("failed to parse event: unknown error");
- error_set(&err, QERR_JSON_PARSING);
+ error_setg(&err, QERR_JSON_PARSING);
} else {
g_warning("failed to parse event: %s", error_get_pretty(err));
}
@@ -598,7 +598,7 @@ static void process_event(JSONMessageParser *parser, QList *tokens)
QDECREF(qdict);
qdict = qdict_new();
g_warning("unrecognized payload format");
- error_set(&err, QERR_UNSUPPORTED);
+ error_setg(&err, QERR_UNSUPPORTED);
qdict_put_obj(qdict, "error", qmp_build_error_object(err));
error_free(err);
}
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 1db6524e97..a05d25ff60 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -276,7 +276,7 @@ EQMP
.args_type = "device:O",
.params = "driver[,prop=value][,...]",
.help = "add device, like -device on the command line",
- .mhandler.cmd_new = do_device_add,
+ .mhandler.cmd_new = qmp_device_add,
},
SQMP
@@ -686,7 +686,7 @@ Notes:
(1) QEMU must be started with -incoming defer to allow migrate-incoming to
be used
-(2) The uri format is the same as to -incoming
+(2) The uri format is the same as for -incoming
EQMP
{
@@ -1983,7 +1983,7 @@ EQMP
.args_type = "",
.params = "",
.help = "enable QMP capabilities",
- .mhandler.cmd_new = do_qmp_capabilities,
+ .mhandler.cmd_new = qmp_capabilities,
},
SQMP
diff --git a/qmp.c b/qmp.c
index fa013e31b8..403805a551 100644
--- a/qmp.c
+++ b/qmp.c
@@ -14,6 +14,7 @@
*/
#include "qemu-common.h"
+#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
#include "qmp-commands.h"
#include "sysemu/char.h"
@@ -24,6 +25,7 @@
#include "hw/qdev.h"
#include "sysemu/blockdev.h"
#include "qom/qom-qobject.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp-input-visitor.h"
#include "hw/boards.h"
@@ -132,13 +134,13 @@ void qmp_cpu_add(int64_t id, Error **errp)
defined in the VNC subsystem */
VncInfo *qmp_query_vnc(Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+ error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
return NULL;
};
VncInfo2List *qmp_query_vnc_servers(Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+ error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
return NULL;
};
#endif
@@ -206,7 +208,8 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
if (ambiguous) {
error_setg(errp, "Path '%s' is ambiguous", path);
} else {
- error_set(errp, QERR_DEVICE_NOT_FOUND, path);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", path);
}
return NULL;
}
@@ -226,55 +229,37 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
}
/* FIXME: teach qapi about how to pass through Visitors */
-int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_qom_set(QDict *qdict, QObject **ret, Error **errp)
{
const char *path = qdict_get_str(qdict, "path");
const char *property = qdict_get_str(qdict, "property");
QObject *value = qdict_get(qdict, "value");
- Error *local_err = NULL;
Object *obj;
obj = object_resolve_path(path, NULL);
if (!obj) {
- error_set(&local_err, QERR_DEVICE_NOT_FOUND, path);
- goto out;
- }
-
- object_property_set_qobject(obj, value, property, &local_err);
-
-out:
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", path);
+ return;
}
- return 0;
+ object_property_set_qobject(obj, value, property, errp);
}
-int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_qom_get(QDict *qdict, QObject **ret, Error **errp)
{
const char *path = qdict_get_str(qdict, "path");
const char *property = qdict_get_str(qdict, "property");
- Error *local_err = NULL;
Object *obj;
obj = object_resolve_path(path, NULL);
if (!obj) {
- error_set(&local_err, QERR_DEVICE_NOT_FOUND, path);
- goto out;
- }
-
- *ret = object_property_get_qobject(obj, property, &local_err);
-
-out:
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", path);
+ return;
}
- return 0;
+ *ret = object_property_get_qobject(obj, property, errp);
}
void qmp_set_password(const char *protocol, const char *password,
@@ -292,7 +277,7 @@ void qmp_set_password(const char *protocol, const char *password,
} else if (strcmp(connected, "keep") == 0) {
/* nothing */
} else {
- error_set(errp, QERR_INVALID_PARAMETER, "connected");
+ error_setg(errp, QERR_INVALID_PARAMETER, "connected");
return;
}
}
@@ -304,7 +289,7 @@ void qmp_set_password(const char *protocol, const char *password,
rc = qemu_spice_set_passwd(password, fail_if_connected,
disconnect_if_connected);
if (rc != 0) {
- error_set(errp, QERR_SET_PASSWD_FAILED);
+ error_setg(errp, QERR_SET_PASSWD_FAILED);
}
return;
}
@@ -312,19 +297,19 @@ void qmp_set_password(const char *protocol, const char *password,
if (strcmp(protocol, "vnc") == 0) {
if (fail_if_connected || disconnect_if_connected) {
/* vnc supports "connected=keep" only */
- error_set(errp, QERR_INVALID_PARAMETER, "connected");
+ error_setg(errp, QERR_INVALID_PARAMETER, "connected");
return;
}
/* Note that setting an empty password will not disable login through
* this interface. */
rc = vnc_display_password(NULL, password);
if (rc < 0) {
- error_set(errp, QERR_SET_PASSWD_FAILED);
+ error_setg(errp, QERR_SET_PASSWD_FAILED);
}
return;
}
- error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+ error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
}
void qmp_expire_password(const char *protocol, const char *whenstr,
@@ -349,7 +334,7 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
}
rc = qemu_spice_set_pw_expire(when);
if (rc != 0) {
- error_set(errp, QERR_SET_PASSWD_FAILED);
+ error_setg(errp, QERR_SET_PASSWD_FAILED);
}
return;
}
@@ -357,19 +342,19 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
if (strcmp(protocol, "vnc") == 0) {
rc = vnc_display_pw_expire(NULL, when);
if (rc != 0) {
- error_set(errp, QERR_SET_PASSWD_FAILED);
+ error_setg(errp, QERR_SET_PASSWD_FAILED);
}
return;
}
- error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+ error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
}
#ifdef CONFIG_VNC
void qmp_change_vnc_password(const char *password, Error **errp)
{
if (vnc_display_password(NULL, password) < 0) {
- error_set(errp, QERR_SET_PASSWD_FAILED);
+ error_setg(errp, QERR_SET_PASSWD_FAILED);
}
}
@@ -387,7 +372,7 @@ static void qmp_change_vnc_listen(const char *target, Error **errp)
if (opts) {
qemu_opts_del(opts);
}
- opts = vnc_parse_func(target);
+ opts = vnc_parse(target, errp);
if (!opts) {
return;
}
@@ -400,7 +385,7 @@ static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
{
if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
if (!has_arg) {
- error_set(errp, QERR_MISSING_PARAMETER, "password");
+ error_setg(errp, QERR_MISSING_PARAMETER, "password");
} else {
qmp_change_vnc_password(arg, errp);
}
@@ -411,12 +396,12 @@ static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
#else
void qmp_change_vnc_password(const char *password, Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+ error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
}
static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
Error **errp)
{
- error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+ error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
}
#endif /* !CONFIG_VNC */
@@ -518,14 +503,14 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
klass = object_class_by_name(typename);
if (klass == NULL) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, typename);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", typename);
return NULL;
}
klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
if (klass == NULL) {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE,
- "name", TYPE_DEVICE);
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "name", TYPE_DEVICE);
return NULL;
}
@@ -670,35 +655,25 @@ out:
object_unref(obj);
}
-int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret)
+void qmp_object_add(QDict *qdict, QObject **ret, Error **errp)
{
const char *type = qdict_get_str(qdict, "qom-type");
const char *id = qdict_get_str(qdict, "id");
QObject *props = qdict_get(qdict, "props");
const QDict *pdict = NULL;
- Error *local_err = NULL;
QmpInputVisitor *qiv;
if (props) {
pdict = qobject_to_qdict(props);
if (!pdict) {
- error_set(&local_err, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
- goto out;
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
+ return;
}
}
qiv = qmp_input_visitor_new(props);
- object_add(type, id, pdict, qmp_input_get_visitor(qiv), &local_err);
+ object_add(type, id, pdict, qmp_input_get_visitor(qiv), errp);
qmp_input_visitor_cleanup(qiv);
-
-out:
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
- }
-
- return 0;
}
void qmp_object_del(const char *id, Error **errp)
diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs
index f7595f56fe..0031e8b691 100644
--- a/qobject/Makefile.objs
+++ b/qobject/Makefile.objs
@@ -1,3 +1,2 @@
util-obj-y = qnull.o qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
-util-obj-y += qerror.o
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 717cb8fde7..ac991ba3cf 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -22,7 +22,6 @@
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/json-parser.h"
#include "qapi/qmp/json-lexer.h"
-#include "qapi/qmp/qerror.h"
typedef struct JSONParserContext
{
@@ -558,9 +557,9 @@ static QObject *parse_keyword(JSONParserContext *ctxt)
}
if (token_is_keyword(token, "true")) {
- ret = QOBJECT(qbool_from_int(true));
+ ret = QOBJECT(qbool_from_bool(true));
} else if (token_is_keyword(token, "false")) {
- ret = QOBJECT(qbool_from_int(false));
+ ret = QOBJECT(qbool_from_bool(false));
} else if (token_is_keyword(token, "null")) {
ret = qnull();
} else {
@@ -593,7 +592,7 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap)
if (token_is_escape(token, "%p")) {
obj = va_arg(*ap, QObject *);
} else if (token_is_escape(token, "%i")) {
- obj = QOBJECT(qbool_from_int(va_arg(*ap, int)));
+ obj = QOBJECT(qbool_from_bool(va_arg(*ap, int)));
} else if (token_is_escape(token, "%d")) {
obj = QOBJECT(qint_from_int(va_arg(*ap, int)));
} else if (token_is_escape(token, "%ld")) {
diff --git a/qobject/qbool.c b/qobject/qbool.c
index a3d2afa827..5ff69f0b2d 100644
--- a/qobject/qbool.c
+++ b/qobject/qbool.c
@@ -23,11 +23,11 @@ static const QType qbool_type = {
};
/**
- * qbool_from_int(): Create a new QBool from an int
+ * qbool_from_bool(): Create a new QBool from a bool
*
* Return strong reference.
*/
-QBool *qbool_from_int(int value)
+QBool *qbool_from_bool(bool value)
{
QBool *qb;
@@ -39,9 +39,9 @@ QBool *qbool_from_int(int value)
}
/**
- * qbool_get_int(): Get the stored int
+ * qbool_get_bool(): Get the stored bool
*/
-int qbool_get_int(const QBool *qb)
+bool qbool_get_bool(const QBool *qb)
{
return qb->value;
}
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 190791becf..67b1a58abf 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -241,10 +241,10 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
*
* Return bool mapped by 'key'.
*/
-int qdict_get_bool(const QDict *qdict, const char *key)
+bool qdict_get_bool(const QDict *qdict, const char *key)
{
QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
- return qbool_get_int(qobject_to_qbool(obj));
+ return qbool_get_bool(qobject_to_qbool(obj));
}
/**
@@ -314,7 +314,7 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key,
* dictionary or if the stored object is not of QBool type
* 'def_value' will be returned.
*/
-int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value)
+bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value)
{
QObject *obj;
@@ -322,7 +322,7 @@ int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value)
if (!obj || qobject_type(obj) != QTYPE_QBOOL)
return def_value;
- return qbool_get_int(qobject_to_qbool(obj));
+ return qbool_get_bool(qobject_to_qbool(obj));
}
/**
diff --git a/qobject/qerror.c b/qobject/qerror.c
deleted file mode 100644
index e3608e2402..0000000000
--- a/qobject/qerror.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * QError Module
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- * Luiz Capitulino <lcapitulino@redhat.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- */
-
-#include "monitor/monitor.h"
-#include "qapi/qmp/qjson.h"
-#include "qapi/qmp/qerror.h"
-#include "qemu-common.h"
-
-static void qerror_destroy_obj(QObject *obj);
-
-static const QType qerror_type = {
- .code = QTYPE_QERROR,
- .destroy = qerror_destroy_obj,
-};
-
-/**
- * qerror_new(): Create a new QError
- *
- * Return strong reference.
- */
-static QError *qerror_new(void)
-{
- QError *qerr;
-
- qerr = g_malloc0(sizeof(*qerr));
- QOBJECT_INIT(qerr, &qerror_type);
-
- return qerr;
-}
-
-/**
- * qerror_from_info(): Create a new QError from error information
- *
- * Return strong reference.
- */
-static QError * GCC_FMT_ATTR(2, 0)
-qerror_from_info(ErrorClass err_class, const char *fmt, va_list *va)
-{
- QError *qerr;
-
- qerr = qerror_new();
- loc_save(&qerr->loc);
-
- qerr->err_msg = g_strdup_vprintf(fmt, *va);
- qerr->err_class = err_class;
-
- return qerr;
-}
-
-/**
- * qerror_human(): Format QError data into human-readable string.
- */
-QString *qerror_human(const QError *qerror)
-{
- return qstring_from_str(qerror->err_msg);
-}
-
-/**
- * qerror_print(): Print QError data
- *
- * This function will print the member 'desc' of the specified QError object,
- * it uses error_report() for this, so that the output is routed to the right
- * place (ie. stderr or Monitor's device).
- */
-static void qerror_print(QError *qerror)
-{
- QString *qstring = qerror_human(qerror);
- loc_push_restore(&qerror->loc);
- error_report("%s", qstring_get_str(qstring));
- loc_pop(&qerror->loc);
- QDECREF(qstring);
-}
-
-void qerror_report(ErrorClass eclass, const char *fmt, ...)
-{
- va_list va;
- QError *qerror;
-
- va_start(va, fmt);
- qerror = qerror_from_info(eclass, fmt, &va);
- va_end(va);
-
- if (monitor_cur_is_qmp()) {
- monitor_set_error(cur_mon, qerror);
- } else {
- qerror_print(qerror);
- QDECREF(qerror);
- }
-}
-
-/* Evil... */
-struct Error
-{
- char *msg;
- ErrorClass err_class;
-};
-
-void qerror_report_err(Error *err)
-{
- QError *qerr;
-
- qerr = qerror_new();
- loc_save(&qerr->loc);
- qerr->err_msg = g_strdup(err->msg);
- qerr->err_class = err->err_class;
-
- if (monitor_cur_is_qmp()) {
- monitor_set_error(cur_mon, qerr);
- } else {
- qerror_print(qerr);
- QDECREF(qerr);
- }
-}
-
-/**
- * qobject_to_qerror(): Convert a QObject into a QError
- */
-static QError *qobject_to_qerror(const QObject *obj)
-{
- if (qobject_type(obj) != QTYPE_QERROR) {
- return NULL;
- }
-
- return container_of(obj, QError, base);
-}
-
-/**
- * qerror_destroy_obj(): Free all memory allocated by a QError
- */
-static void qerror_destroy_obj(QObject *obj)
-{
- QError *qerr;
-
- assert(obj != NULL);
- qerr = qobject_to_qerror(obj);
-
- g_free(qerr->err_msg);
- g_free(qerr);
-}
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 846733dafb..33f8ef530c 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -254,16 +254,13 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
case QTYPE_QBOOL: {
QBool *val = qobject_to_qbool(obj);
- if (qbool_get_int(val)) {
+ if (qbool_get_bool(val)) {
qstring_append(str, "true");
} else {
qstring_append(str, "false");
}
break;
}
- case QTYPE_QERROR:
- /* XXX: should QError be emitted? */
- break;
default:
abort();
}
diff --git a/qom/object.c b/qom/object.c
index ee384311f9..eea8edf3d3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -926,7 +926,7 @@ void object_property_get(Object *obj, Visitor *v, const char *name,
}
if (!prop->get) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_setg(errp, QERR_PERMISSION_DENIED);
} else {
prop->get(obj, v, prop->opaque, name, errp);
}
@@ -941,7 +941,7 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
}
if (!prop->set) {
- error_set(errp, QERR_PERMISSION_DENIED);
+ error_setg(errp, QERR_PERMISSION_DENIED);
} else {
prop->set(obj, v, prop->opaque, name, errp);
}
@@ -968,7 +968,7 @@ char *object_property_get_str(Object *obj, const char *name,
}
qstring = qobject_to_qstring(ret);
if (!qstring) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
retval = NULL;
} else {
retval = g_strdup(qstring_get_str(qstring));
@@ -999,7 +999,8 @@ Object *object_property_get_link(Object *obj, const char *name,
if (str && *str) {
target = object_resolve_path(str, NULL);
if (!target) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, str);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", str);
}
}
@@ -1010,7 +1011,7 @@ Object *object_property_get_link(Object *obj, const char *name,
void object_property_set_bool(Object *obj, bool value,
const char *name, Error **errp)
{
- QBool *qbool = qbool_from_int(value);
+ QBool *qbool = qbool_from_bool(value);
object_property_set_qobject(obj, QOBJECT(qbool), name, errp);
QDECREF(qbool);
@@ -1028,10 +1029,10 @@ bool object_property_get_bool(Object *obj, const char *name,
}
qbool = qobject_to_qbool(ret);
if (!qbool) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean");
retval = false;
} else {
- retval = qbool_get_int(qbool);
+ retval = qbool_get_bool(qbool);
}
QDECREF(qbool);
@@ -1059,7 +1060,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
}
qint = qobject_to_qint(ret);
if (!qint) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
retval = -1;
} else {
retval = qint_get_int(qint);
@@ -1303,9 +1304,10 @@ static Object *object_resolve_link(Object *obj, const char *name,
} else if (!target) {
target = object_resolve_path(path, &ambiguous);
if (target || ambiguous) {
- error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
} else {
- error_set(errp, QERR_DEVICE_NOT_FOUND, path);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", path);
}
target = NULL;
}
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 1c1d3aa029..ca22acc1d5 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -195,12 +195,10 @@ out:
return ret
def gen_marshal_input_decl(name, args, ret_type, middle_mode):
- if middle_mode:
- return 'int qmp_marshal_input_%s(Monitor *mon, const QDict *qdict, QObject **ret)' % c_name(name)
- else:
- return 'static void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
-
-
+ ret = 'void qmp_marshal_input_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
+ if not middle_mode:
+ ret = "static " + ret
+ return ret
def gen_marshal_input(name, args, ret_type, middle_mode):
hdr = gen_marshal_input_decl(name, args, ret_type, middle_mode)
@@ -212,11 +210,6 @@ def gen_marshal_input(name, args, ret_type, middle_mode):
''',
header=hdr)
- if middle_mode:
- ret += mcgen('''
- QDict *args = (QDict *)qdict;
-''')
-
if ret_type:
if is_c_ptr(ret_type):
retval = " %s retval = NULL;" % c_type(ret_type)
@@ -253,35 +246,13 @@ def gen_marshal_input(name, args, ret_type, middle_mode):
out:
''')
- if not middle_mode:
- ret += mcgen('''
- error_propagate(errp, local_err);
-''')
ret += mcgen('''
+ error_propagate(errp, local_err);
%(visitor_input_block_cleanup)s
+}
''',
visitor_input_block_cleanup=gen_visitor_input_block(args,
dealloc=True))
-
- if middle_mode:
- ret += mcgen('''
-
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
- }
- return 0;
-''')
- else:
- ret += mcgen('''
- return;
-''')
-
- ret += mcgen('''
-}
-''')
-
return ret
def gen_registry(commands):
@@ -358,7 +329,6 @@ h_comment = '''
fdef.write(mcgen('''
#include "qemu-common.h"
#include "qemu/module.h"
-#include "qapi/qmp/qerror.h"
#include "qapi/qmp/types.h"
#include "qapi/qmp/dispatch.h"
#include "qapi/visitor.h"
diff --git a/slirp/misc.c b/slirp/misc.c
index 6543dc7772..578e8b2c16 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -9,6 +9,7 @@
#include <libslirp.h>
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#ifdef DEBUG
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 8beff4c732..9937a1295e 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -21,7 +21,6 @@ stub-obj-y += machine-init-done.o
stub-obj-y += migr-blocker.o
stub-obj-y += mon-is-qmp.o
stub-obj-y += mon-printf.o
-stub-obj-y += mon-set-error.o
stub-obj-y += monitor-init.o
stub-obj-y += notify-event.o
stub-obj-$(CONFIG_SPICE) += qemu-chr-open-spice.o
diff --git a/stubs/arch-query-cpu-def.c b/stubs/arch-query-cpu-def.c
index 22e0b43de9..a975ab453a 100644
--- a/stubs/arch-query-cpu-def.c
+++ b/stubs/arch-query-cpu-def.c
@@ -4,6 +4,6 @@
CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
{
- error_set(errp, QERR_UNSUPPORTED);
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
diff --git a/stubs/dump.c b/stubs/dump.c
index fac70191eb..8c24eda847 100644
--- a/stubs/dump.c
+++ b/stubs/dump.c
@@ -13,7 +13,6 @@
#include "qemu-common.h"
#include "sysemu/dump-arch.h"
-#include "qapi/qmp/qerror.h"
#include "qmp-commands.h"
int cpu_get_dump_info(ArchDumpInfo *info,
diff --git a/stubs/mon-is-qmp.c b/stubs/mon-is-qmp.c
index 1ef136ab1d..dd26f19c87 100644
--- a/stubs/mon-is-qmp.c
+++ b/stubs/mon-is-qmp.c
@@ -1,6 +1,8 @@
#include "qemu-common.h"
#include "monitor/monitor.h"
+Monitor *cur_mon;
+
bool monitor_cur_is_qmp(void)
{
return false;
diff --git a/stubs/mon-set-error.c b/stubs/mon-set-error.c
deleted file mode 100644
index d0411f97fa..0000000000
--- a/stubs/mon-set-error.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qemu-common.h"
-#include "monitor/monitor.h"
-
-Monitor *cur_mon;
-
-void monitor_set_error(Monitor *mon, QError *qerror)
-{
-}
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index e9927b56b4..81d4ff827c 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -2939,7 +2939,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, ctx.pc - pc_start, 1);
+ log_target_disas(cs, pc_start, ctx.pc - pc_start, 1);
qemu_log("\n");
}
#endif
diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c
index 74a67e9fdd..a2a7369567 100644
--- a/target-arm/arm-semi.c
+++ b/target-arm/arm-semi.c
@@ -436,12 +436,19 @@ uint32_t do_arm_semihosting(CPUARMState *env)
size_t input_size;
size_t output_size;
int status = 0;
+#if !defined(CONFIG_USER_ONLY)
+ const char *cmdline;
+#endif
GET_ARG(0);
GET_ARG(1);
input_size = arg1;
/* Compute the size of the output string. */
#if !defined(CONFIG_USER_ONLY)
- output_size = strlen(semihosting_get_cmdline()) + 1;
+ cmdline = semihosting_get_cmdline();
+ if (cmdline == NULL) {
+ cmdline = ""; /* Default to an empty line. */
+ }
+ output_size = strlen(cmdline) + 1; /* Count terminating 0. */
#else
unsigned int i;
@@ -472,7 +479,7 @@ uint32_t do_arm_semihosting(CPUARMState *env)
/* Copy the command-line arguments. */
#if !defined(CONFIG_USER_ONLY)
- pstrcpy(output_buffer, output_size, semihosting_get_cmdline());
+ pstrcpy(output_buffer, output_size, cmdline);
#else
if (output_size == 1) {
/* Empty command-line. */
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index b3d07ac7d8..80669a6d1b 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -22,7 +22,6 @@
#include "internals.h"
#include "qemu-common.h"
#include "hw/qdev-properties.h"
-#include "qapi/qmp/qerror.h"
#if !defined(CONFIG_USER_ONLY)
#include "hw/loader.h"
#endif
diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c
index e30af0659e..08c95a3f52 100644
--- a/target-arm/helper-a64.c
+++ b/target-arm/helper-a64.c
@@ -533,6 +533,8 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
env->condexec_bits = 0;
}
+ qemu_log_mask(CPU_LOG_INT, "...with ELR 0x%" PRIx64 "\n",
+ env->elr_el[new_el]);
pstate_write(env, PSTATE_DAIF | new_mode);
env->aarch64 = 1;
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
index ffa6cb8e56..e077f2dc30 100644
--- a/target-arm/translate-a64.c
+++ b/target-arm/translate-a64.c
@@ -11128,7 +11128,7 @@ done_generating:
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, dc->pc - pc_start,
+ log_target_disas(cs, pc_start, dc->pc - pc_start,
4 | (dc->bswap_code << 1));
qemu_log("\n");
}
diff --git a/target-arm/translate.c b/target-arm/translate.c
index ead08f4820..971b6db061 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -11485,7 +11485,7 @@ done_generating:
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, dc->pc - pc_start,
+ log_target_disas(cs, pc_start, dc->pc - pc_start,
dc->thumb | (dc->bswap_code << 1));
qemu_log("\n");
}
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 687c88be28..3e59601eb4 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3345,7 +3345,7 @@ gen_intermediate_code_internal(CRISCPU *cpu, TranslationBlock *tb,
#ifdef DEBUG_DISAS
#if !DISAS_CRIS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
- log_target_disas(env, pc_start, dc->pc - pc_start,
+ log_target_disas(cs, pc_start, dc->pc - pc_start,
env->pregs[PR_VR]);
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4e7cdaaaa5..36b07f99aa 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -26,6 +26,7 @@
#include "sysemu/cpus.h"
#include "kvm_i386.h"
+#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/qmp/qerror.h"
@@ -1524,8 +1525,8 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque,
return;
}
if (value < min || value > max) {
- error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
- name ? name : "null", value, min, max);
+ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+ name ? name : "null", value, min, max);
return;
}
@@ -1565,8 +1566,8 @@ static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque,
return;
}
if (value < min || value > max) {
- error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
- name ? name : "null", value, min, max);
+ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+ name ? name : "null", value, min, max);
return;
}
@@ -1603,8 +1604,8 @@ static void x86_cpuid_version_set_stepping(Object *obj, Visitor *v,
return;
}
if (value < min || value > max) {
- error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
- name ? name : "null", value, min, max);
+ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+ name ? name : "null", value, min, max);
return;
}
@@ -1632,8 +1633,7 @@ static void x86_cpuid_set_vendor(Object *obj, const char *value,
int i;
if (strlen(value) != CPUID_VENDOR_SZ) {
- error_set(errp, QERR_PROPERTY_VALUE_BAD, "",
- "vendor", value);
+ error_setg(errp, QERR_PROPERTY_VALUE_BAD, "", "vendor", value);
return;
}
@@ -1709,8 +1709,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
return;
}
if (value < min || value > max) {
- error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
- name ? name : "null", value, min, max);
+ error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
+ name ? name : "null", value, min, max);
return;
}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 5a236e3103..daced5cb94 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -36,7 +36,6 @@
#include <asm/hyperv.h>
#include "hw/pci/pci.h"
#include "migration/migration.h"
-#include "qapi/qmp/qerror.h"
#include "exec/memattrs.h"
//#define DEBUG_KVM
diff --git a/target-i386/translate.c b/target-i386/translate.c
index 58b1959154..7a1bdee271 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -8093,7 +8093,7 @@ done_generating:
else
#endif
disas_flags = !dc->code32;
- log_target_disas(env, pc_start, pc_ptr - pc_start, disas_flags);
+ log_target_disas(cs, pc_start, pc_ptr - pc_start, disas_flags);
qemu_log("\n");
}
#endif
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index 81a204f5cf..cf7042e3e0 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -1168,7 +1168,7 @@ void gen_intermediate_code_internal(LM32CPU *cpu,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("\n");
- log_target_disas(env, pc_start, dc->pc - pc_start, 0);
+ log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
}
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 96d75bf956..d6c478fd28 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -3077,7 +3077,7 @@ gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb,
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, dc->pc - pc_start, 0);
+ log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
}
#endif
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 1f5fe9afcd..f4e969b29c 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -1851,7 +1851,7 @@ gen_intermediate_code_internal(MicroBlazeCPU *cpu, TranslationBlock *tb,
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("\n");
#if DISAS_GNU
- log_target_disas(env, pc_start, dc->pc - pc_start, 0);
+ log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
#endif
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
diff --git a/target-mips/Makefile.objs b/target-mips/Makefile.objs
index 108fd9b501..bc5ed8511f 100644
--- a/target-mips/Makefile.objs
+++ b/target-mips/Makefile.objs
@@ -1,4 +1,4 @@
obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o
-obj-y += gdbstub.o msa_helper.o
+obj-y += gdbstub.o msa_helper.o mips-semi.o
obj-$(CONFIG_SOFTMMU) += machine.o
obj-$(CONFIG_KVM) += kvm.o
diff --git a/target-mips/helper.h b/target-mips/helper.h
index 8df98c71b8..2b28e875cf 100644
--- a/target-mips/helper.h
+++ b/target-mips/helper.h
@@ -1,6 +1,8 @@
DEF_HELPER_3(raise_exception_err, noreturn, env, i32, int)
DEF_HELPER_2(raise_exception, noreturn, env, i32)
+DEF_HELPER_1(do_semihosting, void, env)
+
#ifdef TARGET_MIPS64
DEF_HELPER_4(sdl, void, env, tl, tl, int)
DEF_HELPER_4(sdr, void, env, tl, tl, int)
diff --git a/target-mips/mips-semi.c b/target-mips/mips-semi.c
new file mode 100644
index 0000000000..1162c76df9
--- /dev/null
+++ b/target-mips/mips-semi.c
@@ -0,0 +1,358 @@
+/*
+ * Unified Hosting Interface syscalls.
+ *
+ * Copyright (c) 2015 Imagination Technologies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/stat.h>
+#include "cpu.h"
+#include "exec/helper-proto.h"
+#include "exec/softmmu-semi.h"
+#include "exec/semihost.h"
+
+typedef enum UHIOp {
+ UHI_exit = 1,
+ UHI_open = 2,
+ UHI_close = 3,
+ UHI_read = 4,
+ UHI_write = 5,
+ UHI_lseek = 6,
+ UHI_unlink = 7,
+ UHI_fstat = 8,
+ UHI_argc = 9,
+ UHI_argnlen = 10,
+ UHI_argn = 11,
+ UHI_plog = 13,
+ UHI_assert = 14,
+ UHI_pread = 19,
+ UHI_pwrite = 20,
+ UHI_link = 22
+} UHIOp;
+
+typedef struct UHIStat {
+ int16_t uhi_st_dev;
+ uint16_t uhi_st_ino;
+ uint32_t uhi_st_mode;
+ uint16_t uhi_st_nlink;
+ uint16_t uhi_st_uid;
+ uint16_t uhi_st_gid;
+ int16_t uhi_st_rdev;
+ uint64_t uhi_st_size;
+ uint64_t uhi_st_atime;
+ uint64_t uhi_st_spare1;
+ uint64_t uhi_st_mtime;
+ uint64_t uhi_st_spare2;
+ uint64_t uhi_st_ctime;
+ uint64_t uhi_st_spare3;
+ uint64_t uhi_st_blksize;
+ uint64_t uhi_st_blocks;
+ uint64_t uhi_st_spare4[2];
+} UHIStat;
+
+enum UHIOpenFlags {
+ UHIOpen_RDONLY = 0x0,
+ UHIOpen_WRONLY = 0x1,
+ UHIOpen_RDWR = 0x2,
+ UHIOpen_APPEND = 0x8,
+ UHIOpen_CREAT = 0x200,
+ UHIOpen_TRUNC = 0x400,
+ UHIOpen_EXCL = 0x800
+};
+
+/* Errno values taken from asm-mips/errno.h */
+static uint16_t host_to_mips_errno[] = {
+ [ENAMETOOLONG] = 78,
+#ifdef EOVERFLOW
+ [EOVERFLOW] = 79,
+#endif
+#ifdef ELOOP
+ [ELOOP] = 90,
+#endif
+};
+
+static int errno_mips(int err)
+{
+ if (err < 0 || err >= ARRAY_SIZE(host_to_mips_errno)) {
+ return EINVAL;
+ } else if (host_to_mips_errno[err]) {
+ return host_to_mips_errno[err];
+ } else {
+ return err;
+ }
+}
+
+static int copy_stat_to_target(CPUMIPSState *env, const struct stat *src,
+ target_ulong vaddr)
+{
+ hwaddr len = sizeof(struct UHIStat);
+ UHIStat *dst = lock_user(VERIFY_WRITE, vaddr, len, 0);
+ if (!dst) {
+ errno = EFAULT;
+ return -1;
+ }
+
+ dst->uhi_st_dev = tswap16(src->st_dev);
+ dst->uhi_st_ino = tswap16(src->st_ino);
+ dst->uhi_st_mode = tswap32(src->st_mode);
+ dst->uhi_st_nlink = tswap16(src->st_nlink);
+ dst->uhi_st_uid = tswap16(src->st_uid);
+ dst->uhi_st_gid = tswap16(src->st_gid);
+ dst->uhi_st_rdev = tswap16(src->st_rdev);
+ dst->uhi_st_size = tswap64(src->st_size);
+ dst->uhi_st_atime = tswap64(src->st_atime);
+ dst->uhi_st_mtime = tswap64(src->st_mtime);
+ dst->uhi_st_ctime = tswap64(src->st_ctime);
+#ifdef _WIN32
+ dst->uhi_st_blksize = 0;
+ dst->uhi_st_blocks = 0;
+#else
+ dst->uhi_st_blksize = tswap64(src->st_blksize);
+ dst->uhi_st_blocks = tswap64(src->st_blocks);
+#endif
+ unlock_user(dst, vaddr, len);
+ return 0;
+}
+
+static int get_open_flags(target_ulong target_flags)
+{
+ int open_flags = 0;
+
+ if (target_flags & UHIOpen_RDWR) {
+ open_flags |= O_RDWR;
+ } else if (target_flags & UHIOpen_WRONLY) {
+ open_flags |= O_WRONLY;
+ } else {
+ open_flags |= O_RDONLY;
+ }
+
+ open_flags |= (target_flags & UHIOpen_APPEND) ? O_APPEND : 0;
+ open_flags |= (target_flags & UHIOpen_CREAT) ? O_CREAT : 0;
+ open_flags |= (target_flags & UHIOpen_TRUNC) ? O_TRUNC : 0;
+ open_flags |= (target_flags & UHIOpen_EXCL) ? O_EXCL : 0;
+
+ return open_flags;
+}
+
+static int write_to_file(CPUMIPSState *env, target_ulong fd, target_ulong vaddr,
+ target_ulong len, target_ulong offset)
+{
+ int num_of_bytes;
+ void *dst = lock_user(VERIFY_READ, vaddr, len, 1);
+ if (!dst) {
+ errno = EFAULT;
+ return -1;
+ }
+
+ if (offset) {
+#ifdef _WIN32
+ num_of_bytes = 0;
+#else
+ num_of_bytes = pwrite(fd, dst, len, offset);
+#endif
+ } else {
+ num_of_bytes = write(fd, dst, len);
+ }
+
+ unlock_user(dst, vaddr, 0);
+ return num_of_bytes;
+}
+
+static int read_from_file(CPUMIPSState *env, target_ulong fd,
+ target_ulong vaddr, target_ulong len,
+ target_ulong offset)
+{
+ int num_of_bytes;
+ void *dst = lock_user(VERIFY_WRITE, vaddr, len, 0);
+ if (!dst) {
+ errno = EFAULT;
+ return -1;
+ }
+
+ if (offset) {
+#ifdef _WIN32
+ num_of_bytes = 0;
+#else
+ num_of_bytes = pread(fd, dst, len, offset);
+#endif
+ } else {
+ num_of_bytes = read(fd, dst, len);
+ }
+
+ unlock_user(dst, vaddr, len);
+ return num_of_bytes;
+}
+
+static int copy_argn_to_target(CPUMIPSState *env, int arg_num,
+ target_ulong vaddr)
+{
+ int strsize = strlen(semihosting_get_arg(arg_num)) + 1;
+ char *dst = lock_user(VERIFY_WRITE, vaddr, strsize, 0);
+ if (!dst) {
+ return -1;
+ }
+
+ strcpy(dst, semihosting_get_arg(arg_num));
+
+ unlock_user(dst, vaddr, strsize);
+ return 0;
+}
+
+#define GET_TARGET_STRING(p, addr) \
+ do { \
+ p = lock_user_string(addr); \
+ if (!p) { \
+ gpr[2] = -1; \
+ gpr[3] = EFAULT; \
+ goto uhi_done; \
+ } \
+ } while (0)
+
+#define FREE_TARGET_STRING(p, gpr) \
+ do { \
+ unlock_user(p, gpr, 0); \
+ } while (0)
+
+void helper_do_semihosting(CPUMIPSState *env)
+{
+ target_ulong *gpr = env->active_tc.gpr;
+ const UHIOp op = gpr[25];
+ char *p, *p2;
+
+ switch (op) {
+ case UHI_exit:
+ qemu_log("UHI(%d): exit(%d)\n", op, (int)gpr[4]);
+ exit(gpr[4]);
+ case UHI_open:
+ GET_TARGET_STRING(p, gpr[4]);
+ if (!strcmp("/dev/stdin", p)) {
+ gpr[2] = 0;
+ } else if (!strcmp("/dev/stdout", p)) {
+ gpr[2] = 1;
+ } else if (!strcmp("/dev/stderr", p)) {
+ gpr[2] = 2;
+ } else {
+ gpr[2] = open(p, get_open_flags(gpr[5]), gpr[6]);
+ gpr[3] = errno_mips(errno);
+ }
+ FREE_TARGET_STRING(p, gpr[4]);
+ break;
+ case UHI_close:
+ if (gpr[4] < 3) {
+ /* ignore closing stdin/stdout/stderr */
+ gpr[2] = 0;
+ goto uhi_done;
+ }
+ gpr[2] = close(gpr[4]);
+ gpr[3] = errno_mips(errno);
+ break;
+ case UHI_read:
+ gpr[2] = read_from_file(env, gpr[4], gpr[5], gpr[6], 0);
+ gpr[3] = errno_mips(errno);
+ break;
+ case UHI_write:
+ gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6], 0);
+ gpr[3] = errno_mips(errno);
+ break;
+ case UHI_lseek:
+ gpr[2] = lseek(gpr[4], gpr[5], gpr[6]);
+ gpr[3] = errno_mips(errno);
+ break;
+ case UHI_unlink:
+ GET_TARGET_STRING(p, gpr[4]);
+ gpr[2] = remove(p);
+ gpr[3] = errno_mips(errno);
+ FREE_TARGET_STRING(p, gpr[4]);
+ break;
+ case UHI_fstat:
+ {
+ struct stat sbuf;
+ memset(&sbuf, 0, sizeof(sbuf));
+ gpr[2] = fstat(gpr[4], &sbuf);
+ gpr[3] = errno_mips(errno);
+ if (gpr[2]) {
+ goto uhi_done;
+ }
+ gpr[2] = copy_stat_to_target(env, &sbuf, gpr[5]);
+ gpr[3] = errno_mips(errno);
+ }
+ break;
+ case UHI_argc:
+ gpr[2] = semihosting_get_argc();
+ break;
+ case UHI_argnlen:
+ if (gpr[4] >= semihosting_get_argc()) {
+ gpr[2] = -1;
+ goto uhi_done;
+ }
+ gpr[2] = strlen(semihosting_get_arg(gpr[4]));
+ break;
+ case UHI_argn:
+ if (gpr[4] >= semihosting_get_argc()) {
+ gpr[2] = -1;
+ goto uhi_done;
+ }
+ gpr[2] = copy_argn_to_target(env, gpr[4], gpr[5]);
+ break;
+ case UHI_plog:
+ GET_TARGET_STRING(p, gpr[4]);
+ p2 = strstr(p, "%d");
+ if (p2) {
+ int char_num = p2 - p;
+ char *buf = g_malloc(char_num + 1);
+ strncpy(buf, p, char_num);
+ buf[char_num] = '\0';
+ gpr[2] = printf("%s%d%s", buf, (int)gpr[5], p2 + 2);
+ g_free(buf);
+ } else {
+ gpr[2] = printf("%s", p);
+ }
+ FREE_TARGET_STRING(p, gpr[4]);
+ break;
+ case UHI_assert:
+ GET_TARGET_STRING(p, gpr[4]);
+ GET_TARGET_STRING(p2, gpr[5]);
+ printf("assertion '");
+ printf("\"%s\"", p);
+ printf("': file \"%s\", line %d\n", p2, (int)gpr[6]);
+ FREE_TARGET_STRING(p2, gpr[5]);
+ FREE_TARGET_STRING(p, gpr[4]);
+ abort();
+ break;
+ case UHI_pread:
+ gpr[2] = read_from_file(env, gpr[4], gpr[5], gpr[6], gpr[7]);
+ gpr[3] = errno_mips(errno);
+ break;
+ case UHI_pwrite:
+ gpr[2] = write_to_file(env, gpr[4], gpr[5], gpr[6], gpr[7]);
+ gpr[3] = errno_mips(errno);
+ break;
+#ifndef _WIN32
+ case UHI_link:
+ GET_TARGET_STRING(p, gpr[4]);
+ GET_TARGET_STRING(p2, gpr[5]);
+ gpr[2] = link(p, p2);
+ gpr[3] = errno_mips(errno);
+ FREE_TARGET_STRING(p2, gpr[5]);
+ FREE_TARGET_STRING(p, gpr[4]);
+ break;
+#endif
+ default:
+ fprintf(stderr, "Unknown UHI operation %d\n", op);
+ abort();
+ }
+uhi_done:
+ return;
+}
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 1d128eef02..73028572c9 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -29,6 +29,7 @@
#include "exec/helper-proto.h"
#include "exec/helper-gen.h"
#include "sysemu/kvm.h"
+#include "exec/semihost.h"
#include "trace-tcg.h"
@@ -1429,6 +1430,7 @@ typedef struct DisasContext {
uint64_t PAMask;
bool mvh;
int CP0_LLAddr_shift;
+ bool ps;
} DisasContext;
enum {
@@ -1723,6 +1725,15 @@ static target_long addr_add(DisasContext *ctx, target_long base,
return sum;
}
+static inline void gen_move_low32(TCGv ret, TCGv_i64 arg)
+{
+#if defined(TARGET_MIPS64)
+ tcg_gen_ext32s_tl(ret, arg);
+#else
+ tcg_gen_trunc_i64_tl(ret, arg);
+#endif
+}
+
static inline void check_cp0_enabled(DisasContext *ctx)
{
if (unlikely(!(ctx->hflags & MIPS_HFLAG_CP0)))
@@ -1816,6 +1827,16 @@ static inline void check_insn_opc_removed(DisasContext *ctx, int flags)
}
}
+/* This code generates a "reserved instruction" exception if the
+ CPU does not support 64-bit paired-single (PS) floating point data type */
+static inline void check_ps(DisasContext *ctx)
+{
+ if (unlikely(!ctx->ps)) {
+ generate_exception(ctx, EXCP_RI);
+ }
+ check_cp1_64bitmode(ctx);
+}
+
#ifdef TARGET_MIPS64
/* This code generates a "reserved instruction" exception if 64-bit
instructions are not enabled. */
@@ -1849,7 +1870,7 @@ static inline void gen_cmp ## type ## _ ## fmt(DisasContext *ctx, int n, \
TCGv_i##bits fp1 = tcg_temp_new_i##bits (); \
switch (ifmt) { \
case FMT_PS: \
- check_cp1_64bitmode(ctx); \
+ check_ps(ctx); \
break; \
case FMT_D: \
if (abs) { \
@@ -3188,45 +3209,46 @@ static inline void gen_r6_ld(target_long addr, int reg, int memidx,
tcg_temp_free(t0);
}
-static inline void gen_pcrel(DisasContext *ctx, int rs, int16_t imm)
+static inline void gen_pcrel(DisasContext *ctx, int opc, target_ulong pc,
+ int rs)
{
target_long offset;
target_long addr;
- switch (MASK_OPC_PCREL_TOP2BITS(ctx->opcode)) {
+ switch (MASK_OPC_PCREL_TOP2BITS(opc)) {
case OPC_ADDIUPC:
if (rs != 0) {
offset = sextract32(ctx->opcode << 2, 0, 21);
- addr = addr_add(ctx, ctx->pc, offset);
+ addr = addr_add(ctx, pc, offset);
tcg_gen_movi_tl(cpu_gpr[rs], addr);
}
break;
case R6_OPC_LWPC:
offset = sextract32(ctx->opcode << 2, 0, 21);
- addr = addr_add(ctx, ctx->pc, offset);
+ addr = addr_add(ctx, pc, offset);
gen_r6_ld(addr, rs, ctx->mem_idx, MO_TESL);
break;
#if defined(TARGET_MIPS64)
case OPC_LWUPC:
check_mips_64(ctx);
offset = sextract32(ctx->opcode << 2, 0, 21);
- addr = addr_add(ctx, ctx->pc, offset);
+ addr = addr_add(ctx, pc, offset);
gen_r6_ld(addr, rs, ctx->mem_idx, MO_TEUL);
break;
#endif
default:
- switch (MASK_OPC_PCREL_TOP5BITS(ctx->opcode)) {
+ switch (MASK_OPC_PCREL_TOP5BITS(opc)) {
case OPC_AUIPC:
if (rs != 0) {
- offset = imm << 16;
- addr = addr_add(ctx, ctx->pc, offset);
+ offset = sextract32(ctx->opcode, 0, 16) << 16;
+ addr = addr_add(ctx, pc, offset);
tcg_gen_movi_tl(cpu_gpr[rs], addr);
}
break;
case OPC_ALUIPC:
if (rs != 0) {
- offset = imm << 16;
- addr = ~0xFFFF & addr_add(ctx, ctx->pc, offset);
+ offset = sextract32(ctx->opcode, 0, 16) << 16;
+ addr = ~0xFFFF & addr_add(ctx, pc, offset);
tcg_gen_movi_tl(cpu_gpr[rs], addr);
}
break;
@@ -3237,7 +3259,7 @@ static inline void gen_pcrel(DisasContext *ctx, int rs, int16_t imm)
case R6_OPC_LDPC + (3 << 16):
check_mips_64(ctx);
offset = sextract32(ctx->opcode << 3, 0, 21);
- addr = addr_add(ctx, (ctx->pc & ~0x7), offset);
+ addr = addr_add(ctx, (pc & ~0x7), offset);
gen_r6_ld(addr, rs, ctx->mem_idx, MO_TEQ);
break;
#endif
@@ -4845,17 +4867,94 @@ static void gen_bshfl (DisasContext *ctx, uint32_t op2, int rt, int rd)
tcg_temp_free(t0);
}
-#ifndef CONFIG_USER_ONLY
-/* CP0 (MMU and control) */
-static inline void gen_move_low32(TCGv ret, TCGv_i64 arg)
+static void gen_lsa(DisasContext *ctx, int opc, int rd, int rs, int rt,
+ int imm2)
+{
+ TCGv t0;
+ TCGv t1;
+ if (rd == 0) {
+ /* Treat as NOP. */
+ return;
+ }
+ t0 = tcg_temp_new();
+ t1 = tcg_temp_new();
+ gen_load_gpr(t0, rs);
+ gen_load_gpr(t1, rt);
+ tcg_gen_shli_tl(t0, t0, imm2 + 1);
+ tcg_gen_add_tl(cpu_gpr[rd], t0, t1);
+ if (opc == OPC_LSA) {
+ tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
+ }
+
+ tcg_temp_free(t1);
+ tcg_temp_free(t0);
+
+ return;
+}
+
+static void gen_align(DisasContext *ctx, int opc, int rd, int rs, int rt,
+ int bp)
{
+ TCGv t0;
+ if (rd == 0) {
+ /* Treat as NOP. */
+ return;
+ }
+ t0 = tcg_temp_new();
+ gen_load_gpr(t0, rt);
+ if (bp == 0) {
+ tcg_gen_mov_tl(cpu_gpr[rd], t0);
+ } else {
+ TCGv t1 = tcg_temp_new();
+ gen_load_gpr(t1, rs);
+ switch (opc) {
+ case OPC_ALIGN:
+ {
+ TCGv_i64 t2 = tcg_temp_new_i64();
+ tcg_gen_concat_tl_i64(t2, t1, t0);
+ tcg_gen_shri_i64(t2, t2, 8 * (4 - bp));
+ gen_move_low32(cpu_gpr[rd], t2);
+ tcg_temp_free_i64(t2);
+ }
+ break;
#if defined(TARGET_MIPS64)
- tcg_gen_ext32s_tl(ret, arg);
-#else
- tcg_gen_trunc_i64_tl(ret, arg);
+ case OPC_DALIGN:
+ tcg_gen_shli_tl(t0, t0, 8 * bp);
+ tcg_gen_shri_tl(t1, t1, 8 * (8 - bp));
+ tcg_gen_or_tl(cpu_gpr[rd], t1, t0);
+ break;
+#endif
+ }
+ tcg_temp_free(t1);
+ }
+
+ tcg_temp_free(t0);
+}
+
+static void gen_bitswap(DisasContext *ctx, int opc, int rd, int rt)
+{
+ TCGv t0;
+ if (rd == 0) {
+ /* Treat as NOP. */
+ return;
+ }
+ t0 = tcg_temp_new();
+ gen_load_gpr(t0, rt);
+ switch (opc) {
+ case OPC_BITSWAP:
+ gen_helper_bitswap(cpu_gpr[rd], t0);
+ break;
+#if defined(TARGET_MIPS64)
+ case OPC_DBITSWAP:
+ gen_helper_dbitswap(cpu_gpr[rd], t0);
+ break;
#endif
+ }
+ tcg_temp_free(t0);
}
+#ifndef CONFIG_USER_ONLY
+/* CP0 (MMU and control) */
static inline void gen_mthc0_entrylo(TCGv arg, target_ulong off)
{
TCGv_i64 t0 = tcg_temp_new_i64();
@@ -8344,7 +8443,8 @@ static void gen_compute_branch1(DisasContext *ctx, uint32_t op,
/* R6 CP1 Branches */
static void gen_compute_branch1_r6(DisasContext *ctx, uint32_t op,
- int32_t ft, int32_t offset)
+ int32_t ft, int32_t offset,
+ int delayslot_size)
{
target_ulong btarget;
const char *opn = "cp1 cond branch";
@@ -8387,7 +8487,15 @@ static void gen_compute_branch1_r6(DisasContext *ctx, uint32_t op,
MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, opn,
ctx->hflags, btarget);
ctx->btarget = btarget;
- ctx->hflags |= MIPS_HFLAG_BDS32;
+
+ switch (delayslot_size) {
+ case 2:
+ ctx->hflags |= MIPS_HFLAG_BDS16;
+ break;
+ case 4:
+ ctx->hflags |= MIPS_HFLAG_BDS32;
+ break;
+ }
out:
tcg_temp_free_i64(t0);
@@ -8912,7 +9020,6 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
};
enum { BINOP, CMPOP, OTHEROP } optype = OTHEROP;
uint32_t func = ctx->opcode & 0x3f;
-
switch (op1) {
case OPC_ADD_S:
{
@@ -9405,8 +9512,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "cvt.l.s";
break;
case OPC_CVT_PS_S:
- check_insn_opc_removed(ctx, ISA_MIPS32R6);
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp64 = tcg_temp_new_i64();
TCGv_i32 fp32_0 = tcg_temp_new_i32();
@@ -10023,8 +10129,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "cvt.d.l";
break;
case OPC_CVT_PS_PW:
- check_insn_opc_removed(ctx, ISA_MIPS32R6);
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10036,7 +10141,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "cvt.ps.pw";
break;
case OPC_ADD_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10051,7 +10156,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "add.ps";
break;
case OPC_SUB_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10066,7 +10171,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "sub.ps";
break;
case OPC_MUL_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10081,7 +10186,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "mul.ps";
break;
case OPC_ABS_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10093,7 +10198,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "abs.ps";
break;
case OPC_MOV_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10104,7 +10209,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "mov.ps";
break;
case OPC_NEG_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10116,12 +10221,12 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "neg.ps";
break;
case OPC_MOVCF_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
gen_movcf_ps(ctx, fs, fd, (ft >> 2) & 0x7, ft & 0x1);
opn = "movcf.ps";
break;
case OPC_MOVZ_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGLabel *l1 = gen_new_label();
TCGv_i64 fp0;
@@ -10137,7 +10242,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "movz.ps";
break;
case OPC_MOVN_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGLabel *l1 = gen_new_label();
TCGv_i64 fp0;
@@ -10154,7 +10259,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "movn.ps";
break;
case OPC_ADDR_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10169,7 +10274,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "addr.ps";
break;
case OPC_MULR_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10184,7 +10289,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "mulr.ps";
break;
case OPC_RECIP2_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10199,7 +10304,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "recip2.ps";
break;
case OPC_RECIP1_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10211,7 +10316,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "recip1.ps";
break;
case OPC_RSQRT1_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10223,7 +10328,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "rsqrt1.ps";
break;
case OPC_RSQRT2_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10250,7 +10355,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "cvt.s.pu";
break;
case OPC_CVT_PW_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
@@ -10274,7 +10379,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "cvt.s.pl";
break;
case OPC_PLL_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
@@ -10289,7 +10394,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "pll.ps";
break;
case OPC_PLU_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
@@ -10304,7 +10409,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "plu.ps";
break;
case OPC_PUL_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
@@ -10319,7 +10424,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,
opn = "pul.ps";
break;
case OPC_PUU_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i32 fp0 = tcg_temp_new_i32();
TCGv_i32 fp1 = tcg_temp_new_i32();
@@ -10478,7 +10583,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
switch (opc) {
case OPC_ALNV_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv t0 = tcg_temp_local_new();
TCGv_i32 fp = tcg_temp_new_i32();
@@ -10553,7 +10658,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
opn = "madd.d";
break;
case OPC_MADD_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10608,7 +10713,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
opn = "msub.d";
break;
case OPC_MSUB_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10663,7 +10768,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
opn = "nmadd.d";
break;
case OPC_NMADD_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10718,7 +10823,7 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc,
opn = "nmsub.d";
break;
case OPC_NMSUB_PS:
- check_cp1_64bitmode(ctx);
+ check_ps(ctx);
{
TCGv_i64 fp0 = tcg_temp_new_i64();
TCGv_i64 fp1 = tcg_temp_new_i64();
@@ -10884,6 +10989,243 @@ static void gen_branch(DisasContext *ctx, int insn_bytes)
}
}
+/* Compact Branches */
+static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc,
+ int rs, int rt, int32_t offset)
+{
+ int bcond_compute = 0;
+ TCGv t0 = tcg_temp_new();
+ TCGv t1 = tcg_temp_new();
+ int m16_lowbit = (ctx->hflags & MIPS_HFLAG_M16) != 0;
+
+ if (ctx->hflags & MIPS_HFLAG_BMASK) {
+#ifdef MIPS_DEBUG_DISAS
+ LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
+ "\n", ctx->pc);
+#endif
+ generate_exception(ctx, EXCP_RI);
+ goto out;
+ }
+
+ /* Load needed operands and calculate btarget */
+ switch (opc) {
+ /* compact branch */
+ case OPC_BOVC: /* OPC_BEQZALC, OPC_BEQC */
+ case OPC_BNVC: /* OPC_BNEZALC, OPC_BNEC */
+ gen_load_gpr(t0, rs);
+ gen_load_gpr(t1, rt);
+ bcond_compute = 1;
+ ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
+ if (rs <= rt && rs == 0) {
+ /* OPC_BEQZALC, OPC_BNEZALC */
+ tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4 + m16_lowbit);
+ }
+ break;
+ case OPC_BLEZC: /* OPC_BGEZC, OPC_BGEC */
+ case OPC_BGTZC: /* OPC_BLTZC, OPC_BLTC */
+ gen_load_gpr(t0, rs);
+ gen_load_gpr(t1, rt);
+ bcond_compute = 1;
+ ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
+ break;
+ case OPC_BLEZALC: /* OPC_BGEZALC, OPC_BGEUC */
+ case OPC_BGTZALC: /* OPC_BLTZALC, OPC_BLTUC */
+ if (rs == 0 || rs == rt) {
+ /* OPC_BLEZALC, OPC_BGEZALC */
+ /* OPC_BGTZALC, OPC_BLTZALC */
+ tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4 + m16_lowbit);
+ }
+ gen_load_gpr(t0, rs);
+ gen_load_gpr(t1, rt);
+ bcond_compute = 1;
+ ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
+ break;
+ case OPC_BC:
+ case OPC_BALC:
+ ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
+ break;
+ case OPC_BEQZC:
+ case OPC_BNEZC:
+ if (rs != 0) {
+ /* OPC_BEQZC, OPC_BNEZC */
+ gen_load_gpr(t0, rs);
+ bcond_compute = 1;
+ ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
+ } else {
+ /* OPC_JIC, OPC_JIALC */
+ TCGv tbase = tcg_temp_new();
+ TCGv toffset = tcg_temp_new();
+
+ gen_load_gpr(tbase, rt);
+ tcg_gen_movi_tl(toffset, offset);
+ gen_op_addr_add(ctx, btarget, tbase, toffset);
+ tcg_temp_free(tbase);
+ tcg_temp_free(toffset);
+ }
+ break;
+ default:
+ MIPS_INVAL("Compact branch/jump");
+ generate_exception(ctx, EXCP_RI);
+ goto out;
+ }
+
+ if (bcond_compute == 0) {
+ /* Uncoditional compact branch */
+ switch (opc) {
+ case OPC_JIALC:
+ tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4 + m16_lowbit);
+ /* Fallthrough */
+ case OPC_JIC:
+ ctx->hflags |= MIPS_HFLAG_BR;
+ break;
+ case OPC_BALC:
+ tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4 + m16_lowbit);
+ /* Fallthrough */
+ case OPC_BC:
+ ctx->hflags |= MIPS_HFLAG_B;
+ break;
+ default:
+ MIPS_INVAL("Compact branch/jump");
+ generate_exception(ctx, EXCP_RI);
+ goto out;
+ }
+
+ /* Generating branch here as compact branches don't have delay slot */
+ gen_branch(ctx, 4);
+ } else {
+ /* Conditional compact branch */
+ TCGLabel *fs = gen_new_label();
+ save_cpu_state(ctx, 0);
+
+ switch (opc) {
+ case OPC_BLEZALC: /* OPC_BGEZALC, OPC_BGEUC */
+ if (rs == 0 && rt != 0) {
+ /* OPC_BLEZALC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* OPC_BGEZALC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
+ } else {
+ /* OPC_BGEUC */
+ tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU), t0, t1, fs);
+ }
+ break;
+ case OPC_BGTZALC: /* OPC_BLTZALC, OPC_BLTUC */
+ if (rs == 0 && rt != 0) {
+ /* OPC_BGTZALC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* OPC_BLTZALC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
+ } else {
+ /* OPC_BLTUC */
+ tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU), t0, t1, fs);
+ }
+ break;
+ case OPC_BLEZC: /* OPC_BGEZC, OPC_BGEC */
+ if (rs == 0 && rt != 0) {
+ /* OPC_BLEZC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* OPC_BGEZC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
+ } else {
+ /* OPC_BGEC */
+ tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE), t0, t1, fs);
+ }
+ break;
+ case OPC_BGTZC: /* OPC_BLTZC, OPC_BLTC */
+ if (rs == 0 && rt != 0) {
+ /* OPC_BGTZC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* OPC_BLTZC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
+ } else {
+ /* OPC_BLTC */
+ tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT), t0, t1, fs);
+ }
+ break;
+ case OPC_BOVC: /* OPC_BEQZALC, OPC_BEQC */
+ case OPC_BNVC: /* OPC_BNEZALC, OPC_BNEC */
+ if (rs >= rt) {
+ /* OPC_BOVC, OPC_BNVC */
+ TCGv t2 = tcg_temp_new();
+ TCGv t3 = tcg_temp_new();
+ TCGv t4 = tcg_temp_new();
+ TCGv input_overflow = tcg_temp_new();
+
+ gen_load_gpr(t0, rs);
+ gen_load_gpr(t1, rt);
+ tcg_gen_ext32s_tl(t2, t0);
+ tcg_gen_setcond_tl(TCG_COND_NE, input_overflow, t2, t0);
+ tcg_gen_ext32s_tl(t3, t1);
+ tcg_gen_setcond_tl(TCG_COND_NE, t4, t3, t1);
+ tcg_gen_or_tl(input_overflow, input_overflow, t4);
+
+ tcg_gen_add_tl(t4, t2, t3);
+ tcg_gen_ext32s_tl(t4, t4);
+ tcg_gen_xor_tl(t2, t2, t3);
+ tcg_gen_xor_tl(t3, t4, t3);
+ tcg_gen_andc_tl(t2, t3, t2);
+ tcg_gen_setcondi_tl(TCG_COND_LT, t4, t2, 0);
+ tcg_gen_or_tl(t4, t4, input_overflow);
+ if (opc == OPC_BOVC) {
+ /* OPC_BOVC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t4, 0, fs);
+ } else {
+ /* OPC_BNVC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t4, 0, fs);
+ }
+ tcg_temp_free(input_overflow);
+ tcg_temp_free(t4);
+ tcg_temp_free(t3);
+ tcg_temp_free(t2);
+ } else if (rs < rt && rs == 0) {
+ /* OPC_BEQZALC, OPC_BNEZALC */
+ if (opc == OPC_BEQZALC) {
+ /* OPC_BEQZALC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t1, 0, fs);
+ } else {
+ /* OPC_BNEZALC */
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t1, 0, fs);
+ }
+ } else {
+ /* OPC_BEQC, OPC_BNEC */
+ if (opc == OPC_BEQC) {
+ /* OPC_BEQC */
+ tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ), t0, t1, fs);
+ } else {
+ /* OPC_BNEC */
+ tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE), t0, t1, fs);
+ }
+ }
+ break;
+ case OPC_BEQZC:
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t0, 0, fs);
+ break;
+ case OPC_BNEZC:
+ tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t0, 0, fs);
+ break;
+ default:
+ MIPS_INVAL("Compact conditional branch/jump");
+ generate_exception(ctx, EXCP_RI);
+ goto out;
+ }
+
+ /* Generating branch here as compact branches don't have delay slot */
+ gen_goto_tb(ctx, 1, ctx->btarget);
+ gen_set_label(fs);
+
+ ctx->hflags |= MIPS_HFLAG_FBNSLOT;
+ MIPS_DEBUG("Compact conditional branch");
+ }
+
+out:
+ tcg_temp_free(t0);
+ tcg_temp_free(t1);
+}
+
/* ISA extensions (ASEs) */
/* MIPS16 extension to MIPS32 */
@@ -11549,6 +11891,15 @@ static int decode_extended_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
return 4;
}
+static inline bool is_uhi(int sdbbp_code)
+{
+#ifdef CONFIG_USER_ONLY
+ return false;
+#else
+ return semihosting_enabled() && sdbbp_code == 1;
+#endif
+}
+
static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
{
int rx, ry;
@@ -11848,13 +12199,13 @@ static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
}
break;
case RR_SDBBP:
- /* XXX: not clear which exception should be raised
- * when in debug mode...
- */
- check_insn(ctx, ISA_MIPS32);
- if (!(ctx->hflags & MIPS_HFLAG_DM)) {
- generate_exception(ctx, EXCP_DBp);
+ if (is_uhi(extract32(ctx->opcode, 5, 6))) {
+ gen_helper_do_semihosting(cpu_env);
} else {
+ /* XXX: not clear which exception should be raised
+ * when in debug mode...
+ */
+ check_insn(ctx, ISA_MIPS32);
generate_exception(ctx, EXCP_DBp);
}
break;
@@ -12038,6 +12389,8 @@ enum {
LBU16 = 0x02,
MOVE16 = 0x03,
ADDI32 = 0x04,
+ R6_LUI = 0x04,
+ AUI = 0x04,
LBU32 = 0x05,
SB32 = 0x06,
LB32 = 0x07,
@@ -12060,56 +12413,88 @@ enum {
POOL32S = 0x16, /* MIPS64 */
DADDIU32 = 0x17, /* MIPS64 */
- /* 0x1f is reserved */
POOL32C = 0x18,
LWGP16 = 0x19,
LW16 = 0x1a,
POOL16E = 0x1b,
XORI32 = 0x1c,
JALS32 = 0x1d,
+ BOVC = 0x1d,
+ BEQC = 0x1d,
+ BEQZALC = 0x1d,
ADDIUPC = 0x1e,
+ PCREL = 0x1e,
+ BNVC = 0x1f,
+ BNEC = 0x1f,
+ BNEZALC = 0x1f,
- /* 0x20 is reserved */
- RES_20 = 0x20,
+ R6_BEQZC = 0x20,
+ JIC = 0x20,
POOL16F = 0x21,
SB16 = 0x22,
BEQZ16 = 0x23,
+ BEQZC16 = 0x23,
SLTI32 = 0x24,
BEQ32 = 0x25,
+ BC = 0x25,
SWC132 = 0x26,
LWC132 = 0x27,
- /* 0x28 and 0x29 are reserved */
- RES_28 = 0x28,
+ /* 0x29 is reserved */
RES_29 = 0x29,
+ R6_BNEZC = 0x28,
+ JIALC = 0x28,
SH16 = 0x2a,
BNEZ16 = 0x2b,
+ BNEZC16 = 0x2b,
SLTIU32 = 0x2c,
BNE32 = 0x2d,
+ BALC = 0x2d,
SDC132 = 0x2e,
LDC132 = 0x2f,
- /* 0x30 and 0x31 are reserved */
- RES_30 = 0x30,
+ /* 0x31 is reserved */
RES_31 = 0x31,
+ BLEZALC = 0x30,
+ BGEZALC = 0x30,
+ BGEUC = 0x30,
SWSP16 = 0x32,
B16 = 0x33,
+ BC16 = 0x33,
ANDI32 = 0x34,
J32 = 0x35,
+ BGTZC = 0x35,
+ BLTZC = 0x35,
+ BLTC = 0x35,
SD32 = 0x36, /* MIPS64 */
LD32 = 0x37, /* MIPS64 */
- /* 0x38 and 0x39 are reserved */
- RES_38 = 0x38,
+ /* 0x39 is reserved */
RES_39 = 0x39,
+ BGTZALC = 0x38,
+ BLTZALC = 0x38,
+ BLTUC = 0x38,
SW16 = 0x3a,
LI16 = 0x3b,
JALX32 = 0x3c,
JAL32 = 0x3d,
+ BLEZC = 0x3d,
+ BGEZC = 0x3d,
+ BGEC = 0x3d,
SW32 = 0x3e,
LW32 = 0x3f
};
+/* PCREL Instructions perform PC-Relative address calculation. bits 20..16 */
+enum {
+ ADDIUPC_00 = 0x00,
+ ADDIUPC_07 = 0x07,
+ AUIPC = 0x1e,
+ ALUIPC = 0x1f,
+ LWPC_08 = 0x08,
+ LWPC_0F = 0x0F,
+};
+
/* POOL32A encoding of minor opcode field */
enum {
@@ -12119,6 +12504,8 @@ enum {
SRL32 = 0x1,
SRA = 0x2,
ROTR = 0x3,
+ SELEQZ = 0x5,
+ SELNEZ = 0x6,
SLLV = 0x0,
SRLV = 0x1,
@@ -12137,11 +12524,21 @@ enum {
SLTU = 0xe,
MOVN = 0x0,
+ R6_MUL = 0x0,
MOVZ = 0x1,
+ MUH = 0x1,
+ MULU = 0x2,
+ MUHU = 0x3,
LWXS = 0x4,
+ R6_DIV = 0x4,
+ MOD = 0x5,
+ R6_DIVU = 0x6,
+ MODU = 0x7,
/* The following can be distinguished by their lower 6 bits. */
INS = 0x0c,
+ LSA = 0x0f,
+ ALIGN = 0x1f,
EXT = 0x2c,
POOL32AXF = 0x3c
};
@@ -12194,6 +12591,7 @@ enum {
/* end of microMIPS32 DSP */
/* bits 15..12 for 0x2c */
+ BITSWAP = 0x0,
SEB = 0x2,
SEH = 0x3,
CLO = 0x4,
@@ -12220,7 +12618,10 @@ enum {
/* bits 15..12 for 0x3c */
JALR = 0x0,
JR = 0x0, /* alias */
+ JALRC = 0x0,
+ JRC = 0x0,
JALR_HB = 0x1,
+ JALRC_HB = 0x1,
JALRS = 0x4,
JALRS_HB = 0x5,
@@ -12233,6 +12634,8 @@ enum {
TLBR = 0x1,
TLBWI = 0x2,
TLBWR = 0x3,
+ TLBINV = 0x4,
+ TLBINVF = 0x5,
WAIT = 0x9,
IRET = 0xd,
DERET = 0xe,
@@ -12302,32 +12705,39 @@ enum {
enum {
/* These are the bit 7..6 values */
ADD_FMT = 0x0,
- MOVN_FMT = 0x0,
SUB_FMT = 0x1,
- MOVZ_FMT = 0x1,
MUL_FMT = 0x2,
DIV_FMT = 0x3,
/* These are the bit 8..6 values */
+ MOVN_FMT = 0x0,
RSQRT2_FMT = 0x0,
MOVF_FMT = 0x0,
+ RINT_FMT = 0x0,
+ SELNEZ_FMT = 0x0,
+ MOVZ_FMT = 0x1,
LWXC1 = 0x1,
MOVT_FMT = 0x1,
+ CLASS_FMT = 0x1,
+ SELEQZ_FMT = 0x1,
PLL_PS = 0x2,
SWXC1 = 0x2,
+ SEL_FMT = 0x2,
PLU_PS = 0x3,
LDXC1 = 0x3,
+ MOVN_FMT_04 = 0x4,
PUL_PS = 0x4,
SDXC1 = 0x4,
RECIP2_FMT = 0x4,
+ MOVZ_FMT_05 = 0x05,
PUU_PS = 0x5,
LUXC1 = 0x5,
@@ -12335,8 +12745,10 @@ enum {
SUXC1 = 0x6,
ADDR_PS = 0x6,
PREFX = 0x6,
+ MADDF_FMT = 0x6,
MULR_PS = 0x7,
+ MSUBF_FMT = 0x7,
MADD_S = 0x01,
MADD_D = 0x09,
@@ -12353,10 +12765,17 @@ enum {
NMSUB_D = 0x2a,
NMSUB_PS = 0x32,
+ MIN_FMT = 0x3,
+ MAX_FMT = 0xb,
+ MINA_FMT = 0x23,
+ MAXA_FMT = 0x2b,
POOL32FXF = 0x3b,
CABS_COND_FMT = 0x1c, /* MIPS3D */
- C_COND_FMT = 0x3c
+ C_COND_FMT = 0x3c,
+
+ CMP_CONDN_S = 0x5,
+ CMP_CONDN_D = 0x15
};
/* POOL32Fxf encoding of minor opcode extension field */
@@ -12409,10 +12828,15 @@ enum {
BGTZ = 0x06,
BEQZC = 0x07,
TLTI = 0x08,
+ BC1EQZC = 0x08,
TGEI = 0x09,
+ BC1NEZC = 0x09,
TLTIU = 0x0a,
+ BC2EQZC = 0x0a,
TGEIU = 0x0b,
+ BC2NEZC = 0x0a,
TNEI = 0x0c,
+ R6_SYNCI = 0x0c,
LUI = 0x0d,
TEQI = 0x0e,
SYNCI = 0x10,
@@ -12465,6 +12889,26 @@ enum {
JRADDIUSP = 0x30
};
+/* R6 POOL16C encoding of minor opcode field (bits 0..5) */
+
+enum {
+ R6_NOT16 = 0x00,
+ R6_AND16 = 0x01,
+ R6_LWM16 = 0x02,
+ R6_JRC16 = 0x03,
+ MOVEP = 0x04,
+ MOVEP_07 = 0x07,
+ R6_XOR16 = 0x08,
+ R6_OR16 = 0x09,
+ R6_SWM16 = 0x0a,
+ JALRC16 = 0x0b,
+ MOVEP_0C = 0x0c,
+ MOVEP_0F = 0x0f,
+ JRCADDIUSP = 0x13,
+ R6_BREAK16 = 0x1b,
+ R6_SDBBP16 = 0x3b
+};
+
/* POOL16D encoding of minor opcode field */
enum {
@@ -12703,13 +13147,13 @@ static void gen_pool16c_insn(DisasContext *ctx)
generate_exception(ctx, EXCP_BREAK);
break;
case SDBBP16:
- /* XXX: not clear which exception should be raised
- * when in debug mode...
- */
- check_insn(ctx, ISA_MIPS32);
- if (!(ctx->hflags & MIPS_HFLAG_DM)) {
- generate_exception(ctx, EXCP_DBp);
+ if (is_uhi(extract32(ctx->opcode, 0, 4))) {
+ gen_helper_do_semihosting(cpu_env);
} else {
+ /* XXX: not clear which exception should be raised
+ * when in debug mode...
+ */
+ check_insn(ctx, ISA_MIPS32);
generate_exception(ctx, EXCP_DBp);
}
break;
@@ -12729,6 +13173,110 @@ static void gen_pool16c_insn(DisasContext *ctx)
}
}
+static inline void gen_movep(DisasContext *ctx, int enc_dest, int enc_rt,
+ int enc_rs)
+{
+ int rd, rs, re, rt;
+ static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
+ static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
+ static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
+ rd = rd_enc[enc_dest];
+ re = re_enc[enc_dest];
+ rs = rs_rt_enc[enc_rs];
+ rt = rs_rt_enc[enc_rt];
+ if (rs) {
+ tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rs]);
+ } else {
+ tcg_gen_movi_tl(cpu_gpr[rd], 0);
+ }
+ if (rt) {
+ tcg_gen_mov_tl(cpu_gpr[re], cpu_gpr[rt]);
+ } else {
+ tcg_gen_movi_tl(cpu_gpr[re], 0);
+ }
+}
+
+static void gen_pool16c_r6_insn(DisasContext *ctx)
+{
+ int rt = mmreg((ctx->opcode >> 7) & 0x7);
+ int rs = mmreg((ctx->opcode >> 4) & 0x7);
+
+ switch (ctx->opcode & 0xf) {
+ case R6_NOT16:
+ gen_logic(ctx, OPC_NOR, rt, rs, 0);
+ break;
+ case R6_AND16:
+ gen_logic(ctx, OPC_AND, rt, rt, rs);
+ break;
+ case R6_LWM16:
+ {
+ int lwm_converted = 0x11 + extract32(ctx->opcode, 8, 2);
+ int offset = extract32(ctx->opcode, 4, 4);
+ gen_ldst_multiple(ctx, LWM32, lwm_converted, 29, offset << 2);
+ }
+ break;
+ case R6_JRC16: /* JRCADDIUSP */
+ if ((ctx->opcode >> 4) & 1) {
+ /* JRCADDIUSP */
+ int imm = extract32(ctx->opcode, 5, 5);
+ gen_compute_branch(ctx, OPC_JR, 2, 31, 0, 0, 0);
+ gen_arith_imm(ctx, OPC_ADDIU, 29, 29, imm << 2);
+ } else {
+ /* JRC16 */
+ int rs = extract32(ctx->opcode, 5, 5);
+ gen_compute_branch(ctx, OPC_JR, 2, rs, 0, 0, 0);
+ }
+ break;
+ case MOVEP ... MOVEP_07:
+ case MOVEP_0C ... MOVEP_0F:
+ {
+ int enc_dest = uMIPS_RD(ctx->opcode);
+ int enc_rt = uMIPS_RS2(ctx->opcode);
+ int enc_rs = (ctx->opcode & 3) | ((ctx->opcode >> 1) & 4);
+ gen_movep(ctx, enc_dest, enc_rt, enc_rs);
+ }
+ break;
+ case R6_XOR16:
+ gen_logic(ctx, OPC_XOR, rt, rt, rs);
+ break;
+ case R6_OR16:
+ gen_logic(ctx, OPC_OR, rt, rt, rs);
+ break;
+ case R6_SWM16:
+ {
+ int swm_converted = 0x11 + extract32(ctx->opcode, 8, 2);
+ int offset = extract32(ctx->opcode, 4, 4);
+ gen_ldst_multiple(ctx, SWM32, swm_converted, 29, offset << 2);
+ }
+ break;
+ case JALRC16: /* BREAK16, SDBBP16 */
+ switch (ctx->opcode & 0x3f) {
+ case JALRC16:
+ case JALRC16 + 0x20:
+ /* JALRC16 */
+ gen_compute_branch(ctx, OPC_JALR, 2, (ctx->opcode >> 5) & 0x1f,
+ 31, 0, 0);
+ break;
+ case R6_BREAK16:
+ /* BREAK16 */
+ generate_exception(ctx, EXCP_BREAK);
+ break;
+ case R6_SDBBP16:
+ /* SDBBP16 */
+ if (ctx->hflags & MIPS_HFLAG_SBRI) {
+ generate_exception(ctx, EXCP_RI);
+ } else {
+ generate_exception(ctx, EXCP_DBp);
+ }
+ break;
+ }
+ break;
+ default:
+ generate_exception(ctx, EXCP_RI);
+ break;
+ }
+}
+
static void gen_ldxs (DisasContext *ctx, int base, int index, int rd)
{
TCGv t0 = tcg_temp_new();
@@ -12900,6 +13448,10 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
break;
case 0x2c:
switch (minor) {
+ case BITSWAP:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_bitswap(ctx, OPC_BITSWAP, rs, rt);
+ break;
case SEB:
gen_bshfl(ctx, OPC_SEB, rs, rt);
break;
@@ -12922,15 +13474,19 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
gen_bshfl(ctx, OPC_WSBH, rs, rt);
break;
case MULT:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MULT;
goto do_mul;
case MULTU:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MULTU;
goto do_mul;
case DIV:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_DIV;
goto do_div;
case DIVU:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_DIVU;
goto do_div;
do_div:
@@ -12938,15 +13494,19 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
gen_muldiv(ctx, mips32_op, 0, rs, rt);
break;
case MADD:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MADD;
goto do_mul;
case MADDU:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MADDU;
goto do_mul;
case MSUB:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MSUB;
goto do_mul;
case MSUBU:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MSUBU;
do_mul:
check_insn(ctx, ISA_MIPS32);
@@ -12972,13 +13532,20 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
break;
case 0x3c:
switch (minor) {
- case JALR:
- case JALR_HB:
- gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 4);
- ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
+ case JALR: /* JALRC */
+ case JALR_HB: /* JALRC_HB */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* JALRC, JALRC_HB */
+ gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 0);
+ } else {
+ /* JALR, JALR_HB */
+ gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 4);
+ ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
+ }
break;
case JALRS:
case JALRS_HB:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_JALR, 4, rs, rt, 0, 2);
ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
break;
@@ -12991,12 +13558,12 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
case RDPGPR:
check_cp0_enabled(ctx);
check_insn(ctx, ISA_MIPS32R2);
- gen_load_srsgpr(rt, rs);
+ gen_load_srsgpr(rs, rt);
break;
case WRPGPR:
check_cp0_enabled(ctx);
check_insn(ctx, ISA_MIPS32R2);
- gen_store_srsgpr(rt, rs);
+ gen_store_srsgpr(rs, rt);
break;
default:
goto pool32axf_invalid;
@@ -13017,6 +13584,12 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
case TLBWR:
mips32_op = OPC_TLBWR;
goto do_cp0;
+ case TLBINV:
+ mips32_op = OPC_TLBINV;
+ goto do_cp0;
+ case TLBINVF:
+ mips32_op = OPC_TLBINVF;
+ goto do_cp0;
case WAIT:
mips32_op = OPC_WAIT;
goto do_cp0;
@@ -13075,11 +13648,15 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
ctx->bstate = BS_STOP;
break;
case SDBBP:
- check_insn(ctx, ISA_MIPS32);
- if (!(ctx->hflags & MIPS_HFLAG_DM)) {
- generate_exception(ctx, EXCP_DBp);
+ if (is_uhi(extract32(ctx->opcode, 16, 10))) {
+ gen_helper_do_semihosting(cpu_env);
} else {
- generate_exception(ctx, EXCP_DBp);
+ check_insn(ctx, ISA_MIPS32);
+ if (ctx->hflags & MIPS_HFLAG_SBRI) {
+ generate_exception(ctx, EXCP_RI);
+ } else {
+ generate_exception(ctx, EXCP_DBp);
+ }
}
break;
default:
@@ -13105,6 +13682,7 @@ static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
}
break;
case 0x35:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
switch (minor) {
case MFHI32:
gen_HILO(ctx, OPC_MFHI, 0, rs);
@@ -13377,6 +13955,7 @@ static void gen_pool32fxf(DisasContext *ctx, int rt, int rs)
case COND_FLOAT_MOV(MOVT, 5):
case COND_FLOAT_MOV(MOVT, 6):
case COND_FLOAT_MOV(MOVT, 7):
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_movci(ctx, rt, rs, (ctx->opcode >> 13) & 0x7, 1);
break;
case COND_FLOAT_MOV(MOVF, 0):
@@ -13387,6 +13966,7 @@ static void gen_pool32fxf(DisasContext *ctx, int rt, int rs)
case COND_FLOAT_MOV(MOVF, 5):
case COND_FLOAT_MOV(MOVF, 6):
case COND_FLOAT_MOV(MOVF, 7):
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_movci(ctx, rt, rs, (ctx->opcode >> 13) & 0x7, 0);
break;
default:
@@ -13396,8 +13976,7 @@ static void gen_pool32fxf(DisasContext *ctx, int rt, int rs)
}
}
-static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
- uint16_t insn_hw1)
+static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx)
{
int32_t offset;
uint16_t insn;
@@ -13437,6 +14016,14 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
do_shifti:
gen_shift_imm(ctx, mips32_op, rt, rs, rd);
break;
+ case SELEQZ:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_cond_move(ctx, OPC_SELEQZ, rd, rs, rt);
+ break;
+ case SELNEZ:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_cond_move(ctx, OPC_SELNEZ, rd, rs, rt);
+ break;
default:
goto pool32a_invalid;
}
@@ -13458,6 +14045,7 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
mips32_op = OPC_SUBU;
goto do_arith;
case MUL:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MUL;
do_arith:
gen_arith(ctx, mips32_op, rd, rs, rt);
@@ -13509,16 +14097,52 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
minor = (ctx->opcode >> 6) & 0xf;
switch (minor) {
/* Conditional moves */
- case MOVN:
- mips32_op = OPC_MOVN;
- goto do_cmov;
- case MOVZ:
- mips32_op = OPC_MOVZ;
- do_cmov:
- gen_cond_move(ctx, mips32_op, rd, rs, rt);
+ case MOVN: /* MUL */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* MUL */
+ gen_r6_muldiv(ctx, R6_OPC_MUL, rd, rs, rt);
+ } else {
+ /* MOVN */
+ gen_cond_move(ctx, OPC_MOVN, rd, rs, rt);
+ }
break;
- case LWXS:
- gen_ldxs(ctx, rs, rt, rd);
+ case MOVZ: /* MUH */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* MUH */
+ gen_r6_muldiv(ctx, R6_OPC_MUH, rd, rs, rt);
+ } else {
+ /* MOVZ */
+ gen_cond_move(ctx, OPC_MOVZ, rd, rs, rt);
+ }
+ break;
+ case MULU:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_muldiv(ctx, R6_OPC_MULU, rd, rs, rt);
+ break;
+ case MUHU:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_muldiv(ctx, R6_OPC_MUHU, rd, rs, rt);
+ break;
+ case LWXS: /* DIV */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* DIV */
+ gen_r6_muldiv(ctx, R6_OPC_DIV, rd, rs, rt);
+ } else {
+ /* LWXS */
+ gen_ldxs(ctx, rs, rt, rd);
+ }
+ break;
+ case MOD:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_muldiv(ctx, R6_OPC_MOD, rd, rs, rt);
+ break;
+ case R6_DIVU:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_muldiv(ctx, R6_OPC_DIVU, rd, rs, rt);
+ break;
+ case MODU:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_muldiv(ctx, R6_OPC_MODU, rd, rs, rt);
break;
default:
goto pool32a_invalid;
@@ -13527,6 +14151,16 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
case INS:
gen_bitops(ctx, OPC_INS, rt, rs, rr, rd);
return;
+ case LSA:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_lsa(ctx, OPC_LSA, rd, rs, rt,
+ extract32(ctx->opcode, 9, 2));
+ break;
+ case ALIGN:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_align(ctx, OPC_ALIGN, rd, rs, rt,
+ extract32(ctx->opcode, 9, 2));
+ break;
case EXT:
gen_bitops(ctx, OPC_EXT, rt, rs, rr, rd);
return;
@@ -13589,47 +14223,61 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
check_cp1_enabled(ctx);
switch (minor) {
case ALNV_PS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_ALNV_PS;
goto do_madd;
case MADD_S:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MADD_S;
goto do_madd;
case MADD_D:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MADD_D;
goto do_madd;
case MADD_PS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MADD_PS;
goto do_madd;
case MSUB_S:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MSUB_S;
goto do_madd;
case MSUB_D:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MSUB_D;
goto do_madd;
case MSUB_PS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_MSUB_PS;
goto do_madd;
case NMADD_S:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_NMADD_S;
goto do_madd;
case NMADD_D:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_NMADD_D;
goto do_madd;
case NMADD_PS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_NMADD_PS;
goto do_madd;
case NMSUB_S:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_NMSUB_S;
goto do_madd;
case NMSUB_D:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_NMSUB_D;
goto do_madd;
case NMSUB_PS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_NMSUB_PS;
do_madd:
gen_flt3_arith(ctx, mips32_op, rd, rr, rs, rt);
break;
case CABS_COND_FMT:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
@@ -13648,6 +14296,7 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
}
break;
case C_COND_FMT:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
cond = (ctx->opcode >> 6) & 0xf;
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 10) & 0x3;
@@ -13665,6 +14314,14 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
goto pool32f_invalid;
}
break;
+ case CMP_CONDN_S:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_cmp_s(ctx, (ctx->opcode >> 6) & 0x1f, rt, rs, rd);
+ break;
+ case CMP_CONDN_D:
+ check_insn(ctx, ISA_MIPS32R6);
+ gen_r6_cmp_d(ctx, (ctx->opcode >> 6) & 0x1f, rt, rs, rd);
+ break;
case POOL32FXF:
gen_pool32fxf(ctx, rt, rs);
break;
@@ -13684,6 +14341,7 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
mips32_op = OPC_PUU_PS;
goto do_ps;
case CVT_PS_S:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_CVT_PS_S;
do_ps:
gen_farith(ctx, mips32_op, rt, rs, rd, 0);
@@ -13692,25 +14350,44 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
goto pool32f_invalid;
}
break;
+ case MIN_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_farith(ctx, OPC_MIN_S, rt, rs, rd, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_farith(ctx, OPC_MIN_D, rt, rs, rd, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
case 0x08:
/* [LS][WDU]XC1 */
switch ((ctx->opcode >> 6) & 0x7) {
case LWXC1:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LWXC1;
goto do_ldst_cp1;
case SWXC1:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SWXC1;
goto do_ldst_cp1;
case LDXC1:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LDXC1;
goto do_ldst_cp1;
case SDXC1:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SDXC1;
goto do_ldst_cp1;
case LUXC1:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LUXC1;
goto do_ldst_cp1;
case SUXC1:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SUXC1;
do_ldst_cp1:
gen_flt3_ldst(ctx, mips32_op, rd, rd, rt, rs);
@@ -13719,8 +14396,22 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
goto pool32f_invalid;
}
break;
+ case MAX_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_farith(ctx, OPC_MAX_S, rt, rs, rd, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_farith(ctx, OPC_MAX_D, rt, rs, rd, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
case 0x18:
/* 3D insns */
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
case RSQRT2_FMT:
@@ -13766,41 +14457,74 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
}
break;
case 0x20:
- /* MOV[FT].fmt and PREFX */
+ /* MOV[FT].fmt, PREFX, RINT.fmt, CLASS.fmt*/
cc = (ctx->opcode >> 13) & 0x7;
fmt = (ctx->opcode >> 9) & 0x3;
switch ((ctx->opcode >> 6) & 0x7) {
- case MOVF_FMT:
- switch (fmt) {
- case FMT_SDPS_S:
- gen_movcf_s(ctx, rs, rt, cc, 0);
- break;
- case FMT_SDPS_D:
- gen_movcf_d(ctx, rs, rt, cc, 0);
- break;
- case FMT_SDPS_PS:
- gen_movcf_ps(ctx, rs, rt, cc, 0);
- break;
- default:
- goto pool32f_invalid;
+ case MOVF_FMT: /* RINT_FMT */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* RINT_FMT */
+ switch (fmt) {
+ case FMT_SDPS_S:
+ gen_farith(ctx, OPC_RINT_S, 0, rt, rs, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_farith(ctx, OPC_RINT_D, 0, rt, rs, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ } else {
+ /* MOVF_FMT */
+ switch (fmt) {
+ case FMT_SDPS_S:
+ gen_movcf_s(ctx, rs, rt, cc, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_movcf_d(ctx, rs, rt, cc, 0);
+ break;
+ case FMT_SDPS_PS:
+ check_ps(ctx);
+ gen_movcf_ps(ctx, rs, rt, cc, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
}
break;
- case MOVT_FMT:
- switch (fmt) {
- case FMT_SDPS_S:
- gen_movcf_s(ctx, rs, rt, cc, 1);
- break;
- case FMT_SDPS_D:
- gen_movcf_d(ctx, rs, rt, cc, 1);
- break;
- case FMT_SDPS_PS:
- gen_movcf_ps(ctx, rs, rt, cc, 1);
- break;
- default:
- goto pool32f_invalid;
+ case MOVT_FMT: /* CLASS_FMT */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* CLASS_FMT */
+ switch (fmt) {
+ case FMT_SDPS_S:
+ gen_farith(ctx, OPC_CLASS_S, 0, rt, rs, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_farith(ctx, OPC_CLASS_D, 0, rt, rs, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ } else {
+ /* MOVT_FMT */
+ switch (fmt) {
+ case FMT_SDPS_S:
+ gen_movcf_s(ctx, rs, rt, cc, 1);
+ break;
+ case FMT_SDPS_D:
+ gen_movcf_d(ctx, rs, rt, cc, 1);
+ break;
+ case FMT_SDPS_PS:
+ check_ps(ctx);
+ gen_movcf_ps(ctx, rs, rt, cc, 1);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
}
break;
case PREFX:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
break;
default:
goto pool32f_invalid;
@@ -13815,11 +14539,38 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
mips32_op = OPC_##prfx##_D; \
goto do_fpop; \
case FMT_SDPS_PS: \
+ check_ps(ctx); \
mips32_op = OPC_##prfx##_PS; \
goto do_fpop; \
default: \
goto pool32f_invalid; \
}
+ case MINA_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_farith(ctx, OPC_MINA_S, rt, rs, rd, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_farith(ctx, OPC_MINA_D, rt, rs, rd, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
+ case MAXA_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_farith(ctx, OPC_MAXA_S, rt, rs, rd, 0);
+ break;
+ case FMT_SDPS_D:
+ gen_farith(ctx, OPC_MAXA_D, rt, rs, rd, 0);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
case 0x30:
/* regular FP ops */
switch ((ctx->opcode >> 6) & 0x3) {
@@ -13848,13 +14599,90 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
break;
case 0x38:
/* cmovs */
- switch ((ctx->opcode >> 6) & 0x3) {
- case MOVN_FMT:
+ switch ((ctx->opcode >> 6) & 0x7) {
+ case MOVN_FMT: /* SELNEZ_FMT */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* SELNEZ_FMT */
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_sel_s(ctx, OPC_SELNEZ_S, rd, rt, rs);
+ break;
+ case FMT_SDPS_D:
+ gen_sel_d(ctx, OPC_SELNEZ_D, rd, rt, rs);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ } else {
+ /* MOVN_FMT */
+ FINSN_3ARG_SDPS(MOVN);
+ }
+ break;
+ case MOVN_FMT_04:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
FINSN_3ARG_SDPS(MOVN);
break;
- case MOVZ_FMT:
+ case MOVZ_FMT: /* SELEQZ_FMT */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* SELEQZ_FMT */
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_sel_s(ctx, OPC_SELEQZ_S, rd, rt, rs);
+ break;
+ case FMT_SDPS_D:
+ gen_sel_d(ctx, OPC_SELEQZ_D, rd, rt, rs);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ } else {
+ /* MOVZ_FMT */
+ FINSN_3ARG_SDPS(MOVZ);
+ }
+ break;
+ case MOVZ_FMT_05:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
FINSN_3ARG_SDPS(MOVZ);
break;
+ case SEL_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ gen_sel_s(ctx, OPC_SEL_S, rd, rt, rs);
+ break;
+ case FMT_SDPS_D:
+ gen_sel_d(ctx, OPC_SEL_D, rd, rt, rs);
+ break;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
+ case MADDF_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ mips32_op = OPC_MADDF_S;
+ goto do_fpop;
+ case FMT_SDPS_D:
+ mips32_op = OPC_MADDF_D;
+ goto do_fpop;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
+ case MSUBF_FMT:
+ check_insn(ctx, ISA_MIPS32R6);
+ switch ((ctx->opcode >> 9) & 0x3) {
+ case FMT_SDPS_S:
+ mips32_op = OPC_MSUBF_S;
+ goto do_fpop;
+ case FMT_SDPS_D:
+ mips32_op = OPC_MSUBF_D;
+ goto do_fpop;
+ default:
+ goto pool32f_invalid;
+ }
+ break;
default:
goto pool32f_invalid;
}
@@ -13876,51 +14704,87 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
minor = (ctx->opcode >> 21) & 0x1f;
switch (minor) {
case BLTZ:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BLTZ, 4, rs, -1, imm << 1, 4);
break;
case BLTZAL:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BLTZAL, 4, rs, -1, imm << 1, 4);
ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
break;
case BLTZALS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BLTZAL, 4, rs, -1, imm << 1, 2);
ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
break;
case BGEZ:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BGEZ, 4, rs, -1, imm << 1, 4);
break;
case BGEZAL:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BGEZAL, 4, rs, -1, imm << 1, 4);
ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
break;
case BGEZALS:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BGEZAL, 4, rs, -1, imm << 1, 2);
ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
break;
case BLEZ:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BLEZ, 4, rs, -1, imm << 1, 4);
break;
case BGTZ:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, OPC_BGTZ, 4, rs, -1, imm << 1, 4);
break;
/* Traps */
- case TLTI:
- mips32_op = OPC_TLTI;
- goto do_trapi;
- case TGEI:
- mips32_op = OPC_TGEI;
- goto do_trapi;
+ case TLTI: /* BC1EQZC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* BC1EQZC */
+ check_cp1_enabled(ctx);
+ gen_compute_branch1_r6(ctx, OPC_BC1EQZ, rs, imm << 1, 0);
+ } else {
+ /* TLTI */
+ mips32_op = OPC_TLTI;
+ goto do_trapi;
+ }
+ break;
+ case TGEI: /* BC1NEZC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* BC1NEZC */
+ check_cp1_enabled(ctx);
+ gen_compute_branch1_r6(ctx, OPC_BC1NEZ, rs, imm << 1, 0);
+ } else {
+ /* TGEI */
+ mips32_op = OPC_TGEI;
+ goto do_trapi;
+ }
+ break;
case TLTIU:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_TLTIU;
goto do_trapi;
case TGEIU:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_TGEIU;
goto do_trapi;
- case TNEI:
- mips32_op = OPC_TNEI;
- goto do_trapi;
+ case TNEI: /* SYNCI */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* SYNCI */
+ /* Break the TB to be able to sync copied instructions
+ immediately */
+ ctx->bstate = BS_STOP;
+ } else {
+ /* TNEI */
+ mips32_op = OPC_TNEI;
+ goto do_trapi;
+ }
+ break;
case TEQI:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_TEQI;
do_trapi:
gen_trap(ctx, mips32_op, rs, -1, imm);
@@ -13928,6 +14792,7 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
case BNEZC:
case BEQZC:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_compute_branch(ctx, minor == BNEZC ? OPC_BNE : OPC_BEQ,
4, rs, 0, imm << 1, 0);
/* Compact branches don't have a delay slot, so just let
@@ -13935,28 +14800,35 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
target. */
break;
case LUI:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
gen_logic_imm(ctx, OPC_LUI, rs, 0, imm);
break;
case SYNCI:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
/* Break the TB to be able to sync copied instructions
immediately */
ctx->bstate = BS_STOP;
break;
case BC2F:
case BC2T:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
/* COP2: Not implemented. */
generate_exception_err(ctx, EXCP_CpU, 2);
break;
case BC1F:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F;
goto do_cp1branch;
case BC1T:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T;
goto do_cp1branch;
case BC1ANY4F:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_BC1FANY4;
goto do_cp1mips3d;
case BC1ANY4T:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_BC1TANY4;
do_cp1mips3d:
check_cop1x(ctx);
@@ -13983,38 +14855,48 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
break;
case POOL32C:
minor = (ctx->opcode >> 12) & 0xf;
+ offset = sextract32(ctx->opcode, 0,
+ (ctx->insn_flags & ISA_MIPS32R6) ? 9 : 12);
switch (minor) {
case LWL:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LWL;
goto do_ld_lr;
case SWL:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SWL;
goto do_st_lr;
case LWR:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LWR;
goto do_ld_lr;
case SWR:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SWR;
goto do_st_lr;
#if defined(TARGET_MIPS64)
case LDL:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LDL;
goto do_ld_lr;
case SDL:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SDL;
goto do_st_lr;
case LDR:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_LDR;
goto do_ld_lr;
case SDR:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
mips32_op = OPC_SDR;
goto do_st_lr;
case LWU:
@@ -14032,23 +14914,27 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
mips32_op = OPC_LL;
goto do_ld_lr;
do_ld_lr:
- gen_ld(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
+ gen_ld(ctx, mips32_op, rt, rs, offset);
break;
do_st_lr:
gen_st(ctx, mips32_op, rt, rs, SIMM(ctx->opcode, 0, 12));
break;
case SC:
- gen_st_cond(ctx, OPC_SC, rt, rs, SIMM(ctx->opcode, 0, 12));
+ gen_st_cond(ctx, OPC_SC, rt, rs, offset);
break;
#if defined(TARGET_MIPS64)
case SCD:
check_insn(ctx, ISA_MIPS3);
check_mips_64(ctx);
- gen_st_cond(ctx, OPC_SCD, rt, rs, SIMM(ctx->opcode, 0, 12));
+ gen_st_cond(ctx, OPC_SCD, rt, rs, offset);
break;
#endif
case PREF:
/* Treat as no-op */
+ if ((ctx->insn_flags & ISA_MIPS32R6) && (rt >= 24)) {
+ /* hint codes 24-31 are reserved and signal RI */
+ generate_exception(ctx, EXCP_RI);
+ }
break;
default:
MIPS_INVAL("pool32c");
@@ -14056,9 +14942,16 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
break;
}
break;
- case ADDI32:
- mips32_op = OPC_ADDI;
- goto do_addi;
+ case ADDI32: /* AUI, LUI */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* AUI, LUI */
+ gen_logic_imm(ctx, OPC_LUI, rt, rs, imm);
+ } else {
+ /* ADDI32 */
+ mips32_op = OPC_ADDI;
+ goto do_addi;
+ }
+ break;
case ADDIU32:
mips32_op = OPC_ADDIU;
do_addi:
@@ -14088,29 +14981,89 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
gen_slt_imm(ctx, mips32_op, rt, rs, imm);
break;
case JALX32:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2;
gen_compute_branch(ctx, OPC_JALX, 4, rt, rs, offset, 4);
ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
break;
- case JALS32:
- offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 1;
- gen_compute_branch(ctx, OPC_JAL, 4, rt, rs, offset, 2);
- ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
+ case JALS32: /* BOVC, BEQC, BEQZALC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ if (rs >= rt) {
+ /* BOVC */
+ mips32_op = OPC_BOVC;
+ } else if (rs < rt && rs == 0) {
+ /* BEQZALC */
+ mips32_op = OPC_BEQZALC;
+ } else {
+ /* BEQC */
+ mips32_op = OPC_BEQC;
+ }
+ gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1);
+ } else {
+ /* JALS32 */
+ offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 1;
+ gen_compute_branch(ctx, OPC_JAL, 4, rt, rs, offset, 2);
+ ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
+ }
break;
- case BEQ32:
- gen_compute_branch(ctx, OPC_BEQ, 4, rt, rs, imm << 1, 4);
+ case BEQ32: /* BC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* BC */
+ gen_compute_compact_branch(ctx, OPC_BC, 0, 0,
+ sextract32(ctx->opcode << 1, 0, 27));
+ } else {
+ /* BEQ32 */
+ gen_compute_branch(ctx, OPC_BEQ, 4, rt, rs, imm << 1, 4);
+ }
break;
- case BNE32:
- gen_compute_branch(ctx, OPC_BNE, 4, rt, rs, imm << 1, 4);
+ case BNE32: /* BALC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* BALC */
+ gen_compute_compact_branch(ctx, OPC_BALC, 0, 0,
+ sextract32(ctx->opcode << 1, 0, 27));
+ } else {
+ /* BNE32 */
+ gen_compute_branch(ctx, OPC_BNE, 4, rt, rs, imm << 1, 4);
+ }
break;
- case J32:
- gen_compute_branch(ctx, OPC_J, 4, rt, rs,
- (int32_t)(ctx->opcode & 0x3FFFFFF) << 1, 4);
+ case J32: /* BGTZC, BLTZC, BLTC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ if (rs == 0 && rt != 0) {
+ /* BGTZC */
+ mips32_op = OPC_BGTZC;
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* BLTZC */
+ mips32_op = OPC_BLTZC;
+ } else {
+ /* BLTC */
+ mips32_op = OPC_BLTC;
+ }
+ gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1);
+ } else {
+ /* J32 */
+ gen_compute_branch(ctx, OPC_J, 4, rt, rs,
+ (int32_t)(ctx->opcode & 0x3FFFFFF) << 1, 4);
+ }
break;
- case JAL32:
- gen_compute_branch(ctx, OPC_JAL, 4, rt, rs,
- (int32_t)(ctx->opcode & 0x3FFFFFF) << 1, 4);
- ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
+ case JAL32: /* BLEZC, BGEZC, BGEC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ if (rs == 0 && rt != 0) {
+ /* BLEZC */
+ mips32_op = OPC_BLEZC;
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* BGEZC */
+ mips32_op = OPC_BGEZC;
+ } else {
+ /* BGEC */
+ mips32_op = OPC_BGEC;
+ }
+ gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1);
+ } else {
+ /* JAL32 */
+ gen_compute_branch(ctx, OPC_JAL, 4, rt, rs,
+ (int32_t)(ctx->opcode & 0x3FFFFFF) << 1, 4);
+ ctx->hflags |= MIPS_HFLAG_BDS_STRICT;
+ }
break;
/* Floating point (COP1) */
case LWC132:
@@ -14127,14 +15080,98 @@ static void decode_micromips32_opc (CPUMIPSState *env, DisasContext *ctx,
do_cop1:
gen_cop1_ldst(ctx, mips32_op, rt, rs, imm);
break;
- case ADDIUPC:
- {
+ case ADDIUPC: /* PCREL: ADDIUPC, AUIPC, ALUIPC, LWPC */
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* PCREL: ADDIUPC, AUIPC, ALUIPC, LWPC */
+ switch ((ctx->opcode >> 16) & 0x1f) {
+ case ADDIUPC_00 ... ADDIUPC_07:
+ gen_pcrel(ctx, OPC_ADDIUPC, ctx->pc & ~0x3, rt);
+ break;
+ case AUIPC:
+ gen_pcrel(ctx, OPC_AUIPC, ctx->pc, rt);
+ break;
+ case ALUIPC:
+ gen_pcrel(ctx, OPC_ALUIPC, ctx->pc, rt);
+ break;
+ case LWPC_08 ... LWPC_0F:
+ gen_pcrel(ctx, R6_OPC_LWPC, ctx->pc & ~0x3, rt);
+ break;
+ default:
+ generate_exception(ctx, EXCP_RI);
+ break;
+ }
+ } else {
+ /* ADDIUPC */
int reg = mmreg(ZIMM(ctx->opcode, 23, 3));
int offset = SIMM(ctx->opcode, 0, 23) << 2;
gen_addiupc(ctx, reg, offset, 0, 0);
}
break;
+ case BNVC: /* BNEC, BNEZALC */
+ check_insn(ctx, ISA_MIPS32R6);
+ if (rs >= rt) {
+ /* BNVC */
+ mips32_op = OPC_BNVC;
+ } else if (rs < rt && rs == 0) {
+ /* BNEZALC */
+ mips32_op = OPC_BNEZALC;
+ } else {
+ /* BNEC */
+ mips32_op = OPC_BNEC;
+ }
+ gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1);
+ break;
+ case R6_BNEZC: /* JIALC */
+ check_insn(ctx, ISA_MIPS32R6);
+ if (rt != 0) {
+ /* BNEZC */
+ gen_compute_compact_branch(ctx, OPC_BNEZC, rt, 0,
+ sextract32(ctx->opcode << 1, 0, 22));
+ } else {
+ /* JIALC */
+ gen_compute_compact_branch(ctx, OPC_JIALC, 0, rs, imm);
+ }
+ break;
+ case R6_BEQZC: /* JIC */
+ check_insn(ctx, ISA_MIPS32R6);
+ if (rt != 0) {
+ /* BEQZC */
+ gen_compute_compact_branch(ctx, OPC_BEQZC, rt, 0,
+ sextract32(ctx->opcode << 1, 0, 22));
+ } else {
+ /* JIC */
+ gen_compute_compact_branch(ctx, OPC_JIC, 0, rs, imm);
+ }
+ break;
+ case BLEZALC: /* BGEZALC, BGEUC */
+ check_insn(ctx, ISA_MIPS32R6);
+ if (rs == 0 && rt != 0) {
+ /* BLEZALC */
+ mips32_op = OPC_BLEZALC;
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* BGEZALC */
+ mips32_op = OPC_BGEZALC;
+ } else {
+ /* BGEUC */
+ mips32_op = OPC_BGEUC;
+ }
+ gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1);
+ break;
+ case BGTZALC: /* BLTZALC, BLTUC */
+ check_insn(ctx, ISA_MIPS32R6);
+ if (rs == 0 && rt != 0) {
+ /* BGTZALC */
+ mips32_op = OPC_BGTZALC;
+ } else if (rs != 0 && rt != 0 && rs == rt) {
+ /* BLTZALC */
+ mips32_op = OPC_BLTZALC;
+ } else {
+ /* BLTUC */
+ mips32_op = OPC_BLTUC;
+ }
+ gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1);
+ break;
/* Loads and stores */
case LB32:
mips32_op = OPC_LB;
@@ -14249,8 +15286,14 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
opc = OPC_SUBU;
break;
}
-
- gen_arith(ctx, opc, rd, rs1, rs2);
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ /* In the Release 6 the register number location in
+ * the instruction encoding has changed.
+ */
+ gen_arith(ctx, opc, rs1, rd, rs2);
+ } else {
+ gen_arith(ctx, opc, rd, rs1, rs2);
+ }
}
break;
case POOL16B:
@@ -14274,7 +15317,11 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
}
break;
case POOL16C:
- gen_pool16c_insn(ctx);
+ if (ctx->insn_flags & ISA_MIPS32R6) {
+ gen_pool16c_r6_insn(ctx);
+ } else {
+ gen_pool16c_insn(ctx);
+ }
break;
case LWGP16:
{
@@ -14286,6 +15333,7 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
}
break;
case POOL16F:
+ check_insn_opc_removed(ctx, ISA_MIPS32R6);
if (ctx->opcode & 1) {
generate_exception(ctx, EXCP_RI);
} else {
@@ -14293,18 +15341,7 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
int enc_dest = uMIPS_RD(ctx->opcode);
int enc_rt = uMIPS_RS2(ctx->opcode);
int enc_rs = uMIPS_RS1(ctx->opcode);
- int rd, rs, re, rt;
- static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
- static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
- static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
-
- rd = rd_enc[enc_dest];
- re = re_enc[enc_dest];
- rs = rs_rt_enc[enc_rs];
- rt = rs_rt_enc[enc_rt];
-
- gen_arith(ctx, OPC_ADDU, rd, rs, 0);
- gen_arith(ctx, OPC_ADDU, re, rt, 0);
+ gen_movep(ctx, enc_dest, enc_rt, enc_rs);
}
break;
case LBU16:
@@ -14411,15 +15448,18 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
break;
}
break;
- case B16:
+ case B16: /* BC16 */
gen_compute_branch(ctx, OPC_BEQ, 2, 0, 0,
- SIMM(ctx->opcode, 0, 10) << 1, 4);
+ sextract32(ctx->opcode, 0, 10) << 1,
+ (ctx->insn_flags & ISA_MIPS32R6) ? 0 : 4);
break;
- case BNEZ16:
- case BEQZ16:
+ case BNEZ16: /* BNEZC16 */
+ case BEQZ16: /* BEQZC16 */
gen_compute_branch(ctx, op == BNEZ16 ? OPC_BNE : OPC_BEQ, 2,
mmreg(uMIPS_RD(ctx->opcode)),
- 0, SIMM(ctx->opcode, 0, 7) << 1, 4);
+ 0, sextract32(ctx->opcode, 0, 7) << 1,
+ (ctx->insn_flags & ISA_MIPS32R6) ? 0 : 4);
+
break;
case LI16:
{
@@ -14430,17 +15470,13 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
tcg_gen_movi_tl(cpu_gpr[reg], imm);
}
break;
- case RES_20:
- case RES_28:
case RES_29:
- case RES_30:
case RES_31:
- case RES_38:
case RES_39:
generate_exception(ctx, EXCP_RI);
break;
default:
- decode_micromips32_opc (env, ctx, op);
+ decode_micromips32_opc(env, ctx);
return 4;
}
@@ -16176,242 +17212,6 @@ static void gen_mipsdsp_accinsn(DisasContext *ctx, uint32_t op1, uint32_t op2,
/* End MIPSDSP functions. */
-/* Compact Branches */
-static void gen_compute_compact_branch(DisasContext *ctx, uint32_t opc,
- int rs, int rt, int32_t offset)
-{
- int bcond_compute = 0;
- TCGv t0 = tcg_temp_new();
- TCGv t1 = tcg_temp_new();
-
- if (ctx->hflags & MIPS_HFLAG_BMASK) {
-#ifdef MIPS_DEBUG_DISAS
- LOG_DISAS("Branch in delay / forbidden slot at PC 0x" TARGET_FMT_lx
- "\n", ctx->pc);
-#endif
- generate_exception(ctx, EXCP_RI);
- goto out;
- }
-
- /* Load needed operands and calculate btarget */
- switch (opc) {
- /* compact branch */
- case OPC_BOVC: /* OPC_BEQZALC, OPC_BEQC */
- case OPC_BNVC: /* OPC_BNEZALC, OPC_BNEC */
- gen_load_gpr(t0, rs);
- gen_load_gpr(t1, rt);
- bcond_compute = 1;
- ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
- if (rs <= rt && rs == 0) {
- /* OPC_BEQZALC, OPC_BNEZALC */
- tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
- }
- break;
- case OPC_BLEZC: /* OPC_BGEZC, OPC_BGEC */
- case OPC_BGTZC: /* OPC_BLTZC, OPC_BLTC */
- gen_load_gpr(t0, rs);
- gen_load_gpr(t1, rt);
- bcond_compute = 1;
- ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
- break;
- case OPC_BLEZALC: /* OPC_BGEZALC, OPC_BGEUC */
- case OPC_BGTZALC: /* OPC_BLTZALC, OPC_BLTUC */
- if (rs == 0 || rs == rt) {
- /* OPC_BLEZALC, OPC_BGEZALC */
- /* OPC_BGTZALC, OPC_BLTZALC */
- tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
- }
- gen_load_gpr(t0, rs);
- gen_load_gpr(t1, rt);
- bcond_compute = 1;
- ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
- break;
- case OPC_BC:
- case OPC_BALC:
- ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
- break;
- case OPC_BEQZC:
- case OPC_BNEZC:
- if (rs != 0) {
- /* OPC_BEQZC, OPC_BNEZC */
- gen_load_gpr(t0, rs);
- bcond_compute = 1;
- ctx->btarget = addr_add(ctx, ctx->pc + 4, offset);
- } else {
- /* OPC_JIC, OPC_JIALC */
- TCGv tbase = tcg_temp_new();
- TCGv toffset = tcg_temp_new();
-
- gen_load_gpr(tbase, rt);
- tcg_gen_movi_tl(toffset, offset);
- gen_op_addr_add(ctx, btarget, tbase, toffset);
- tcg_temp_free(tbase);
- tcg_temp_free(toffset);
- }
- break;
- default:
- MIPS_INVAL("Compact branch/jump");
- generate_exception(ctx, EXCP_RI);
- goto out;
- }
-
- if (bcond_compute == 0) {
- /* Uncoditional compact branch */
- switch (opc) {
- case OPC_JIALC:
- tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
- /* Fallthrough */
- case OPC_JIC:
- ctx->hflags |= MIPS_HFLAG_BR;
- break;
- case OPC_BALC:
- tcg_gen_movi_tl(cpu_gpr[31], ctx->pc + 4);
- /* Fallthrough */
- case OPC_BC:
- ctx->hflags |= MIPS_HFLAG_B;
- break;
- default:
- MIPS_INVAL("Compact branch/jump");
- generate_exception(ctx, EXCP_RI);
- goto out;
- }
-
- /* Generating branch here as compact branches don't have delay slot */
- gen_branch(ctx, 4);
- } else {
- /* Conditional compact branch */
- TCGLabel *fs = gen_new_label();
- save_cpu_state(ctx, 0);
-
- switch (opc) {
- case OPC_BLEZALC: /* OPC_BGEZALC, OPC_BGEUC */
- if (rs == 0 && rt != 0) {
- /* OPC_BLEZALC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
- } else if (rs != 0 && rt != 0 && rs == rt) {
- /* OPC_BGEZALC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
- } else {
- /* OPC_BGEUC */
- tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GEU), t0, t1, fs);
- }
- break;
- case OPC_BGTZALC: /* OPC_BLTZALC, OPC_BLTUC */
- if (rs == 0 && rt != 0) {
- /* OPC_BGTZALC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
- } else if (rs != 0 && rt != 0 && rs == rt) {
- /* OPC_BLTZALC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
- } else {
- /* OPC_BLTUC */
- tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LTU), t0, t1, fs);
- }
- break;
- case OPC_BLEZC: /* OPC_BGEZC, OPC_BGEC */
- if (rs == 0 && rt != 0) {
- /* OPC_BLEZC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LE), t1, 0, fs);
- } else if (rs != 0 && rt != 0 && rs == rt) {
- /* OPC_BGEZC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GE), t1, 0, fs);
- } else {
- /* OPC_BGEC */
- tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_GE), t0, t1, fs);
- }
- break;
- case OPC_BGTZC: /* OPC_BLTZC, OPC_BLTC */
- if (rs == 0 && rt != 0) {
- /* OPC_BGTZC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_GT), t1, 0, fs);
- } else if (rs != 0 && rt != 0 && rs == rt) {
- /* OPC_BLTZC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_LT), t1, 0, fs);
- } else {
- /* OPC_BLTC */
- tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_LT), t0, t1, fs);
- }
- break;
- case OPC_BOVC: /* OPC_BEQZALC, OPC_BEQC */
- case OPC_BNVC: /* OPC_BNEZALC, OPC_BNEC */
- if (rs >= rt) {
- /* OPC_BOVC, OPC_BNVC */
- TCGv t2 = tcg_temp_new();
- TCGv t3 = tcg_temp_new();
- TCGv t4 = tcg_temp_new();
- TCGv input_overflow = tcg_temp_new();
-
- gen_load_gpr(t0, rs);
- gen_load_gpr(t1, rt);
- tcg_gen_ext32s_tl(t2, t0);
- tcg_gen_setcond_tl(TCG_COND_NE, input_overflow, t2, t0);
- tcg_gen_ext32s_tl(t3, t1);
- tcg_gen_setcond_tl(TCG_COND_NE, t4, t3, t1);
- tcg_gen_or_tl(input_overflow, input_overflow, t4);
-
- tcg_gen_add_tl(t4, t2, t3);
- tcg_gen_ext32s_tl(t4, t4);
- tcg_gen_xor_tl(t2, t2, t3);
- tcg_gen_xor_tl(t3, t4, t3);
- tcg_gen_andc_tl(t2, t3, t2);
- tcg_gen_setcondi_tl(TCG_COND_LT, t4, t2, 0);
- tcg_gen_or_tl(t4, t4, input_overflow);
- if (opc == OPC_BOVC) {
- /* OPC_BOVC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t4, 0, fs);
- } else {
- /* OPC_BNVC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t4, 0, fs);
- }
- tcg_temp_free(input_overflow);
- tcg_temp_free(t4);
- tcg_temp_free(t3);
- tcg_temp_free(t2);
- } else if (rs < rt && rs == 0) {
- /* OPC_BEQZALC, OPC_BNEZALC */
- if (opc == OPC_BEQZALC) {
- /* OPC_BEQZALC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t1, 0, fs);
- } else {
- /* OPC_BNEZALC */
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t1, 0, fs);
- }
- } else {
- /* OPC_BEQC, OPC_BNEC */
- if (opc == OPC_BEQC) {
- /* OPC_BEQC */
- tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_EQ), t0, t1, fs);
- } else {
- /* OPC_BNEC */
- tcg_gen_brcond_tl(tcg_invert_cond(TCG_COND_NE), t0, t1, fs);
- }
- }
- break;
- case OPC_BEQZC:
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_EQ), t0, 0, fs);
- break;
- case OPC_BNEZC:
- tcg_gen_brcondi_tl(tcg_invert_cond(TCG_COND_NE), t0, 0, fs);
- break;
- default:
- MIPS_INVAL("Compact conditional branch/jump");
- generate_exception(ctx, EXCP_RI);
- goto out;
- }
-
- /* Generating branch here as compact branches don't have delay slot */
- gen_goto_tb(ctx, 1, ctx->btarget);
- gen_set_label(fs);
-
- ctx->hflags |= MIPS_HFLAG_FBNSLOT;
- MIPS_DEBUG("Compact conditional branch");
- }
-
-out:
- tcg_temp_free(t0);
- tcg_temp_free(t1);
-}
-
static void decode_opc_special_r6(CPUMIPSState *env, DisasContext *ctx)
{
int rs, rt, rd, sa;
@@ -16425,18 +17225,7 @@ static void decode_opc_special_r6(CPUMIPSState *env, DisasContext *ctx)
op1 = MASK_SPECIAL(ctx->opcode);
switch (op1) {
case OPC_LSA:
- if (rd != 0) {
- int imm2 = extract32(ctx->opcode, 6, 3);
- TCGv t0 = tcg_temp_new();
- TCGv t1 = tcg_temp_new();
- gen_load_gpr(t0, rs);
- gen_load_gpr(t1, rt);
- tcg_gen_shli_tl(t0, t0, imm2 + 1);
- tcg_gen_add_tl(t0, t0, t1);
- tcg_gen_ext32s_tl(cpu_gpr[rd], t0);
- tcg_temp_free(t1);
- tcg_temp_free(t0);
- }
+ gen_lsa(ctx, op1, rd, rs, rt, extract32(ctx->opcode, 6, 2));
break;
case OPC_MULT ... OPC_DIVU:
op2 = MASK_R6_MULDIV(ctx->opcode);
@@ -16472,26 +17261,20 @@ static void decode_opc_special_r6(CPUMIPSState *env, DisasContext *ctx)
}
break;
case R6_OPC_SDBBP:
- if (ctx->hflags & MIPS_HFLAG_SBRI) {
- generate_exception(ctx, EXCP_RI);
+ if (is_uhi(extract32(ctx->opcode, 6, 20))) {
+ gen_helper_do_semihosting(cpu_env);
} else {
- generate_exception(ctx, EXCP_DBp);
+ if (ctx->hflags & MIPS_HFLAG_SBRI) {
+ generate_exception(ctx, EXCP_RI);
+ } else {
+ generate_exception(ctx, EXCP_DBp);
+ }
}
break;
#if defined(TARGET_MIPS64)
case OPC_DLSA:
check_mips_64(ctx);
- if (rd != 0) {
- int imm2 = extract32(ctx->opcode, 6, 3);
- TCGv t0 = tcg_temp_new();
- TCGv t1 = tcg_temp_new();
- gen_load_gpr(t0, rs);
- gen_load_gpr(t1, rt);
- tcg_gen_shli_tl(t0, t0, imm2 + 1);
- tcg_gen_add_tl(cpu_gpr[rd], t0, t1);
- tcg_temp_free(t1);
- tcg_temp_free(t0);
- }
+ gen_lsa(ctx, op1, rd, rs, rt, extract32(ctx->opcode, 6, 2));
break;
case R6_OPC_DCLO:
case R6_OPC_DCLZ:
@@ -16845,16 +17628,15 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
gen_cl(ctx, op1, rd, rs);
break;
case OPC_SDBBP:
- /* XXX: not clear which exception should be raised
- * when in debug mode...
- */
- check_insn(ctx, ISA_MIPS32);
- if (!(ctx->hflags & MIPS_HFLAG_DM)) {
- generate_exception(ctx, EXCP_DBp);
+ if (is_uhi(extract32(ctx->opcode, 6, 20))) {
+ gen_helper_do_semihosting(cpu_env);
} else {
+ /* XXX: not clear which exception should be raised
+ * when in debug mode...
+ */
+ check_insn(ctx, ISA_MIPS32);
generate_exception(ctx, EXCP_DBp);
}
- /* Treat as NOP. */
break;
#if defined(TARGET_MIPS64)
case OPC_DCLO:
@@ -16916,35 +17698,15 @@ static void decode_opc_special3_r6(CPUMIPSState *env, DisasContext *ctx)
/* Treat as NOP. */
break;
}
- TCGv t0 = tcg_temp_new();
- gen_load_gpr(t0, rt);
-
op2 = MASK_BSHFL(ctx->opcode);
switch (op2) {
case OPC_ALIGN ... OPC_ALIGN_END:
- sa &= 3;
- if (sa == 0) {
- tcg_gen_mov_tl(cpu_gpr[rd], t0);
- } else {
- TCGv t1 = tcg_temp_new();
- TCGv_i64 t2 = tcg_temp_new_i64();
- gen_load_gpr(t1, rs);
- tcg_gen_concat_tl_i64(t2, t1, t0);
- tcg_gen_shri_i64(t2, t2, 8 * (4 - sa));
-#if defined(TARGET_MIPS64)
- tcg_gen_ext32s_i64(cpu_gpr[rd], t2);
-#else
- tcg_gen_trunc_i64_i32(cpu_gpr[rd], t2);
-#endif
- tcg_temp_free_i64(t2);
- tcg_temp_free(t1);
- }
+ gen_align(ctx, OPC_ALIGN, rd, rs, rt, sa & 3);
break;
case OPC_BITSWAP:
- gen_helper_bitswap(cpu_gpr[rd], t0);
+ gen_bitswap(ctx, op2, rd, rt);
break;
}
- tcg_temp_free(t0);
}
break;
#if defined(TARGET_MIPS64)
@@ -16961,29 +17723,16 @@ static void decode_opc_special3_r6(CPUMIPSState *env, DisasContext *ctx)
/* Treat as NOP. */
break;
}
- TCGv t0 = tcg_temp_new();
- gen_load_gpr(t0, rt);
-
op2 = MASK_DBSHFL(ctx->opcode);
switch (op2) {
case OPC_DALIGN ... OPC_DALIGN_END:
- sa &= 7;
- if (sa == 0) {
- tcg_gen_mov_tl(cpu_gpr[rd], t0);
- } else {
- TCGv t1 = tcg_temp_new();
- gen_load_gpr(t1, rs);
- tcg_gen_shli_tl(t0, t0, 8 * sa);
- tcg_gen_shri_tl(t1, t1, 8 * (8 - sa));
- tcg_gen_or_tl(cpu_gpr[rd], t1, t0);
- tcg_temp_free(t1);
- }
+ gen_align(ctx, OPC_DALIGN, rd, rs, rt, sa & 7);
break;
case OPC_DBITSWAP:
- gen_helper_dbitswap(cpu_gpr[rd], t0);
+ gen_bitswap(ctx, op2, rd, rt);
break;
}
- tcg_temp_free(t0);
+
}
break;
#endif
@@ -19082,7 +19831,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
if (ctx->insn_flags & ISA_MIPS32R6) {
/* OPC_BC1EQZ */
gen_compute_branch1_r6(ctx, MASK_CP1(ctx->opcode),
- rt, imm << 2);
+ rt, imm << 2, 4);
} else {
/* OPC_BC1ANY2 */
check_cop1x(ctx);
@@ -19095,7 +19844,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
check_cp1_enabled(ctx);
check_insn(ctx, ISA_MIPS32R6);
gen_compute_branch1_r6(ctx, MASK_CP1(ctx->opcode),
- rt, imm << 2);
+ rt, imm << 2, 4);
break;
case OPC_BC1ANY4:
check_cp1_enabled(ctx);
@@ -19110,8 +19859,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
(rt >> 2) & 0x7, imm << 2);
break;
case OPC_PS_FMT:
- check_cp1_enabled(ctx);
- check_insn_opc_removed(ctx, ISA_MIPS32R6);
+ check_ps(ctx);
/* fall through */
case OPC_S_FMT:
case OPC_D_FMT:
@@ -19372,7 +20120,7 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
break;
case OPC_PCREL:
check_insn(ctx, ISA_MIPS32R6);
- gen_pcrel(ctx, rs, imm);
+ gen_pcrel(ctx, ctx->opcode, ctx->pc, rs);
break;
default: /* Invalid */
MIPS_INVAL("major opcode");
@@ -19420,6 +20168,8 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb,
/* Restore delay slot state from the tb context. */
ctx.hflags = (uint32_t)tb->flags; /* FIXME: maybe use 64 bits here? */
ctx.ulri = (env->CP0_Config3 >> CP0C3_ULRI) & 1;
+ ctx.ps = ((env->active_fpu.fcr0 >> FCR0_PS) & 1) ||
+ (env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F));
restore_cpu_state(env, &ctx);
#ifdef CONFIG_USER_ONLY
ctx.mem_idx = MIPS_HFLAG_UM;
@@ -19489,6 +20239,12 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb,
forbidden slot */
is_slot = 1;
}
+ if ((ctx.hflags & MIPS_HFLAG_M16) &&
+ (ctx.hflags & MIPS_HFLAG_FBNSLOT)) {
+ /* Force to generate branch as microMIPS R6 doesn't restrict
+ branches in the forbidden slot. */
+ is_slot = 1;
+ }
}
if (is_slot) {
gen_branch(&ctx, insn_bytes);
@@ -19558,7 +20314,7 @@ done_generating:
LOG_DISAS("\n");
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
+ log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
@@ -19927,6 +20683,11 @@ void cpu_state_reset(CPUMIPSState *env)
restore_flush_mode(env);
restore_pamask(env);
cs->exception_index = EXCP_NONE;
+
+ if (semihosting_get_argc()) {
+ /* UHI interface can be used to obtain argc and argv */
+ env->active_tc.gpr[4] = -1;
+ }
}
void restore_state_to_opc(CPUMIPSState *env, TranslationBlock *tb, int pc_pos)
diff --git a/target-mips/translate_init.c b/target-mips/translate_init.c
index 30605dab06..ddfaff8052 100644
--- a/target-mips/translate_init.c
+++ b/target-mips/translate_init.c
@@ -424,6 +424,43 @@ static const mips_def_t mips_defs[] =
.insn_flags = CPU_MIPS32R5 | ASE_MIPS16 | ASE_MSA,
.mmu_type = MMU_TYPE_R4000,
},
+ {
+ /* A generic CPU supporting MIPS32 Release 6 ISA.
+ FIXME: Support IEEE 754-2008 FP.
+ Eventually this should be replaced by a real CPU model. */
+ .name = "mips32r6-generic",
+ .CP0_PRid = 0x00010000,
+ .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) |
+ (MMU_TYPE_R4000 << CP0C0_MT),
+ .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
+ (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
+ (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
+ (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
+ .CP0_Config2 = MIPS_CONFIG2,
+ .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_BP) | (1 << CP0C3_BI) |
+ (2 << CP0C3_ISA) | (1 << CP0C3_ULRI) |
+ (1 << CP0C3_RXI) | (1U << CP0C3_M),
+ .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
+ (3 << CP0C4_IE) | (1U << CP0C4_M),
+ .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_LLB),
+ .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
+ (1 << CP0C5_UFE),
+ .CP0_LLAddr_rw_bitmask = 0,
+ .CP0_LLAddr_shift = 0,
+ .SYNCI_Step = 32,
+ .CCRes = 2,
+ .CP0_Status_rw_bitmask = 0x3058FF1F,
+ .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
+ (1U << CP0PG_RIE),
+ .CP0_PageGrain_rw_bitmask = 0,
+ .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_F64) | (1 << FCR0_L) |
+ (1 << FCR0_W) | (1 << FCR0_D) | (1 << FCR0_S) |
+ (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
+ .SEGBITS = 32,
+ .PABITS = 32,
+ .insn_flags = CPU_MIPS32R6 | ASE_MICROMIPS,
+ .mmu_type = MMU_TYPE_R4000,
+ },
#if defined(TARGET_MIPS64)
{
.name = "R4000",
diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c
index dc76789785..a62cbf4011 100644
--- a/target-openrisc/translate.c
+++ b/target-openrisc/translate.c
@@ -1770,7 +1770,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("\n");
- log_target_disas(&cpu->env, pc_start, dc->pc - pc_start, 0);
+ log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%d\n",
dc->pc - pc_start, tcg_op_buf_count());
}
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 8f255ea5c2..84c5cead6b 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -11607,7 +11607,7 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
flags = env->bfd_mach;
flags |= ctx.le_mode << 16;
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, ctx.nip - pc_start, flags);
+ log_target_disas(cs, pc_start, ctx.nip - pc_start, flags);
qemu_log("\n");
}
#endif
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b02ff8d61d..135111a2c4 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -29,6 +29,7 @@
#include <asm/ptrace.h>
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
#include "sysemu/kvm.h"
@@ -36,7 +37,6 @@
#include "cpu.h"
#include "sysemu/device_tree.h"
#include "qapi/qmp/qjson.h"
-#include "monitor/monitor.h"
#include "exec/gdbstub.h"
#include "exec/address-spaces.h"
#include "trace.h"
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index 42f52c70c6..c748290d5c 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -5446,7 +5446,7 @@ static inline void gen_intermediate_code_internal(S390CPU *cpu,
#if defined(S390X_DEBUG_DISAS)
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, dc.pc - pc_start, 1);
+ log_target_disas(cs, pc_start, dc.pc - pc_start, 1);
qemu_log("\n");
}
#endif
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index 28259f9e14..3b4a1b5cea 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -1961,7 +1961,7 @@ gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */
- log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
+ log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index 3708c0148e..c58dd4e95b 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -5334,7 +5334,7 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu,
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("--------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, last_pc + 4 - pc_start, 0);
+ log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0);
qemu_log("\n");
}
#endif
diff --git a/target-tricore/translate.c b/target-tricore/translate.c
index 8d41239617..7dc7a325b4 100644
--- a/target-tricore/translate.c
+++ b/target-tricore/translate.c
@@ -8324,7 +8324,7 @@ gen_intermediate_code_internal(TriCoreCPU *cpu, struct TranslationBlock *tb,
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
+ log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c
index 9efcff5faf..2fc78e6f3e 100644
--- a/target-unicore32/translate.c
+++ b/target-unicore32/translate.c
@@ -2039,7 +2039,7 @@ done_generating:
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, dc->pc - pc_start, 0);
+ log_target_disas(cs, pc_start, dc->pc - pc_start, 0);
qemu_log("\n");
}
#endif
diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
index 3d52079233..86e4849fb6 100644
--- a/target-xtensa/translate.c
+++ b/target-xtensa/translate.c
@@ -3138,7 +3138,7 @@ void gen_intermediate_code_internal(XtensaCPU *cpu,
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
- log_target_disas(env, pc_start, dc.pc - pc_start, 0);
+ log_target_disas(cs, pc_start, dc.pc - pc_start, 0);
qemu_log("\n");
}
#endif
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 60e5b22a98..1cfffa5934 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1013,7 +1013,7 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) != 0);
+ g_assert(qbool_get_bool(qbool) == true);
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), "true") == 0);
@@ -1026,7 +1026,7 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) == 0);
+ g_assert(qbool_get_bool(qbool) == false);
str = qobject_to_json(obj);
g_assert(strcmp(qstring_get_str(str), "false") == 0);
@@ -1039,16 +1039,17 @@ static void keyword_literal(void)
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) == 0);
+ g_assert(qbool_get_bool(qbool) == false);
QDECREF(qbool);
- obj = qobject_from_jsonf("%i", true);
+ /* Test that non-zero values other than 1 get collapsed to true */
+ obj = qobject_from_jsonf("%i", 2);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
qbool = qobject_to_qbool(obj);
- g_assert(qbool_get_int(qbool) != 0);
+ g_assert(qbool_get_bool(qbool) == true);
QDECREF(qbool);
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 652dd63bf8..23c282357c 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -52,7 +52,6 @@ QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specif
Testing: -device virtio-scsi-pci -device scsi-hd
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device scsi-hd: drive property not set
-QEMU_PROG: -device scsi-hd: Device 'scsi-hd' could not be initialized
=== Overriding backing file ===
@@ -128,7 +127,6 @@ QEMU_PROG: Initialization of device ide-hd failed: Device initialization failed.
Testing: -drive if=virtio
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -drive if=virtio: Device needs media, but drive is empty
-QEMU_PROG: -drive if=virtio: Device 'virtio-blk-pci' could not be initialized
Testing: -drive if=scsi
QEMU X.Y.Z monitor - type 'help' for more information
@@ -146,23 +144,19 @@ Testing: -drive if=none,id=disk -device ide-drive,drive=disk
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device ide-drive,drive=disk: Device needs media, but drive is empty
QEMU_PROG: -device ide-drive,drive=disk: Device initialization failed.
-QEMU_PROG: -device ide-drive,drive=disk: Device 'ide-drive' could not be initialized
Testing: -drive if=none,id=disk -device ide-hd,drive=disk
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device ide-hd,drive=disk: Device needs media, but drive is empty
QEMU_PROG: -device ide-hd,drive=disk: Device initialization failed.
-QEMU_PROG: -device ide-hd,drive=disk: Device 'ide-hd' could not be initialized
Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device scsi-disk,drive=disk: Device needs media, but drive is empty
-QEMU_PROG: -device scsi-disk,drive=disk: Device 'scsi-disk' could not be initialized
Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device scsi-hd,drive=disk: Device needs media, but drive is empty
-QEMU_PROG: -device scsi-hd,drive=disk: Device 'scsi-hd' could not be initialized
=== Read-only ===
@@ -204,13 +198,11 @@ Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device ide-dr
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device ide-drive,drive=disk: Can't use a read-only drive
QEMU_PROG: -device ide-drive,drive=disk: Device initialization failed.
-QEMU_PROG: -device ide-drive,drive=disk: Device 'ide-drive' could not be initialized
Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device ide-hd,drive=disk
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) QEMU_PROG: -device ide-hd,drive=disk: Can't use a read-only drive
QEMU_PROG: -device ide-hd,drive=disk: Device initialization failed.
-QEMU_PROG: -device ide-hd,drive=disk: Device 'ide-hd' could not be initialized
Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk
QEMU X.Y.Z monitor - type 'help' for more information
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
index 9f41b5fd2e..161eeb496d 100644
--- a/tests/test-hbitmap.c
+++ b/tests/test-hbitmap.c
@@ -184,6 +184,23 @@ static void hbitmap_test_reset(TestHBitmapData *data,
}
}
+static void hbitmap_test_reset_all(TestHBitmapData *data)
+{
+ size_t n;
+
+ hbitmap_reset_all(data->hb);
+
+ n = (data->size + BITS_PER_LONG - 1) / BITS_PER_LONG;
+ if (n == 0) {
+ n = 1;
+ }
+ memset(data->bits, 0, n * sizeof(unsigned long));
+
+ if (data->granularity == 0) {
+ hbitmap_test_check(data, 0);
+ }
+}
+
static void hbitmap_test_check_get(TestHBitmapData *data)
{
uint64_t count = 0;
@@ -364,6 +381,26 @@ static void test_hbitmap_reset(TestHBitmapData *data,
hbitmap_test_set(data, L3 / 2, L3);
}
+static void test_hbitmap_reset_all(TestHBitmapData *data,
+ const void *unused)
+{
+ hbitmap_test_init(data, L3 * 2, 0);
+ hbitmap_test_set(data, L1 - 1, L1 + 2);
+ hbitmap_test_reset_all(data);
+ hbitmap_test_set(data, 0, L1 * 3);
+ hbitmap_test_reset_all(data);
+ hbitmap_test_set(data, L2, L1);
+ hbitmap_test_reset_all(data);
+ hbitmap_test_set(data, L2, L3 - L2 + 1);
+ hbitmap_test_reset_all(data);
+ hbitmap_test_set(data, L3 - 1, 3);
+ hbitmap_test_reset_all(data);
+ hbitmap_test_set(data, 0, L3 * 2);
+ hbitmap_test_reset_all(data);
+ hbitmap_test_set(data, L3 / 2, L3);
+ hbitmap_test_reset_all(data);
+}
+
static void test_hbitmap_granularity(TestHBitmapData *data,
const void *unused)
{
@@ -627,6 +664,7 @@ int main(int argc, char **argv)
hbitmap_test_add("/hbitmap/set/overlap", test_hbitmap_set_overlap);
hbitmap_test_add("/hbitmap/reset/empty", test_hbitmap_reset_empty);
hbitmap_test_add("/hbitmap/reset/general", test_hbitmap_reset);
+ hbitmap_test_add("/hbitmap/reset/all", test_hbitmap_reset_all);
hbitmap_test_add("/hbitmap/granularity", test_hbitmap_granularity);
hbitmap_test_add("/hbitmap/truncate/nop", test_hbitmap_truncate_nop);
diff --git a/tests/test-opts-visitor.c b/tests/test-opts-visitor.c
index ebeee5d589..1c753d9824 100644
--- a/tests/test-opts-visitor.c
+++ b/tests/test-opts-visitor.c
@@ -39,7 +39,8 @@ setup_fixture(OptsVisitorFixture *f, gconstpointer test_data)
QemuOpts *opts;
OptsVisitor *ov;
- opts = qemu_opts_parse(qemu_find_opts("userdef"), opts_string, 0);
+ opts = qemu_opts_parse(qemu_find_opts("userdef"), opts_string, false,
+ NULL);
g_assert(opts != NULL);
ov = opts_visitor_new(opts);
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index da564923d0..0c1136d1b2 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -323,7 +323,7 @@ static void test_qemu_opt_unset(void)
int ret;
/* dynamically initialized (parsed) opts */
- opts = qemu_opts_parse(&opts_list_03, "key=value", 0);
+ opts = qemu_opts_parse(&opts_list_03, "key=value", false, NULL);
g_assert(opts != NULL);
/* check default/parsed value */
diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c
index cb354e6e81..1ee40e148a 100644
--- a/tests/test-qmp-event.c
+++ b/tests/test-qmp-event.c
@@ -60,8 +60,8 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque)
switch (qobject_type(obj1)) {
case QTYPE_QBOOL:
- d->result = (qbool_get_int(qobject_to_qbool(obj1)) ==
- qbool_get_int(qobject_to_qbool(obj2)));
+ d->result = (qbool_get_bool(qobject_to_qbool(obj1)) ==
+ qbool_get_bool(qobject_to_qbool(obj2)));
return;
case QTYPE_QINT:
d->result = (qint_get_int(qobject_to_qint(obj1)) ==
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index f8c9367e48..87ba350b43 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -72,7 +72,7 @@ static void test_visitor_out_bool(TestOutputVisitorData *data,
obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL);
g_assert(qobject_type(obj) == QTYPE_QBOOL);
- g_assert(qbool_get_int(qobject_to_qbool(obj)) == value);
+ g_assert(qbool_get_bool(qobject_to_qbool(obj)) == value);
qobject_decref(obj);
}
@@ -223,7 +223,7 @@ static void test_visitor_out_struct(TestOutputVisitorData *data,
qdict = qobject_to_qdict(obj);
g_assert_cmpint(qdict_size(qdict), ==, 3);
g_assert_cmpint(qdict_get_int(qdict, "integer"), ==, 42);
- g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, 0);
+ g_assert_cmpint(qdict_get_bool(qdict, "boolean"), ==, false);
g_assert_cmpstr(qdict_get_str(qdict, "string"), ==, "foo");
QDECREF(qdict);
@@ -662,7 +662,7 @@ static void check_native_list(QObject *qobj,
tmp = qlist_peek(qlist);
g_assert(tmp);
qvalue = qobject_to_qbool(tmp);
- g_assert_cmpint(qbool_get_int(qvalue), ==, (i % 3 == 0) ? 1 : 0);
+ g_assert_cmpint(qbool_get_bool(qvalue), ==, i % 3 == 0);
qobject_decref(qlist_pop(qlist));
}
break;
diff --git a/tpm.c b/tpm.c
index a3f3b7f90f..4e9b109fba 100644
--- a/tpm.c
+++ b/tpm.c
@@ -13,11 +13,11 @@
*/
#include "config-host.h"
-#include "monitor/monitor.h"
#include "qapi/qmp/qerror.h"
#include "sysemu/tpm_backend.h"
#include "sysemu/tpm.h"
#include "qemu/config-file.h"
+#include "qemu/error-report.h"
#include "qmp-commands.h"
static QLIST_HEAD(, TPMBackend) tpm_backends =
@@ -140,21 +140,21 @@ static int configure_tpm(QemuOpts *opts)
id = qemu_opts_id(opts);
if (id == NULL) {
- qerror_report(QERR_MISSING_PARAMETER, "id");
+ error_report(QERR_MISSING_PARAMETER, "id");
return 1;
}
value = qemu_opt_get(opts, "type");
if (!value) {
- qerror_report(QERR_MISSING_PARAMETER, "type");
+ error_report(QERR_MISSING_PARAMETER, "type");
tpm_display_backend_drivers();
return 1;
}
be = tpm_get_backend_driver(value);
if (be == NULL) {
- qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",
- "a TPM backend type");
+ error_report(QERR_INVALID_PARAMETER_VALUE,
+ "type", "a TPM backend type");
tpm_display_backend_drivers();
return 1;
}
@@ -228,7 +228,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
tpm_display_backend_drivers();
return -1;
}
- opts = qemu_opts_parse(opts_list, optarg, 1);
+ opts = qemu_opts_parse_noisily(opts_list, optarg, true);
if (!opts) {
return -1;
}
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 3e9bb380e5..e50f2968e1 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -23,7 +23,6 @@
*/
#include "sysemu/sysemu.h"
-#include "monitor/monitor.h"
#include "ui/console.h"
#include "qapi/error.h"
#include "qmp-commands.h"
diff --git a/ui/input.c b/ui/input.c
index eeeabe844c..1a552d1de1 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -1,6 +1,7 @@
#include "hw/qdev.h"
#include "sysemu/sysemu.h"
#include "qapi-types.h"
+#include "qemu/error-report.h"
#include "qmp-commands.h"
#include "trace.h"
#include "ui/input.h"
@@ -84,7 +85,8 @@ void qemu_input_handler_bind(QemuInputHandlerState *s,
dev = qdev_find_recursive(sysbus_get_default(), device_id);
if (dev == NULL) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device_id);
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+ "Device '%s' not found", device_id);
return;
}
diff --git a/ui/spice-core.c b/ui/spice-core.c
index a30da3cf9f..bf4fd07499 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -22,6 +22,7 @@
#include "qemu-common.h"
#include "ui/qemu-spice.h"
+#include "qemu/error-report.h"
#include "qemu/thread.h"
#include "qemu/timer.h"
#include "qemu/queue.h"
diff --git a/ui/spice-display.c b/ui/spice-display.c
index cc4a6ce98d..0360abfd2c 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -19,7 +19,6 @@
#include "ui/qemu-spice.h"
#include "qemu/timer.h"
#include "qemu/queue.h"
-#include "monitor/monitor.h"
#include "ui/console.h"
#include "sysemu/sysemu.h"
#include "trace.h"
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index c8ee203495..22c9abce55 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -29,6 +29,7 @@
#include "vnc.h"
#include "vnc-jobs.h"
#include "qemu/sockets.h"
+#include "block/aio.h"
/*
* Locking:
diff --git a/ui/vnc.c b/ui/vnc.c
index 69b605c709..2ffd9e500f 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -29,10 +29,12 @@
#include "trace.h"
#include "hw/qdev.h"
#include "sysemu/sysemu.h"
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "qemu/timer.h"
#include "qemu/acl.h"
#include "qemu/config-file.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/qmp/types.h"
#include "qmp-commands.h"
#include "qemu/osdep.h"
@@ -427,7 +429,7 @@ VncInfo *qmp_query_vnc(Error **errp)
if (getsockname(vd->lsock, (struct sockaddr *)&sa,
&salen) == -1) {
- error_set(errp, QERR_UNDEFINED_ERROR);
+ error_setg(errp, QERR_UNDEFINED_ERROR);
goto out_error;
}
@@ -435,7 +437,7 @@ VncInfo *qmp_query_vnc(Error **errp)
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV) < 0) {
- error_set(errp, QERR_UNDEFINED_ERROR);
+ error_setg(errp, QERR_UNDEFINED_ERROR);
goto out_error;
}
@@ -3749,10 +3751,10 @@ static void vnc_auto_assign_id(QemuOptsList *olist, QemuOpts *opts)
qemu_opts_set_id(opts, id);
}
-QemuOpts *vnc_parse_func(const char *str)
+QemuOpts *vnc_parse(const char *str, Error **errp)
{
QemuOptsList *olist = qemu_find_opts("vnc");
- QemuOpts *opts = qemu_opts_parse(olist, str, 1);
+ QemuOpts *opts = qemu_opts_parse(olist, str, true, errp);
const char *id;
if (!opts) {
diff --git a/util/hbitmap.c b/util/hbitmap.c
index a10c7aeeda..50b888fd60 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -356,6 +356,19 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count)
hb_reset_between(hb, HBITMAP_LEVELS - 1, start, last);
}
+void hbitmap_reset_all(HBitmap *hb)
+{
+ unsigned int i;
+
+ /* Same as hbitmap_alloc() except for memset() instead of malloc() */
+ for (i = HBITMAP_LEVELS; --i >= 1; ) {
+ memset(hb->levels[i], 0, hb->sizes[i] * sizeof(unsigned long));
+ }
+
+ hb->levels[0][0] = 1UL << (BITS_PER_LONG - 1);
+ hb->count = 0;
+}
+
bool hbitmap_get(const HBitmap *hb, uint64_t item)
{
/* Compute position and bit in the last layer. */
diff --git a/util/iov.c b/util/iov.c
index 2fb18e6654..a0d5934e8e 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
#endif
}
-ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
+ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
size_t offset, size_t bytes,
bool do_send)
{
@@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
ssize_t ret;
size_t orig_len, tail;
unsigned niov;
+ struct iovec *local_iov, *iov;
+
+ if (bytes <= 0) {
+ return 0;
+ }
+
+ local_iov = g_new0(struct iovec, iov_cnt);
+ iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
+ offset = 0;
+ iov = local_iov;
while (bytes > 0) {
/* Find the start position, skipping `offset' bytes:
@@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
if (ret < 0) {
assert(errno != EINTR);
+ g_free(local_iov);
if (errno == EAGAIN && total > 0) {
return total;
}
@@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
bytes -= ret;
}
+ g_free(local_iov);
return total;
}
diff --git a/util/osdep.c b/util/osdep.c
index f938b69466..0092bb61b9 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -47,6 +47,7 @@ extern int madvise(caddr_t, size_t, int);
#include "qemu-common.h"
#include "qemu/sockets.h"
+#include "qemu/error-report.h"
#include "monitor/monitor.h"
static bool fips_enabled = false;
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 6cfdd7204a..5fcfd0e6ac 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -2,7 +2,6 @@
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
-#include "qapi/qmp/qerror.h"
#include "qapi/error.h"
#include "qmp-commands.h"
diff --git a/util/qemu-error.c b/util/qemu-error.c
index 9bba5f53d8..77ea6c6145 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include "monitor/monitor.h"
+#include "qemu/error-report.h"
/*
* Print to current monitor if we have one, else to stderr.
@@ -202,7 +203,7 @@ bool enable_timestamp_msg;
* Format arguments like vsprintf(). The result should not contain
* newlines.
* Prepend the current location and append a newline.
- * It's wrong to call this in a QMP monitor. Use qerror_report() there.
+ * It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void error_vreport(const char *fmt, va_list ap)
{
@@ -226,7 +227,7 @@ void error_vreport(const char *fmt, va_list ap)
* Format arguments like sprintf(). The result should not contain
* newlines.
* Prepend the current location and append a newline.
- * It's wrong to call this in a QMP monitor. Use qerror_report() there.
+ * It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void error_report(const char *fmt, ...)
{
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 840f5f7a5b..efe9d279c4 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -132,7 +132,8 @@ static void parse_option_bool(const char *name, const char *value, bool *ret,
} else if (!strcmp(value, "off")) {
*ret = 0;
} else {
- error_set(errp,QERR_INVALID_PARAMETER_VALUE, name, "'on' or 'off'");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ name, "'on' or 'off'");
}
} else {
*ret = 1;
@@ -148,12 +149,12 @@ static void parse_option_number(const char *name, const char *value,
if (value != NULL) {
number = strtoull(value, &postfix, 0);
if (*postfix != '\0') {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
return;
}
*ret = number;
} else {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a number");
}
}
@@ -198,7 +199,7 @@ void parse_option_size(const char *name, const char *value,
*ret = (uint64_t) sizef;
break;
default:
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
#if 0 /* conversion from qerror_report() to error_set() broke this: */
error_printf_unless_qmp("You may use k, M, G or T suffixes for "
"kilobytes, megabytes, gigabytes and terabytes.\n");
@@ -206,7 +207,7 @@ void parse_option_size(const char *name, const char *value,
return;
}
} else {
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
}
}
@@ -527,7 +528,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,
desc = find_desc_by_name(opts->list->desc, name);
if (!desc && !opts_accepts_any(opts)) {
- error_set(errp, QERR_INVALID_PARAMETER, name);
+ error_setg(errp, QERR_INVALID_PARAMETER, name);
return;
}
@@ -563,7 +564,7 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
opt = g_malloc0(sizeof(*opt));
opt->desc = find_desc_by_name(desc, name);
if (!opt->desc && !opts_accepts_any(opts)) {
- error_set(errp, QERR_INVALID_PARAMETER, name);
+ error_setg(errp, QERR_INVALID_PARAMETER, name);
g_free(opt);
return;
}
@@ -584,7 +585,7 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
opt = g_malloc0(sizeof(*opt));
opt->desc = find_desc_by_name(desc, name);
if (!opt->desc && !opts_accepts_any(opts)) {
- error_set(errp, QERR_INVALID_PARAMETER, name);
+ error_setg(errp, QERR_INVALID_PARAMETER, name);
g_free(opt);
return;
}
@@ -640,7 +641,8 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
if (id) {
if (!id_wellformed(id)) {
- error_set(errp,QERR_INVALID_PARAMETER_VALUE, "id", "an identifier");
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id",
+ "an identifier");
#if 0 /* conversion from qerror_report() to error_set() broke this: */
error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n");
#endif
@@ -820,7 +822,7 @@ void qemu_opts_do_parse(QemuOpts *opts, const char *params,
}
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
- int permit_abbrev, bool defaults, Error **errp)
+ bool permit_abbrev, bool defaults, Error **errp)
{
const char *firstname;
char value[1024], *id = NULL;
@@ -867,19 +869,32 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
* Create a QemuOpts in @list and with options parsed from @params.
* If @permit_abbrev, the first key=value in @params may omit key=,
* and is treated as if key was @list->implied_opt_name.
- * Report errors with qerror_report_err().
+ * On error, store an error object through @errp if non-null.
* Return the new QemuOpts on success, null pointer on error.
*/
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
- int permit_abbrev)
+ bool permit_abbrev, Error **errp)
+{
+ return opts_parse(list, params, permit_abbrev, false, errp);
+}
+
+/**
+ * Create a QemuOpts in @list and with options parsed from @params.
+ * If @permit_abbrev, the first key=value in @params may omit key=,
+ * and is treated as if key was @list->implied_opt_name.
+ * Report errors with error_report_err(). This is inappropriate in
+ * QMP context. Do not use this function there!
+ * Return the new QemuOpts on success, null pointer on error.
+ */
+QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const char *params,
+ bool permit_abbrev)
{
Error *err = NULL;
QemuOpts *opts;
opts = opts_parse(list, params, permit_abbrev, false, &err);
- if (!opts) {
- qerror_report_err(err);
- error_free(err);
+ if (err) {
+ error_report_err(err);
}
return opts;
}
@@ -927,7 +942,7 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
break;
case QTYPE_QBOOL:
pstrcpy(buf, sizeof(buf),
- qbool_get_int(qobject_to_qbool(obj)) ? "on" : "off");
+ qbool_get_bool(qobject_to_qbool(obj)) ? "on" : "off");
value = buf;
break;
default:
@@ -1042,7 +1057,7 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
QTAILQ_FOREACH(opt, &opts->head, next) {
opt->desc = find_desc_by_name(desc, opt->name);
if (!opt->desc) {
- error_set(errp, QERR_INVALID_PARAMETER, opt->name);
+ error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
return;
}
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 4026314435..2add83a0fc 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -29,6 +29,9 @@
#ifndef AI_ADDRCONFIG
# define AI_ADDRCONFIG 0
#endif
+#ifndef AI_V4MAPPED
+# define AI_V4MAPPED 0
+#endif
/* used temporarily until all users are converted to QemuOpts */
QemuOptsList socket_optslist = {
@@ -118,7 +121,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
int slisten, rc, to, port_min, port_max, p;
memset(&ai,0, sizeof(ai));
- ai.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+ ai.ai_flags = AI_PASSIVE;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
@@ -335,7 +338,7 @@ static struct addrinfo *inet_parse_connect_opts(QemuOpts *opts, Error **errp)
memset(&ai, 0, sizeof(ai));
- ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+ ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_STREAM;
@@ -435,7 +438,7 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp)
/* lookup peer addr */
memset(&ai,0, sizeof(ai));
- ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+ ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
ai.ai_family = PF_UNSPEC;
ai.ai_socktype = SOCK_DGRAM;
diff --git a/vl.c b/vl.c
index 0c2208f723..69ad90c87f 100644
--- a/vl.c
+++ b/vl.c
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
#include <glib.h>
+#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "hw/hw.h"
#include "hw/boards.h"
@@ -990,13 +991,13 @@ static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
if (qemu_opt_get_bool(opts, "enable", false)) {
#ifdef CONFIG_SECCOMP
if (seccomp_start() < 0) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "failed to install seccomp syscall filter in the kernel");
+ error_report("failed to install seccomp syscall filter "
+ "in the kernel");
return -1;
}
#else
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "sandboxing request but seccomp is not compiled into this build");
+ error_report("sandboxing request but seccomp is not compiled "
+ "into this build");
return -1;
#endif
}
@@ -1044,14 +1045,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
fd_opaque = qemu_opt_get(opts, "opaque");
if (fd < 0) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "fd option is required and must be non-negative");
+ error_report("fd option is required and must be non-negative");
return -1;
}
if (fd <= STDERR_FILENO) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "fd cannot be a standard I/O stream");
+ error_report("fd cannot be a standard I/O stream");
return -1;
}
@@ -1061,14 +1060,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
*/
flags = fcntl(fd, F_GETFD);
if (flags == -1 || (flags & FD_CLOEXEC)) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "fd is not valid or already in use");
+ error_report("fd is not valid or already in use");
return -1;
}
if (fdset_id < 0) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "set option is required and must be non-negative");
+ error_report("set option is required and must be non-negative");
return -1;
}
@@ -1081,8 +1078,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
}
#endif
if (dupfd == -1) {
- qerror_report(ERROR_CLASS_GENERIC_ERROR,
- "Error duplicating fd: %s", strerror(errno));
+ error_report("Error duplicating fd: %s", strerror(errno));
return -1;
}
@@ -2046,6 +2042,7 @@ static void select_vgahw (const char *p)
static DisplayType select_display(const char *p)
{
+ Error *err = NULL;
const char *opts;
DisplayType display = DT_DEFAULT;
@@ -2102,34 +2099,35 @@ static DisplayType select_display(const char *p)
}
} else {
invalid_sdl_args:
- fprintf(stderr, "Invalid SDL option string: %s\n", p);
+ error_report("Invalid SDL option string");
exit(1);
}
opts = nextopt;
}
#else
- fprintf(stderr, "SDL support is disabled\n");
+ error_report("SDL support is disabled");
exit(1);
#endif
} else if (strstart(p, "vnc", &opts)) {
#ifdef CONFIG_VNC
if (*opts == '=') {
- if (vnc_parse_func(opts+1) == NULL) {
+ if (vnc_parse(opts + 1, &err) == NULL) {
+ error_report_err(err);
exit(1);
}
} else {
- fprintf(stderr, "VNC requires a display argument vnc=<display>\n");
+ error_report("VNC requires a display argument vnc=<display>");
exit(1);
}
#else
- fprintf(stderr, "VNC support is disabled\n");
+ error_report("VNC support is disabled");
exit(1);
#endif
} else if (strstart(p, "curses", &opts)) {
#ifdef CONFIG_CURSES
display = DT_CURSES;
#else
- fprintf(stderr, "Curses support is disabled\n");
+ error_report("Curses support is disabled");
exit(1);
#endif
} else if (strstart(p, "gtk", &opts)) {
@@ -2158,19 +2156,19 @@ static DisplayType select_display(const char *p)
}
} else {
invalid_gtk_args:
- fprintf(stderr, "Invalid GTK option string: %s\n", p);
+ error_report("Invalid GTK option string");
exit(1);
}
opts = nextopt;
}
#else
- fprintf(stderr, "GTK support is disabled\n");
+ error_report("GTK support is disabled");
exit(1);
#endif
} else if (strstart(p, "none", &opts)) {
display = DT_NONE;
} else {
- fprintf(stderr, "Unknown display type: %s\n", p);
+ error_report("Unknown display type");
exit(1);
}
@@ -2188,7 +2186,8 @@ static int balloon_parse(const char *arg)
if (!strncmp(arg, "virtio", 6)) {
if (arg[6] == ',') {
/* have params -> parse them */
- opts = qemu_opts_parse(qemu_find_opts("device"), arg+7, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("device"), arg + 7,
+ false);
if (!opts)
return -1;
} else {
@@ -2276,11 +2275,14 @@ static int device_help_func(void *opaque, QemuOpts *opts, Error **errp)
static int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
{
+ Error *err = NULL;
DeviceState *dev;
- dev = qdev_device_add(opts);
- if (!dev)
+ dev = qdev_device_add(opts, &err);
+ if (!dev) {
+ error_report_err(err);
return -1;
+ }
object_unref(OBJECT(dev));
return 0;
}
@@ -3064,7 +3066,7 @@ int main(int argc, char **argv, char **envp)
switch(popt->index) {
case QEMU_OPTION_no_kvm_irqchip: {
olist = qemu_find_opts("machine");
- qemu_opts_parse(olist, "kernel_irqchip=off", 0);
+ qemu_opts_parse_noisily(olist, "kernel_irqchip=off", false);
break;
}
case QEMU_OPTION_cpu:
@@ -3181,7 +3183,8 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_numa:
- opts = qemu_opts_parse(qemu_find_opts("numa"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
+ optarg, true);
if (!opts) {
exit(1);
}
@@ -3232,7 +3235,8 @@ int main(int argc, char **argv, char **envp)
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
- opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("boot-opts"),
+ optarg, true);
if (!opts) {
exit(1);
}
@@ -3257,7 +3261,8 @@ int main(int argc, char **argv, char **envp)
break;
#ifdef CONFIG_LIBISCSI
case QEMU_OPTION_iscsi:
- opts = qemu_opts_parse(qemu_find_opts("iscsi"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
+ optarg, false);
if (!opts) {
exit(1);
}
@@ -3293,8 +3298,8 @@ int main(int argc, char **argv, char **envp)
exit(0);
break;
case QEMU_OPTION_m:
- opts = qemu_opts_parse(qemu_find_opts("memory"),
- optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("memory"),
+ optarg, true);
if (!opts) {
exit(EXIT_FAILURE);
}
@@ -3406,14 +3411,16 @@ int main(int argc, char **argv, char **envp)
default_monitor = 0;
break;
case QEMU_OPTION_mon:
- opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg,
+ true);
if (!opts) {
exit(1);
}
default_monitor = 0;
break;
case QEMU_OPTION_chardev:
- opts = qemu_opts_parse(qemu_find_opts("chardev"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"),
+ optarg, true);
if (!opts) {
exit(1);
}
@@ -3424,7 +3431,7 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "fsdev is not supported by this qemu build.\n");
exit(1);
}
- opts = qemu_opts_parse(olist, optarg, 1);
+ opts = qemu_opts_parse_noisily(olist, optarg, true);
if (!opts) {
exit(1);
}
@@ -3439,7 +3446,7 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "virtfs is not supported by this qemu build.\n");
exit(1);
}
- opts = qemu_opts_parse(olist, optarg, 1);
+ opts = qemu_opts_parse_noisily(olist, optarg, true);
if (!opts) {
exit(1);
}
@@ -3599,40 +3606,43 @@ int main(int argc, char **argv, char **envp)
break;
}
case QEMU_OPTION_acpitable:
- opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"),
+ optarg, true);
if (!opts) {
exit(1);
}
do_acpitable_option(opts);
break;
case QEMU_OPTION_smbios:
- opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"),
+ optarg, false);
if (!opts) {
exit(1);
}
do_smbios_option(opts);
break;
case QEMU_OPTION_fwcfg:
- opts = qemu_opts_parse(qemu_find_opts("fw_cfg"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
+ optarg, true);
if (opts == NULL) {
exit(1);
}
break;
case QEMU_OPTION_enable_kvm:
olist = qemu_find_opts("machine");
- qemu_opts_parse(olist, "accel=kvm", 0);
+ qemu_opts_parse_noisily(olist, "accel=kvm", false);
break;
case QEMU_OPTION_M:
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
- opts = qemu_opts_parse(olist, optarg, 1);
+ opts = qemu_opts_parse_noisily(olist, optarg, true);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_no_kvm:
olist = qemu_find_opts("machine");
- qemu_opts_parse(olist, "accel=tcg", 0);
+ qemu_opts_parse_noisily(olist, "accel=tcg", false);
break;
case QEMU_OPTION_no_kvm_pit: {
fprintf(stderr, "Warning: KVM PIT can no longer be disabled "
@@ -3656,26 +3666,32 @@ int main(int argc, char **argv, char **envp)
}
case QEMU_OPTION_usb:
olist = qemu_find_opts("machine");
- qemu_opts_parse(olist, "usb=on", 0);
+ qemu_opts_parse_noisily(olist, "usb=on", false);
break;
case QEMU_OPTION_usbdevice:
olist = qemu_find_opts("machine");
- qemu_opts_parse(olist, "usb=on", 0);
+ qemu_opts_parse_noisily(olist, "usb=on", false);
add_device_config(DEV_USB, optarg);
break;
case QEMU_OPTION_device:
- if (!qemu_opts_parse(qemu_find_opts("device"), optarg, 1)) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
+ optarg, true)) {
exit(1);
}
break;
case QEMU_OPTION_smp:
- if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) {
+ if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"),
+ optarg, true)) {
exit(1);
}
break;
case QEMU_OPTION_vnc:
+ {
#ifdef CONFIG_VNC
- if (vnc_parse_func(optarg) == NULL) {
+ Error *local_err = NULL;
+
+ if (vnc_parse(optarg, &local_err) == NULL) {
+ error_report_err(local_err);
exit(1);
}
#else
@@ -3683,6 +3699,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
#endif
break;
+ }
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
@@ -3717,7 +3734,8 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "Too many option ROMs\n");
exit(1);
}
- opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("option-rom"),
+ optarg, true);
if (!opts) {
exit(1);
}
@@ -3736,8 +3754,8 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_semihosting_config:
semihosting.enabled = true;
- opts = qemu_opts_parse(qemu_find_opts("semihosting-config"),
- optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("semihosting-config"),
+ optarg, false);
if (opts != NULL) {
semihosting.enabled = qemu_opt_get_bool(opts, "enable",
true);
@@ -3772,7 +3790,8 @@ int main(int argc, char **argv, char **envp)
"is no longer supported.\n");
break;
case QEMU_OPTION_name:
- opts = qemu_opts_parse(qemu_find_opts("name"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("name"),
+ optarg, true);
if (!opts) {
exit(1);
}
@@ -3797,7 +3816,8 @@ int main(int argc, char **argv, char **envp)
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
- opts = qemu_opts_parse(qemu_find_opts("rtc"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg,
+ false);
if (!opts) {
exit(1);
}
@@ -3810,8 +3830,8 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_icount:
- icount_opts = qemu_opts_parse(qemu_find_opts("icount"),
- optarg, 1);
+ icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"),
+ optarg, true);
if (!icount_opts) {
exit(1);
}
@@ -3848,7 +3868,8 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_trace:
{
- opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
+ optarg, false);
if (!opts) {
exit(1);
}
@@ -3872,7 +3893,7 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "spice is not supported by this qemu build.\n");
exit(1);
}
- opts = qemu_opts_parse(olist, optarg, 0);
+ opts = qemu_opts_parse_noisily(olist, optarg, false);
if (!opts) {
exit(1);
}
@@ -3903,14 +3924,16 @@ int main(int argc, char **argv, char **envp)
qtest_log = optarg;
break;
case QEMU_OPTION_sandbox:
- opts = qemu_opts_parse(qemu_find_opts("sandbox"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"),
+ optarg, true);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_add_fd:
#ifndef _WIN32
- opts = qemu_opts_parse(qemu_find_opts("add-fd"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"),
+ optarg, false);
if (!opts) {
exit(1);
}
@@ -3921,20 +3944,23 @@ int main(int argc, char **argv, char **envp)
#endif
break;
case QEMU_OPTION_object:
- opts = qemu_opts_parse(qemu_find_opts("object"), optarg, 1);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
+ optarg, true);
if (!opts) {
exit(1);
}
break;
case QEMU_OPTION_realtime:
- opts = qemu_opts_parse(qemu_find_opts("realtime"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"),
+ optarg, false);
if (!opts) {
exit(1);
}
enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
break;
case QEMU_OPTION_msg:
- opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
+ opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg,
+ false);
if (!opts) {
exit(1);
}
@@ -4186,7 +4212,7 @@ int main(int argc, char **argv, char **envp)
#elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
#elif defined(CONFIG_VNC)
- vnc_parse_func("localhost:0,to=99,id=default");
+ vnc_parse("localhost:0,to=99,id=default", &error_abort);
show_vnc_port = 1;
#else
display_type = DT_NONE;
diff --git a/xen-hvm.c b/xen-hvm.c
index 42356b836a..040846236c 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -87,12 +87,6 @@ static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu)
#endif
#define BUFFER_IO_MAX_DELAY 100
-/* Leave some slack so that hvmloader does not complain about lack of
- * memory at boot time ("Could not allocate order=0 extent").
- * Once hvmloader is modified to cope with that situation without
- * printing warning messages, QEMU_SPARE_PAGES can be removed.
- */
-#define QEMU_SPARE_PAGES 16
typedef struct XenPhysmap {
hwaddr start_addr;
@@ -250,8 +244,6 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
unsigned long nr_pfn;
xen_pfn_t *pfn_list;
int i;
- xc_domaininfo_t info;
- unsigned long free_pages;
if (runstate_check(RUN_STATE_INMIGRATE)) {
/* RAM already populated in Xen */
@@ -274,22 +266,6 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
pfn_list[i] = (ram_addr >> TARGET_PAGE_BITS) + i;
}
- if ((xc_domain_getinfolist(xen_xc, xen_domid, 1, &info) != 1) ||
- (info.domain != xen_domid)) {
- hw_error("xc_domain_getinfolist failed");
- }
- free_pages = info.max_pages - info.tot_pages;
- if (free_pages > QEMU_SPARE_PAGES) {
- free_pages -= QEMU_SPARE_PAGES;
- } else {
- free_pages = 0;
- }
- if ((free_pages < nr_pfn) &&
- (xc_domain_setmaxmem(xen_xc, xen_domid,
- ((info.max_pages + nr_pfn - free_pages)
- << (XC_PAGE_SHIFT - 10))) < 0)) {
- hw_error("xc_domain_setmaxmem failed");
- }
if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, pfn_list)) {
hw_error("xen: failed to populate ram at " RAM_ADDR_FMT, ram_addr);
}