From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuMUt-0005tM-UN for qemu-devel@nongnu.org; Thu, 05 Nov 2015 10:31:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuMUS-0002dF-Jd for qemu-devel@nongnu.org; Thu, 05 Nov 2015 10:30:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuMUR-0002cz-M3 for qemu-devel@nongnu.org; Thu, 05 Nov 2015 10:30:16 -0500 From: Markus Armbruster Date: Thu, 5 Nov 2015 16:30:00 +0100 Message-Id: <1446737402-15597-4-git-send-email-armbru@redhat.com> In-Reply-To: <1446737402-15597-1-git-send-email-armbru@redhat.com> References: <1446618049-13596-22-git-send-email-eblake@redhat.com> <1446737402-15597-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC 3/5] qapi: Use common name mangling for enumeration constants List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com QAPI names needn't be valid C identifiers, so we mangle them with c_name(). Except for enumeration constants, which we mangle with camel_to_upper(). c_name() is easy enough to understand: replace '.' and '-' by '_', prefix certain ticklish identifiers with 'q_'. camel_to_upper() is a hairball of heuristics, and guessing how it'll mangle interesting input could serve as a (nerdy) game. Despite some tweaking (commit 5d371f4), it's still inadqeuate for some QAPI names (commit 351d36e). Example: QAPI definition { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] } generates typedef enum BlockDeviceIoStatus { BLOCK_DEVICE_IO_STATUS_OK = 0, BLOCK_DEVICE_IO_STATUS_FAILED = 1, BLOCK_DEVICE_IO_STATUS_NOSPACE = 2, BLOCK_DEVICE_IO_STATUS_MAX = 3, } BlockDeviceIoStatus; Observe that c_name() maps BlockDeviceIoStatus to itself, and camel_to_upper() maps it to BLOCK_DEVICE_IO_STATUS, i.e. the enumeration constants are shouted, the enumeration type isn't. Because mangled names must not clash, name mangling restricts the names you can use. For example, you can't have member 'a-b' and 'a_b'. Having two separate manglings complicates this. Enumeration constants must be distinct after mangling with camel_to_upper(). But as soon as you use the enumeration as union tag, they must *also* be distinct after mangling with c_name(). Having shouted enumeration constants isn't worth the complexity cost. Mangle them with c_name() instead, and drop camel_to_upper() along with its helper camel_case(). The example above becomes typedef enum BlockDeviceIoStatus { BlockDeviceIoStatus_ok = 0, BlockDeviceIoStatus_failed = 1, BlockDeviceIoStatus_nospace = 2, BlockDeviceIoStatus_MAX = 3, } BlockDeviceIoStatus; Use the sed script generated with the help of the commit just reverted to update the code using QAPI-generated enumeration constants. The sed script misses an occurence in target-i386/cpu.c, because we construct enumeration constants with the ## operator there. Updated manually. The sed script misses commented out occurences in ui/sdl2-keymap.h that show possible future extensions, i.e. enumeration constants that aren't defined, yet. Update them like this: $ sed -r -i 's/Q_KEY_CODE(_[A-Za-z0-9_]*)/QKeyCode\L\1/' ui/sdl2-keymap.h The changed mangling affects a few tests. Fix them up. Examples in docs/qapi-code-gen.txt updated manually. The paragraph explaining enumeration type name mangling is now obsolete. I'll fix it shortly, mark it FIXME until then. "git-grep -E $enum_mangle_regexp" with enum_mangle_regexp from the commit just reverted shows possible missed occurences. Most of them are QCRYPTO_TLS_CREDS_ENDPOINT, which is not to be replaced now, because it uses the name mangling override from commit 351d36e. The rest are all false positives. Signed-off-by: Markus Armbruster --- backends/baum.c | 2 +- backends/hostmem.c | 10 +- backends/msmouse.c | 2 +- backends/rng-egd.c | 2 +- backends/testdev.c | 2 +- balloon.c | 4 +- block.c | 18 +- block/backup.c | 20 +- block/block-backend.c | 38 +-- block/commit.c | 12 +- block/io.c | 4 +- block/mirror.c | 22 +- block/nbd.c | 6 +- block/qcow2.c | 10 +- block/quorum.c | 10 +- block/raw-posix.c | 8 +- block/stream.c | 10 +- block/vmdk.c | 2 +- blockdev-nbd.c | 2 +- blockdev.c | 134 ++++----- blockjob.c | 30 +- crypto/tlscredsanon.c | 6 +- crypto/tlscredsx509.c | 6 +- crypto/tlssession.c | 6 +- docs/qapi-code-gen.txt | 11 +- docs/writing-qmp-commands.txt | 8 +- dump.c | 28 +- gdbstub.c | 26 +- hmp.c | 80 +++--- hw/acpi/memory_hotplug.c | 2 +- hw/arm/musicpal.c | 2 +- hw/block/block.c | 2 +- hw/block/fdc.c | 4 +- hw/block/hd-geometry.c | 12 +- hw/block/virtio-blk.c | 8 +- hw/char/escc.c | 246 ++++++++-------- hw/core/qdev-properties-system.c | 2 +- hw/display/qxl.c | 4 +- hw/i386/kvm/i8254.c | 6 +- hw/i386/pc.c | 10 +- hw/i386/pc_piix.c | 10 +- hw/i386/pc_q35.c | 10 +- hw/ide/ahci.c | 4 +- hw/ide/core.c | 6 +- hw/ide/qdev.c | 2 +- hw/input/hid.c | 26 +- hw/input/ps2.c | 20 +- hw/input/virtio-input-hid.c | 242 ++++++++-------- hw/mem/pc-dimm.c | 2 +- hw/net/allwinner_emac.c | 2 +- hw/net/cadence_gem.c | 2 +- hw/net/dp8393x.c | 2 +- hw/net/e1000.c | 2 +- hw/net/eepro100.c | 2 +- hw/net/etraxfs_eth.c | 2 +- hw/net/fsl_etsec/etsec.c | 2 +- hw/net/imx_fec.c | 2 +- hw/net/lan9118.c | 2 +- hw/net/lance.c | 2 +- hw/net/mcf_fec.c | 2 +- hw/net/milkymist-minimac2.c | 2 +- hw/net/mipsnet.c | 2 +- hw/net/ne2000-isa.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/opencores_eth.c | 2 +- hw/net/pcnet-pci.c | 2 +- hw/net/rocker/rocker.c | 4 +- hw/net/rocker/rocker_fp.c | 2 +- hw/net/rocker/rocker_of_dpa.c | 8 +- hw/net/rtl8139.c | 2 +- hw/net/smc91c111.c | 2 +- hw/net/spapr_llan.c | 2 +- hw/net/stellaris_enet.c | 2 +- hw/net/vhost_net.c | 18 +- hw/net/virtio-net.c | 28 +- hw/net/vmxnet3.c | 2 +- hw/net/xen_nic.c | 2 +- hw/net/xgmac.c | 2 +- hw/net/xilinx_axienet.c | 2 +- hw/net/xilinx_ethlite.c | 2 +- hw/ppc/spapr_rtas.c | 2 +- hw/scsi/scsi-disk.c | 6 +- hw/scsi/scsi-generic.c | 4 +- hw/timer/mc146818rtc.c | 14 +- hw/tpm/tpm_passthrough.c | 2 +- hw/tpm/tpm_tis.c | 4 +- hw/usb/dev-network.c | 2 +- hw/usb/hcd-ehci.c | 4 +- hw/usb/redirect.c | 8 +- hw/vfio/pci.c | 2 +- hw/watchdog/watchdog.c | 16 +- include/block/block_int.h | 2 +- include/crypto/tlssession.h | 2 +- include/migration/migration.h | 4 +- include/qapi/error.h | 6 +- include/ui/input.h | 8 +- include/ui/qemu-spice.h | 2 +- kvm-all.c | 2 +- migration/migration.c | 170 +++++------ migration/ram.c | 4 +- migration/rdma.c | 2 +- migration/savevm.c | 4 +- monitor.c | 62 ++-- net/dump.c | 4 +- net/filter.c | 10 +- net/hub.c | 20 +- net/l2tpv3.c | 4 +- net/net.c | 78 ++--- net/netmap.c | 2 +- net/slirp.c | 4 +- net/socket.c | 6 +- net/tap-win32.c | 4 +- net/tap.c | 20 +- net/vde.c | 4 +- net/vhost-user.c | 16 +- numa.c | 4 +- qapi/qmp-dispatch.c | 2 +- qdev-monitor.c | 4 +- qemu-char.c | 54 ++-- qemu-img.c | 2 +- qemu-nbd.c | 12 +- qga/commands-posix.c | 34 +-- qga/commands-win32.c | 44 +-- qmp.c | 16 +- qom/object.c | 6 +- scripts/qapi.py | 48 +--- spice-qemu-char.c | 4 +- stubs/runstate-check.c | 2 +- target-i386/cpu.c | 2 +- target-lm32/op_helper.c | 2 +- tests/qapi-schema/enum-clash-member.err | 2 +- tests/qapi-schema/enum-clash-member.json | 2 +- tests/qapi-schema/enum-max-member.err | 2 +- tests/qapi-schema/enum-max-member.json | 4 +- tests/qapi-schema/union-bad-branch.err | 2 +- tests/qapi-schema/union-bad-branch.json | 4 +- tests/qapi-schema/union-max.err | 2 +- tests/qapi-schema/union-max.json | 2 +- tests/test-crypto-tlscredsx509.c | 6 +- tests/test-crypto-tlssession.c | 12 +- tests/test-qmp-commands.c | 2 +- tests/test-qmp-event.c | 6 +- tests/test-qmp-input-visitor.c | 66 ++--- tests/test-qmp-output-visitor.c | 84 +++--- tests/test-string-output-visitor.c | 4 +- tpm.c | 14 +- trace/qmp.c | 6 +- ui/cocoa.m | 20 +- ui/console.c | 22 +- ui/gtk.c | 20 +- ui/input-keymap.c | 274 +++++++++--------- ui/input-legacy.c | 38 +-- ui/input.c | 56 ++-- ui/sdl.c | 22 +- ui/sdl2-keymap.h | 480 +++++++++++++++---------------- ui/sdl2.c | 20 +- ui/spice-core.c | 4 +- ui/spice-input.c | 20 +- ui/vnc-auth-vencrypt.c | 2 +- ui/vnc-ws.c | 2 +- ui/vnc.c | 84 +++--- util/error.c | 6 +- util/qemu-config.c | 8 +- util/qemu-sockets.c | 32 +-- vl.c | 166 +++++------ xen-hvm.c | 4 +- 166 files changed, 1728 insertions(+), 1763 deletions(-) diff --git a/backends/baum.c b/backends/baum.c index 723c658..b4f58f2 100644 --- a/backends/baum.c +++ b/backends/baum.c @@ -635,7 +635,7 @@ fail_handle: static void register_types(void) { - register_char_driver("braille", CHARDEV_BACKEND_KIND_BRAILLE, NULL, + register_char_driver("braille", ChardevBackendKind_braille, NULL, chr_baum_init); } diff --git a/backends/hostmem.c b/backends/hostmem.c index 41ba2af..d3fb769 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -19,10 +19,10 @@ #ifdef CONFIG_NUMA #include -QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_DEFAULT != MPOL_DEFAULT); -QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_PREFERRED != MPOL_PREFERRED); -QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND); -QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE); +QEMU_BUILD_BUG_ON(HostMemPolicy_default != MPOL_DEFAULT); +QEMU_BUILD_BUG_ON(HostMemPolicy_preferred != MPOL_PREFERRED); +QEMU_BUILD_BUG_ON(HostMemPolicy_bind != MPOL_BIND); +QEMU_BUILD_BUG_ON(HostMemPolicy_interleave != MPOL_INTERLEAVE); #endif static void @@ -127,7 +127,7 @@ host_memory_backend_set_policy(Object *obj, int policy, Error **errp) backend->policy = policy; #ifndef CONFIG_NUMA - if (policy != HOST_MEM_POLICY_DEFAULT) { + if (policy != HostMemPolicy_default) { error_setg(errp, "NUMA policies are not supported by this QEMU"); } #endif diff --git a/backends/msmouse.c b/backends/msmouse.c index 0126fa0..3c36f80 100644 --- a/backends/msmouse.c +++ b/backends/msmouse.c @@ -82,7 +82,7 @@ static CharDriverState *qemu_chr_open_msmouse(const char *id, static void register_types(void) { - register_char_driver("msmouse", CHARDEV_BACKEND_KIND_MSMOUSE, NULL, + register_char_driver("msmouse", ChardevBackendKind_msmouse, NULL, qemu_chr_open_msmouse); } diff --git a/backends/rng-egd.c b/backends/rng-egd.c index 6c13409..b5bd641 100644 --- a/backends/rng-egd.c +++ b/backends/rng-egd.c @@ -147,7 +147,7 @@ static void rng_egd_opened(RngBackend *b, Error **errp) s->chr = qemu_chr_find(s->chr_name); if (s->chr == NULL) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", s->chr_name); return; } diff --git a/backends/testdev.c b/backends/testdev.c index 26d5c73..c416d9e 100644 --- a/backends/testdev.c +++ b/backends/testdev.c @@ -128,7 +128,7 @@ static CharDriverState *chr_testdev_init(const char *id, static void register_types(void) { - register_char_driver("testdev", CHARDEV_BACKEND_KIND_TESTDEV, NULL, + register_char_driver("testdev", ChardevBackendKind_testdev, NULL, chr_testdev_init); } diff --git a/balloon.c b/balloon.c index 5d69e8a..f1a1fa4 100644 --- a/balloon.c +++ b/balloon.c @@ -40,12 +40,12 @@ static void *balloon_opaque; static bool have_balloon(Error **errp) { if (kvm_enabled() && !kvm_has_sync_mmu()) { - error_set(errp, ERROR_CLASS_KVM_MISSING_CAP, + error_set(errp, ErrorClass_KVMMissingCap, "Using KVM without synchronous MMU, balloon unavailable"); return false; } if (!balloon_event_fn) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE, + error_set(errp, ErrorClass_DeviceNotActive, "No balloon device has been activated"); return false; } diff --git a/block.c b/block.c index e9f40dc..5be623d 100644 --- a/block.c +++ b/block.c @@ -1079,7 +1079,7 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, } } - if (runstate_check(RUN_STATE_INMIGRATE)) { + if (runstate_check(RunState_inmigrate)) { *flags |= BDRV_O_INCOMING; } @@ -1548,9 +1548,9 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, if (bs->blk) { blk_dev_change_media_cb(bs->blk, true); } - } else if (!runstate_check(RUN_STATE_PRELAUNCH) - && !runstate_check(RUN_STATE_INMIGRATE) - && !runstate_check(RUN_STATE_PAUSED)) { /* HACK */ + } else if (!runstate_check(RunState_prelaunch) + && !runstate_check(RunState_inmigrate) + && !runstate_check(RunState_paused)) { /* HACK */ error_setg(errp, "Guest must be stopped for opening of encrypted image"); ret = -EBUSY; @@ -1795,7 +1795,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, ret = bdrv_flush(reopen_state->bs); if (ret) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, "Error (%s) flushing drive", + error_set(errp, ErrorClass_GenericError, "Error (%s) flushing drive", strerror(-ret)); goto error; } @@ -2585,7 +2585,7 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp) } } else { if (bdrv_key_required(bs)) { - error_set(errp, ERROR_CLASS_DEVICE_ENCRYPTED, + error_set(errp, ErrorClass_DeviceEncrypted, "'%s' (%s) is encrypted", bdrv_get_device_or_node_name(bs), bdrv_get_encrypted_filename(bs)); @@ -3190,11 +3190,11 @@ bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap) DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap) { if (bdrv_dirty_bitmap_frozen(bitmap)) { - return DIRTY_BITMAP_STATUS_FROZEN; + return DirtyBitmapStatus_frozen; } else if (!bdrv_dirty_bitmap_enabled(bitmap)) { - return DIRTY_BITMAP_STATUS_DISABLED; + return DirtyBitmapStatus_disabled; } else { - return DIRTY_BITMAP_STATUS_ACTIVE; + return DirtyBitmapStatus_active; } } diff --git a/block/backup.c b/block/backup.c index ec01db8..e60a08d 100644 --- a/block/backup.c +++ b/block/backup.c @@ -223,7 +223,7 @@ static void backup_iostatus_reset(BlockJob *job) static const BlockJobDriver backup_job_driver = { .instance_size = sizeof(BackupBlockJob), - .job_type = BLOCK_JOB_TYPE_BACKUP, + .job_type = BlockJobType_backup, .set_speed = backup_set_speed, .iostatus_reset = backup_iostatus_reset, }; @@ -317,7 +317,7 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) false); if ((ret < 0) && backup_error_action(job, error_is_read, -ret) == - BLOCK_ERROR_ACTION_REPORT) { + BlockErrorAction_report) { return ret; } } while (ret < 0); @@ -370,7 +370,7 @@ static void coroutine_fn backup_run(void *opaque) bdrv_add_before_write_notifier(bs, &before_write); - if (job->sync_mode == MIRROR_SYNC_MODE_NONE) { + if (job->sync_mode == MirrorSyncMode_none) { while (!block_job_is_cancelled(&job->common)) { /* Yield until the job is cancelled. We just let our before_write * notify callback service CoW requests. */ @@ -378,7 +378,7 @@ static void coroutine_fn backup_run(void *opaque) qemu_coroutine_yield(); job->common.busy = true; } - } else if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) { + } else if (job->sync_mode == MirrorSyncMode_incremental) { ret = backup_run_incremental(job); } else { /* Both FULL and TOP SYNC_MODE's require copying.. */ @@ -388,7 +388,7 @@ static void coroutine_fn backup_run(void *opaque) break; } - if (job->sync_mode == MIRROR_SYNC_MODE_TOP) { + if (job->sync_mode == MirrorSyncMode_top) { int i, n; int alloced = 0; @@ -426,7 +426,7 @@ static void coroutine_fn backup_run(void *opaque) /* Depending on error action, fail now or retry cluster */ BlockErrorAction action = backup_error_action(job, error_is_read, -ret); - if (action == BLOCK_ERROR_ACTION_REPORT) { + if (action == BlockErrorAction_report) { break; } else { start--; @@ -485,8 +485,8 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, return; } - if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || - on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && + if ((on_source_error == BlockdevOnError_stop || + on_source_error == BlockdevOnError_enospc) && (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error"); return; @@ -512,7 +512,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, return; } - if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) { + if (sync_mode == MirrorSyncMode_incremental) { if (!sync_bitmap) { error_setg(errp, "must provide a valid bitmap name for " "\"incremental\" sync mode"); @@ -550,7 +550,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, job->on_target_error = on_target_error; job->target = target; job->sync_mode = sync_mode; - job->sync_bitmap = sync_mode == MIRROR_SYNC_MODE_INCREMENTAL ? + job->sync_bitmap = sync_mode == MirrorSyncMode_incremental ? sync_bitmap : NULL; job->common.len = len; job->common.co = qemu_coroutine_create(backup_run); diff --git a/block/block-backend.c b/block/block-backend.c index 19fdaae..827a5dc 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -489,7 +489,7 @@ void blk_dev_resize_cb(BlockBackend *blk) void blk_iostatus_enable(BlockBackend *blk) { blk->iostatus_enabled = true; - blk->iostatus = BLOCK_DEVICE_IO_STATUS_OK; + blk->iostatus = BlockDeviceIoStatus_ok; } /* The I/O status is only enabled if the drive explicitly @@ -497,9 +497,9 @@ void blk_iostatus_enable(BlockBackend *blk) bool blk_iostatus_is_enabled(const BlockBackend *blk) { return (blk->iostatus_enabled && - (blk->on_write_error == BLOCKDEV_ON_ERROR_ENOSPC || - blk->on_write_error == BLOCKDEV_ON_ERROR_STOP || - blk->on_read_error == BLOCKDEV_ON_ERROR_STOP)); + (blk->on_write_error == BlockdevOnError_enospc || + blk->on_write_error == BlockdevOnError_stop || + blk->on_read_error == BlockdevOnError_stop)); } BlockDeviceIoStatus blk_iostatus(const BlockBackend *blk) @@ -515,7 +515,7 @@ void blk_iostatus_disable(BlockBackend *blk) void blk_iostatus_reset(BlockBackend *blk) { if (blk_iostatus_is_enabled(blk)) { - blk->iostatus = BLOCK_DEVICE_IO_STATUS_OK; + blk->iostatus = BlockDeviceIoStatus_ok; if (blk->bs && blk->bs->job) { block_job_iostatus_reset(blk->bs->job); } @@ -525,9 +525,9 @@ void blk_iostatus_reset(BlockBackend *blk) void blk_iostatus_set_err(BlockBackend *blk, int error) { assert(blk_iostatus_is_enabled(blk)); - if (blk->iostatus == BLOCK_DEVICE_IO_STATUS_OK) { - blk->iostatus = error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : - BLOCK_DEVICE_IO_STATUS_FAILED; + if (blk->iostatus == BlockDeviceIoStatus_ok) { + blk->iostatus = error == ENOSPC ? BlockDeviceIoStatus_nospace : + BlockDeviceIoStatus_failed; } } @@ -856,15 +856,15 @@ BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, BlockdevOnError on_err = blk_get_on_error(blk, is_read); switch (on_err) { - case BLOCKDEV_ON_ERROR_ENOSPC: + case BlockdevOnError_enospc: return (error == ENOSPC) ? - BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; - case BLOCKDEV_ON_ERROR_STOP: - return BLOCK_ERROR_ACTION_STOP; - case BLOCKDEV_ON_ERROR_REPORT: - return BLOCK_ERROR_ACTION_REPORT; - case BLOCKDEV_ON_ERROR_IGNORE: - return BLOCK_ERROR_ACTION_IGNORE; + BlockErrorAction_stop : BlockErrorAction_report; + case BlockdevOnError_stop: + return BlockErrorAction_stop; + case BlockdevOnError_report: + return BlockErrorAction_report; + case BlockdevOnError_ignore: + return BlockErrorAction_ignore; default: abort(); } @@ -876,7 +876,7 @@ static void send_qmp_error_event(BlockBackend *blk, { IoOperationType optype; - optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE; + optype = is_read ? IoOperationType_read : IoOperationType_write; qapi_event_send_block_io_error(blk_name(blk), optype, action, blk_iostatus_is_enabled(blk), error == ENOSPC, strerror(error), @@ -892,7 +892,7 @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, { assert(error >= 0); - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { /* First set the iostatus, so that "info block" returns an iostatus * that matches the events raised so far (an additional error iostatus * is fine, but not a lost one). @@ -909,7 +909,7 @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, */ qemu_system_vmstop_request_prepare(); send_qmp_error_event(blk, action, is_read, error); - qemu_system_vmstop_request(RUN_STATE_IO_ERROR); + qemu_system_vmstop_request(RunState_io_error); } else { send_qmp_error_event(blk, action, is_read, error); } diff --git a/block/commit.c b/block/commit.c index fdebe87..7173832 100644 --- a/block/commit.c +++ b/block/commit.c @@ -160,9 +160,9 @@ wait: bytes_written += n * BDRV_SECTOR_SIZE; } if (ret < 0) { - if (s->on_error == BLOCKDEV_ON_ERROR_STOP || - s->on_error == BLOCKDEV_ON_ERROR_REPORT|| - (s->on_error == BLOCKDEV_ON_ERROR_ENOSPC && ret == -ENOSPC)) { + if (s->on_error == BlockdevOnError_stop || + s->on_error == BlockdevOnError_report|| + (s->on_error == BlockdevOnError_enospc && ret == -ENOSPC)) { goto out; } else { n = 0; @@ -196,7 +196,7 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp) static const BlockJobDriver commit_job_driver = { .instance_size = sizeof(CommitBlockJob), - .job_type = BLOCK_JOB_TYPE_COMMIT, + .job_type = BlockJobType_commit, .set_speed = commit_set_speed, }; @@ -212,8 +212,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, BlockDriverState *overlay_bs; Error *local_err = NULL; - if ((on_error == BLOCKDEV_ON_ERROR_STOP || - on_error == BLOCKDEV_ON_ERROR_ENOSPC) && + if ((on_error == BlockdevOnError_stop || + on_error == BlockdevOnError_enospc) && (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, "Invalid parameter combination"); return; diff --git a/block/io.c b/block/io.c index 8dcad3b..f32ee63 100644 --- a/block/io.c +++ b/block/io.c @@ -1129,11 +1129,11 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req); - if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF && + if (!ret && bs->detect_zeroes != BlockdevDetectZeroesOptions_off && !(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_write_zeroes && qemu_iovec_is_zero(qiov)) { flags |= BDRV_REQ_ZERO_WRITE; - if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) { + if (bs->detect_zeroes == BlockdevDetectZeroesOptions_unmap) { flags |= BDRV_REQ_MAY_UNMAP; } } diff --git a/block/mirror.c b/block/mirror.c index b1252a1..80cacd0 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -130,7 +130,7 @@ static void mirror_write_complete(void *opaque, int ret) bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors); action = mirror_error_action(s, false, -ret); - if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) { + if (action == BlockErrorAction_report && s->ret >= 0) { s->ret = ret; } } @@ -146,7 +146,7 @@ static void mirror_read_complete(void *opaque, int ret) bdrv_set_dirty_bitmap(s->dirty_bitmap, op->sector_num, op->nb_sectors); action = mirror_error_action(s, true, -ret); - if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) { + if (action == BlockErrorAction_report && s->ret >= 0) { s->ret = ret; } @@ -511,7 +511,7 @@ static void coroutine_fn mirror_run(void *opaque) * or when the source is clean, whichever comes first. */ if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME && - s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { + s->common.iostatus == BlockDeviceIoStatus_ok) { if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || (cnt == 0 && s->in_flight > 0)) { trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); @@ -530,7 +530,7 @@ static void coroutine_fn mirror_run(void *opaque) ret = bdrv_flush(s->target); if (ret < 0) { if (mirror_error_action(s, false, -ret) == - BLOCK_ERROR_ACTION_REPORT) { + BlockErrorAction_report) { goto immediate_exit; } } else { @@ -672,7 +672,7 @@ static void mirror_complete(BlockJob *job, Error **errp) static const BlockJobDriver mirror_job_driver = { .instance_size = sizeof(MirrorBlockJob), - .job_type = BLOCK_JOB_TYPE_MIRROR, + .job_type = BlockJobType_mirror, .set_speed = mirror_set_speed, .iostatus_reset= mirror_iostatus_reset, .complete = mirror_complete, @@ -680,7 +680,7 @@ static const BlockJobDriver mirror_job_driver = { static const BlockJobDriver commit_active_job_driver = { .instance_size = sizeof(MirrorBlockJob), - .job_type = BLOCK_JOB_TYPE_COMMIT, + .job_type = BlockJobType_commit, .set_speed = mirror_set_speed, .iostatus_reset = mirror_iostatus_reset, @@ -707,8 +707,8 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, assert ((granularity & (granularity - 1)) == 0); - if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || - on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && + if ((on_source_error == BlockdevOnError_stop || + on_source_error == BlockdevOnError_enospc) && (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error"); return; @@ -766,12 +766,12 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, bool is_none_mode; BlockDriverState *base; - if (mode == MIRROR_SYNC_MODE_INCREMENTAL) { + if (mode == MirrorSyncMode_incremental) { error_setg(errp, "Sync mode 'incremental' not supported"); return; } - is_none_mode = mode == MIRROR_SYNC_MODE_NONE; - base = mode == MIRROR_SYNC_MODE_TOP ? backing_bs(bs) : NULL; + is_none_mode = mode == MirrorSyncMode_none; + base = mode == MirrorSyncMode_top ? backing_bs(bs) : NULL; mirror_start_job(bs, target, replaces, speed, granularity, buf_size, on_source_error, on_target_error, unmap, cb, opaque, errp, diff --git a/block/nbd.c b/block/nbd.c index cd6a587..281799a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -206,12 +206,12 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, char **export, saddr = g_new0(SocketAddress, 1); if (qdict_haskey(options, "path")) { - saddr->type = SOCKET_ADDRESS_KIND_UNIX; + saddr->type = SocketAddressKind_unix; saddr->u.q_unix = g_new0(UnixSocketAddress, 1); saddr->u.q_unix->path = g_strdup(qdict_get_str(options, "path")); qdict_del(options, "path"); } else { - saddr->type = SOCKET_ADDRESS_KIND_INET; + saddr->type = SocketAddressKind_inet; saddr->u.inet = g_new0(InetSocketAddress, 1); saddr->u.inet->host = g_strdup(qdict_get_str(options, "host")); if (!qdict_get_try_str(options, "port")) { @@ -223,7 +223,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, char **export, qdict_del(options, "port"); } - s->client.is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX; + s->client.is_unix = saddr->type == SocketAddressKind_unix; *export = g_strdup(qdict_get_try_str(options, "export")); if (*export) { diff --git a/block/qcow2.c b/block/qcow2.c index 88f56c8..49a3cfe 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2040,7 +2040,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, Error *local_err = NULL; int ret; - if (prealloc == PREALLOC_MODE_FULL || prealloc == PREALLOC_MODE_FALLOC) { + if (prealloc == PreallocMode_full || prealloc == PreallocMode_falloc) { /* Note: The following calculation does not need to be exact; if it is a * bit off, either some bytes will be "leaked" (which is fine) or we * will need to increase the file size by some bytes (which is fine, @@ -2209,7 +2209,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, } /* And if we're supposed to preallocate metadata, do that now */ - if (prealloc != PREALLOC_MODE_OFF) { + if (prealloc != PreallocMode_off) { BDRVQcow2State *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = preallocate(bs); @@ -2269,7 +2269,7 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp) DEFAULT_CLUSTER_SIZE); buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); prealloc = qapi_enum_parse(PreallocMode_lookup, buf, - PREALLOC_MODE_MAX, PREALLOC_MODE_OFF, + PreallocMode_MAX, PreallocMode_off, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -2294,7 +2294,7 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp) flags |= BLOCK_FLAG_LAZY_REFCOUNTS; } - if (backing_file && prealloc != PREALLOC_MODE_OFF) { + if (backing_file && prealloc != PreallocMode_off) { error_setg(errp, "Backing file and preallocation cannot be used at " "the same time"); ret = -EINVAL; @@ -2738,7 +2738,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ - .type = IMAGE_INFO_SPECIFIC_KIND_QCOW2, + .type = ImageInfoSpecificKind_qcow2, .u.qcow2 = g_new(ImageInfoSpecificQCow2, 1), }; if (s->qcow_version == 2) { diff --git a/block/quorum.c b/block/quorum.c index b9ba028..f9de3a6 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -283,7 +283,7 @@ static void quorum_aio_cb(void *opaque, int ret) BDRVQuorumState *s = acb->common.bs->opaque; bool rewrite = false; - if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) { + if (acb->is_read && s->read_pattern == QuorumReadPattern_fifo) { /* We try to read next child in FIFO order if we fail to read */ if (ret < 0 && ++acb->child_iter < s->num_children) { read_fifo_child(acb); @@ -681,7 +681,7 @@ static BlockAIOCB *quorum_aio_readv(BlockDriverState *bs, nb_sectors, cb, opaque); acb->is_read = true; - if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { + if (s->read_pattern == QuorumReadPattern_quorum) { acb->child_iter = s->num_children - 1; return read_quorum_children(acb); } @@ -844,10 +844,10 @@ static int parse_read_pattern(const char *opt) if (!opt) { /* Set quorum as default */ - return QUORUM_READ_PATTERN_QUORUM; + return QuorumReadPattern_quorum; } - for (i = 0; i < QUORUM_READ_PATTERN_MAX; i++) { + for (i = 0; i < QuorumReadPattern_MAX; i++) { if (!strcmp(opt, QuorumReadPattern_lookup[i])) { return i; } @@ -903,7 +903,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } s->read_pattern = ret; - if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { + if (s->read_pattern == QuorumReadPattern_quorum) { /* is the driver in blkverify mode */ if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && s->num_children == 2 && s->threshold == 2) { diff --git a/block/raw-posix.c b/block/raw-posix.c index 918c756..d825003 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1636,7 +1636,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false); buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); prealloc = qapi_enum_parse(PreallocMode_lookup, buf, - PREALLOC_MODE_MAX, PREALLOC_MODE_OFF, + PreallocMode_MAX, PreallocMode_off, &local_err); g_free(buf); if (local_err) { @@ -1676,7 +1676,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) switch (prealloc) { #ifdef CONFIG_POSIX_FALLOCATE - case PREALLOC_MODE_FALLOC: + case PreallocMode_falloc: /* posix_fallocate() doesn't set errno. */ result = -posix_fallocate(fd, 0, total_size); if (result != 0) { @@ -1685,7 +1685,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) } break; #endif - case PREALLOC_MODE_FULL: + case PreallocMode_full: { int64_t num = 0, left = total_size; buf = g_malloc0(65536); @@ -1712,7 +1712,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) g_free(buf); break; } - case PREALLOC_MODE_OFF: + case PreallocMode_off: break; default: result = -EINVAL; diff --git a/block/stream.c b/block/stream.c index 25af7ef..268c09f 100644 --- a/block/stream.c +++ b/block/stream.c @@ -163,14 +163,14 @@ wait: BlockErrorAction action = block_job_error_action(&s->common, s->common.bs, s->on_error, true, -ret); - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { n = 0; continue; } if (error == 0) { error = ret; } - if (action == BLOCK_ERROR_ACTION_REPORT) { + if (action == BlockErrorAction_report) { break; } } @@ -209,7 +209,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp) static const BlockJobDriver stream_job_driver = { .instance_size = sizeof(StreamBlockJob), - .job_type = BLOCK_JOB_TYPE_STREAM, + .job_type = BlockJobType_stream, .set_speed = stream_set_speed, }; @@ -221,8 +221,8 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base, { StreamBlockJob *s; - if ((on_error == BLOCKDEV_ON_ERROR_STOP || - on_error == BLOCKDEV_ON_ERROR_ENOSPC) && + if ((on_error == BlockdevOnError_stop || + on_error == BlockdevOnError_enospc) && (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, QERR_INVALID_PARAMETER, "on-error"); return; diff --git a/block/vmdk.c b/block/vmdk.c index 6f819e4..6c029c0 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2161,7 +2161,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) ImageInfoList **next; *spec_info = (ImageInfoSpecific){ - .type = IMAGE_INFO_SPECIFIC_KIND_VMDK, + .type = ImageInfoSpecificKind_vmdk, { .vmdk = g_new0(ImageInfoSpecificVmdk, 1), }, diff --git a/blockdev-nbd.c b/blockdev-nbd.c index bcdd18b..491aba5 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -90,7 +90,7 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable, blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } diff --git a/blockdev.c b/blockdev.c index 8b8bfa9..1ffd6b1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -312,13 +312,13 @@ static void bdrv_put_ref_bh_schedule(BlockDriverState *bs) static int parse_block_error_action(const char *buf, bool is_read, Error **errp) { if (!strcmp(buf, "ignore")) { - return BLOCKDEV_ON_ERROR_IGNORE; + return BlockdevOnError_ignore; } else if (!is_read && !strcmp(buf, "enospc")) { - return BLOCKDEV_ON_ERROR_ENOSPC; + return BlockdevOnError_enospc; } else if (!strcmp(buf, "stop")) { - return BLOCKDEV_ON_ERROR_STOP; + return BlockdevOnError_stop; } else if (!strcmp(buf, "report")) { - return BLOCKDEV_ON_ERROR_REPORT; + return BlockdevOnError_report; } else { error_setg(errp, "'%s' invalid %s error action", buf, is_read ? "read" : "write"); @@ -441,8 +441,8 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, *detect_zeroes = qapi_enum_parse(BlockdevDetectZeroesOptions_lookup, qemu_opt_get(opts, "detect-zeroes"), - BLOCKDEV_DETECT_ZEROES_OPTIONS_MAX, - BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, + BlockdevDetectZeroesOptions_MAX, + BlockdevDetectZeroesOptions_off, &local_error); if (local_error) { error_propagate(errp, local_error); @@ -450,7 +450,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, } if (bdrv_flags && - *detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP && + *detect_zeroes == BlockdevDetectZeroesOptions_unmap && !(*bdrv_flags & BDRV_O_UNMAP)) { error_setg(errp, "setting detect-zeroes to unmap is not allowed " @@ -476,7 +476,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, const char *id; bool has_driver_specific_opts; BlockdevDetectZeroesOptions detect_zeroes = - BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF; + BlockdevDetectZeroesOptions_off; const char *throttling_group = NULL; /* Check common options by copying from bs_opts to opts, all other options @@ -525,7 +525,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, qdict_put(bs_opts, "driver", qstring_from_str(buf)); } - on_write_error = BLOCKDEV_ON_ERROR_ENOSPC; + on_write_error = BlockdevOnError_enospc; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { on_write_error = parse_block_error_action(buf, 0, &error); if (error) { @@ -534,7 +534,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, } } - on_read_error = BLOCKDEV_ON_ERROR_REPORT; + on_read_error = BlockdevOnError_report; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { on_read_error = parse_block_error_action(buf, 1, &error); if (error) { @@ -928,7 +928,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) } } - translation = BIOS_ATA_TRANSLATION_AUTO; + translation = BiosAtaTranslation_auto; value = qemu_opt_get(legacy_opts, "trans"); if (value != NULL) { if (!cyls) { @@ -937,15 +937,15 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) goto fail; } if (!strcmp(value, "none")) { - translation = BIOS_ATA_TRANSLATION_NONE; + translation = BiosAtaTranslation_none; } else if (!strcmp(value, "lba")) { - translation = BIOS_ATA_TRANSLATION_LBA; + translation = BiosAtaTranslation_lba; } else if (!strcmp(value, "large")) { - translation = BIOS_ATA_TRANSLATION_LARGE; + translation = BiosAtaTranslation_large; } else if (!strcmp(value, "rechs")) { - translation = BIOS_ATA_TRANSLATION_RECHS; + translation = BiosAtaTranslation_rechs; } else if (!strcmp(value, "auto")) { - translation = BIOS_ATA_TRANSLATION_AUTO; + translation = BiosAtaTranslation_auto; } else { error_report("'%s' invalid translation type", value); goto fail; @@ -1171,7 +1171,7 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, .has_mode = has_mode, .mode = mode, }; - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, + blockdev_do_action(TransactionActionKind_blockdev_snapshot_sync, &snapshot, errp); } @@ -1184,7 +1184,7 @@ void qmp_blockdev_snapshot_internal_sync(const char *device, .name = (char *) name }; - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, + blockdev_do_action(TransactionActionKind_blockdev_snapshot_internal_sync, &snapshot, errp); } @@ -1205,7 +1205,7 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return NULL; } @@ -1390,7 +1390,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common, int ret1; g_assert(common->action->type == - TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC); + TransactionActionKind_blockdev_snapshot_internal_sync); internal = common->action->u.blockdev_snapshot_internal_sync; state = DO_UPCAST(InternalSnapshotState, common, common); @@ -1401,7 +1401,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common, /* 2. check for validation */ blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -1531,13 +1531,13 @@ static void external_snapshot_prepare(BlkTransactionState *common, const char *snapshot_node_name; const char *new_image_file; const char *format = "qcow2"; - enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; + enum NewImageMode mode = NewImageMode_absolute_paths; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; /* get parameters */ - g_assert(action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); + g_assert(action->type == TransactionActionKind_blockdev_snapshot_sync); has_device = action->u.blockdev_snapshot_sync->has_device; device = action->u.blockdev_snapshot_sync->device; @@ -1604,7 +1604,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, flags = state->old_bs->open_flags; /* create new image w/backing file */ - if (mode != NEW_IMAGE_MODE_EXISTING) { + if (mode != NewImageMode_existing) { bdrv_img_create(new_image_file, format, state->old_bs->filename, state->old_bs->drv->format_name, @@ -1682,12 +1682,12 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) DriveBackup *backup; Error *local_err = NULL; - assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); + assert(common->action->type == TransactionActionKind_drive_backup); backup = common->action->u.drive_backup; blk = blk_by_name(backup->device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", backup->device); return; } @@ -1755,7 +1755,7 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) BlockBackend *blk, *target; Error *local_err = NULL; - assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); + assert(common->action->type == TransactionActionKind_blockdev_backup); backup = common->action->u.blockdev_backup; blk = blk_by_name(backup->device); @@ -1832,31 +1832,31 @@ static void abort_commit(BlkTransactionState *common) } static const BdrvActionOps actions[] = { - [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { + [TransactionActionKind_blockdev_snapshot_sync] = { .instance_size = sizeof(ExternalSnapshotState), .prepare = external_snapshot_prepare, .commit = external_snapshot_commit, .abort = external_snapshot_abort, .clean = external_snapshot_clean, }, - [TRANSACTION_ACTION_KIND_DRIVE_BACKUP] = { + [TransactionActionKind_drive_backup] = { .instance_size = sizeof(DriveBackupState), .prepare = drive_backup_prepare, .abort = drive_backup_abort, .clean = drive_backup_clean, }, - [TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP] = { + [TransactionActionKind_blockdev_backup] = { .instance_size = sizeof(BlockdevBackupState), .prepare = blockdev_backup_prepare, .abort = blockdev_backup_abort, .clean = blockdev_backup_clean, }, - [TRANSACTION_ACTION_KIND_ABORT] = { + [TransactionActionKind_abort] = { .instance_size = sizeof(BlkTransactionState), .prepare = abort_prepare, .commit = abort_commit, }, - [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC] = { + [TransactionActionKind_blockdev_snapshot_internal_sync] = { .instance_size = sizeof(InternalSnapshotState), .prepare = internal_snapshot_prepare, .abort = internal_snapshot_abort, @@ -1974,7 +1974,7 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp) blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2042,7 +2042,7 @@ void qmp_change_blockdev(const char *device, const char *filename, blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2108,7 +2108,7 @@ 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, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2315,8 +2315,8 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) if (blk_get_attached_dev(blk)) { blk_hide_on_behalf_of_hmp_drive_del(blk); /* Further I/O must not pause the guest */ - blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT, - BLOCKDEV_ON_ERROR_REPORT); + blk_set_on_error(blk, BlockdevOnError_report, + BlockdevOnError_report); } else { blk_unref(blk); } @@ -2429,12 +2429,12 @@ void qmp_block_stream(const char *device, const char *base_name = NULL; if (!has_on_error) { - on_error = BLOCKDEV_ON_ERROR_REPORT; + on_error = BlockdevOnError_report; } blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2501,7 +2501,7 @@ void qmp_block_commit(const char *device, /* This will be part of the QMP command, if/when the * BlockdevOnError change for blkmirror makes it in */ - BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; + BlockdevOnError on_error = BlockdevOnError_report; if (!has_speed) { speed = 0; @@ -2514,7 +2514,7 @@ 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, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2618,18 +2618,18 @@ void qmp_drive_backup(const char *device, const char *target, speed = 0; } if (!has_on_source_error) { - on_source_error = BLOCKDEV_ON_ERROR_REPORT; + on_source_error = BlockdevOnError_report; } if (!has_on_target_error) { - on_target_error = BLOCKDEV_ON_ERROR_REPORT; + on_target_error = BlockdevOnError_report; } if (!has_mode) { - mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; + mode = NewImageMode_absolute_paths; } blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2646,7 +2646,7 @@ void qmp_drive_backup(const char *device, const char *target, bs = blk_bs(blk); if (!has_format) { - format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; + format = mode == NewImageMode_existing ? NULL : bs->drv->format_name; } /* Early check to avoid creating target */ @@ -2658,13 +2658,13 @@ void qmp_drive_backup(const char *device, const char *target, /* See if we have a backing HD we can use to create our new image * on top of. */ - if (sync == MIRROR_SYNC_MODE_TOP) { + if (sync == MirrorSyncMode_top) { source = backing_bs(bs); if (!source) { - sync = MIRROR_SYNC_MODE_FULL; + sync = MirrorSyncMode_full; } } - if (sync == MIRROR_SYNC_MODE_NONE) { + if (sync == MirrorSyncMode_none) { source = bs; } @@ -2674,7 +2674,7 @@ void qmp_drive_backup(const char *device, const char *target, goto out; } - if (mode != NEW_IMAGE_MODE_EXISTING) { + if (mode != NewImageMode_existing) { assert(format); if (source) { bdrv_img_create(target, format, source->filename, @@ -2750,10 +2750,10 @@ void qmp_blockdev_backup(const char *device, const char *target, speed = 0; } if (!has_on_source_error) { - on_source_error = BLOCKDEV_ON_ERROR_REPORT; + on_source_error = BlockdevOnError_report; } if (!has_on_target_error) { - on_target_error = BLOCKDEV_ON_ERROR_REPORT; + on_target_error = BlockdevOnError_report; } blk = blk_by_name(device); @@ -2823,13 +2823,13 @@ void qmp_drive_mirror(const char *device, const char *target, speed = 0; } if (!has_on_source_error) { - on_source_error = BLOCKDEV_ON_ERROR_REPORT; + on_source_error = BlockdevOnError_report; } if (!has_on_target_error) { - on_target_error = BLOCKDEV_ON_ERROR_REPORT; + on_target_error = BlockdevOnError_report; } if (!has_mode) { - mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; + mode = NewImageMode_absolute_paths; } if (!has_granularity) { granularity = 0; @@ -2854,7 +2854,7 @@ void qmp_drive_mirror(const char *device, const char *target, blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -2869,7 +2869,7 @@ void qmp_drive_mirror(const char *device, const char *target, bs = blk_bs(blk); if (!has_format) { - format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; + format = mode == NewImageMode_existing ? NULL : bs->drv->format_name; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, errp)) { @@ -2878,10 +2878,10 @@ void qmp_drive_mirror(const char *device, const char *target, flags = bs->open_flags | BDRV_O_RDWR; source = backing_bs(bs); - if (!source && sync == MIRROR_SYNC_MODE_TOP) { - sync = MIRROR_SYNC_MODE_FULL; + if (!source && sync == MirrorSyncMode_top) { + sync = MirrorSyncMode_full; } - if (sync == MIRROR_SYNC_MODE_NONE) { + if (sync == MirrorSyncMode_none) { source = bs; } @@ -2921,8 +2921,8 @@ void qmp_drive_mirror(const char *device, const char *target, } } - if ((sync == MIRROR_SYNC_MODE_FULL || !source) - && mode != NEW_IMAGE_MODE_EXISTING) + if ((sync == MirrorSyncMode_full || !source) + && mode != NewImageMode_existing) { /* create new image w/o backing file */ assert(format); @@ -2930,9 +2930,9 @@ void qmp_drive_mirror(const char *device, const char *target, NULL, NULL, NULL, size, flags, &local_err, false); } else { switch (mode) { - case NEW_IMAGE_MODE_EXISTING: + case NewImageMode_existing: break; - case NEW_IMAGE_MODE_ABSOLUTE_PATHS: + case NewImageMode_absolute_paths: /* create new image with backing file */ bdrv_img_create(target, format, source->filename, @@ -3018,7 +3018,7 @@ static BlockJob *find_block_job(const char *device, AioContext **aio_context, return bs->job; notfound: - error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE, + error_set(errp, ErrorClass_DeviceNotActive, "No active block job on device '%s'", device); if (*aio_context) { aio_context_release(*aio_context); @@ -3126,7 +3126,7 @@ void qmp_change_backing_file(const char *device, blk = blk_by_name(device); if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device); return; } @@ -3217,7 +3217,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) * when called from drive_new(). * * For now, simply forbidding the combination for all drivers will do. */ - if (options->has_aio && options->aio == BLOCKDEV_AIO_OPTIONS_NATIVE) { + if (options->has_aio && options->aio == BlockdevAioOptions_native) { bool direct = options->has_cache && options->cache->has_direct && options->cache->direct; diff --git a/blockjob.c b/blockjob.c index c02fe59..c0e2824 100644 --- a/blockjob.c +++ b/blockjob.c @@ -164,7 +164,7 @@ bool block_job_is_cancelled(BlockJob *job) void block_job_iostatus_reset(BlockJob *job) { - job->iostatus = BLOCK_DEVICE_IO_STATUS_OK; + job->iostatus = BlockDeviceIoStatus_ok; if (job->driver->iostatus_reset) { job->driver->iostatus_reset(job); } @@ -284,9 +284,9 @@ BlockJobInfo *block_job_query(BlockJob *job) static void block_job_iostatus_set_err(BlockJob *job, int error) { - if (job->iostatus == BLOCK_DEVICE_IO_STATUS_OK) { - job->iostatus = error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : - BLOCK_DEVICE_IO_STATUS_FAILED; + if (job->iostatus == BlockDeviceIoStatus_ok) { + job->iostatus = error == ENOSPC ? BlockDeviceIoStatus_nospace : + BlockDeviceIoStatus_failed; } } @@ -330,27 +330,27 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, BlockErrorAction action; switch (on_err) { - case BLOCKDEV_ON_ERROR_ENOSPC: + case BlockdevOnError_enospc: action = (error == ENOSPC) ? - BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; + BlockErrorAction_stop : BlockErrorAction_report; break; - case BLOCKDEV_ON_ERROR_STOP: - action = BLOCK_ERROR_ACTION_STOP; + case BlockdevOnError_stop: + action = BlockErrorAction_stop; break; - case BLOCKDEV_ON_ERROR_REPORT: - action = BLOCK_ERROR_ACTION_REPORT; + case BlockdevOnError_report: + action = BlockErrorAction_report; break; - case BLOCKDEV_ON_ERROR_IGNORE: - action = BLOCK_ERROR_ACTION_IGNORE; + case BlockdevOnError_ignore: + action = BlockErrorAction_ignore; break; default: abort(); } qapi_event_send_block_job_error(job->id, - is_read ? IO_OPERATION_TYPE_READ : - IO_OPERATION_TYPE_WRITE, + is_read ? IoOperationType_read : + IoOperationType_write, action, &error_abort); - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { /* make the pause user visible, which will be resumed from QMP. */ job->user_paused = true; block_job_pause(job); diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c index c3fcdaf..3f03c70 100644 --- a/crypto/tlscredsanon.c +++ b/crypto/tlscredsanon.c @@ -38,7 +38,7 @@ qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds, trace_qcrypto_tls_creds_anon_load(creds, creds->parent_obj.dir ? creds->parent_obj.dir : ""); - if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { if (qcrypto_tls_creds_get_path(&creds->parent_obj, QCRYPTO_TLS_CREDS_DH_PARAMS, false, &dhparams, errp) < 0) { @@ -79,7 +79,7 @@ qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds, static void qcrypto_tls_creds_anon_unload(QCryptoTLSCredsAnon *creds) { - if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) { + if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_client) { if (creds->data.client) { gnutls_anon_free_client_credentials(creds->data.client); creds->data.client = NULL; @@ -141,7 +141,7 @@ qcrypto_tls_creds_anon_prop_get_loaded(Object *obj, { QCryptoTLSCredsAnon *creds = QCRYPTO_TLS_CREDS_ANON(obj); - if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { return creds->data.server != NULL; } else { return creds->data.client != NULL; diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c index dc46bc4..9137da3 100644 --- a/crypto/tlscredsx509.c +++ b/crypto/tlscredsx509.c @@ -549,7 +549,7 @@ qcrypto_tls_creds_x509_load(QCryptoTLSCredsX509 *creds, trace_qcrypto_tls_creds_x509_load(creds, creds->parent_obj.dir ? creds->parent_obj.dir : ""); - if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { if (qcrypto_tls_creds_get_path(&creds->parent_obj, QCRYPTO_TLS_CREDS_X509_CA_CERT, true, &cacert, errp) < 0 || @@ -583,7 +583,7 @@ qcrypto_tls_creds_x509_load(QCryptoTLSCredsX509 *creds, if (creds->sanityCheck && qcrypto_tls_creds_x509_sanity_check(creds, - creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, + creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server, cacert, cert, errp) < 0) { goto cleanup; } @@ -626,7 +626,7 @@ qcrypto_tls_creds_x509_load(QCryptoTLSCredsX509 *creds, } } - if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { if (qcrypto_tls_creds_get_dh_params_file(&creds->parent_obj, dhparams, &creds->parent_obj.dh_params, errp) < 0) { diff --git a/crypto/tlssession.c b/crypto/tlssession.c index ffc5c47..bd0bac4 100644 --- a/crypto/tlssession.c +++ b/crypto/tlssession.c @@ -116,7 +116,7 @@ qcrypto_tls_session_new(QCryptoTLSCreds *creds, goto error; } - if (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { ret = gnutls_init(&session->handle, GNUTLS_SERVER); } else { ret = gnutls_init(&session->handle, GNUTLS_CLIENT); @@ -138,7 +138,7 @@ qcrypto_tls_session_new(QCryptoTLSCreds *creds, gnutls_strerror(ret)); goto error; } - if (creds->endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (creds->endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { ret = gnutls_credentials_set(session->handle, GNUTLS_CRD_ANON, acreds->data.server); @@ -171,7 +171,7 @@ qcrypto_tls_session_new(QCryptoTLSCreds *creds, goto error; } - if (creds->endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (creds->endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server) { /* This requests, but does not enforce a client cert. * The cert checking code later does enforcement */ gnutls_certificate_server_set_request(session->handle, diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index 20e6907..24ab324 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -257,6 +257,7 @@ useful. The list of strings should be lower case; if an enum name represents multiple words, use '-' between words. The string 'max' is not allowed as an enum value, and values should not be repeated. +FIXME obsolete, rewrite The enum constants will be named by using a heuristic to turn the type name into a set of underscore separated words. For the example above, 'MyEnum' will turn into 'MY_ENUM' giving a constant name @@ -1034,15 +1035,15 @@ Example: qmp = qmp_event_build_dict("MY_EVENT"); - emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp, &err); + emit(example_QAPIEvent_MY_EVENT, qmp, &err); error_propagate(errp, err); QDECREF(qmp); } const char *const example_QAPIEvent_lookup[] = { - [EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT", - [EXAMPLE_QAPI_EVENT_MAX] = NULL, + [example_QAPIEvent_MY_EVENT] = "MY_EVENT", + [example_QAPIEvent_MAX] = NULL, }; $ cat qapi-generated/example-qapi-event.h [Uninteresting stuff omitted...] @@ -1058,8 +1059,8 @@ Example: void qapi_event_send_my_event(Error **errp); typedef enum example_QAPIEvent { - EXAMPLE_QAPI_EVENT_MY_EVENT = 0, - EXAMPLE_QAPI_EVENT_MAX = 1, + example_QAPIEvent_MY_EVENT = 0, + example_QAPIEvent_MAX = 1, } example_QAPIEvent; extern const char *const example_QAPIEvent_lookup[]; diff --git a/docs/writing-qmp-commands.txt b/docs/writing-qmp-commands.txt index 8647cac..fb0f42a 100644 --- a/docs/writing-qmp-commands.txt +++ b/docs/writing-qmp-commands.txt @@ -219,7 +219,7 @@ void qmp_hello_world(bool has_message, const char *message, Error **errp) { if (has_message) { if (strstr(message, "love")) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "the word 'love' is not allowed"); return; } @@ -231,7 +231,7 @@ void qmp_hello_world(bool has_message, const char *message, Error **errp) The first argument to the error_set() function is the Error pointer to pointer, which is passed to all QMP functions. The second argument is a ErrorClass -value, which should be ERROR_CLASS_GENERIC_ERROR most of the time (more +value, which should be ErrorClass_GenericError most of the time (more details about error classes are given below). The third argument is a human description of the error, this is a free-form printf-like string. @@ -249,7 +249,7 @@ The QMP server's response should be: } } -As a general rule, all QMP errors should use ERROR_CLASS_GENERIC_ERROR. There +As a general rule, all QMP errors should use ErrorClass_GenericError. There are two exceptions to this rule: 1. A non-generic ErrorClass value exists* for the failure you want to report @@ -260,7 +260,7 @@ are two exceptions to this rule: can check for it If the failure you want to report doesn't fall in one of the two cases above, -just report ERROR_CLASS_GENERIC_ERROR. +just report ErrorClass_GenericError. * All existing ErrorClass values are defined in the qapi-schema.json file diff --git a/dump.c b/dump.c index 78b7d84..f0c87a8 100644 --- a/dump.c +++ b/dump.c @@ -1443,12 +1443,12 @@ static void dump_init(DumpState *s, int fd, bool has_format, int ret; /* kdump-compressed is conflict with paging and filter */ - if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) { + if (has_format && format != DumpGuestMemoryFormat_elf) { assert(!paging && !has_filter); } if (runstate_is_running()) { - vm_stop(RUN_STATE_SAVE_VM); + vm_stop(RunState_save_vm); s->resume = true; } else { s->resume = false; @@ -1516,13 +1516,13 @@ static void dump_init(DumpState *s, int fd, bool has_format, s->len_dump_bitmap = tmp * TARGET_PAGE_SIZE; /* init for kdump-compressed format */ - if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) { + if (has_format && format != DumpGuestMemoryFormat_elf) { switch (format) { - case DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB: + case DumpGuestMemoryFormat_kdump_zlib: s->flag_compress = DUMP_DH_COMPRESSED_ZLIB; break; - case DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO: + case DumpGuestMemoryFormat_kdump_lzo: #ifdef CONFIG_LZO if (lzo_init() != LZO_E_OK) { error_setg(errp, "failed to initialize the LZO library"); @@ -1532,7 +1532,7 @@ static void dump_init(DumpState *s, int fd, bool has_format, s->flag_compress = DUMP_DH_COMPRESSED_LZO; break; - case DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY: + case DumpGuestMemoryFormat_kdump_snappy: s->flag_compress = DUMP_DH_COMPRESSED_SNAPPY; break; @@ -1609,7 +1609,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, * kdump-compressed format need the whole memory dumped, so paging or * filter is not supported here. */ - if ((has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) && + if ((has_format && format != DumpGuestMemoryFormat_elf) && (paging || has_begin || has_length)) { error_setg(errp, "kdump-compressed format doesn't support paging or " "filter"); @@ -1626,14 +1626,14 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, /* check whether lzo/snappy is supported */ #ifndef CONFIG_LZO - if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO) { + if (has_format && format == DumpGuestMemoryFormat_kdump_lzo) { error_setg(errp, "kdump-lzo is not available now"); return; } #endif #ifndef CONFIG_SNAPPY - if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY) { + if (has_format && format == DumpGuestMemoryFormat_kdump_snappy) { error_setg(errp, "kdump-snappy is not available now"); return; } @@ -1671,7 +1671,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, return; } - if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) { + if (has_format && format != DumpGuestMemoryFormat_elf) { create_kdump_vmcore(s, errp); } else { create_vmcore(s, errp); @@ -1689,25 +1689,25 @@ DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp) /* elf is always available */ item = g_malloc0(sizeof(DumpGuestMemoryFormatList)); cap->formats = item; - item->value = DUMP_GUEST_MEMORY_FORMAT_ELF; + item->value = DumpGuestMemoryFormat_elf; /* kdump-zlib is always available */ item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList)); item = item->next; - item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; + item->value = DumpGuestMemoryFormat_kdump_zlib; /* add new item if kdump-lzo is available */ #ifdef CONFIG_LZO item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList)); item = item->next; - item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; + item->value = DumpGuestMemoryFormat_kdump_lzo; #endif /* add new item if kdump-snappy is available */ #ifdef CONFIG_SNAPPY item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList)); item = item->next; - item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; + item->value = DumpGuestMemoryFormat_kdump_snappy; #endif return cap; diff --git a/gdbstub.c b/gdbstub.c index d2c95b5..34c20e1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1237,7 +1237,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) return; } switch (state) { - case RUN_STATE_DEBUG: + case RunState_debug: if (cpu->watchpoint_hit) { switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { case BP_MEM_READ: @@ -1260,25 +1260,25 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) tb_flush(cpu); ret = GDB_SIGNAL_TRAP; break; - case RUN_STATE_PAUSED: + case RunState_paused: ret = GDB_SIGNAL_INT; break; - case RUN_STATE_SHUTDOWN: + case RunState_shutdown: ret = GDB_SIGNAL_QUIT; break; - case RUN_STATE_IO_ERROR: + case RunState_io_error: ret = GDB_SIGNAL_IO; break; - case RUN_STATE_WATCHDOG: + case RunState_watchdog: ret = GDB_SIGNAL_ALRM; break; - case RUN_STATE_INTERNAL_ERROR: + case RunState_internal_error: ret = GDB_SIGNAL_ABRT; break; - case RUN_STATE_SAVE_VM: - case RUN_STATE_RESTORE_VM: + case RunState_save_vm: + case RunState_restore_vm: return; - case RUN_STATE_FINISH_MIGRATE: + case RunState_finish_migrate: ret = GDB_SIGNAL_XCPU; break; default: @@ -1314,7 +1314,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) return; s->current_syscall_cb = cb; #ifndef CONFIG_USER_ONLY - vm_stop(RUN_STATE_DEBUG); + vm_stop(RunState_debug); #endif p = s->syscall_buf; p_end = &s->syscall_buf[sizeof(s->syscall_buf)]; @@ -1401,7 +1401,7 @@ static void gdb_read_byte(GDBState *s, int ch) if (runstate_is_running()) { /* when the CPU is running, we cannot do anything except stop it when receiving a char */ - vm_stop(RUN_STATE_PAUSED); + vm_stop(RunState_paused); } else #endif { @@ -1666,7 +1666,7 @@ static void gdb_chr_event(void *opaque, int event) { switch (event) { case CHR_EVENT_OPENED: - vm_stop(RUN_STATE_PAUSED); + vm_stop(RunState_paused); gdb_has_xml = false; break; default: @@ -1707,7 +1707,7 @@ static int gdb_monitor_write(CharDriverState *chr, const uint8_t *buf, int len) static void gdb_sigterm_handler(int signal) { if (runstate_is_running()) { - vm_stop(RUN_STATE_PAUSED); + vm_stop(RunState_paused); } } #endif diff --git a/hmp.c b/hmp.c index a15d00c..6a7a779 100644 --- a/hmp.c +++ b/hmp.c @@ -94,7 +94,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict) info->running ? "running" : "paused", info->singlestep ? " (single step mode)" : ""); - if (!info->running && info->status != RUN_STATE_PAUSED) { + if (!info->running && info->status != RunState_paused) { monitor_printf(mon, " (%s)", RunState_lookup[info->status]); } @@ -269,19 +269,19 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) if (params) { monitor_printf(mon, "parameters:"); monitor_printf(mon, " %s: %" PRId64, - MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL], + MigrationParameter_lookup[MigrationParameter_compress_level], params->compress_level); monitor_printf(mon, " %s: %" PRId64, - MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS], + MigrationParameter_lookup[MigrationParameter_compress_threads], params->compress_threads); monitor_printf(mon, " %s: %" PRId64, - MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS], + MigrationParameter_lookup[MigrationParameter_decompress_threads], params->decompress_threads); monitor_printf(mon, " %s: %" PRId64, - MigrationParameter_lookup[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL], + MigrationParameter_lookup[MigrationParameter_x_cpu_throttle_initial], params->x_cpu_throttle_initial); monitor_printf(mon, " %s: %" PRId64, - MigrationParameter_lookup[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT], + MigrationParameter_lookup[MigrationParameter_x_cpu_throttle_increment], params->x_cpu_throttle_increment); monitor_printf(mon, "\n"); } @@ -364,7 +364,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info, } if (info) { - if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) { + if (info->has_io_status && info->io_status != BlockDeviceIoStatus_ok) { monitor_printf(mon, " I/O status: %s\n", BlockDeviceIoStatus_lookup[info->io_status]); } @@ -394,7 +394,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info, inserted->backing_file_depth); } - if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) { + if (inserted->detect_zeroes != BlockdevDetectZeroesOptions_off) { monitor_printf(mon, " Detect zeroes: %s\n", BlockdevDetectZeroesOptions_lookup[inserted->detect_zeroes]); } @@ -844,7 +844,7 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) ti->id, TpmTypeOptionsKind_lookup[ti->options->type]); switch (ti->options->type) { - case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: + case TpmTypeOptionsKind_passthrough: tpo = ti->options->u.passthrough; monitor_printf(mon, "%s%s%s%s", tpo->has_path ? ",path=" : "", @@ -852,7 +852,7 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) tpo->has_cancel_path ? ",cancel-path=" : "", tpo->has_cancel_path ? tpo->cancel_path : ""); break; - case TPM_TYPE_OPTIONS_KIND_MAX: + case TpmTypeOptionsKind_MAX: break; } monitor_printf(mon, "\n"); @@ -1063,14 +1063,14 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict) } if (reuse) { - mode = NEW_IMAGE_MODE_EXISTING; + mode = NewImageMode_existing; } else { - mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; + mode = NewImageMode_absolute_paths; } qmp_drive_mirror(device, filename, !!format, format, false, NULL, false, NULL, - full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, + full ? MirrorSyncMode_full : MirrorSyncMode_top, true, mode, false, 0, false, 0, false, 0, false, 0, false, 0, false, true, &err); hmp_handle_error(mon, &err); @@ -1093,13 +1093,13 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) } if (reuse) { - mode = NEW_IMAGE_MODE_EXISTING; + mode = NewImageMode_existing; } else { - mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; + mode = NewImageMode_absolute_paths; } qmp_drive_backup(device, filename, !!format, format, - full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, + full ? MirrorSyncMode_full : MirrorSyncMode_top, true, mode, false, 0, false, NULL, false, 0, false, 0, &err); hmp_handle_error(mon, &err); @@ -1122,7 +1122,7 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) return; } - mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS; + mode = reuse ? NewImageMode_existing : NewImageMode_absolute_paths; qmp_blockdev_snapshot_sync(true, device, false, NULL, filename, false, NULL, !!format, format, @@ -1200,7 +1200,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict) MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps)); int i; - for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) { + for (i = 0; i < MigrationCapability_MAX; i++) { if (strcmp(cap, MigrationCapability_lookup[i]) == 0) { caps->value = g_malloc0(sizeof(*caps->value)); caps->value->capability = i; @@ -1211,7 +1211,7 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict) } } - if (i == MIGRATION_CAPABILITY_MAX) { + if (i == MigrationCapability_MAX) { error_setg(&err, QERR_INVALID_PARAMETER, cap); } @@ -1236,22 +1236,22 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) bool has_x_cpu_throttle_increment = false; int i; - for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) { + for (i = 0; i < MigrationParameter_MAX; i++) { if (strcmp(param, MigrationParameter_lookup[i]) == 0) { switch (i) { - case MIGRATION_PARAMETER_COMPRESS_LEVEL: + case MigrationParameter_compress_level: has_compress_level = true; break; - case MIGRATION_PARAMETER_COMPRESS_THREADS: + case MigrationParameter_compress_threads: has_compress_threads = true; break; - case MIGRATION_PARAMETER_DECOMPRESS_THREADS: + case MigrationParameter_decompress_threads: has_decompress_threads = true; break; - case MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL: + case MigrationParameter_x_cpu_throttle_initial: has_x_cpu_throttle_initial = true; break; - case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT: + case MigrationParameter_x_cpu_throttle_increment: has_x_cpu_throttle_increment = true; break; } @@ -1265,7 +1265,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) } } - if (i == MIGRATION_PARAMETER_MAX) { + if (i == MigrationParameter_MAX) { error_setg(&err, QERR_INVALID_PARAMETER, param); } @@ -1349,7 +1349,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) qmp_change(device, target, !!arg, arg, &err); if (err && - error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { + error_get_class(err) == ErrorClass_DeviceEncrypted) { error_free(err); monitor_read_block_device_key(mon, device, NULL, NULL); return; @@ -1396,7 +1396,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict) qmp_block_stream(device, base != NULL, base, false, NULL, qdict_haskey(qdict, "speed"), speed, - true, BLOCKDEV_ON_ERROR_REPORT, &error); + true, BlockdevOnError_report, &error); hmp_handle_error(mon, &error); } @@ -1466,8 +1466,8 @@ static void hmp_migrate_status_cb(void *opaque) MigrationInfo *info; info = qmp_query_migrate(NULL); - if (!info->has_status || info->status == MIGRATION_STATUS_ACTIVE || - info->status == MIGRATION_STATUS_SETUP) { + if (!info->has_status || info->status == MigrationStatus_active || + info->status == MigrationStatus_setup) { if (info->has_disk) { int progress; @@ -1556,7 +1556,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) bool has_length = qdict_haskey(qdict, "length"); int64_t begin = 0; int64_t length = 0; - enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; + enum DumpGuestMemoryFormat dump_format = DumpGuestMemoryFormat_elf; char *prot; if (zlib + lzo + snappy > 1) { @@ -1566,15 +1566,15 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) } if (zlib) { - dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; + dump_format = DumpGuestMemoryFormat_kdump_zlib; } if (lzo) { - dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; + dump_format = DumpGuestMemoryFormat_kdump_lzo; } if (snappy) { - dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; + dump_format = DumpGuestMemoryFormat_kdump_snappy; } if (has_begin) { @@ -1735,14 +1735,14 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) if (*endp != '\0') { goto err_out; } - keylist->value->type = KEY_VALUE_KIND_NUMBER; + keylist->value->type = KeyValueKind_number; keylist->value->u.number = value; } else { int idx = index_from_key(keyname_buf); - if (idx == Q_KEY_CODE_MAX) { + if (idx == QKeyCode_MAX) { goto err_out; } - keylist->value->type = KEY_VALUE_KIND_QCODE; + keylist->value->type = KeyValueKind_qcode; keylist->value->u.qcode = idx; } @@ -1892,7 +1892,7 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) if (blk) { qemuio_command(blk, command); } else { - error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(&err, ErrorClass_DeviceNotFound, "Device '%s' not found", device); } @@ -1959,7 +1959,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) if (value) { switch (value->type) { - case MEMORY_DEVICE_INFO_KIND_DIMM: + case MemoryDeviceInfoKind_dimm: di = value->u.dimm; monitor_printf(mon, "Memory device [%s]: \"%s\"\n", @@ -2034,7 +2034,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict) obj = object_resolve_path(path, &ambiguous); if (obj == NULL) { - error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(&err, ErrorClass_DeviceNotFound, "Device '%s' not found", path); } else { if (ambiguous) { diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index ce428df..20caa31 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -10,7 +10,7 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { ACPIOSTInfo *info = g_new0(ACPIOSTInfo, 1); - info->slot_type = ACPI_SLOT_TYPE_DIMM; + info->slot_type = ACPISlotType_DIMM; info->slot = g_strdup_printf("%d", slot); info->source = mdev->ost_event; info->status = mdev->ost_status; diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index b534bb9..127dae9 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -374,7 +374,7 @@ static void eth_cleanup(NetClientState *nc) } static NetClientInfo net_mv88w8618_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = eth_receive, .cleanup = eth_cleanup, diff --git a/hw/block/block.c b/hw/block/block.c index f7243e5..2a458a4 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -71,7 +71,7 @@ void blkconf_geometry(BlockConf *conf, int *ptrans, hd_geometry_guess(conf->blk, &conf->cyls, &conf->heads, &conf->secs, ptrans); - } else if (ptrans && *ptrans == BIOS_ATA_TRANSLATION_AUTO) { + } else if (ptrans && *ptrans == BiosAtaTranslation_auto) { *ptrans = hd_bios_chs_auto_trans(conf->cyls, conf->heads, conf->secs); } if (conf->cyls || conf->heads || conf->secs) { diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 4292ece..145f2ad 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -2214,11 +2214,11 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl, Error **errp) drive->fdctrl = fdctrl; if (drive->blk) { - if (blk_get_on_error(drive->blk, 0) != BLOCKDEV_ON_ERROR_ENOSPC) { + if (blk_get_on_error(drive->blk, 0) != BlockdevOnError_enospc) { error_setg(errp, "fdc doesn't support drive option werror"); return; } - if (blk_get_on_error(drive->blk, 1) != BLOCKDEV_ON_ERROR_REPORT) { + if (blk_get_on_error(drive->blk, 1) != BlockdevOnError_report) { error_setg(errp, "fdc doesn't support drive option rerror"); return; } diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index b187878..5479359 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -129,7 +129,7 @@ void hd_geometry_guess(BlockBackend *blk, *pcyls = geo.cylinders; *psecs = geo.sectors; *pheads = geo.heads; - translation = BIOS_ATA_TRANSLATION_NONE; + translation = BiosAtaTranslation_none; } else if (guess_disk_lchs(blk, &cylinders, &heads, &secs) < 0) { /* no LCHS guess: use a standard physical disk geometry */ guess_chs_for_size(blk, pcyls, pheads, psecs); @@ -140,8 +140,8 @@ void hd_geometry_guess(BlockBackend *blk, geometry is OK */ guess_chs_for_size(blk, pcyls, pheads, psecs); translation = *pcyls * *pheads <= 131072 - ? BIOS_ATA_TRANSLATION_LARGE - : BIOS_ATA_TRANSLATION_LBA; + ? BiosAtaTranslation_large + : BiosAtaTranslation_lba; } else { /* LCHS guess with heads <= 16: use as physical geometry */ *pcyls = cylinders; @@ -149,7 +149,7 @@ void hd_geometry_guess(BlockBackend *blk, *psecs = secs; /* disable any translation to be in sync with the logical geometry */ - translation = BIOS_ATA_TRANSLATION_NONE; + translation = BiosAtaTranslation_none; } if (ptrans) { *ptrans = translation; @@ -160,6 +160,6 @@ void hd_geometry_guess(BlockBackend *blk, int hd_bios_chs_auto_trans(uint32_t cyls, uint32_t heads, uint32_t secs) { return cyls <= 1024 && heads <= 16 && secs <= 63 - ? BIOS_ATA_TRANSLATION_NONE - : BIOS_ATA_TRANSLATION_LBA; + ? BiosAtaTranslation_none + : BiosAtaTranslation_lba; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 093e475..988868f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -71,17 +71,17 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, is_read, error); VirtIOBlock *s = req->dev; - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { req->next = s->rq; s->rq = req; - } else if (action == BLOCK_ERROR_ACTION_REPORT) { + } else if (action == BlockErrorAction_report) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); block_acct_done(blk_get_stats(s->blk), &req->acct); virtio_blk_free_request(req); } blk_error_action(s->blk, action, is_read, error); - return action != BLOCK_ERROR_ACTION_IGNORE; + return action != BlockErrorAction_ignore; } static void virtio_blk_rw_complete(void *opaque, int ret) @@ -105,7 +105,7 @@ static void virtio_blk_rw_complete(void *opaque, int ret) bool is_read = !(p & VIRTIO_BLK_T_OUT); /* Note that memory may be dirtied on read failure. If the * virtio request is not completed here, as is the case for - * BLOCK_ERROR_ACTION_STOP, the memory may not be copied + * BlockErrorAction_stop, the memory may not be copied * correctly during live migration. While this is ugly, * it is acceptable because the device is free to write to * the memory until the request is completed (which will diff --git a/hw/char/escc.c b/hw/char/escc.c index c9840e1..d1c6e7b 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -714,126 +714,126 @@ MemoryRegion *escc_init(hwaddr base, qemu_irq irqA, qemu_irq irqB, return &d->mmio; } -static const uint8_t qcode_to_keycode[Q_KEY_CODE_MAX] = { - [Q_KEY_CODE_SHIFT] = 99, - [Q_KEY_CODE_SHIFT_R] = 110, - [Q_KEY_CODE_ALT] = 19, - [Q_KEY_CODE_ALT_R] = 13, - [Q_KEY_CODE_ALTGR] = 13, - [Q_KEY_CODE_CTRL] = 76, - [Q_KEY_CODE_CTRL_R] = 76, - [Q_KEY_CODE_ESC] = 29, - [Q_KEY_CODE_1] = 30, - [Q_KEY_CODE_2] = 31, - [Q_KEY_CODE_3] = 32, - [Q_KEY_CODE_4] = 33, - [Q_KEY_CODE_5] = 34, - [Q_KEY_CODE_6] = 35, - [Q_KEY_CODE_7] = 36, - [Q_KEY_CODE_8] = 37, - [Q_KEY_CODE_9] = 38, - [Q_KEY_CODE_0] = 39, - [Q_KEY_CODE_MINUS] = 40, - [Q_KEY_CODE_EQUAL] = 41, - [Q_KEY_CODE_BACKSPACE] = 43, - [Q_KEY_CODE_TAB] = 53, - [Q_KEY_CODE_Q] = 54, - [Q_KEY_CODE_W] = 55, - [Q_KEY_CODE_E] = 56, - [Q_KEY_CODE_R] = 57, - [Q_KEY_CODE_T] = 58, - [Q_KEY_CODE_Y] = 59, - [Q_KEY_CODE_U] = 60, - [Q_KEY_CODE_I] = 61, - [Q_KEY_CODE_O] = 62, - [Q_KEY_CODE_P] = 63, - [Q_KEY_CODE_BRACKET_LEFT] = 64, - [Q_KEY_CODE_BRACKET_RIGHT] = 65, - [Q_KEY_CODE_RET] = 89, - [Q_KEY_CODE_A] = 77, - [Q_KEY_CODE_S] = 78, - [Q_KEY_CODE_D] = 79, - [Q_KEY_CODE_F] = 80, - [Q_KEY_CODE_G] = 81, - [Q_KEY_CODE_H] = 82, - [Q_KEY_CODE_J] = 83, - [Q_KEY_CODE_K] = 84, - [Q_KEY_CODE_L] = 85, - [Q_KEY_CODE_SEMICOLON] = 86, - [Q_KEY_CODE_APOSTROPHE] = 87, - [Q_KEY_CODE_GRAVE_ACCENT] = 42, - [Q_KEY_CODE_BACKSLASH] = 88, - [Q_KEY_CODE_Z] = 100, - [Q_KEY_CODE_X] = 101, - [Q_KEY_CODE_C] = 102, - [Q_KEY_CODE_V] = 103, - [Q_KEY_CODE_B] = 104, - [Q_KEY_CODE_N] = 105, - [Q_KEY_CODE_M] = 106, - [Q_KEY_CODE_COMMA] = 107, - [Q_KEY_CODE_DOT] = 108, - [Q_KEY_CODE_SLASH] = 109, - [Q_KEY_CODE_ASTERISK] = 47, - [Q_KEY_CODE_SPC] = 121, - [Q_KEY_CODE_CAPS_LOCK] = 119, - [Q_KEY_CODE_F1] = 5, - [Q_KEY_CODE_F2] = 6, - [Q_KEY_CODE_F3] = 8, - [Q_KEY_CODE_F4] = 10, - [Q_KEY_CODE_F5] = 12, - [Q_KEY_CODE_F6] = 14, - [Q_KEY_CODE_F7] = 16, - [Q_KEY_CODE_F8] = 17, - [Q_KEY_CODE_F9] = 18, - [Q_KEY_CODE_F10] = 7, - [Q_KEY_CODE_NUM_LOCK] = 98, - [Q_KEY_CODE_SCROLL_LOCK] = 23, - [Q_KEY_CODE_KP_DIVIDE] = 46, - [Q_KEY_CODE_KP_MULTIPLY] = 47, - [Q_KEY_CODE_KP_SUBTRACT] = 71, - [Q_KEY_CODE_KP_ADD] = 125, - [Q_KEY_CODE_KP_ENTER] = 90, - [Q_KEY_CODE_KP_DECIMAL] = 50, - [Q_KEY_CODE_KP_0] = 94, - [Q_KEY_CODE_KP_1] = 112, - [Q_KEY_CODE_KP_2] = 113, - [Q_KEY_CODE_KP_3] = 114, - [Q_KEY_CODE_KP_4] = 91, - [Q_KEY_CODE_KP_5] = 92, - [Q_KEY_CODE_KP_6] = 93, - [Q_KEY_CODE_KP_7] = 68, - [Q_KEY_CODE_KP_8] = 69, - [Q_KEY_CODE_KP_9] = 70, - [Q_KEY_CODE_LESS] = 124, - [Q_KEY_CODE_F11] = 9, - [Q_KEY_CODE_F12] = 11, - [Q_KEY_CODE_HOME] = 52, - [Q_KEY_CODE_PGUP] = 96, - [Q_KEY_CODE_PGDN] = 123, - [Q_KEY_CODE_END] = 74, - [Q_KEY_CODE_LEFT] = 24, - [Q_KEY_CODE_UP] = 20, - [Q_KEY_CODE_DOWN] = 27, - [Q_KEY_CODE_RIGHT] = 28, - [Q_KEY_CODE_INSERT] = 44, - [Q_KEY_CODE_DELETE] = 66, - [Q_KEY_CODE_STOP] = 1, - [Q_KEY_CODE_AGAIN] = 3, - [Q_KEY_CODE_PROPS] = 25, - [Q_KEY_CODE_UNDO] = 26, - [Q_KEY_CODE_FRONT] = 49, - [Q_KEY_CODE_COPY] = 51, - [Q_KEY_CODE_OPEN] = 72, - [Q_KEY_CODE_PASTE] = 73, - [Q_KEY_CODE_FIND] = 95, - [Q_KEY_CODE_CUT] = 97, - [Q_KEY_CODE_LF] = 111, - [Q_KEY_CODE_HELP] = 118, - [Q_KEY_CODE_META_L] = 120, - [Q_KEY_CODE_META_R] = 122, - [Q_KEY_CODE_COMPOSE] = 67, - [Q_KEY_CODE_PRINT] = 22, - [Q_KEY_CODE_SYSRQ] = 21, +static const uint8_t qcode_to_keycode[QKeyCode_MAX] = { + [QKeyCode_shift] = 99, + [QKeyCode_shift_r] = 110, + [QKeyCode_alt] = 19, + [QKeyCode_alt_r] = 13, + [QKeyCode_altgr] = 13, + [QKeyCode_ctrl] = 76, + [QKeyCode_ctrl_r] = 76, + [QKeyCode_esc] = 29, + [QKeyCode_1] = 30, + [QKeyCode_2] = 31, + [QKeyCode_3] = 32, + [QKeyCode_4] = 33, + [QKeyCode_5] = 34, + [QKeyCode_6] = 35, + [QKeyCode_7] = 36, + [QKeyCode_8] = 37, + [QKeyCode_9] = 38, + [QKeyCode_0] = 39, + [QKeyCode_minus] = 40, + [QKeyCode_equal] = 41, + [QKeyCode_backspace] = 43, + [QKeyCode_tab] = 53, + [QKeyCode_q] = 54, + [QKeyCode_w] = 55, + [QKeyCode_e] = 56, + [QKeyCode_r] = 57, + [QKeyCode_t] = 58, + [QKeyCode_y] = 59, + [QKeyCode_u] = 60, + [QKeyCode_i] = 61, + [QKeyCode_o] = 62, + [QKeyCode_p] = 63, + [QKeyCode_bracket_left] = 64, + [QKeyCode_bracket_right] = 65, + [QKeyCode_ret] = 89, + [QKeyCode_a] = 77, + [QKeyCode_s] = 78, + [QKeyCode_d] = 79, + [QKeyCode_f] = 80, + [QKeyCode_g] = 81, + [QKeyCode_h] = 82, + [QKeyCode_j] = 83, + [QKeyCode_k] = 84, + [QKeyCode_l] = 85, + [QKeyCode_semicolon] = 86, + [QKeyCode_apostrophe] = 87, + [QKeyCode_grave_accent] = 42, + [QKeyCode_backslash] = 88, + [QKeyCode_z] = 100, + [QKeyCode_x] = 101, + [QKeyCode_c] = 102, + [QKeyCode_v] = 103, + [QKeyCode_b] = 104, + [QKeyCode_n] = 105, + [QKeyCode_m] = 106, + [QKeyCode_comma] = 107, + [QKeyCode_dot] = 108, + [QKeyCode_slash] = 109, + [QKeyCode_asterisk] = 47, + [QKeyCode_spc] = 121, + [QKeyCode_caps_lock] = 119, + [QKeyCode_f1] = 5, + [QKeyCode_f2] = 6, + [QKeyCode_f3] = 8, + [QKeyCode_f4] = 10, + [QKeyCode_f5] = 12, + [QKeyCode_f6] = 14, + [QKeyCode_f7] = 16, + [QKeyCode_f8] = 17, + [QKeyCode_f9] = 18, + [QKeyCode_f10] = 7, + [QKeyCode_num_lock] = 98, + [QKeyCode_scroll_lock] = 23, + [QKeyCode_kp_divide] = 46, + [QKeyCode_kp_multiply] = 47, + [QKeyCode_kp_subtract] = 71, + [QKeyCode_kp_add] = 125, + [QKeyCode_kp_enter] = 90, + [QKeyCode_kp_decimal] = 50, + [QKeyCode_kp_0] = 94, + [QKeyCode_kp_1] = 112, + [QKeyCode_kp_2] = 113, + [QKeyCode_kp_3] = 114, + [QKeyCode_kp_4] = 91, + [QKeyCode_kp_5] = 92, + [QKeyCode_kp_6] = 93, + [QKeyCode_kp_7] = 68, + [QKeyCode_kp_8] = 69, + [QKeyCode_kp_9] = 70, + [QKeyCode_less] = 124, + [QKeyCode_f11] = 9, + [QKeyCode_f12] = 11, + [QKeyCode_home] = 52, + [QKeyCode_pgup] = 96, + [QKeyCode_pgdn] = 123, + [QKeyCode_end] = 74, + [QKeyCode_left] = 24, + [QKeyCode_up] = 20, + [QKeyCode_down] = 27, + [QKeyCode_right] = 28, + [QKeyCode_insert] = 44, + [QKeyCode_delete] = 66, + [QKeyCode_stop] = 1, + [QKeyCode_again] = 3, + [QKeyCode_props] = 25, + [QKeyCode_undo] = 26, + [QKeyCode_front] = 49, + [QKeyCode_copy] = 51, + [QKeyCode_open] = 72, + [QKeyCode_paste] = 73, + [QKeyCode_find] = 95, + [QKeyCode_cut] = 97, + [QKeyCode_lf] = 111, + [QKeyCode_help] = 118, + [QKeyCode_meta_l] = 120, + [QKeyCode_meta_r] = 122, + [QKeyCode_compose] = 67, + [QKeyCode_print] = 22, + [QKeyCode_sysrq] = 21, }; static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src, @@ -842,12 +842,12 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src, ChannelState *s = (ChannelState *)dev; int qcode, keycode; - assert(evt->type == INPUT_EVENT_KIND_KEY); + assert(evt->type == InputEventKind_key); qcode = qemu_input_key_value_to_qcode(evt->u.key->key); trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode], evt->u.key->down); - if (qcode == Q_KEY_CODE_CAPS_LOCK) { + if (qcode == QKeyCode_caps_lock) { if (evt->u.key->down) { s->caps_lock_mode ^= 1; if (s->caps_lock_mode == 2) { @@ -861,7 +861,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src, } } - if (qcode == Q_KEY_CODE_NUM_LOCK) { + if (qcode == QKeyCode_num_lock) { if (evt->u.key->down) { s->num_lock_mode ^= 1; if (s->num_lock_mode == 2) { diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 921e799..e0ddedb 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -229,7 +229,7 @@ static void set_netdev(Object *obj, Visitor *v, void *opaque, } queues = qemu_find_net_clients_except(str, peers, - NET_CLIENT_OPTIONS_KIND_NIC, + NetClientOptionsKind_nic, MAX_QUEUE_NUM); if (queues == 0) { err = -ENOENT; diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 9c961da..64c76ba 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -963,8 +963,8 @@ static void interface_set_client_capabilities(QXLInstance *sin, return; } - if (runstate_check(RUN_STATE_INMIGRATE) || - runstate_check(RUN_STATE_POSTMIGRATE)) { + if (runstate_check(RunState_inmigrate) || + runstate_check(RunState_postmigrate)) { return; } diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index 90eea10..2b613d7 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -269,9 +269,9 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp) return; } switch (s->lost_tick_policy) { - case LOST_TICK_POLICY_DELAY: + case LostTickPolicy_delay: break; /* enabled by default */ - case LOST_TICK_POLICY_DISCARD: + case LostTickPolicy_discard: if (kvm_check_extension(kvm_state, KVM_CAP_REINJECT_CONTROL)) { struct kvm_reinject_control control = { .pit_reinject = 0 }; @@ -301,7 +301,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp) static Property kvm_pit_properties[] = { DEFINE_PROP_UINT32("iobase", PITCommonState, iobase, -1), DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", KVMPITState, - lost_tick_policy, LOST_TICK_POLICY_DELAY), + lost_tick_policy, LostTickPolicy_delay), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0cb8afd..f360988 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1795,7 +1795,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, return; } if (value > (1ULL << 32)) { - error_set(&error, ERROR_CLASS_GENERIC_ERROR, + error_set(&error, ErrorClass_GenericError, "Machine option 'max-ram-below-4g=%"PRIu64 "' expects size less than or equal to 4G", value); error_propagate(errp, error); @@ -1832,7 +1832,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms) { bool smm_available = false; - if (pcms->smm == ON_OFF_AUTO_OFF) { + if (pcms->smm == OnOffAuto_off) { return false; } @@ -1846,7 +1846,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms) return true; } - if (pcms->smm == ON_OFF_AUTO_ON) { + if (pcms->smm == OnOffAuto_on) { error_report("System Management Mode not supported by this hypervisor."); exit(1); } @@ -1894,7 +1894,7 @@ static void pc_machine_initfn(Object *obj) "Maximum ram below the 4G boundary (32bit boundary)", &error_abort); - pcms->smm = ON_OFF_AUTO_AUTO; + pcms->smm = OnOffAuto_auto; object_property_add(obj, PC_MACHINE_SMM, "OnOffAuto", pc_machine_get_smm, pc_machine_set_smm, @@ -1903,7 +1903,7 @@ static void pc_machine_initfn(Object *obj) "Enable SMM (pc & q35)", &error_abort); - pcms->vmport = ON_OFF_AUTO_AUTO; + pcms->vmport = OnOffAuto_auto; object_property_add(obj, PC_MACHINE_VMPORT, "OnOffAuto", pc_machine_get_vmport, pc_machine_set_vmport, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 393dcc4..8e0544e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -225,14 +225,14 @@ static void pc_init1(MachineState *machine, pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); - assert(pcms->vmport != ON_OFF_AUTO_MAX); - if (pcms->vmport == ON_OFF_AUTO_AUTO) { - pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; + assert(pcms->vmport != OnOffAuto_MAX); + if (pcms->vmport == OnOffAuto_auto) { + pcms->vmport = xen_enabled() ? OnOffAuto_off : OnOffAuto_on; } /* init basic PC hardware */ pc_basic_device_init(isa_bus, gsi, &rtc_state, true, - (pcms->vmport != ON_OFF_AUTO_ON), 0x4); + (pcms->vmport != OnOffAuto_on), 0x4); pc_nic_init(isa_bus, pci_bus); @@ -306,7 +306,7 @@ static void pc_compat_2_3(MachineState *machine) PCMachineState *pcms = PC_MACHINE(machine); savevm_skip_section_footers(); if (kvm_enabled()) { - pcms->smm = ON_OFF_AUTO_OFF; + pcms->smm = OnOffAuto_off; } global_state_set_optional(); savevm_skip_configuration(); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 2f8f396..23796fd 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -233,14 +233,14 @@ static void pc_q35_init(MachineState *machine) pc_register_ferr_irq(gsi[13]); - assert(pcms->vmport != ON_OFF_AUTO_MAX); - if (pcms->vmport == ON_OFF_AUTO_AUTO) { - pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; + assert(pcms->vmport != OnOffAuto_MAX); + if (pcms->vmport == OnOffAuto_auto) { + pcms->vmport = xen_enabled() ? OnOffAuto_off : OnOffAuto_on; } /* init basic PC hardware */ pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy, - (pcms->vmport != ON_OFF_AUTO_ON), 0xff0104); + (pcms->vmport != OnOffAuto_on), 0xff0104); /* connect pm stuff to lpc */ ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms), !mc->no_tco); @@ -289,7 +289,7 @@ static void pc_compat_2_3(MachineState *machine) PCMachineState *pcms = PC_MACHINE(machine); savevm_skip_section_footers(); if (kvm_enabled()) { - pcms->smm = ON_OFF_AUTO_OFF; + pcms->smm = OnOffAuto_off; } global_state_set_optional(); savevm_skip_configuration(); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 21f76ed..76bb87c 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -938,10 +938,10 @@ static void ncq_cb(void *opaque, int ret) bool is_read = ncq_tfs->cmd == READ_FPDMA_QUEUED; BlockErrorAction action = blk_get_error_action(ide_state->blk, is_read, -ret); - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { ncq_tfs->halt = true; ide_state->bus->error_status = IDE_RETRY_HBA; - } else if (action == BLOCK_ERROR_ACTION_REPORT) { + } else if (action == BlockErrorAction_report) { ncq_err(ncq_tfs); } blk_error_action(ide_state->blk, action, is_read, -ret); diff --git a/hw/ide/core.c b/hw/ide/core.c index 317406d..e1a08e7 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -668,10 +668,10 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) bool is_read = (op & IDE_RETRY_READ) != 0; BlockErrorAction action = blk_get_error_action(s->blk, is_read, error); - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { assert(s->bus->retry_unit == s->unit); s->bus->error_status = op; - } else if (action == BLOCK_ERROR_ACTION_REPORT) { + } else if (action == BlockErrorAction_report) { if (op & IDE_RETRY_DMA) { ide_dma_error(s); } else { @@ -679,7 +679,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) } } blk_error_action(s->blk, action, is_read, error); - return action != BLOCK_ERROR_ACTION_IGNORE; + return action != BlockErrorAction_ignore; } static void ide_dma_cb(void *opaque, int ret) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 788b361..9ac3290 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -271,7 +271,7 @@ static Property ide_hd_properties[] = { DEFINE_IDE_DEV_PROPERTIES(), DEFINE_BLOCK_CHS_PROPERTIES(IDEDrive, dev.conf), DEFINE_PROP_BIOS_CHS_TRANS("bios-chs-trans", - IDEDrive, dev.chs_trans, BIOS_ATA_TRANSLATION_AUTO), + IDEDrive, dev.chs_trans, BiosAtaTranslation_auto), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/input/hid.c b/hw/input/hid.c index e39269f..0d23912 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -108,10 +108,10 @@ void hid_set_next_idle(HIDState *hs) static void hid_pointer_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { - static const int bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = 0x01, - [INPUT_BUTTON_RIGHT] = 0x02, - [INPUT_BUTTON_MIDDLE] = 0x04, + static const int bmap[InputButton_MAX] = { + [InputButton_Left] = 0x01, + [InputButton_Right] = 0x02, + [InputButton_Middle] = 0x04, }; HIDState *hs = (HIDState *)dev; HIDPointerEvent *e; @@ -120,28 +120,28 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src, e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK]; switch (evt->type) { - case INPUT_EVENT_KIND_REL: - if (evt->u.rel->axis == INPUT_AXIS_X) { + case InputEventKind_rel: + if (evt->u.rel->axis == InputAxis_X) { e->xdx += evt->u.rel->value; - } else if (evt->u.rel->axis == INPUT_AXIS_Y) { + } else if (evt->u.rel->axis == InputAxis_Y) { e->ydy += evt->u.rel->value; } break; - case INPUT_EVENT_KIND_ABS: - if (evt->u.rel->axis == INPUT_AXIS_X) { + case InputEventKind_abs: + if (evt->u.rel->axis == InputAxis_X) { e->xdx = evt->u.rel->value; - } else if (evt->u.rel->axis == INPUT_AXIS_Y) { + } else if (evt->u.rel->axis == InputAxis_Y) { e->ydy = evt->u.rel->value; } break; - case INPUT_EVENT_KIND_BTN: + case InputEventKind_btn: if (evt->u.btn->down) { e->buttons_state |= bmap[evt->u.btn->button]; - if (evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) { + if (evt->u.btn->button == InputButton_WheelUp) { e->dz--; - } else if (evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) { + } else if (evt->u.btn->button == InputButton_WheelDown) { e->dz++; } } else { diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 3d6d496..0bfbbdc 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -382,10 +382,10 @@ static void ps2_mouse_send_packet(PS2MouseState *s) static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { - static const int bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, + static const int bmap[InputButton_MAX] = { + [InputButton_Left] = MOUSE_EVENT_LBUTTON, + [InputButton_Middle] = MOUSE_EVENT_MBUTTON, + [InputButton_Right] = MOUSE_EVENT_RBUTTON, }; PS2MouseState *s = (PS2MouseState *)dev; @@ -394,20 +394,20 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, return; switch (evt->type) { - case INPUT_EVENT_KIND_REL: - if (evt->u.rel->axis == INPUT_AXIS_X) { + case InputEventKind_rel: + if (evt->u.rel->axis == InputAxis_X) { s->mouse_dx += evt->u.rel->value; - } else if (evt->u.rel->axis == INPUT_AXIS_Y) { + } else if (evt->u.rel->axis == InputAxis_Y) { s->mouse_dy -= evt->u.rel->value; } break; - case INPUT_EVENT_KIND_BTN: + case InputEventKind_btn: if (evt->u.btn->down) { s->mouse_buttons |= bmap[evt->u.btn->button]; - if (evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) { + if (evt->u.btn->button == InputButton_WheelUp) { s->mouse_dz--; - } else if (evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) { + } else if (evt->u.btn->button == InputButton_WheelDown) { s->mouse_dz++; } } else { diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index bdd479c..ce8c2c1 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -21,139 +21,139 @@ /* ----------------------------------------------------------------- */ -static const unsigned int keymap_qcode[Q_KEY_CODE_MAX] = { - [Q_KEY_CODE_ESC] = KEY_ESC, - [Q_KEY_CODE_1] = KEY_1, - [Q_KEY_CODE_2] = KEY_2, - [Q_KEY_CODE_3] = KEY_3, - [Q_KEY_CODE_4] = KEY_4, - [Q_KEY_CODE_5] = KEY_5, - [Q_KEY_CODE_6] = KEY_6, - [Q_KEY_CODE_7] = KEY_7, - [Q_KEY_CODE_8] = KEY_8, - [Q_KEY_CODE_9] = KEY_9, - [Q_KEY_CODE_0] = KEY_0, - [Q_KEY_CODE_MINUS] = KEY_MINUS, - [Q_KEY_CODE_EQUAL] = KEY_EQUAL, - [Q_KEY_CODE_BACKSPACE] = KEY_BACKSPACE, +static const unsigned int keymap_qcode[QKeyCode_MAX] = { + [QKeyCode_esc] = KEY_ESC, + [QKeyCode_1] = KEY_1, + [QKeyCode_2] = KEY_2, + [QKeyCode_3] = KEY_3, + [QKeyCode_4] = KEY_4, + [QKeyCode_5] = KEY_5, + [QKeyCode_6] = KEY_6, + [QKeyCode_7] = KEY_7, + [QKeyCode_8] = KEY_8, + [QKeyCode_9] = KEY_9, + [QKeyCode_0] = KEY_0, + [QKeyCode_minus] = KEY_MINUS, + [QKeyCode_equal] = KEY_EQUAL, + [QKeyCode_backspace] = KEY_BACKSPACE, - [Q_KEY_CODE_TAB] = KEY_TAB, - [Q_KEY_CODE_Q] = KEY_Q, - [Q_KEY_CODE_W] = KEY_W, - [Q_KEY_CODE_E] = KEY_E, - [Q_KEY_CODE_R] = KEY_R, - [Q_KEY_CODE_T] = KEY_T, - [Q_KEY_CODE_Y] = KEY_Y, - [Q_KEY_CODE_U] = KEY_U, - [Q_KEY_CODE_I] = KEY_I, - [Q_KEY_CODE_O] = KEY_O, - [Q_KEY_CODE_P] = KEY_P, - [Q_KEY_CODE_BRACKET_LEFT] = KEY_LEFTBRACE, - [Q_KEY_CODE_BRACKET_RIGHT] = KEY_RIGHTBRACE, - [Q_KEY_CODE_RET] = KEY_ENTER, + [QKeyCode_tab] = KEY_TAB, + [QKeyCode_q] = KEY_Q, + [QKeyCode_w] = KEY_W, + [QKeyCode_e] = KEY_E, + [QKeyCode_r] = KEY_R, + [QKeyCode_t] = KEY_T, + [QKeyCode_y] = KEY_Y, + [QKeyCode_u] = KEY_U, + [QKeyCode_i] = KEY_I, + [QKeyCode_o] = KEY_O, + [QKeyCode_p] = KEY_P, + [QKeyCode_bracket_left] = KEY_LEFTBRACE, + [QKeyCode_bracket_right] = KEY_RIGHTBRACE, + [QKeyCode_ret] = KEY_ENTER, - [Q_KEY_CODE_CTRL] = KEY_LEFTCTRL, - [Q_KEY_CODE_A] = KEY_A, - [Q_KEY_CODE_S] = KEY_S, - [Q_KEY_CODE_D] = KEY_D, - [Q_KEY_CODE_F] = KEY_F, - [Q_KEY_CODE_G] = KEY_G, - [Q_KEY_CODE_H] = KEY_H, - [Q_KEY_CODE_J] = KEY_J, - [Q_KEY_CODE_K] = KEY_K, - [Q_KEY_CODE_L] = KEY_L, - [Q_KEY_CODE_SEMICOLON] = KEY_SEMICOLON, - [Q_KEY_CODE_APOSTROPHE] = KEY_APOSTROPHE, - [Q_KEY_CODE_GRAVE_ACCENT] = KEY_GRAVE, + [QKeyCode_ctrl] = KEY_LEFTCTRL, + [QKeyCode_a] = KEY_A, + [QKeyCode_s] = KEY_S, + [QKeyCode_d] = KEY_D, + [QKeyCode_f] = KEY_F, + [QKeyCode_g] = KEY_G, + [QKeyCode_h] = KEY_H, + [QKeyCode_j] = KEY_J, + [QKeyCode_k] = KEY_K, + [QKeyCode_l] = KEY_L, + [QKeyCode_semicolon] = KEY_SEMICOLON, + [QKeyCode_apostrophe] = KEY_APOSTROPHE, + [QKeyCode_grave_accent] = KEY_GRAVE, - [Q_KEY_CODE_SHIFT] = KEY_LEFTSHIFT, - [Q_KEY_CODE_BACKSLASH] = KEY_BACKSLASH, - [Q_KEY_CODE_LESS] = KEY_102ND, - [Q_KEY_CODE_Z] = KEY_Z, - [Q_KEY_CODE_X] = KEY_X, - [Q_KEY_CODE_C] = KEY_C, - [Q_KEY_CODE_V] = KEY_V, - [Q_KEY_CODE_B] = KEY_B, - [Q_KEY_CODE_N] = KEY_N, - [Q_KEY_CODE_M] = KEY_M, - [Q_KEY_CODE_COMMA] = KEY_COMMA, - [Q_KEY_CODE_DOT] = KEY_DOT, - [Q_KEY_CODE_SLASH] = KEY_SLASH, - [Q_KEY_CODE_SHIFT_R] = KEY_RIGHTSHIFT, + [QKeyCode_shift] = KEY_LEFTSHIFT, + [QKeyCode_backslash] = KEY_BACKSLASH, + [QKeyCode_less] = KEY_102ND, + [QKeyCode_z] = KEY_Z, + [QKeyCode_x] = KEY_X, + [QKeyCode_c] = KEY_C, + [QKeyCode_v] = KEY_V, + [QKeyCode_b] = KEY_B, + [QKeyCode_n] = KEY_N, + [QKeyCode_m] = KEY_M, + [QKeyCode_comma] = KEY_COMMA, + [QKeyCode_dot] = KEY_DOT, + [QKeyCode_slash] = KEY_SLASH, + [QKeyCode_shift_r] = KEY_RIGHTSHIFT, - [Q_KEY_CODE_ALT] = KEY_LEFTALT, - [Q_KEY_CODE_SPC] = KEY_SPACE, - [Q_KEY_CODE_CAPS_LOCK] = KEY_CAPSLOCK, + [QKeyCode_alt] = KEY_LEFTALT, + [QKeyCode_spc] = KEY_SPACE, + [QKeyCode_caps_lock] = KEY_CAPSLOCK, - [Q_KEY_CODE_F1] = KEY_F1, - [Q_KEY_CODE_F2] = KEY_F2, - [Q_KEY_CODE_F3] = KEY_F3, - [Q_KEY_CODE_F4] = KEY_F4, - [Q_KEY_CODE_F5] = KEY_F5, - [Q_KEY_CODE_F6] = KEY_F6, - [Q_KEY_CODE_F7] = KEY_F7, - [Q_KEY_CODE_F8] = KEY_F8, - [Q_KEY_CODE_F9] = KEY_F9, - [Q_KEY_CODE_F10] = KEY_F10, - [Q_KEY_CODE_NUM_LOCK] = KEY_NUMLOCK, - [Q_KEY_CODE_SCROLL_LOCK] = KEY_SCROLLLOCK, + [QKeyCode_f1] = KEY_F1, + [QKeyCode_f2] = KEY_F2, + [QKeyCode_f3] = KEY_F3, + [QKeyCode_f4] = KEY_F4, + [QKeyCode_f5] = KEY_F5, + [QKeyCode_f6] = KEY_F6, + [QKeyCode_f7] = KEY_F7, + [QKeyCode_f8] = KEY_F8, + [QKeyCode_f9] = KEY_F9, + [QKeyCode_f10] = KEY_F10, + [QKeyCode_num_lock] = KEY_NUMLOCK, + [QKeyCode_scroll_lock] = KEY_SCROLLLOCK, - [Q_KEY_CODE_KP_0] = KEY_KP0, - [Q_KEY_CODE_KP_1] = KEY_KP1, - [Q_KEY_CODE_KP_2] = KEY_KP2, - [Q_KEY_CODE_KP_3] = KEY_KP3, - [Q_KEY_CODE_KP_4] = KEY_KP4, - [Q_KEY_CODE_KP_5] = KEY_KP5, - [Q_KEY_CODE_KP_6] = KEY_KP6, - [Q_KEY_CODE_KP_7] = KEY_KP7, - [Q_KEY_CODE_KP_8] = KEY_KP8, - [Q_KEY_CODE_KP_9] = KEY_KP9, - [Q_KEY_CODE_KP_SUBTRACT] = KEY_KPMINUS, - [Q_KEY_CODE_KP_ADD] = KEY_KPPLUS, - [Q_KEY_CODE_KP_DECIMAL] = KEY_KPDOT, - [Q_KEY_CODE_KP_ENTER] = KEY_KPENTER, - [Q_KEY_CODE_KP_DIVIDE] = KEY_KPSLASH, - [Q_KEY_CODE_KP_MULTIPLY] = KEY_KPASTERISK, + [QKeyCode_kp_0] = KEY_KP0, + [QKeyCode_kp_1] = KEY_KP1, + [QKeyCode_kp_2] = KEY_KP2, + [QKeyCode_kp_3] = KEY_KP3, + [QKeyCode_kp_4] = KEY_KP4, + [QKeyCode_kp_5] = KEY_KP5, + [QKeyCode_kp_6] = KEY_KP6, + [QKeyCode_kp_7] = KEY_KP7, + [QKeyCode_kp_8] = KEY_KP8, + [QKeyCode_kp_9] = KEY_KP9, + [QKeyCode_kp_subtract] = KEY_KPMINUS, + [QKeyCode_kp_add] = KEY_KPPLUS, + [QKeyCode_kp_decimal] = KEY_KPDOT, + [QKeyCode_kp_enter] = KEY_KPENTER, + [QKeyCode_kp_divide] = KEY_KPSLASH, + [QKeyCode_kp_multiply] = KEY_KPASTERISK, - [Q_KEY_CODE_F11] = KEY_F11, - [Q_KEY_CODE_F12] = KEY_F12, + [QKeyCode_f11] = KEY_F11, + [QKeyCode_f12] = KEY_F12, - [Q_KEY_CODE_CTRL_R] = KEY_RIGHTCTRL, - [Q_KEY_CODE_SYSRQ] = KEY_SYSRQ, - [Q_KEY_CODE_ALT_R] = KEY_RIGHTALT, + [QKeyCode_ctrl_r] = KEY_RIGHTCTRL, + [QKeyCode_sysrq] = KEY_SYSRQ, + [QKeyCode_alt_r] = KEY_RIGHTALT, - [Q_KEY_CODE_HOME] = KEY_HOME, - [Q_KEY_CODE_UP] = KEY_UP, - [Q_KEY_CODE_PGUP] = KEY_PAGEUP, - [Q_KEY_CODE_LEFT] = KEY_LEFT, - [Q_KEY_CODE_RIGHT] = KEY_RIGHT, - [Q_KEY_CODE_END] = KEY_END, - [Q_KEY_CODE_DOWN] = KEY_DOWN, - [Q_KEY_CODE_PGDN] = KEY_PAGEDOWN, - [Q_KEY_CODE_INSERT] = KEY_INSERT, - [Q_KEY_CODE_DELETE] = KEY_DELETE, + [QKeyCode_home] = KEY_HOME, + [QKeyCode_up] = KEY_UP, + [QKeyCode_pgup] = KEY_PAGEUP, + [QKeyCode_left] = KEY_LEFT, + [QKeyCode_right] = KEY_RIGHT, + [QKeyCode_end] = KEY_END, + [QKeyCode_down] = KEY_DOWN, + [QKeyCode_pgdn] = KEY_PAGEDOWN, + [QKeyCode_insert] = KEY_INSERT, + [QKeyCode_delete] = KEY_DELETE, - [Q_KEY_CODE_META_L] = KEY_LEFTMETA, - [Q_KEY_CODE_META_R] = KEY_RIGHTMETA, - [Q_KEY_CODE_MENU] = KEY_MENU, + [QKeyCode_meta_l] = KEY_LEFTMETA, + [QKeyCode_meta_r] = KEY_RIGHTMETA, + [QKeyCode_menu] = KEY_MENU, }; -static const unsigned int keymap_button[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = BTN_LEFT, - [INPUT_BUTTON_RIGHT] = BTN_RIGHT, - [INPUT_BUTTON_MIDDLE] = BTN_MIDDLE, - [INPUT_BUTTON_WHEEL_UP] = BTN_GEAR_UP, - [INPUT_BUTTON_WHEEL_DOWN] = BTN_GEAR_DOWN, +static const unsigned int keymap_button[InputButton_MAX] = { + [InputButton_Left] = BTN_LEFT, + [InputButton_Right] = BTN_RIGHT, + [InputButton_Middle] = BTN_MIDDLE, + [InputButton_WheelUp] = BTN_GEAR_UP, + [InputButton_WheelDown] = BTN_GEAR_DOWN, }; -static const unsigned int axismap_rel[INPUT_AXIS_MAX] = { - [INPUT_AXIS_X] = REL_X, - [INPUT_AXIS_Y] = REL_Y, +static const unsigned int axismap_rel[InputAxis_MAX] = { + [InputAxis_X] = REL_X, + [InputAxis_Y] = REL_Y, }; -static const unsigned int axismap_abs[INPUT_AXIS_MAX] = { - [INPUT_AXIS_X] = ABS_X, - [INPUT_AXIS_Y] = ABS_Y, +static const unsigned int axismap_abs[InputAxis_MAX] = { + [InputAxis_X] = ABS_X, + [InputAxis_Y] = ABS_Y, }; /* ----------------------------------------------------------------- */ @@ -192,7 +192,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, int qcode; switch (evt->type) { - case INPUT_EVENT_KIND_KEY: + case InputEventKind_key: qcode = qemu_input_key_value_to_qcode(evt->u.key->key); if (qcode && keymap_qcode[qcode]) { event.type = cpu_to_le16(EV_KEY); @@ -206,7 +206,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, } } break; - case INPUT_EVENT_KIND_BTN: + case InputEventKind_btn: if (keymap_button[evt->u.btn->button]) { event.type = cpu_to_le16(EV_KEY); event.code = cpu_to_le16(keymap_button[evt->u.btn->button]); @@ -220,13 +220,13 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, } } break; - case INPUT_EVENT_KIND_REL: + case InputEventKind_rel: event.type = cpu_to_le16(EV_REL); event.code = cpu_to_le16(axismap_rel[evt->u.rel->axis]); event.value = cpu_to_le32(evt->u.rel->value); virtio_input_send(vinput, &event); break; - case INPUT_EVENT_KIND_ABS: + case InputEventKind_abs: event.type = cpu_to_le16(EV_ABS); event.code = cpu_to_le16(axismap_abs[evt->u.abs->axis]); event.value = cpu_to_le32(evt->u.abs->value); diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index d5cdab2..16c1a84 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -204,7 +204,7 @@ ram_addr_t get_current_ram_size(void) if (value) { switch (value->type) { - case MEMORY_DEVICE_INFO_KIND_DIMM: + case MemoryDeviceInfoKind_dimm: size += value->u.dimm->size; break; default: diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c index 0407dee..2569e14 100644 --- a/hw/net/allwinner_emac.c +++ b/hw/net/allwinner_emac.c @@ -422,7 +422,7 @@ static const MemoryRegionOps aw_emac_mem_ops = { }; static NetClientInfo net_aw_emac_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = aw_emac_can_receive, .receive = aw_emac_receive, diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 3639fc1..902d988 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -1181,7 +1181,7 @@ static void gem_set_link(NetClientState *nc) } static NetClientInfo net_gem_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = gem_can_receive, .receive = gem_receive, diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index ab607e4..3ab8f0a 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -810,7 +810,7 @@ static void dp8393x_reset(DeviceState *dev) } static NetClientInfo net_dp83932_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = dp8393x_can_receive, .receive = dp8393x_receive, diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 910de3a..a1ccb95 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -1516,7 +1516,7 @@ pci_e1000_uninit(PCIDevice *dev) } static NetClientInfo net_e1000_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = e1000_can_receive, .receive = e1000_receive, diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 60333b7..db5d41f 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1832,7 +1832,7 @@ static void pci_nic_uninit(PCIDevice *pci_dev) } static NetClientInfo net_eepro100_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = nic_receive, }; diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c index d600275..fc629a5 100644 --- a/hw/net/etraxfs_eth.c +++ b/hw/net/etraxfs_eth.c @@ -577,7 +577,7 @@ static const MemoryRegionOps eth_ops = { }; static NetClientInfo net_etraxfs_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = eth_receive, .link_status_changed = eth_set_link, diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index 04bb41d..f0dfa07 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -369,7 +369,7 @@ static void etsec_set_link_status(NetClientState *nc) } static NetClientInfo net_etsec_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = etsec_receive, .link_status_changed = etsec_set_link_status, diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index c50bf7f..cf5985a 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -651,7 +651,7 @@ static void imx_fec_cleanup(NetClientState *nc) } static NetClientInfo net_imx_fec_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = imx_fec_can_receive, .receive = imx_fec_receive, diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 4f0e840..47747c0 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -1305,7 +1305,7 @@ static const MemoryRegionOps lan9118_16bit_mem_ops = { }; static NetClientInfo net_lan9118_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = lan9118_receive, .link_status_changed = lan9118_set_link, diff --git a/hw/net/lance.c b/hw/net/lance.c index 780b39d..72be9d1 100644 --- a/hw/net/lance.c +++ b/hw/net/lance.c @@ -92,7 +92,7 @@ static const MemoryRegionOps lance_mem_ops = { }; static NetClientInfo net_lance_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = pcnet_receive, .link_status_changed = pcnet_set_link_status, diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c index 21928f9..cf6c642 100644 --- a/hw/net/mcf_fec.c +++ b/hw/net/mcf_fec.c @@ -506,7 +506,7 @@ static const MemoryRegionOps mcf_fec_ops = { }; static NetClientInfo net_mcf_fec_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = mcf_fec_receive, }; diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c index 6302b8b..5dd73ef 100644 --- a/hw/net/milkymist-minimac2.c +++ b/hw/net/milkymist-minimac2.c @@ -443,7 +443,7 @@ static void milkymist_minimac2_reset(DeviceState *d) } static NetClientInfo net_milkymist_minimac2_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = minimac2_rx, }; diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c index f261011..d664294 100644 --- a/hw/net/mipsnet.c +++ b/hw/net/mipsnet.c @@ -218,7 +218,7 @@ static const VMStateDescription vmstate_mipsnet = { }; static NetClientInfo net_mipsnet_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = mipsnet_receive, }; diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c index 18b0644..6e893f7 100644 --- a/hw/net/ne2000-isa.c +++ b/hw/net/ne2000-isa.c @@ -42,7 +42,7 @@ typedef struct ISANE2000State { } ISANE2000State; static NetClientInfo net_ne2000_isa_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = ne2000_receive, }; diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c index 010f9ef..e17d871 100644 --- a/hw/net/ne2000.c +++ b/hw/net/ne2000.c @@ -705,7 +705,7 @@ void ne2000_setup_io(NE2000State *s, DeviceState *dev, unsigned size) } static NetClientInfo net_ne2000_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = ne2000_receive, }; diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c index 3642046..145da70 100644 --- a/hw/net/opencores_eth.c +++ b/hw/net/opencores_eth.c @@ -473,7 +473,7 @@ static ssize_t open_eth_receive(NetClientState *nc, } static NetClientInfo net_open_eth_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = open_eth_can_receive, .receive = open_eth_receive, diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c index b4d60b8..536e3a9 100644 --- a/hw/net/pcnet-pci.c +++ b/hw/net/pcnet-pci.c @@ -271,7 +271,7 @@ static void pci_pcnet_uninit(PCIDevice *dev) } static NetClientInfo net_pci_pcnet_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = pcnet_receive, .link_status_changed = pcnet_set_link_status, diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c index bb6fdc3..32aa2a8 100644 --- a/hw/net/rocker/rocker.c +++ b/hw/net/rocker/rocker.c @@ -101,7 +101,7 @@ RockerSwitch *qmp_query_rocker(const char *name, Error **errp) r = rocker_find(name); if (!r) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "rocker %s not found", name); return NULL; } @@ -122,7 +122,7 @@ RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp) r = rocker_find(name); if (!r) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "rocker %s not found", name); return NULL; } diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c index 5906396..7acbe7c 100644 --- a/hw/net/rocker/rocker_fp.c +++ b/hw/net/rocker/rocker_fp.c @@ -166,7 +166,7 @@ static void fp_port_set_link_status(NetClientState *nc) } static NetClientInfo fp_port_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = fp_port_receive, .receive_iov = fp_port_receive_iov, diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index 1ad2791..b5d096d 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -2462,14 +2462,14 @@ RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name, r = rocker_find(name); if (!r) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "rocker %s not found", name); return NULL; } w = rocker_get_world(r, ROCKER_WORLD_TYPE_OF_DPA); if (!w) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "rocker %s doesn't have OF-DPA world", name); return NULL; } @@ -2597,14 +2597,14 @@ RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name, r = rocker_find(name); if (!r) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "rocker %s not found", name); return NULL; } w = rocker_get_world(r, ROCKER_WORLD_TYPE_OF_DPA); if (!w) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "rocker %s doesn't have OF-DPA world", name); return NULL; } diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 68e43f3..3c7640f 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -3411,7 +3411,7 @@ static void rtl8139_set_link_status(NetClientState *nc) } static NetClientInfo net_rtl8139_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = rtl8139_can_receive, .receive = rtl8139_receive, diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c index c19cdd1..7f8c3b8 100644 --- a/hw/net/smc91c111.c +++ b/hw/net/smc91c111.c @@ -754,7 +754,7 @@ static const MemoryRegionOps smc91c111_mem_ops = { }; static NetClientInfo net_smc91c111_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = smc91c111_can_receive_nc, .receive = smc91c111_receive, diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c index 1ca5e9c..2f20381 100644 --- a/hw/net/spapr_llan.c +++ b/hw/net/spapr_llan.c @@ -188,7 +188,7 @@ static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf, } static NetClientInfo net_spapr_vlan_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = spapr_vlan_can_receive, .receive = spapr_vlan_receive, diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c index 21a4773..25b6496 100644 --- a/hw/net/stellaris_enet.c +++ b/hw/net/stellaris_enet.c @@ -449,7 +449,7 @@ static void stellaris_enet_reset(stellaris_enet_state *s) } static NetClientInfo net_stellaris_enet_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = stellaris_enet_receive, }; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index d91b7b1..704c398 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -97,10 +97,10 @@ static const int *vhost_net_get_feature_bits(struct vhost_net *net) const int *feature_bits = 0; switch (net->nc->info->type) { - case NET_CLIENT_OPTIONS_KIND_TAP: + case NetClientOptionsKind_tap: feature_bits = kernel_feature_bits; break; - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: + case NetClientOptionsKind_vhost_user: feature_bits = user_feature_bits; break; default: @@ -132,7 +132,7 @@ uint64_t vhost_net_get_max_queues(VHostNetState *net) static int vhost_net_get_fd(NetClientState *backend) { switch (backend->info->type) { - case NET_CLIENT_OPTIONS_KIND_TAP: + case NetClientOptionsKind_tap: return tap_get_fd(backend); default: fprintf(stderr, "vhost-net requires tap backend\n"); @@ -249,7 +249,7 @@ static int vhost_net_start_one(struct vhost_net *net, net->nc->info->poll(net->nc, false); } - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { + if (net->nc->info->type == NetClientOptionsKind_tap) { qemu_set_fd_handler(net->backend, NULL, NULL, NULL); file.fd = net->backend; for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { @@ -264,7 +264,7 @@ static int vhost_net_start_one(struct vhost_net *net, return 0; fail: file.fd = -1; - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { + if (net->nc->info->type == NetClientOptionsKind_tap) { while (file.index-- > 0) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); @@ -286,13 +286,13 @@ static void vhost_net_stop_one(struct vhost_net *net, { struct vhost_vring_file file = { .fd = -1 }; - if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP) { + if (net->nc->info->type == NetClientOptionsKind_tap) { for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); assert(r >= 0); } - } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { + } else if (net->nc->info->type == NetClientOptionsKind_vhost_user) { for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { const VhostOps *vhost_ops = net->dev.vhost_ops; int r = vhost_ops->vhost_reset_device(&net->dev); @@ -420,10 +420,10 @@ VHostNetState *get_vhost_net(NetClientState *nc) } switch (nc->info->type) { - case NET_CLIENT_OPTIONS_KIND_TAP: + case NetClientOptionsKind_tap: vhost_net = tap_get_vhost_net(nc); break; - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: + case NetClientOptionsKind_vhost_user: vhost_net = vhost_user_get_vhost_net(nc); break; default: diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index a877614..0ee732b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -264,19 +264,19 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) info->promiscuous = n->promisc; if (n->nouni) { - info->unicast = RX_STATE_NONE; + info->unicast = RxState_none; } else if (n->alluni) { - info->unicast = RX_STATE_ALL; + info->unicast = RxState_all; } else { - info->unicast = RX_STATE_NORMAL; + info->unicast = RxState_normal; } if (n->nomulti) { - info->multicast = RX_STATE_NONE; + info->multicast = RxState_none; } else if (n->allmulti) { - info->multicast = RX_STATE_ALL; + info->multicast = RxState_all; } else { - info->multicast = RX_STATE_NORMAL; + info->multicast = RxState_normal; } info->broadcast_allowed = n->nobcast; @@ -305,11 +305,11 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) info->vlan_table = get_vlan_table(n); if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) { - info->vlan = RX_STATE_ALL; + info->vlan = RxState_all; } else if (!info->vlan_table) { - info->vlan = RX_STATE_NONE; + info->vlan = RxState_none; } else { - info->vlan = RX_STATE_NORMAL; + info->vlan = RxState_normal; } /* enable event notification after query */ @@ -406,11 +406,11 @@ static int peer_attach(VirtIONet *n, int index) return 0; } - if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { + if (nc->peer->info->type == NetClientOptionsKind_vhost_user) { vhost_set_vring_enable(nc->peer, 1); } - if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) { + if (nc->peer->info->type != NetClientOptionsKind_tap) { return 0; } @@ -425,11 +425,11 @@ static int peer_detach(VirtIONet *n, int index) return 0; } - if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { + if (nc->peer->info->type == NetClientOptionsKind_vhost_user) { vhost_set_vring_enable(nc->peer, 0); } - if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) { + if (nc->peer->info->type != NetClientOptionsKind_tap) { return 0; } @@ -1604,7 +1604,7 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, } static NetClientInfo net_virtio_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = virtio_net_can_receive, .receive = virtio_net_receive, diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 5e3a233..0d27056 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2001,7 +2001,7 @@ static void vmxnet3_set_link_status(NetClientState *nc) } static NetClientInfo net_vmxnet3_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = vmxnet3_receive, .link_status_changed = vmxnet3_set_link_status, diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 0da16b4..994c163 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -279,7 +279,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size /* ------------------------------------------------------------- */ static NetClientInfo net_xen_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = net_rx_packet, }; diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c index 15fb681..bf08312 100644 --- a/hw/net/xgmac.c +++ b/hw/net/xgmac.c @@ -370,7 +370,7 @@ out: } static NetClientInfo net_xgmac_enet_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = eth_rx, }; diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c index d63c423..11a199b 100644 --- a/hw/net/xilinx_axienet.c +++ b/hw/net/xilinx_axienet.c @@ -933,7 +933,7 @@ xilinx_axienet_data_stream_push(StreamSlave *obj, uint8_t *buf, size_t size) } static NetClientInfo net_xilinx_enet_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = eth_rx, }; diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index ad6b553..a738306 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -214,7 +214,7 @@ static void xilinx_ethlite_reset(DeviceState *dev) } static NetClientInfo net_xilinx_ethlite_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .can_receive = eth_can_rx, .receive = eth_rx, diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 34b12a3..aaed8d7 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -297,7 +297,7 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu, { target_ulong ret = 0; - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); + qapi_event_send_guest_panicked(GuestPanicAction_pause, &error_abort); rtas_st(rets, 0, ret); } diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index bada9a7..c070447 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -414,7 +414,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error) BlockErrorAction action = blk_get_error_action(s->qdev.conf.blk, is_read, error); - if (action == BLOCK_ERROR_ACTION_REPORT) { + if (action == BlockErrorAction_report) { switch (error) { case ENOMEDIUM: scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); @@ -434,10 +434,10 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error) } } blk_error_action(s->qdev.conf.blk, action, is_read, error); - if (action == BLOCK_ERROR_ACTION_STOP) { + if (action == BlockErrorAction_stop) { scsi_req_retry(&r->req); } - return action != BLOCK_ERROR_ACTION_IGNORE; + return action != BlockErrorAction_ignore; } static void scsi_write_complete_noio(SCSIDiskReq *r, int ret) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index a4626f7..674d62f 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -407,11 +407,11 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp) return; } - if (blk_get_on_error(s->conf.blk, 0) != BLOCKDEV_ON_ERROR_ENOSPC) { + if (blk_get_on_error(s->conf.blk, 0) != BlockdevOnError_enospc) { error_setg(errp, "Device doesn't support drive option werror"); return; } - if (blk_get_on_error(s->conf.blk, 1) != BLOCKDEV_ON_ERROR_REPORT) { + if (blk_get_on_error(s->conf.blk, 1) != BlockdevOnError_report) { error_setg(errp, "Device doesn't support drive option rerror"); return; } diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index a9f0efd..9e11d20 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -187,7 +187,7 @@ static void rtc_periodic_timer(void *opaque) if (s->cmos_data[RTC_REG_B] & REG_B_PIE) { s->cmos_data[RTC_REG_C] |= REG_C_IRQF; #ifdef TARGET_I386 - if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { + if (s->lost_tick_policy == LostTickPolicy_slew) { if (s->irq_reinject_on_ack_count >= RTC_REINJECT_ON_ACK_COUNT) s->irq_reinject_on_ack_count = 0; apic_reset_irq_delivered(); @@ -732,7 +732,7 @@ static int rtc_post_load(void *opaque, int version_id) #ifdef TARGET_I386 if (version_id >= 2) { - if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { + if (s->lost_tick_policy == LostTickPolicy_slew) { rtc_coalesced_timer_update(s); } } @@ -793,7 +793,7 @@ static void rtc_notify_clock_reset(Notifier *notifier, void *data) periodic_timer_update(s, now); check_update_timer(s); #ifdef TARGET_I386 - if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { + if (s->lost_tick_policy == LostTickPolicy_slew) { rtc_coalesced_timer_update(s); } #endif @@ -818,7 +818,7 @@ static void rtc_reset(void *opaque) qemu_irq_lower(s->irq); #ifdef TARGET_I386 - if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) { + if (s->lost_tick_policy == LostTickPolicy_slew) { s->irq_coalesced = 0; s->irq_reinject_on_ack_count = 0; } @@ -870,11 +870,11 @@ static void rtc_realizefn(DeviceState *dev, Error **errp) #ifdef TARGET_I386 switch (s->lost_tick_policy) { - case LOST_TICK_POLICY_SLEW: + case LostTickPolicy_slew: s->coalesced_timer = timer_new_ns(rtc_clock, rtc_coalesced_timer, s); break; - case LOST_TICK_POLICY_DISCARD: + case LostTickPolicy_discard: break; default: error_setg(errp, "Invalid lost tick policy."); @@ -929,7 +929,7 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) static Property mc146818rtc_properties[] = { DEFINE_PROP_INT32("base_year", RTCState, base_year, 1980), DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", RTCState, - lost_tick_policy, LOST_TICK_POLICY_DISCARD), + lost_tick_policy, LostTickPolicy_discard), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index be160c1..46d6612 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -491,7 +491,7 @@ static const QemuOptDesc tpm_passthrough_cmdline_opts[] = { }; static const TPMDriverOps tpm_passthrough_driver = { - .type = TPM_TYPE_PASSTHROUGH, + .type = TpmType_passthrough, .opts = tpm_passthrough_cmdline_opts, .desc = tpm_passthrough_create_desc, .create = tpm_passthrough_create, diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 0806b5f..96d1db3 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -1041,7 +1041,7 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp) return; } - s->be_driver->fe_model = TPM_MODEL_TPM_TIS; + s->be_driver->fe_model = TpmModel_tpm_tis; if (tpm_backend_init(s->be_driver, s, tpm_tis_receive_cb)) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " @@ -1093,7 +1093,7 @@ static const TypeInfo tpm_tis_info = { static void tpm_tis_register(void) { type_register_static(&tpm_tis_info); - tpm_register_model(TPM_MODEL_TPM_TIS); + tpm_register_model(TpmModel_tpm_tis); } type_init(tpm_tis_register) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 7800cee..10b35f7 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1330,7 +1330,7 @@ static void usb_net_handle_destroy(USBDevice *dev) } static NetClientInfo net_usbnet_info = { - .type = NET_CLIENT_OPTIONS_KIND_NIC, + .type = NetClientOptionsKind_nic, .size = sizeof(NICState), .receive = usbnet_receive, .cleanup = usbnet_cleanup, diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 64a54c6..29c2f5a 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2390,7 +2390,7 @@ static void usb_ehci_vm_state_change(void *opaque, int running, RunState state) * USB-devices which have async handled packages have a packet in the * ep queue to match the completion with. */ - if (state == RUN_STATE_RUNNING) { + if (state == RunState_running) { ehci_advance_async_state(ehci); } @@ -2400,7 +2400,7 @@ static void usb_ehci_vm_state_change(void *opaque, int running, RunState state) * will never have existed on the destination. Therefor we must flush the * async schedule on savevm to catch any not yet noticed unlinks. */ - if (state == RUN_STATE_SAVE_VM) { + if (state == RunState_save_vm) { ehci_advance_async_state(ehci); ehci_queues_rip_unseen(ehci, 1); } diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 38086cd..5b42858 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -285,7 +285,7 @@ static int usbredir_write(void *priv, uint8_t *data, int count) } /* Don't send new data to the chardev until our state is fully synced */ - if (!runstate_check(RUN_STATE_RUNNING)) { + if (!runstate_check(RunState_running)) { return 0; } @@ -1227,7 +1227,7 @@ static void usbredir_create_parser(USBRedirDevice *dev) usbredirparser_caps_set_cap(caps, usb_redir_cap_bulk_streams); #endif - if (runstate_check(RUN_STATE_INMIGRATE)) { + if (runstate_check(RunState_inmigrate)) { flags |= usbredirparser_fl_no_hello; } usbredirparser_init(dev->parser, VERSION, caps, USB_REDIR_CAPS_SIZE, @@ -1295,7 +1295,7 @@ static int usbredir_chardev_can_read(void *opaque) } /* Don't read new data from the chardev until our state is fully synced */ - if (!runstate_check(RUN_STATE_RUNNING)) { + if (!runstate_check(RunState_running)) { return 0; } @@ -1345,7 +1345,7 @@ static void usbredir_vm_state_change(void *priv, int running, RunState state) { USBRedirDevice *dev = priv; - if (state == RUN_STATE_RUNNING && dev->parser != NULL) { + if (state == RunState_running && dev->parser != NULL) { usbredirparser_do_write(dev->parser); /* Flush any pending writes */ } } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8fadbcf..b507671 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2139,7 +2139,7 @@ static void vfio_err_notifier_handler(void *opaque) __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); - vm_stop(RUN_STATE_INTERNAL_ERROR); + vm_stop(RunState_internal_error); } /* diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index 8d4b0ee..bdbda9d 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -112,17 +112,17 @@ void watchdog_perform_action(void) { switch (watchdog_action) { case WDT_RESET: /* same as 'system_reset' in monitor */ - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort); + qapi_event_send_watchdog(WatchdogExpirationAction_reset, &error_abort); qemu_system_reset_request(); break; case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */ - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort); + qapi_event_send_watchdog(WatchdogExpirationAction_shutdown, &error_abort); qemu_system_powerdown_request(); break; case WDT_POWEROFF: /* same as 'quit' command in monitor */ - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort); + qapi_event_send_watchdog(WatchdogExpirationAction_poweroff, &error_abort); exit(0); case WDT_PAUSE: /* same as 'stop' command in monitor */ @@ -130,21 +130,21 @@ void watchdog_perform_action(void) * you would get a deadlock. Bypass the problem. */ qemu_system_vmstop_request_prepare(); - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort); - qemu_system_vmstop_request(RUN_STATE_WATCHDOG); + qapi_event_send_watchdog(WatchdogExpirationAction_pause, &error_abort); + qemu_system_vmstop_request(RunState_watchdog); break; case WDT_DEBUG: - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort); + qapi_event_send_watchdog(WatchdogExpirationAction_debug, &error_abort); fprintf(stderr, "watchdog: timer fired\n"); break; case WDT_NONE: - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort); + qapi_event_send_watchdog(WatchdogExpirationAction_none, &error_abort); break; case WDT_NMI: - qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_INJECT_NMI, + qapi_event_send_watchdog(WatchdogExpirationAction_inject_nmi, &error_abort); inject_nmi(); break; diff --git a/include/block/block_int.h b/include/block/block_int.h index 3ceeb5a..9f8481b 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -646,7 +646,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, * @target: Block device to write to. * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @sync_mode: What parts of the disk image should be copied to the destination. - * @sync_bitmap: The dirty bitmap if sync_mode is MIRROR_SYNC_MODE_INCREMENTAL. + * @sync_bitmap: The dirty bitmap if sync_mode is MirrorSyncMode_incremental. * @on_source_error: The action to take upon error reading from the source. * @on_target_error: The action to take upon error writing to the target. * @cb: Completion function for the job. diff --git a/include/crypto/tlssession.h b/include/crypto/tlssession.h index b38fe69..1d9c7aa 100644 --- a/include/crypto/tlssession.h +++ b/include/crypto/tlssession.h @@ -63,7 +63,7 @@ * sess = qcrypto_tls_session_new(creds, * "vnc.example.com", * NULL, - * QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT, + * QCRYPTO_TLS_CREDS_ENDPOINT_client, * errp); * if (sess == NULL) { * return -1; diff --git a/include/migration/migration.h b/include/migration/migration.h index 8334621..729d8cd 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -66,7 +66,7 @@ struct MigrationState QemuThread thread; QEMUBH *cleanup_bh; QEMUFile *file; - int parameters[MIGRATION_PARAMETER_MAX]; + int parameters[MigrationParameter_MAX]; int state; MigrationParams params; @@ -76,7 +76,7 @@ struct MigrationState int64_t expected_downtime; int64_t dirty_pages_rate; int64_t dirty_bytes_rate; - bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; + bool enabled_capabilities[MigrationCapability_MAX]; int64_t xbzrle_cache_size; int64_t setup_time; int64_t dirty_sync_count; diff --git a/include/qapi/error.h b/include/qapi/error.h index c69dddb..4e34dfe 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -93,7 +93,7 @@ const char *error_get_pretty(Error *err); /* * Get @err's error class. - * Note: use of error classes other than ERROR_CLASS_GENERIC_ERROR is + * Note: use of error classes other than ErrorClass_GenericError is * strongly discouraged. */ ErrorClass error_get_class(const Error *err); @@ -105,7 +105,7 @@ ErrorClass error_get_class(const Error *err); * If @errp is &error_abort, print a suitable message and abort(). * If @errp is &error_fatal, print a suitable message and exit(1). * If @errp is anything else, *@errp must be NULL. - * The new error's class is ERROR_CLASS_GENERIC_ERROR, and its + * The new error's class is ErrorClass_GenericError, and its * human-readable error message is made from printf-style @fmt, ... */ #define error_setg(errp, fmt, ...) \ @@ -196,7 +196,7 @@ void error_report_err(Error *); /* * Just like error_setg(), except you get to specify the error class. - * Note: use of error classes other than ERROR_CLASS_GENERIC_ERROR is + * Note: use of error classes other than ErrorClass_GenericError is * strongly discouraged. */ #define error_set(errp, err_class, fmt, ...) \ diff --git a/include/ui/input.h b/include/ui/input.h index 5d5ac00..b459eae 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -3,10 +3,10 @@ #include "qapi-types.h" -#define INPUT_EVENT_MASK_KEY (1<exit_request = 0; diff --git a/migration/migration.c b/migration/migration.c index b092f38..c2f77a0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -65,19 +65,19 @@ static bool deferred_incoming; MigrationState *migrate_get_current(void) { static MigrationState current_migration = { - .state = MIGRATION_STATUS_NONE, + .state = MigrationStatus_none, .bandwidth_limit = MAX_THROTTLE, .xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE, .mbps = -1, - .parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = + .parameters[MigrationParameter_compress_level] = DEFAULT_MIGRATE_COMPRESS_LEVEL, - .parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] = + .parameters[MigrationParameter_compress_threads] = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, - .parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = + .parameters[MigrationParameter_decompress_threads] = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, - .parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] = + .parameters[MigrationParameter_x_cpu_throttle_initial] = DEFAULT_MIGRATE_X_CPU_THROTTLE_INITIAL, - .parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] = + .parameters[MigrationParameter_x_cpu_throttle_increment] = DEFAULT_MIGRATE_X_CPU_THROTTLE_INCREMENT, }; @@ -132,7 +132,7 @@ int global_state_store(void) void global_state_store_running(void) { - const char *state = RunState_lookup[RUN_STATE_RUNNING]; + const char *state = RunState_lookup[RunState_running]; strncpy((char *)global_state.runstate, state, sizeof(global_state.runstate)); } @@ -184,7 +184,7 @@ static int global_state_post_load(void *opaque, int version_id) s->received = true; trace_migrate_global_state_post_load(runstate); - r = qapi_enum_parse(RunState_lookup, runstate, RUN_STATE_MAX, + r = qapi_enum_parse(RunState_lookup, runstate, RunState_MAX, -1, &local_err); if (r == -1) { @@ -252,7 +252,7 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; - qapi_event_send_migration(MIGRATION_STATUS_SETUP, &error_abort); + qapi_event_send_migration(MigrationStatus_setup, &error_abort); if (!strcmp(uri, "defer")) { deferred_incoming_migration(errp); } else if (strstart(uri, "tcp:", &p)) { @@ -281,7 +281,7 @@ static void process_incoming_migration_co(void *opaque) int ret; migration_incoming_state_new(f); - migrate_generate_event(MIGRATION_STATUS_ACTIVE); + migrate_generate_event(MigrationStatus_active); ret = qemu_loadvm_state(f); qemu_fclose(f); @@ -289,7 +289,7 @@ static void process_incoming_migration_co(void *opaque) migration_incoming_state_destroy(); if (ret < 0) { - migrate_generate_event(MIGRATION_STATUS_FAILED); + migrate_generate_event(MigrationStatus_failed); error_report("load of migration failed: %s", strerror(-ret)); migrate_decompress_threads_join(); exit(EXIT_FAILURE); @@ -298,7 +298,7 @@ static void process_incoming_migration_co(void *opaque) /* Make sure all file formats flush their mutable metadata */ bdrv_invalidate_cache_all(&local_err); if (local_err) { - migrate_generate_event(MIGRATION_STATUS_FAILED); + migrate_generate_event(MigrationStatus_failed); error_report_err(local_err); migrate_decompress_threads_join(); exit(EXIT_FAILURE); @@ -315,11 +315,11 @@ static void process_incoming_migration_co(void *opaque) runstate_set. */ if (!global_state_received() || - global_state_get_runstate() == RUN_STATE_RUNNING) { + global_state_get_runstate() == RunState_running) { if (autostart) { vm_start(); } else { - runstate_set(RUN_STATE_PAUSED); + runstate_set(RunState_paused); } } else { runstate_set(global_state_get_runstate()); @@ -330,7 +330,7 @@ static void process_incoming_migration_co(void *opaque) * observer sees this event they might start to prod at the VM assuming * it's ready to use. */ - migrate_generate_event(MIGRATION_STATUS_COMPLETED); + migrate_generate_event(MigrationStatus_completed); } void process_incoming_migration(QEMUFile *f) @@ -363,7 +363,7 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) int i; caps = NULL; /* silence compiler warning */ - for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) { + for (i = 0; i < MigrationCapability_MAX; i++) { if (head == NULL) { head = g_malloc0(sizeof(*caps)); caps = head; @@ -386,15 +386,15 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) MigrationState *s = migrate_get_current(); params = g_malloc0(sizeof(*params)); - params->compress_level = s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL]; + params->compress_level = s->parameters[MigrationParameter_compress_level]; params->compress_threads = - s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; + s->parameters[MigrationParameter_compress_threads]; params->decompress_threads = - s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; + s->parameters[MigrationParameter_decompress_threads]; params->x_cpu_throttle_initial = - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL]; + s->parameters[MigrationParameter_x_cpu_throttle_initial]; params->x_cpu_throttle_increment = - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT]; + s->parameters[MigrationParameter_x_cpu_throttle_increment]; return params; } @@ -419,15 +419,15 @@ MigrationInfo *qmp_query_migrate(Error **errp) MigrationState *s = migrate_get_current(); switch (s->state) { - case MIGRATION_STATUS_NONE: + case MigrationStatus_none: /* no migration has happened ever */ break; - case MIGRATION_STATUS_SETUP: + case MigrationStatus_setup: info->has_status = true; info->has_total_time = false; break; - case MIGRATION_STATUS_ACTIVE: - case MIGRATION_STATUS_CANCELLING: + case MigrationStatus_active: + case MigrationStatus_cancelling: info->has_status = true; info->has_total_time = true; info->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) @@ -465,7 +465,7 @@ MigrationInfo *qmp_query_migrate(Error **errp) get_xbzrle_cache_stats(info); break; - case MIGRATION_STATUS_COMPLETED: + case MigrationStatus_completed: get_xbzrle_cache_stats(info); info->has_status = true; @@ -488,10 +488,10 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->ram->mbps = s->mbps; info->ram->dirty_sync_count = s->dirty_sync_count; break; - case MIGRATION_STATUS_FAILED: + case MigrationStatus_failed: info->has_status = true; break; - case MIGRATION_STATUS_CANCELLED: + case MigrationStatus_cancelled: info->has_status = true; break; } @@ -506,8 +506,8 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, MigrationState *s = migrate_get_current(); MigrationCapabilityStatusList *cap; - if (s->state == MIGRATION_STATUS_ACTIVE || - s->state == MIGRATION_STATUS_SETUP) { + if (s->state == MigrationStatus_active || + s->state == MigrationStatus_setup) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } @@ -563,22 +563,22 @@ void qmp_migrate_set_parameters(bool has_compress_level, } if (has_compress_level) { - s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level; + s->parameters[MigrationParameter_compress_level] = compress_level; } if (has_compress_threads) { - s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] = compress_threads; + s->parameters[MigrationParameter_compress_threads] = compress_threads; } if (has_decompress_threads) { - s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = + s->parameters[MigrationParameter_decompress_threads] = decompress_threads; } if (has_x_cpu_throttle_initial) { - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] = + s->parameters[MigrationParameter_x_cpu_throttle_initial] = x_cpu_throttle_initial; } if (has_x_cpu_throttle_increment) { - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] = + s->parameters[MigrationParameter_x_cpu_throttle_increment] = x_cpu_throttle_increment; } } @@ -611,13 +611,13 @@ static void migrate_fd_cleanup(void *opaque) s->file = NULL; } - assert(s->state != MIGRATION_STATUS_ACTIVE); + assert(s->state != MigrationStatus_active); - if (s->state != MIGRATION_STATUS_COMPLETED) { + if (s->state != MigrationStatus_completed) { qemu_savevm_state_cancel(); - if (s->state == MIGRATION_STATUS_CANCELLING) { - migrate_set_state(s, MIGRATION_STATUS_CANCELLING, - MIGRATION_STATUS_CANCELLED); + if (s->state == MigrationStatus_cancelling) { + migrate_set_state(s, MigrationStatus_cancelling, + MigrationStatus_cancelled); } } @@ -628,7 +628,7 @@ void migrate_fd_error(MigrationState *s) { trace_migrate_fd_error(); assert(s->file == NULL); - migrate_set_state(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); + migrate_set_state(s, MigrationStatus_setup, MigrationStatus_failed); notifier_list_notify(&migration_state_notifiers, s); } @@ -640,12 +640,12 @@ static void migrate_fd_cancel(MigrationState *s) do { old_state = s->state; - if (old_state != MIGRATION_STATUS_SETUP && - old_state != MIGRATION_STATUS_ACTIVE) { + if (old_state != MigrationStatus_setup && + old_state != MigrationStatus_active) { break; } - migrate_set_state(s, old_state, MIGRATION_STATUS_CANCELLING); - } while (s->state != MIGRATION_STATUS_CANCELLING); + migrate_set_state(s, old_state, MigrationStatus_cancelling); + } while (s->state != MigrationStatus_cancelling); /* * If we're unlucky the migration code might be stuck somewhere in a @@ -654,7 +654,7 @@ static void migrate_fd_cancel(MigrationState *s) * The outgoing qemu file gets closed in migrate_fd_cleanup that is * called in a bh, so there is no race against this cancel. */ - if (s->state == MIGRATION_STATUS_CANCELLING && f) { + if (s->state == MigrationStatus_cancelling && f) { qemu_file_shutdown(f); } } @@ -671,35 +671,35 @@ void remove_migration_state_change_notifier(Notifier *notify) bool migration_in_setup(MigrationState *s) { - return s->state == MIGRATION_STATUS_SETUP; + return s->state == MigrationStatus_setup; } bool migration_has_finished(MigrationState *s) { - return s->state == MIGRATION_STATUS_COMPLETED; + return s->state == MigrationStatus_completed; } bool migration_has_failed(MigrationState *s) { - return (s->state == MIGRATION_STATUS_CANCELLED || - s->state == MIGRATION_STATUS_FAILED); + return (s->state == MigrationStatus_cancelled || + s->state == MigrationStatus_failed); } static MigrationState *migrate_init(const MigrationParams *params) { MigrationState *s = migrate_get_current(); int64_t bandwidth_limit = s->bandwidth_limit; - bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; + bool enabled_capabilities[MigrationCapability_MAX]; int64_t xbzrle_cache_size = s->xbzrle_cache_size; - int compress_level = s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL]; + int compress_level = s->parameters[MigrationParameter_compress_level]; int compress_thread_count = - s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; + s->parameters[MigrationParameter_compress_threads]; int decompress_thread_count = - s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; + s->parameters[MigrationParameter_decompress_threads]; int x_cpu_throttle_initial = - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL]; + s->parameters[MigrationParameter_x_cpu_throttle_initial]; int x_cpu_throttle_increment = - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT]; + s->parameters[MigrationParameter_x_cpu_throttle_increment]; memcpy(enabled_capabilities, s->enabled_capabilities, sizeof(enabled_capabilities)); @@ -710,17 +710,17 @@ static MigrationState *migrate_init(const MigrationParams *params) sizeof(enabled_capabilities)); s->xbzrle_cache_size = xbzrle_cache_size; - s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level; - s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] = + s->parameters[MigrationParameter_compress_level] = compress_level; + s->parameters[MigrationParameter_compress_threads] = compress_thread_count; - s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = + s->parameters[MigrationParameter_decompress_threads] = decompress_thread_count; - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL] = + s->parameters[MigrationParameter_x_cpu_throttle_initial] = x_cpu_throttle_initial; - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] = + s->parameters[MigrationParameter_x_cpu_throttle_increment] = x_cpu_throttle_increment; s->bandwidth_limit = bandwidth_limit; - migrate_set_state(s, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP); + migrate_set_state(s, MigrationStatus_none, MigrationStatus_setup); s->total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); return s; @@ -773,13 +773,13 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, params.blk = has_blk && blk; params.shared = has_inc && inc; - if (s->state == MIGRATION_STATUS_ACTIVE || - s->state == MIGRATION_STATUS_SETUP || - s->state == MIGRATION_STATUS_CANCELLING) { + if (s->state == MigrationStatus_active || + s->state == MigrationStatus_setup || + s->state == MigrationStatus_cancelling) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } - if (runstate_check(RUN_STATE_INMIGRATE)) { + if (runstate_check(RunState_inmigrate)) { error_setg(errp, "Guest is waiting for an incoming migration"); return; } @@ -797,7 +797,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, state. This change is only needed if previous migration failed/was cancelled. We don't use migrate_set_state() because we are setting the initial state, not changing it. */ - s->state = MIGRATION_STATUS_NONE; + s->state = MigrationStatus_none; s = migrate_init(¶ms); @@ -818,7 +818,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } else { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol"); - migrate_set_state(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); + migrate_set_state(s, MigrationStatus_setup, MigrationStatus_failed); return; } @@ -899,7 +899,7 @@ bool migrate_auto_converge(void) s = migrate_get_current(); - return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE]; + return s->enabled_capabilities[MigrationCapability_auto_converge]; } bool migrate_zero_blocks(void) @@ -908,7 +908,7 @@ bool migrate_zero_blocks(void) s = migrate_get_current(); - return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS]; + return s->enabled_capabilities[MigrationCapability_zero_blocks]; } bool migrate_use_compression(void) @@ -917,7 +917,7 @@ bool migrate_use_compression(void) s = migrate_get_current(); - return s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS]; + return s->enabled_capabilities[MigrationCapability_compress]; } int migrate_compress_level(void) @@ -926,7 +926,7 @@ int migrate_compress_level(void) s = migrate_get_current(); - return s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL]; + return s->parameters[MigrationParameter_compress_level]; } int migrate_compress_threads(void) @@ -935,7 +935,7 @@ int migrate_compress_threads(void) s = migrate_get_current(); - return s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; + return s->parameters[MigrationParameter_compress_threads]; } int migrate_decompress_threads(void) @@ -944,7 +944,7 @@ int migrate_decompress_threads(void) s = migrate_get_current(); - return s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; + return s->parameters[MigrationParameter_decompress_threads]; } bool migrate_use_events(void) @@ -953,7 +953,7 @@ bool migrate_use_events(void) s = migrate_get_current(); - return s->enabled_capabilities[MIGRATION_CAPABILITY_EVENTS]; + return s->enabled_capabilities[MigrationCapability_events]; } int migrate_use_xbzrle(void) @@ -962,7 +962,7 @@ int migrate_use_xbzrle(void) s = migrate_get_current(); - return s->enabled_capabilities[MIGRATION_CAPABILITY_XBZRLE]; + return s->enabled_capabilities[MigrationCapability_xbzrle]; } int64_t migrate_xbzrle_cache_size(void) @@ -994,7 +994,7 @@ static void migration_completion(MigrationState *s, bool *old_vm_running, ret = global_state_store(); if (!ret) { - ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); + ret = vm_stop_force_state(RunState_finish_migrate); if (ret >= 0) { qemu_file_set_rate_limit(s->file, INT64_MAX); qemu_savevm_state_complete(s->file); @@ -1011,11 +1011,11 @@ static void migration_completion(MigrationState *s, bool *old_vm_running, goto fail; } - migrate_set_state(s, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COMPLETED); + migrate_set_state(s, MigrationStatus_active, MigrationStatus_completed); return; fail: - migrate_set_state(s, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); + migrate_set_state(s, MigrationStatus_active, MigrationStatus_failed); } /* migration thread support */ @@ -1036,9 +1036,9 @@ static void *migration_thread(void *opaque) qemu_savevm_state_begin(s->file, &s->params); s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; - migrate_set_state(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); + migrate_set_state(s, MigrationStatus_setup, MigrationStatus_active); - while (s->state == MIGRATION_STATUS_ACTIVE) { + while (s->state == MigrationStatus_active) { int64_t current_time; uint64_t pending_size; @@ -1055,8 +1055,8 @@ static void *migration_thread(void *opaque) } if (qemu_file_get_error(s->file)) { - migrate_set_state(s, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_FAILED); + migrate_set_state(s, MigrationStatus_active, + MigrationStatus_failed); break; } current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); @@ -1091,7 +1091,7 @@ static void *migration_thread(void *opaque) cpu_throttle_stop(); qemu_mutex_lock_iothread(); - if (s->state == MIGRATION_STATUS_COMPLETED) { + if (s->state == MigrationStatus_completed) { int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); uint64_t transferred_bytes = qemu_ftell(s->file); s->total_time = end_time - s->total_time; @@ -1100,7 +1100,7 @@ static void *migration_thread(void *opaque) s->mbps = (((double) transferred_bytes * 8.0) / ((double) s->total_time)) / 1000; } - runstate_set(RUN_STATE_POSTMIGRATE); + runstate_set(RunState_postmigrate); } else { if (old_vm_running) { vm_start(); diff --git a/migration/ram.c b/migration/ram.c index a25bcc7..1d6fb68 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -419,9 +419,9 @@ static void mig_throttle_guest_down(void) { MigrationState *s = migrate_get_current(); uint64_t pct_initial = - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL]; + s->parameters[MigrationParameter_x_cpu_throttle_initial]; uint64_t pct_icrement = - s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT]; + s->parameters[MigrationParameter_x_cpu_throttle_increment]; /* We have not started throttling yet. Let's start it. */ if (!cpu_throttle_active()) { diff --git a/migration/rdma.c b/migration/rdma.c index 553fbd7..ed34279 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3491,7 +3491,7 @@ void rdma_start_outgoing_migration(void *opaque, } ret = qemu_rdma_source_init(rdma, &local_err, - s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL]); + s->enabled_capabilities[MigrationCapability_rdma_pin_all]); if (ret) { goto err; diff --git a/migration/savevm.c b/migration/savevm.c index dbcc39a..199b687 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1318,7 +1318,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict) monitor_printf(mon, "Error saving global state\n"); return; } - vm_stop(RUN_STATE_SAVE_VM); + vm_stop(RunState_save_vm); memset(sn, 0, sizeof(*sn)); @@ -1390,7 +1390,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) int ret; saved_vm_running = runstate_is_running(); - vm_stop(RUN_STATE_SAVE_VM); + vm_stop(RunState_save_vm); global_state_store_running(); f = qemu_fopen(filename, "wb"); diff --git a/monitor.c b/monitor.c index 6cd747f..c10cd41 100644 --- a/monitor.c +++ b/monitor.c @@ -441,14 +441,14 @@ static void monitor_protocol_emitter(Monitor *mon, QObject *data, } -static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT_MAX] = { +static MonitorQAPIEventConf monitor_qapi_event_conf[QAPIEvent_MAX] = { /* Limit guest-triggerable events to 1 per second */ - [QAPI_EVENT_RTC_CHANGE] = { 1000 * SCALE_MS }, - [QAPI_EVENT_WATCHDOG] = { 1000 * SCALE_MS }, - [QAPI_EVENT_BALLOON_CHANGE] = { 1000 * SCALE_MS }, - [QAPI_EVENT_QUORUM_REPORT_BAD] = { 1000 * SCALE_MS }, - [QAPI_EVENT_QUORUM_FAILURE] = { 1000 * SCALE_MS }, - [QAPI_EVENT_VSERPORT_CHANGE] = { 1000 * SCALE_MS }, + [QAPIEvent_RTC_CHANGE] = { 1000 * SCALE_MS }, + [QAPIEvent_WATCHDOG] = { 1000 * SCALE_MS }, + [QAPIEvent_BALLOON_CHANGE] = { 1000 * SCALE_MS }, + [QAPIEvent_QUORUM_REPORT_BAD] = { 1000 * SCALE_MS }, + [QAPIEvent_QUORUM_FAILURE] = { 1000 * SCALE_MS }, + [QAPIEvent_VSERPORT_CHANGE] = { 1000 * SCALE_MS }, }; GHashTable *monitor_qapi_event_state; @@ -481,7 +481,7 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp) MonitorQAPIEventConf *evconf; MonitorQAPIEventState *evstate; - assert(event < QAPI_EVENT_MAX); + assert(event < QAPIEvent_MAX); evconf = &monitor_qapi_event_conf[event]; trace_monitor_protocol_event_queue(event, qdict, evconf->rate); @@ -568,7 +568,7 @@ static unsigned int qapi_event_throttle_hash(const void *key) const MonitorQAPIEventState *evstate = key; unsigned int hash = evstate->event * 255; - if (evstate->event == QAPI_EVENT_VSERPORT_CHANGE) { + if (evstate->event == QAPIEvent_VSERPORT_CHANGE) { hash += g_str_hash(qdict_get_str(evstate->data, "id")); } @@ -584,7 +584,7 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b) return FALSE; } - if (eva->event == QAPI_EVENT_VSERPORT_CHANGE) { + if (eva->event == QAPIEvent_VSERPORT_CHANGE) { return !strcmp(qdict_get_str(eva->data, "id"), qdict_get_str(evb->data, "id")); } @@ -946,7 +946,7 @@ EventInfoList *qmp_query_events(Error **errp) EventInfoList *info, *ev_list = NULL; QAPIEvent e; - for (e = 0 ; e < QAPI_EVENT_MAX ; e++) { + for (e = 0 ; e < QAPIEvent_MAX ; e++) { const char *event_name = QAPIEvent_lookup[e]; assert(event_name != NULL); info = g_malloc0(sizeof(*info)); @@ -1053,7 +1053,7 @@ static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) for (elem = events; elem != NULL; elem = elem->next) { monitor_printf(mon, "%s : state %u\n", elem->value->name, - elem->value->state == TRACE_EVENT_STATE_ENABLED ? 1 : 0); + elem->value->state == TraceEventState_enabled ? 1 : 0); } qapi_free_TraceEventInfoList(events); } @@ -1369,13 +1369,13 @@ static void hmp_mouse_move(Monitor *mon, const QDict *qdict) dx = strtol(dx_str, NULL, 0); dy = strtol(dy_str, NULL, 0); - qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx); - qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy); + qemu_input_queue_rel(NULL, InputAxis_X, dx); + qemu_input_queue_rel(NULL, InputAxis_Y, dy); if (dz_str) { dz = strtol(dz_str, NULL, 0); if (dz != 0) { - button = (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN; + button = (dz > 0) ? InputButton_WheelUp : InputButton_WheelDown; qemu_input_queue_btn(NULL, button, true); qemu_input_event_sync(); qemu_input_queue_btn(NULL, button, false); @@ -1386,10 +1386,10 @@ static void hmp_mouse_move(Monitor *mon, const QDict *qdict) static void hmp_mouse_button(Monitor *mon, const QDict *qdict) { - static uint32_t bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, + static uint32_t bmap[InputButton_MAX] = { + [InputButton_Left] = MOUSE_EVENT_LBUTTON, + [InputButton_Middle] = MOUSE_EVENT_MBUTTON, + [InputButton_Right] = MOUSE_EVENT_RBUTTON, }; int button_state = qdict_get_int(qdict, "button_state"); @@ -1740,7 +1740,7 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict) int saved_vm_running = runstate_is_running(); const char *name = qdict_get_str(qdict, "name"); - vm_stop(RUN_STATE_RESTORE_VM); + vm_stop(RunState_restore_vm); if (load_vmstate(name) == 0 && saved_vm_running) { vm_start(); @@ -3209,7 +3209,7 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) } len = strlen(str); readline_set_completion_index(rs, len); - for (i = 0; i < Q_KEY_CODE_MAX; i++) { + for (i = 0; i < QKeyCode_MAX; i++) { if (!strncmp(str, QKeyCode_lookup[i], len)) { readline_add_completion(rs, QKeyCode_lookup[i]); } @@ -3226,7 +3226,7 @@ void set_link_completion(ReadLineState *rs, int nb_args, const char *str) NetClientState *ncs[MAX_QUEUE_NUM]; int count, i; count = qemu_find_net_clients_except(NULL, ncs, - NET_CLIENT_OPTIONS_KIND_NONE, + NetClientOptionsKind_none, MAX_QUEUE_NUM); for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) { const char *name = ncs[i]->name; @@ -3251,7 +3251,7 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) len = strlen(str); readline_set_completion_index(rs, len); - count = qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS_KIND_NIC, + count = qemu_find_net_clients_except(NULL, ncs, NetClientOptionsKind_nic, MAX_QUEUE_NUM); for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) { QemuOpts *opts; @@ -3308,7 +3308,7 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args, readline_set_completion_index(rs, len); if (nb_args == 2) { int i; - for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) { + for (i = 0; i < MigrationCapability_MAX; i++) { const char *name = MigrationCapability_lookup[i]; if (!strncmp(str, name, len)) { readline_add_completion(rs, name); @@ -3329,7 +3329,7 @@ void migrate_set_parameter_completion(ReadLineState *rs, int nb_args, readline_set_completion_index(rs, len); if (nb_args == 2) { int i; - for (i = 0; i < MIGRATION_PARAMETER_MAX; i++) { + for (i = 0; i < MigrationParameter_MAX; i++) { const char *name = MigrationParameter_lookup[i]; if (!strncmp(str, name, len)) { readline_add_completion(rs, name); @@ -3363,7 +3363,7 @@ void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str) readline_set_completion_index(rs, len); if (nb_args == 2) { count = qemu_find_net_clients_except(NULL, ncs, - NET_CLIENT_OPTIONS_KIND_NONE, + NetClientOptionsKind_none, MAX_QUEUE_NUM); for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) { int id; @@ -3380,13 +3380,13 @@ void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str) return; } else if (nb_args == 3) { count = qemu_find_net_clients_except(NULL, ncs, - NET_CLIENT_OPTIONS_KIND_NIC, + NetClientOptionsKind_nic, MAX_QUEUE_NUM); for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) { int id; const char *name; - if (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT || + if (ncs[i]->info->type == NetClientOptionsKind_hubport || net_hub_id_for_client(ncs[i], &id)) { continue; } @@ -3573,13 +3573,13 @@ static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd, 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, + error_set(errp, ErrorClass_CommandNotFound, "Capabilities negotiation is already complete, command " "'%s' ignored", cmd->name); return true; } if (!is_cap && !mon->qmp.in_command_mode) { - error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + error_set(errp, ErrorClass_CommandNotFound, "Expecting capabilities negotiation with " "'qmp_capabilities' before command '%s'", cmd->name); return true; @@ -3868,7 +3868,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) trace_handle_qmp_command(mon, cmd_name); cmd = qmp_find_cmd(cmd_name); if (!cmd) { - error_set(&local_err, ERROR_CLASS_COMMAND_NOT_FOUND, + error_set(&local_err, ErrorClass_CommandNotFound, "The command %s has not been found", cmd_name); goto err_out; } diff --git a/net/dump.c b/net/dump.c index ce16a4b..be6d487 100644 --- a/net/dump.c +++ b/net/dump.c @@ -170,7 +170,7 @@ static void dumpclient_cleanup(NetClientState *nc) } static NetClientInfo net_dump_info = { - .type = NET_CLIENT_OPTIONS_KIND_DUMP, + .type = NetClientOptionsKind_dump, .size = sizeof(DumpNetClient), .receive = dumpclient_receive, .receive_iov = dumpclient_receive_iov, @@ -187,7 +187,7 @@ int net_init_dump(const NetClientOptions *opts, const char *name, NetClientState *nc; DumpNetClient *dnc; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_DUMP); + assert(opts->type == NetClientOptionsKind_dump); dump = opts->u.dump; assert(peer); diff --git a/net/filter.c b/net/filter.c index 326f2b5..8303c0f 100644 --- a/net/filter.c +++ b/net/filter.c @@ -26,7 +26,7 @@ ssize_t qemu_netfilter_receive(NetFilterState *nf, NetPacketSent *sent_cb) { if (nf->direction == direction || - nf->direction == NET_FILTER_DIRECTION_ALL) { + nf->direction == NetFilterDirection_all) { return NETFILTER_GET_CLASS(OBJECT(nf))->receive_iov( nf, sender, flags, iov, iovcnt, sent_cb); } @@ -50,12 +50,12 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *sender, goto out; } - if (nf->direction == NET_FILTER_DIRECTION_ALL) { + if (nf->direction == NetFilterDirection_all) { if (sender == nf->netdev) { /* This packet is sent by netdev itself */ - direction = NET_FILTER_DIRECTION_TX; + direction = NetFilterDirection_tx; } else { - direction = NET_FILTER_DIRECTION_RX; + direction = NetFilterDirection_rx; } } else { direction = nf->direction; @@ -145,7 +145,7 @@ static void netfilter_complete(UserCreatable *uc, Error **errp) } queues = qemu_find_net_clients_except(nf->netdev_id, ncs, - NET_CLIENT_OPTIONS_KIND_NIC, + NetClientOptionsKind_nic, MAX_QUEUE_NUM); if (queues < 1) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "netdev", diff --git a/net/hub.c b/net/hub.c index 9ae9f01..7ad1e36 100644 --- a/net/hub.c +++ b/net/hub.c @@ -130,7 +130,7 @@ static void net_hub_port_cleanup(NetClientState *nc) } static NetClientInfo net_hub_port_info = { - .type = NET_CLIENT_OPTIONS_KIND_HUBPORT, + .type = NetClientOptionsKind_hubport, .size = sizeof(NetHubPort), .can_receive = net_hub_port_can_receive, .receive = net_hub_port_receive, @@ -265,10 +265,10 @@ int net_hub_id_for_client(NetClientState *nc, int *id) { NetHubPort *port; - if (nc->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (nc->info->type == NetClientOptionsKind_hubport) { port = DO_UPCAST(NetHubPort, nc, nc); } else if (nc->peer != NULL && nc->peer->info->type == - NET_CLIENT_OPTIONS_KIND_HUBPORT) { + NetClientOptionsKind_hubport) { port = DO_UPCAST(NetHubPort, nc, nc->peer); } else { return -ENOENT; @@ -285,7 +285,7 @@ int net_init_hubport(const NetClientOptions *opts, const char *name, { const NetdevHubPortOptions *hubport; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT); + assert(opts->type == NetClientOptionsKind_hubport); assert(!peer); hubport = opts->u.hubport; @@ -314,14 +314,14 @@ void net_hub_check_clients(void) } switch (peer->info->type) { - case NET_CLIENT_OPTIONS_KIND_NIC: + case NetClientOptionsKind_nic: has_nic = 1; break; - case NET_CLIENT_OPTIONS_KIND_USER: - case NET_CLIENT_OPTIONS_KIND_TAP: - case NET_CLIENT_OPTIONS_KIND_SOCKET: - case NET_CLIENT_OPTIONS_KIND_VDE: - case NET_CLIENT_OPTIONS_KIND_VHOST_USER: + case NetClientOptionsKind_user: + case NetClientOptionsKind_tap: + case NetClientOptionsKind_socket: + case NetClientOptionsKind_vde: + case NetClientOptionsKind_vhost_user: has_host_dev = 1; break; default: diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 8e68e54..05303f5 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -516,7 +516,7 @@ static void net_l2tpv3_cleanup(NetClientState *nc) } static NetClientInfo net_l2tpv3_info = { - .type = NET_CLIENT_OPTIONS_KIND_L2TPV3, + .type = NetClientOptionsKind_l2tpv3, .size = sizeof(NetL2TPV3State), .receive = net_l2tpv3_receive_dgram, .receive_iov = net_l2tpv3_receive_dgram_iov, @@ -545,7 +545,7 @@ int net_init_l2tpv3(const NetClientOptions *opts, s->queue_tail = 0; s->header_mismatch = false; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_L2TPV3); + assert(opts->type == NetClientOptionsKind_l2tpv3); l2tpv3 = opts->u.l2tpv3; if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { diff --git a/net/net.c b/net/net.c index ade6051..f972c55 100644 --- a/net/net.c +++ b/net/net.c @@ -317,7 +317,7 @@ NICState *qemu_new_nic(NetClientInfo *info, NICState *nic; int i, queues = MAX(1, conf->peers.queues); - assert(info->type == NET_CLIENT_OPTIONS_KIND_NIC); + assert(info->type == NetClientOptionsKind_nic); assert(info->size >= sizeof(NICState)); nic = g_malloc0(info->size + sizeof(NetClientState) * queues); @@ -388,13 +388,13 @@ void qemu_del_net_client(NetClientState *nc) int queues, i; NetFilterState *nf, *next; - assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC); + assert(nc->info->type != NetClientOptionsKind_nic); /* If the NetClientState belongs to a multiqueue backend, we will change all * other NetClientStates also. */ queues = qemu_find_net_clients_except(nc->name, ncs, - NET_CLIENT_OPTIONS_KIND_NIC, + NetClientOptionsKind_nic, MAX_QUEUE_NUM); assert(queues != 0); @@ -403,7 +403,7 @@ void qemu_del_net_client(NetClientState *nc) } /* If there is a peer NIC, delete and cleanup client, but do not free. */ - if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (nc->peer && nc->peer->info->type == NetClientOptionsKind_nic) { NICState *nic = qemu_get_nic(nc->peer); if (nic->peer_deleted) { return; @@ -459,7 +459,7 @@ void qemu_foreach_nic(qemu_nic_foreach func, void *opaque) NetClientState *nc; QTAILQ_FOREACH(nc, &net_clients, next) { - if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (nc->info->type == NetClientOptionsKind_nic) { if (nc->queue_index == 0) { func(qemu_get_nic(nc), opaque); } @@ -621,7 +621,7 @@ void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge) { nc->receive_disabled = 0; - if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (nc->peer && nc->peer->info->type == NetClientOptionsKind_hubport) { if (net_hub_flush(nc->peer)) { qemu_notify_event(); } @@ -660,13 +660,13 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender, } /* Let filters handle the packet first */ - ret = filter_receive(sender, NET_FILTER_DIRECTION_TX, + ret = filter_receive(sender, NetFilterDirection_tx, sender, flags, buf, size, sent_cb); if (ret) { return ret; } - ret = filter_receive(sender->peer, NET_FILTER_DIRECTION_RX, + ret = filter_receive(sender->peer, NetFilterDirection_rx, sender, flags, buf, size, sent_cb); if (ret) { return ret; @@ -760,13 +760,13 @@ ssize_t qemu_sendv_packet_async(NetClientState *sender, } /* Let filters handle the packet first */ - ret = filter_receive_iov(sender, NET_FILTER_DIRECTION_TX, sender, + ret = filter_receive_iov(sender, NetFilterDirection_tx, sender, QEMU_NET_PACKET_FLAG_NONE, iov, iovcnt, sent_cb); if (ret) { return ret; } - ret = filter_receive_iov(sender->peer, NET_FILTER_DIRECTION_RX, sender, + ret = filter_receive_iov(sender->peer, NetFilterDirection_rx, sender, QEMU_NET_PACKET_FLAG_NONE, iov, iovcnt, sent_cb); if (ret) { return ret; @@ -790,7 +790,7 @@ NetClientState *qemu_find_netdev(const char *id) NetClientState *nc; QTAILQ_FOREACH(nc, &net_clients, next) { - if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) + if (nc->info->type == NetClientOptionsKind_nic) continue; if (!strcmp(nc->name, id)) { return nc; @@ -882,7 +882,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, NICInfo *nd; const NetLegacyNicOptions *nic; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_NIC); + assert(opts->type == NetClientOptionsKind_nic); nic = opts->u.nic; idx = nic_get_free_idx(); @@ -943,32 +943,32 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, } -static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( +static int (* const net_client_init_fun[NetClientOptionsKind_MAX])( const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) = { - [NET_CLIENT_OPTIONS_KIND_NIC] = net_init_nic, + [NetClientOptionsKind_nic] = net_init_nic, #ifdef CONFIG_SLIRP - [NET_CLIENT_OPTIONS_KIND_USER] = net_init_slirp, + [NetClientOptionsKind_user] = net_init_slirp, #endif - [NET_CLIENT_OPTIONS_KIND_TAP] = net_init_tap, - [NET_CLIENT_OPTIONS_KIND_SOCKET] = net_init_socket, + [NetClientOptionsKind_tap] = net_init_tap, + [NetClientOptionsKind_socket] = net_init_socket, #ifdef CONFIG_VDE - [NET_CLIENT_OPTIONS_KIND_VDE] = net_init_vde, + [NetClientOptionsKind_vde] = net_init_vde, #endif #ifdef CONFIG_NETMAP - [NET_CLIENT_OPTIONS_KIND_NETMAP] = net_init_netmap, + [NetClientOptionsKind_netmap] = net_init_netmap, #endif - [NET_CLIENT_OPTIONS_KIND_DUMP] = net_init_dump, + [NetClientOptionsKind_dump] = net_init_dump, #ifdef CONFIG_NET_BRIDGE - [NET_CLIENT_OPTIONS_KIND_BRIDGE] = net_init_bridge, + [NetClientOptionsKind_bridge] = net_init_bridge, #endif - [NET_CLIENT_OPTIONS_KIND_HUBPORT] = net_init_hubport, + [NetClientOptionsKind_hubport] = net_init_hubport, #ifdef CONFIG_VHOST_NET_USED - [NET_CLIENT_OPTIONS_KIND_VHOST_USER] = net_init_vhost_user, + [NetClientOptionsKind_vhost_user] = net_init_vhost_user, #endif #ifdef CONFIG_L2TPV3 - [NET_CLIENT_OPTIONS_KIND_L2TPV3] = net_init_l2tpv3, + [NetClientOptionsKind_l2tpv3] = net_init_l2tpv3, #endif }; @@ -984,8 +984,8 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) opts = netdev->opts; name = netdev->id; - if (opts->type == NET_CLIENT_OPTIONS_KIND_DUMP || - opts->type == NET_CLIENT_OPTIONS_KIND_NIC || + if (opts->type == NetClientOptionsKind_dump || + opts->type == NetClientOptionsKind_nic || !net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); @@ -997,10 +997,10 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) /* missing optional values have been initialized to "all bits zero" */ name = net->has_id ? net->id : net->name; - if (opts->type == NET_CLIENT_OPTIONS_KIND_NONE) { + if (opts->type == NetClientOptionsKind_none) { return 0; /* nothing to do */ } - if (opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (opts->type == NetClientOptionsKind_hubport) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net type"); return -1; @@ -1014,7 +1014,7 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } /* Do not add to a vlan if it's a nic with a netdev= parameter. */ - if (opts->type != NET_CLIENT_OPTIONS_KIND_NIC || + if (opts->type != NetClientOptionsKind_nic || !opts->u.nic->has_netdev) { peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); } @@ -1123,7 +1123,7 @@ void hmp_host_net_remove(Monitor *mon, const QDict *qdict) device, vlan_id); return; } - if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (nc->info->type == NetClientOptionsKind_nic) { error_report("invalid host network device '%s'", device); return; } @@ -1170,7 +1170,7 @@ void qmp_netdev_del(const char *id, Error **errp) nc = qemu_find_netdev(id); if (!nc) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", id); return; } @@ -1220,7 +1220,7 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, } /* only query rx-filter information of NIC */ - if (nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC) { + if (nc->info->type != NetClientOptionsKind_nic) { if (has_name) { error_setg(errp, "net client(%s) isn't a NIC", name); return NULL; @@ -1279,10 +1279,10 @@ void hmp_info_network(Monitor *mon, const QDict *qdict) continue; } - if (!peer || type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (!peer || type == NetClientOptionsKind_nic) { print_net_client(mon, nc); } /* else it's a netdev connected to a NIC, printed with the NIC */ - if (peer && type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (peer && type == NetClientOptionsKind_nic) { monitor_printf(mon, " \\ "); print_net_client(mon, peer); } @@ -1296,11 +1296,11 @@ void qmp_set_link(const char *name, bool up, Error **errp) int queues, i; queues = qemu_find_net_clients_except(name, ncs, - NET_CLIENT_OPTIONS_KIND_MAX, + NetClientOptionsKind_MAX, MAX_QUEUE_NUM); if (queues == 0) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", name); return; } @@ -1323,7 +1323,7 @@ void qmp_set_link(const char *name, bool up, Error **errp) * multiple clients that can still communicate with each other in * disconnected mode. For now maintain this compatibility. */ - if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (nc->peer->info->type == NetClientOptionsKind_nic) { for (i = 0; i < queues; i++) { ncs[i]->peer->link_down = !up; } @@ -1364,7 +1364,7 @@ void net_cleanup(void) */ while (!QTAILQ_EMPTY(&net_clients)) { nc = QTAILQ_FIRST(&net_clients); - if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { + if (nc->info->type == NetClientOptionsKind_nic) { qemu_del_nic(qemu_get_nic(nc)); } else { qemu_del_net_client(nc); @@ -1396,7 +1396,7 @@ void net_check_clients(void) QTAILQ_FOREACH(nc, &net_clients, next) { if (!nc->peer) { fprintf(stderr, "Warning: %s %s has no peer\n", - nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC ? + nc->info->type == NetClientOptionsKind_nic ? "nic" : "netdev", nc->name); } } diff --git a/net/netmap.c b/net/netmap.c index 508b829..381d3d0 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -417,7 +417,7 @@ static void netmap_set_offload(NetClientState *nc, int csum, int tso4, int tso6, /* NetClientInfo methods */ static NetClientInfo net_netmap_info = { - .type = NET_CLIENT_OPTIONS_KIND_NETMAP, + .type = NetClientOptionsKind_netmap, .size = sizeof(NetmapState), .receive = netmap_receive, .receive_iov = netmap_receive_iov, diff --git a/net/slirp.c b/net/slirp.c index f505570..d912756 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -126,7 +126,7 @@ static void net_slirp_cleanup(NetClientState *nc) } static NetClientInfo net_slirp_info = { - .type = NET_CLIENT_OPTIONS_KIND_USER, + .type = NetClientOptionsKind_user, .size = sizeof(SlirpState), .receive = net_slirp_receive, .cleanup = net_slirp_cleanup, @@ -746,7 +746,7 @@ int net_init_slirp(const NetClientOptions *opts, const char *name, const NetdevUserOptions *user; const char **dnssearch; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_USER); + assert(opts->type == NetClientOptionsKind_user); user = opts->u.user; vnet = user->has_net ? g_strdup(user->net) : diff --git a/net/socket.c b/net/socket.c index e8605d4..ef9cfea 100644 --- a/net/socket.c +++ b/net/socket.c @@ -346,7 +346,7 @@ static void net_socket_cleanup(NetClientState *nc) } static NetClientInfo net_dgram_socket_info = { - .type = NET_CLIENT_OPTIONS_KIND_SOCKET, + .type = NetClientOptionsKind_socket, .size = sizeof(NetSocketState), .receive = net_socket_receive_dgram, .cleanup = net_socket_cleanup, @@ -429,7 +429,7 @@ static void net_socket_connect(void *opaque) } static NetClientInfo net_socket_info = { - .type = NET_CLIENT_OPTIONS_KIND_SOCKET, + .type = NetClientOptionsKind_socket, .size = sizeof(NetSocketState), .receive = net_socket_receive, .cleanup = net_socket_cleanup, @@ -706,7 +706,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, Error *err = NULL; const NetdevSocketOptions *sock; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_SOCKET); + assert(opts->type == NetClientOptionsKind_socket); sock = opts->u.socket; if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast + diff --git a/net/tap-win32.c b/net/tap-win32.c index 4e2fa55..803ff4e 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -723,7 +723,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, int len) } static NetClientInfo net_tap_win32_info = { - .type = NET_CLIENT_OPTIONS_KIND_TAP, + .type = NetClientOptionsKind_tap, .size = sizeof(TAPState), .receive = tap_receive, .cleanup = tap_cleanup, @@ -767,7 +767,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, /* FIXME error_setg(errp, ...) on failure */ const NetdevTapOptions *tap; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(opts->type == NetClientOptionsKind_tap); tap = opts->u.tap; if (!tap->has_ifname) { diff --git a/net/tap.c b/net/tap.c index 85c4142..50aaf65 100644 --- a/net/tap.c +++ b/net/tap.c @@ -221,7 +221,7 @@ static bool tap_has_ufo(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); return s->has_ufo; } @@ -230,7 +230,7 @@ static bool tap_has_vnet_hdr(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); return !!s->host_vnet_hdr_len; } @@ -239,7 +239,7 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, int len) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); return !!tap_probe_vnet_hdr_len(s->fd, len); } @@ -248,7 +248,7 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, int len) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); assert(len == sizeof(struct virtio_net_hdr_mrg_rxbuf) || len == sizeof(struct virtio_net_hdr)); @@ -260,7 +260,7 @@ static void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); assert(!!s->host_vnet_hdr_len == using_vnet_hdr); s->using_vnet_hdr = using_vnet_hdr; @@ -326,14 +326,14 @@ static void tap_poll(NetClientState *nc, bool enable) int tap_get_fd(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); return s->fd; } /* fd support */ static NetClientInfo net_tap_info = { - .type = NET_CLIENT_OPTIONS_KIND_TAP, + .type = NetClientOptionsKind_tap, .size = sizeof(TAPState), .receive = tap_receive, .receive_raw = tap_receive_raw, @@ -565,7 +565,7 @@ int net_init_bridge(const NetClientOptions *opts, const char *name, TAPState *s; int fd, vnet_hdr; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_BRIDGE); + assert(opts->type == NetClientOptionsKind_bridge); bridge = opts->u.bridge; helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER; @@ -728,7 +728,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, const char *vhostfdname; char ifname[128]; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(opts->type == NetClientOptionsKind_tap); tap = opts->u.tap; queues = tap->has_queues ? tap->queues : 1; vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL; @@ -890,7 +890,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, VHostNetState *tap_get_vhost_net(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP); + assert(nc->info->type == NetClientOptionsKind_tap); return s->vhost_net; } diff --git a/net/vde.c b/net/vde.c index 4475d92..9c508bb 100644 --- a/net/vde.c +++ b/net/vde.c @@ -68,7 +68,7 @@ static void vde_cleanup(NetClientState *nc) } static NetClientInfo net_vde_info = { - .type = NET_CLIENT_OPTIONS_KIND_VDE, + .type = NetClientOptionsKind_vde, .size = sizeof(VDEState), .receive = vde_receive, .cleanup = vde_cleanup, @@ -115,7 +115,7 @@ int net_init_vde(const NetClientOptions *opts, const char *name, /* FIXME error_setg(errp, ...) on failure */ const NetdevVdeOptions *vde; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_VDE); + assert(opts->type == NetClientOptionsKind_vde); vde = opts->u.vde; /* missing optional values have been initialized to "all bits zero" */ diff --git a/net/vhost-user.c b/net/vhost-user.c index 0ebd7df..51d96bd 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -32,7 +32,7 @@ typedef struct VhostUserChardevProps { VHostNetState *vhost_user_get_vhost_net(NetClientState *nc) { VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(nc->info->type == NetClientOptionsKind_vhost_user); return s->vhost_net; } @@ -47,7 +47,7 @@ static void vhost_user_stop(int queues, NetClientState *ncs[]) int i; for (i = 0; i < queues; i++) { - assert (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert (ncs[i]->info->type == NetClientOptionsKind_vhost_user); s = DO_UPCAST(VhostUserState, nc, ncs[i]); if (!vhost_user_running(s)) { @@ -71,7 +71,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[]) options.backend_type = VHOST_BACKEND_TYPE_USER; for (i = 0; i < queues; i++) { - assert (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert (ncs[i]->info->type == NetClientOptionsKind_vhost_user); s = DO_UPCAST(VhostUserState, nc, ncs[i]); if (vhost_user_running(s)) { @@ -146,20 +146,20 @@ static void vhost_user_cleanup(NetClientState *nc) static bool vhost_user_has_vnet_hdr(NetClientState *nc) { - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(nc->info->type == NetClientOptionsKind_vhost_user); return true; } static bool vhost_user_has_ufo(NetClientState *nc) { - assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(nc->info->type == NetClientOptionsKind_vhost_user); return true; } static NetClientInfo net_vhost_user_info = { - .type = NET_CLIENT_OPTIONS_KIND_VHOST_USER, + .type = NetClientOptionsKind_vhost_user, .size = sizeof(VhostUserState), .receive = vhost_user_receive, .cleanup = vhost_user_cleanup, @@ -176,7 +176,7 @@ static void net_vhost_user_event(void *opaque, int event) int queues; queues = qemu_find_net_clients_except(name, ncs, - NET_CLIENT_OPTIONS_KIND_NIC, + NetClientOptionsKind_nic, MAX_QUEUE_NUM); s = DO_UPCAST(VhostUserState, nc, ncs[0]); trace_vhost_user_event(s->chr->label, event); @@ -301,7 +301,7 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name, const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; - assert(opts->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(opts->type == NetClientOptionsKind_vhost_user); vhost_user_opts = opts->u.vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); diff --git a/numa.c b/numa.c index fdfe294..17ba4cb 100644 --- a/numa.c +++ b/numa.c @@ -227,7 +227,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) } switch (object->type) { - case NUMA_OPTIONS_KIND_NODE: + case NumaOptionsKind_node: numa_node_parse(object->u.node, opts, &err); if (err) { goto error; @@ -488,7 +488,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[]) if (value) { switch (value->type) { - case MEMORY_DEVICE_INFO_KIND_DIMM: + case MemoryDeviceInfoKind_dimm: node_mem[value->u.dimm->node] += value->u.dimm->size; break; default: diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 7bcc860..77d9990 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -76,7 +76,7 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp) command = qdict_get_str(dict, "execute"); cmd = qmp_find_command(command); if (cmd == NULL) { - error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, + error_set(errp, ErrorClass_CommandNotFound, "The command %s has not been found", command); return NULL; } diff --git a/qdev-monitor.c b/qdev-monitor.c index a35098f..ecc0818 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -461,7 +461,7 @@ static BusState *qbus_find(const char *path, Error **errp) pos += len; dev = qbus_find_dev(bus, elem); if (!dev) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", elem); qbus_list_dev(bus, errp); return NULL; @@ -788,7 +788,7 @@ void qmp_device_del(const char *id, Error **errp) } if (!obj) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", id); return; } diff --git a/qemu-char.c b/qemu-char.c index 5448b0f..9fe4935 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -98,16 +98,16 @@ static int SocketAddress_to_str(char *dest, int max_len, bool is_listen, bool is_telnet) { switch (addr->type) { - case SOCKET_ADDRESS_KIND_INET: + case SocketAddressKind_inet: return snprintf(dest, max_len, "%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", addr->u.inet->host, addr->u.inet->port, is_listen ? ",server" : ""); break; - case SOCKET_ADDRESS_KIND_UNIX: + case SocketAddressKind_unix: return snprintf(dest, max_len, "%sunix:%s%s", prefix, addr->u.q_unix->path, is_listen ? ",server" : ""); break; - case SOCKET_ADDRESS_KIND_FD: + case SocketAddressKind_fd: return snprintf(dest, max_len, "%sfd:%s%s", prefix, addr->u.fd->str, is_listen ? ",server" : ""); break; @@ -3258,7 +3258,7 @@ void qmp_ringbuf_write(const char *device, const char *data, return; } - if (has_format && (format == DATA_FORMAT_BASE64)) { + if (has_format && (format == DataFormat_base64)) { write_data = g_base64_decode(data, &write_count); } else { write_data = (uint8_t *)data; @@ -3308,7 +3308,7 @@ char *qmp_ringbuf_read(const char *device, int64_t size, ringbuf_chr_read(chr, read_data, size); - if (has_format && (format == DATA_FORMAT_BASE64)) { + if (has_format && (format == DataFormat_base64)) { data = g_base64_encode(read_data, size); g_free(read_data); } else { @@ -3598,11 +3598,11 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, addr = g_new0(SocketAddress, 1); if (path) { - addr->type = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SocketAddressKind_unix; addr->u.q_unix = g_new0(UnixSocketAddress, 1); addr->u.q_unix->path = g_strdup(path); } else { - addr->type = SOCKET_ADDRESS_KIND_INET; + addr->type = SocketAddressKind_inet; addr->u.inet = g_new0(InetSocketAddress, 1); addr->u.inet->host = g_strdup(host); addr->u.inet->port = g_strdup(port); @@ -3647,7 +3647,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, backend->u.udp = g_new0(ChardevUdp, 1); addr = g_new0(SocketAddress, 1); - addr->type = SOCKET_ADDRESS_KIND_INET; + addr->type = SocketAddressKind_inet; addr->u.inet = g_new0(InetSocketAddress, 1); addr->u.inet->host = g_strdup(host); addr->u.inet->port = g_strdup(port); @@ -3660,7 +3660,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, if (has_local) { backend->u.udp->has_local = true; addr = g_new0(SocketAddress, 1); - addr->type = SOCKET_ADDRESS_KIND_INET; + addr->type = SocketAddressKind_inet; addr->u.inet = g_new0(InetSocketAddress, 1); addr->u.inet->host = g_strdup(localaddr); addr->u.inet->port = g_strdup(localport); @@ -3755,7 +3755,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, qapi_free_ChardevReturn(ret); backend = g_new0(ChardevBackend, 1); backend->u.mux = g_new0(ChardevMux, 1); - backend->type = CHARDEV_BACKEND_KIND_MUX; + backend->type = ChardevBackendKind_mux; backend->u.mux->chardev = g_strdup(bid); ret = qmp_chardev_add(id, backend, errp); if (!ret) { @@ -4196,7 +4196,7 @@ static CharDriverState *qmp_chardev_open_socket(const char *id, s->fd = -1; s->listen_fd = -1; - s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX; + s->is_unix = addr->type == SocketAddressKind_unix; s->is_listen = is_listen; s->is_telnet = is_telnet; s->do_nodelay = do_nodelay; @@ -4297,7 +4297,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, chr->label = g_strdup(id); chr->avail_connections = - (backend->type == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; + (backend->type == ChardevBackendKind_mux) ? MAX_MUX : 1; if (!chr->filename) { chr->filename = g_strdup(ChardevBackendKind_lookup[backend->type]); } @@ -4331,44 +4331,44 @@ void qmp_chardev_remove(const char *id, Error **errp) static void register_types(void) { - register_char_driver("null", CHARDEV_BACKEND_KIND_NULL, NULL, + register_char_driver("null", ChardevBackendKind_null, NULL, qemu_chr_open_null); - register_char_driver("socket", CHARDEV_BACKEND_KIND_SOCKET, + register_char_driver("socket", ChardevBackendKind_socket, qemu_chr_parse_socket, qmp_chardev_open_socket); - register_char_driver("udp", CHARDEV_BACKEND_KIND_UDP, qemu_chr_parse_udp, + register_char_driver("udp", ChardevBackendKind_udp, qemu_chr_parse_udp, qmp_chardev_open_udp); - register_char_driver("ringbuf", CHARDEV_BACKEND_KIND_RINGBUF, + register_char_driver("ringbuf", ChardevBackendKind_ringbuf, qemu_chr_parse_ringbuf, qemu_chr_open_ringbuf); - register_char_driver("file", CHARDEV_BACKEND_KIND_FILE, + register_char_driver("file", ChardevBackendKind_file, qemu_chr_parse_file_out, qmp_chardev_open_file); - register_char_driver("stdio", CHARDEV_BACKEND_KIND_STDIO, + register_char_driver("stdio", ChardevBackendKind_stdio, qemu_chr_parse_stdio, qemu_chr_open_stdio); #if defined HAVE_CHARDEV_SERIAL - register_char_driver("serial", CHARDEV_BACKEND_KIND_SERIAL, + register_char_driver("serial", ChardevBackendKind_serial, qemu_chr_parse_serial, qmp_chardev_open_serial); - register_char_driver("tty", CHARDEV_BACKEND_KIND_SERIAL, + register_char_driver("tty", ChardevBackendKind_serial, qemu_chr_parse_serial, qmp_chardev_open_serial); #endif #ifdef HAVE_CHARDEV_PARPORT - register_char_driver("parallel", CHARDEV_BACKEND_KIND_PARALLEL, + register_char_driver("parallel", ChardevBackendKind_parallel, qemu_chr_parse_parallel, qmp_chardev_open_parallel); - register_char_driver("parport", CHARDEV_BACKEND_KIND_PARALLEL, + register_char_driver("parport", ChardevBackendKind_parallel, qemu_chr_parse_parallel, qmp_chardev_open_parallel); #endif #ifdef HAVE_CHARDEV_PTY - register_char_driver("pty", CHARDEV_BACKEND_KIND_PTY, NULL, + register_char_driver("pty", ChardevBackendKind_pty, NULL, qemu_chr_open_pty); #endif #ifdef _WIN32 - register_char_driver("console", CHARDEV_BACKEND_KIND_CONSOLE, NULL, + register_char_driver("console", ChardevBackendKind_console, NULL, qemu_chr_open_win_con); #endif - register_char_driver("pipe", CHARDEV_BACKEND_KIND_PIPE, + register_char_driver("pipe", ChardevBackendKind_pipe, qemu_chr_parse_pipe, qemu_chr_open_pipe); - register_char_driver("mux", CHARDEV_BACKEND_KIND_MUX, qemu_chr_parse_mux, + register_char_driver("mux", ChardevBackendKind_mux, qemu_chr_parse_mux, qemu_chr_open_mux); /* Bug-compatibility: */ - register_char_driver("memory", CHARDEV_BACKEND_KIND_MEMORY, + register_char_driver("memory", ChardevBackendKind_memory, qemu_chr_parse_ringbuf, qemu_chr_open_ringbuf); /* this must be done after machine init, since we register FEs with muxes * as part of realize functions like serial_isa_realizefn when -nographic diff --git a/qemu-img.c b/qemu-img.c index 3025776..0358a49 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -760,7 +760,7 @@ static int img_commit(int argc, char **argv) .bs = bs, }; - commit_active_start(bs, base_bs, 0, BLOCKDEV_ON_ERROR_REPORT, + commit_active_start(bs, base_bs, 0, BlockdevOnError_report, common_block_job_cb, &cbi, &local_err); if (local_err) { goto done; diff --git a/qemu-nbd.c b/qemu-nbd.c index 3afec76..10407ac 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -362,11 +362,11 @@ static SocketAddress *nbd_build_socket_address(const char *sockpath, saddr = g_new0(SocketAddress, 1); if (sockpath) { - saddr->type = SOCKET_ADDRESS_KIND_UNIX; + saddr->type = SocketAddressKind_unix; saddr->u.q_unix = g_new0(UnixSocketAddress, 1); saddr->u.q_unix->path = g_strdup(sockpath); } else { - saddr->type = SOCKET_ADDRESS_KIND_INET; + saddr->type = SocketAddressKind_inet; saddr->u.inet = g_new0(InetSocketAddress, 1); saddr->u.inet->host = g_strdup(bindto); if (port) { @@ -432,7 +432,7 @@ int main(int argc, char **argv) pthread_t client_thread; const char *fmt = NULL; Error *local_err = NULL; - BlockdevDetectZeroesOptions detect_zeroes = BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF; + BlockdevDetectZeroesOptions detect_zeroes = BlockdevDetectZeroesOptions_off; QDict *options = NULL; /* The client thread uses SIGTERM to interrupt the server. A signal @@ -487,14 +487,14 @@ int main(int argc, char **argv) detect_zeroes = qapi_enum_parse(BlockdevDetectZeroesOptions_lookup, optarg, - BLOCKDEV_DETECT_ZEROES_OPTIONS_MAX, - BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, + BlockdevDetectZeroesOptions_MAX, + BlockdevDetectZeroesOptions_off, &local_err); if (local_err) { errx(EXIT_FAILURE, "Failed to parse detect_zeroes mode: %s", error_get_pretty(local_err)); } - if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP && + if (detect_zeroes == BlockdevDetectZeroesOptions_unmap && !(flags & BDRV_O_UNMAP)) { errx(EXIT_FAILURE, "setting detect-zeroes to unmap is not allowed " "without setting discard operation to unmap"); diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 67a173a..73a2f32 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -902,7 +902,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, } for (i = 0; i < nhosts; i++) { if (host == hosts[i]) { - disk->bus_type = GUEST_DISK_BUS_TYPE_IDE; + disk->bus_type = GuestDiskBusType_ide; disk->bus = i; disk->unit = tgt[1]; break; @@ -918,16 +918,16 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, g_debug("invalid sysfs path '%s' (driver '%s')", syspath, driver); goto cleanup; } - disk->bus_type = GUEST_DISK_BUS_TYPE_SCSI; + disk->bus_type = GuestDiskBusType_scsi; disk->unit = tgt[1]; } else if (strcmp(driver, "virtio-pci") == 0) { if (has_tgt) { /* virtio-scsi: target*:0:0: */ - disk->bus_type = GUEST_DISK_BUS_TYPE_SCSI; + disk->bus_type = GuestDiskBusType_scsi; disk->unit = tgt[2]; } else { /* virtio-blk: 1 disk per 1 device */ - disk->bus_type = GUEST_DISK_BUS_TYPE_VIRTIO; + disk->bus_type = GuestDiskBusType_virtio; } } else if (strcmp(driver, "ahci") == 0) { /* ahci: 1 host per 1 unit */ @@ -938,7 +938,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, for (i = 0; i < nhosts; i++) { if (host == hosts[i]) { disk->unit = i; - disk->bus_type = GUEST_DISK_BUS_TYPE_SATA; + disk->bus_type = GuestDiskBusType_sata; break; } } @@ -1156,10 +1156,10 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg, Error **errp) GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp) { if (ga_is_frozen(ga_state)) { - return GUEST_FSFREEZE_STATUS_FROZEN; + return GuestFsfreezeStatus_frozen; } - return GUEST_FSFREEZE_STATUS_THAWED; + return GuestFsfreezeStatus_thawed; } int64_t qmp_guest_fsfreeze_freeze(Error **errp) @@ -1314,7 +1314,7 @@ static void guest_fsfreeze_cleanup(void) { Error *err = NULL; - if (ga_is_frozen(ga_state) == GUEST_FSFREEZE_STATUS_FROZEN) { + if (ga_is_frozen(ga_state) == GuestFsfreezeStatus_frozen) { qmp_guest_fsfreeze_thaw(&err); if (err) { slog("failed to clean up frozen filesystems: %s", @@ -1697,7 +1697,7 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) address_item = g_malloc0(sizeof(*address_item)); address_item->value = g_malloc0(sizeof(*address_item->value)); address_item->value->ip_address = g_strdup(addr4); - address_item->value->ip_address_type = GUEST_IP_ADDRESS_TYPE_IPV4; + address_item->value->ip_address_type = GuestIpAddressType_ipv4; if (ifa->ifa_netmask) { /* Count the number of set bits in netmask. @@ -1717,7 +1717,7 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) address_item = g_malloc0(sizeof(*address_item)); address_item->value = g_malloc0(sizeof(*address_item->value)); address_item->value->ip_address = g_strdup(addr6); - address_item->value->ip_address_type = GUEST_IP_ADDRESS_TYPE_IPV6; + address_item->value->ip_address_type = GuestIpAddressType_ipv6; if (ifa->ifa_netmask) { /* Count the number of set bits in netmask. @@ -2099,7 +2099,7 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk, */ if (!dp && errno == ENOENT) { result->response = - GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED; + GuestMemoryBlockResponseType_operation_not_supported; goto out1; } closedir(dp); @@ -2113,10 +2113,10 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk, error_setg_errno(errp, errno, "open(\"%s\")", dirpath); } else { if (errno == ENOENT) { - result->response = GUEST_MEMORY_BLOCK_RESPONSE_TYPE_NOT_FOUND; + result->response = GuestMemoryBlockResponseType_not_found; } else { result->response = - GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED; + GuestMemoryBlockResponseType_operation_failed; } } g_free(dirpath); @@ -2135,14 +2135,14 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk, mem_blk->can_offline = false; } else if (!mem_blk->online) { result->response = - GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED; + GuestMemoryBlockResponseType_operation_not_supported; } } else { if (sys2memblk) { error_propagate(errp, local_err); } else { result->response = - GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED; + GuestMemoryBlockResponseType_operation_failed; } } goto out2; @@ -2176,11 +2176,11 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk, if (local_err) { error_free(local_err); result->response = - GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED; + GuestMemoryBlockResponseType_operation_failed; goto out2; } - result->response = GUEST_MEMORY_BLOCK_RESPONSE_TYPE_SUCCESS; + result->response = GuestMemoryBlockResponseType_success; result->has_error_code = false; } /* otherwise pretend successful re-(on|off)-lining */ } diff --git a/qga/commands-win32.c b/qga/commands-win32.c index d9de23b..2990ee7 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -395,32 +395,32 @@ void qmp_guest_file_flush(int64_t handle, Error **errp) #ifdef CONFIG_QGA_NTDDSCSI static STORAGE_BUS_TYPE win2qemu[] = { - [BusTypeUnknown] = GUEST_DISK_BUS_TYPE_UNKNOWN, - [BusTypeScsi] = GUEST_DISK_BUS_TYPE_SCSI, - [BusTypeAtapi] = GUEST_DISK_BUS_TYPE_IDE, - [BusTypeAta] = GUEST_DISK_BUS_TYPE_IDE, - [BusType1394] = GUEST_DISK_BUS_TYPE_IEEE1394, - [BusTypeSsa] = GUEST_DISK_BUS_TYPE_SSA, - [BusTypeFibre] = GUEST_DISK_BUS_TYPE_SSA, - [BusTypeUsb] = GUEST_DISK_BUS_TYPE_USB, - [BusTypeRAID] = GUEST_DISK_BUS_TYPE_RAID, + [BusTypeUnknown] = GuestDiskBusType_unknown, + [BusTypeScsi] = GuestDiskBusType_scsi, + [BusTypeAtapi] = GuestDiskBusType_ide, + [BusTypeAta] = GuestDiskBusType_ide, + [BusType1394] = GuestDiskBusType_ieee1394, + [BusTypeSsa] = GuestDiskBusType_ssa, + [BusTypeFibre] = GuestDiskBusType_ssa, + [BusTypeUsb] = GuestDiskBusType_usb, + [BusTypeRAID] = GuestDiskBusType_raid, #if (_WIN32_WINNT >= 0x0600) - [BusTypeiScsi] = GUEST_DISK_BUS_TYPE_ISCSI, - [BusTypeSas] = GUEST_DISK_BUS_TYPE_SAS, - [BusTypeSata] = GUEST_DISK_BUS_TYPE_SATA, - [BusTypeSd] = GUEST_DISK_BUS_TYPE_SD, - [BusTypeMmc] = GUEST_DISK_BUS_TYPE_MMC, + [BusTypeiScsi] = GuestDiskBusType_iscsi, + [BusTypeSas] = GuestDiskBusType_sas, + [BusTypeSata] = GuestDiskBusType_sata, + [BusTypeSd] = GuestDiskBusType_sd, + [BusTypeMmc] = GuestDiskBusType_mmc, #endif #if (_WIN32_WINNT >= 0x0601) - [BusTypeVirtual] = GUEST_DISK_BUS_TYPE_VIRTUAL, - [BusTypeFileBackedVirtual] = GUEST_DISK_BUS_TYPE_FILE_BACKED_VIRTUAL, + [BusTypeVirtual] = GuestDiskBusType_virtual, + [BusTypeFileBackedVirtual] = GuestDiskBusType_file_backed_virtual, #endif }; static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE bus) { if (bus > ARRAY_SIZE(win2qemu) || (int)bus < 0) { - return GUEST_DISK_BUS_TYPE_UNKNOWN; + return GuestDiskBusType_unknown; } return win2qemu[(int)bus]; } @@ -704,10 +704,10 @@ GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp) } if (ga_is_frozen(ga_state)) { - return GUEST_FSFREEZE_STATUS_FROZEN; + return GuestFsfreezeStatus_frozen; } - return GUEST_FSFREEZE_STATUS_THAWED; + return GuestFsfreezeStatus_thawed; } /* @@ -782,7 +782,7 @@ static void guest_fsfreeze_cleanup(void) return; } - if (ga_is_frozen(ga_state) == GUEST_FSFREEZE_STATUS_FROZEN) { + if (ga_is_frozen(ga_state) == GuestFsfreezeStatus_frozen) { qmp_guest_fsfreeze_thaw(&err); if (err) { slog("failed to clean up frozen filesystems: %s", @@ -1093,10 +1093,10 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) address_item->value->prefix = guest_ip_prefix(ip_addr); if (ip_addr->Address.lpSockaddr->sa_family == AF_INET) { address_item->value->ip_address_type = - GUEST_IP_ADDRESS_TYPE_IPV4; + GuestIpAddressType_ipv4; } else if (ip_addr->Address.lpSockaddr->sa_family == AF_INET6) { address_item->value->ip_address_type = - GUEST_IP_ADDRESS_TYPE_IPV6; + GuestIpAddressType_ipv6; } } if (head_addr) { diff --git a/qmp.c b/qmp.c index ff54e5a..6982d2e 100644 --- a/qmp.c +++ b/qmp.c @@ -102,10 +102,10 @@ void qmp_quit(Error **errp) void qmp_stop(Error **errp) { - if (runstate_check(RUN_STATE_INMIGRATE)) { + if (runstate_check(RunState_inmigrate)) { autostart = 0; } else { - vm_stop(RUN_STATE_PAUSED); + vm_stop(RunState_paused); } } @@ -177,7 +177,7 @@ void qmp_cont(Error **errp) if (runstate_needs_reset()) { error_setg(errp, "Resetting the Virtual Machine is required"); return; - } else if (runstate_check(RUN_STATE_SUSPENDED)) { + } else if (runstate_check(RunState_suspended)) { return; } @@ -192,7 +192,7 @@ void qmp_cont(Error **errp) } } - if (runstate_check(RUN_STATE_INMIGRATE)) { + if (runstate_check(RunState_inmigrate)) { autostart = 1; } else { vm_start(); @@ -216,7 +216,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) if (ambiguous) { error_setg(errp, "Path '%s' is ambiguous", path); } else { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", path); } return NULL; @@ -243,7 +243,7 @@ void qmp_qom_set(const char *path, const char *property, QObject *value, obj = object_resolve_path(path, NULL); if (!obj) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", path); return; } @@ -257,7 +257,7 @@ QObject *qmp_qom_get(const char *path, const char *property, Error **errp) obj = object_resolve_path(path, NULL); if (!obj) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", path); return NULL; } @@ -506,7 +506,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, klass = object_class_by_name(typename); if (klass == NULL) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", typename); return NULL; } diff --git a/qom/object.c b/qom/object.c index 11cd86b..9aa4f41 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1018,7 +1018,7 @@ Object *object_property_get_link(Object *obj, const char *name, if (str && *str) { target = object_resolve_path(str, NULL); if (!target) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", str); } } @@ -1330,14 +1330,14 @@ static Object *object_resolve_link(Object *obj, const char *name, target = object_resolve_path_type(path, target_type, &ambiguous); if (ambiguous) { - error_set(errp, ERROR_CLASS_GENERIC_ERROR, + error_set(errp, ErrorClass_GenericError, "Path '%s' does not uniquely identify an object", path); } else if (!target) { target = object_resolve_path(path, &ambiguous); if (target || ambiguous) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type); } else { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", path); } target = NULL; diff --git a/scripts/qapi.py b/scripts/qapi.py index 843e364..8e935d7 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -548,8 +548,8 @@ def check_union(expr, expr_info): base = expr.get('base') discriminator = expr.get('discriminator') members = expr['data'] - values = {'MAX': '(automatic)', 'KIND': '(automatic)', - 'TYPE': '(automatic)'} + values = {'MAX': '(automatic)', 'kind': '(automatic)', + 'type': '(automatic)'} # Two types of unions, determined by discriminator. @@ -623,7 +623,7 @@ def check_union(expr, expr_info): # Otherwise, check for conflicts in the generated enum else: - c_key = camel_to_upper(key) + c_key = c_name(key) if c_key in values: raise QAPIExprError(expr_info, "Union '%s' member '%s' clashes with '%s'" @@ -642,7 +642,7 @@ def check_alternate(expr, expr_info): check_name(expr_info, "Member of alternate '%s'" % name, key) # Check for conflicts in the generated enum - c_key = camel_to_upper(key) + c_key = c_name(key) if c_key in values: raise QAPIExprError(expr_info, "Alternate '%s' member '%s' clashes with '%s'" @@ -678,7 +678,7 @@ def check_enum(expr, expr_info): for member in members: check_name(expr_info, "Member of enum '%s'" % name, member, enum_member=True) - key = camel_to_upper(member) + key = c_name(member) if key in values: raise QAPIExprError(expr_info, "Enum '%s' member '%s' clashes with '%s'" @@ -1362,46 +1362,10 @@ class QAPISchema(object): # Code generation helpers # -def camel_case(name): - new_name = '' - first = True - for ch in name: - if ch in ['_', '-']: - first = True - elif first: - new_name += ch.upper() - first = False - else: - new_name += ch.lower() - return new_name - - -# ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1 -# ENUM_NAME -> ENUM_NAME, ENUM_NAME1 -> ENUM_NAME1, ENUM_Name2 -> ENUM_NAME2 -# ENUM24_Name -> ENUM24_NAME -def camel_to_upper(value): - c_fun_str = c_name(value, False) - if value.isupper(): - return c_fun_str - - new_name = '' - l = len(c_fun_str) - for i in range(l): - c = c_fun_str[i] - # When c is upper and no "_" appears before, do more checks - if c.isupper() and (i > 0) and c_fun_str[i - 1] != "_": - if i < l - 1 and c_fun_str[i + 1].islower(): - new_name += '_' - elif c_fun_str[i - 1].isdigit(): - new_name += '_' - new_name += c - return new_name.lstrip('_').upper() - - def c_enum_const(type_name, const_name, prefix=None): if prefix is not None: type_name = prefix - return camel_to_upper(type_name + '_' + const_name) + return c_name(type_name + '_' + const_name) c_name_trans = string.maketrans('.-', '__') diff --git a/spice-qemu-char.c b/spice-qemu-char.c index e70e0f7..b8dea83 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -381,9 +381,9 @@ static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend, static void register_types(void) { - register_char_driver("spicevmc", CHARDEV_BACKEND_KIND_SPICEVMC, + register_char_driver("spicevmc", ChardevBackendKind_spicevmc, qemu_chr_parse_spice_vmc, qemu_chr_open_spice_vmc); - register_char_driver("spiceport", CHARDEV_BACKEND_KIND_SPICEPORT, + register_char_driver("spiceport", ChardevBackendKind_spiceport, qemu_chr_parse_spice_port, qemu_chr_open_spice_port); } diff --git a/stubs/runstate-check.c b/stubs/runstate-check.c index bd2e375..efc02ab 100644 --- a/stubs/runstate-check.c +++ b/stubs/runstate-check.c @@ -2,5 +2,5 @@ bool runstate_check(RunState state) { - return state == RUN_STATE_PRELAUNCH; + return state == RunState_prelaunch; } diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 9280bfc..5e4f8e3 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -436,7 +436,7 @@ typedef struct X86RegisterInfo32 { } X86RegisterInfo32; #define REGISTER(reg) \ - [R_##reg] = { .name = #reg, .qapi_enum = X86_CPU_REGISTER32_##reg } + [R_##reg] = { .name = #reg, .qapi_enum = X86CPURegister32_##reg } static const X86RegisterInfo32 x86_reg_info_32[CPU_NB_REGS32] = { REGISTER(EAX), REGISTER(ECX), diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c index 61209c1..afe9de1 100644 --- a/target-lm32/op_helper.c +++ b/target-lm32/op_helper.c @@ -42,7 +42,7 @@ void HELPER(ill)(CPULM32State *env) fprintf(stderr, "VM paused due to illegal instruction. " "Connect a debugger or switch to the monitor console " "to find out more.\n"); - vm_stop(RUN_STATE_PAUSED); + vm_stop(RunState_paused); cs->halted = 1; raise_exception(env, EXCP_HALTED); #endif diff --git a/tests/qapi-schema/enum-clash-member.err b/tests/qapi-schema/enum-clash-member.err index 48bd136..d012611 100644 --- a/tests/qapi-schema/enum-clash-member.err +++ b/tests/qapi-schema/enum-clash-member.err @@ -1 +1 @@ -tests/qapi-schema/enum-clash-member.json:2: Enum 'MyEnum' member 'ONE' clashes with 'one' +tests/qapi-schema/enum-clash-member.json:2: Enum 'MyEnum' member 'a_b' clashes with 'a-b' diff --git a/tests/qapi-schema/enum-clash-member.json b/tests/qapi-schema/enum-clash-member.json index b7dc02a..7342991 100644 --- a/tests/qapi-schema/enum-clash-member.json +++ b/tests/qapi-schema/enum-clash-member.json @@ -1,2 +1,2 @@ # we reject enums where members will clash when mapped to C enum -{ 'enum': 'MyEnum', 'data': [ 'one', 'ONE' ] } +{ 'enum': 'MyEnum', 'data': [ 'a-b', 'a_b' ] } diff --git a/tests/qapi-schema/enum-max-member.err b/tests/qapi-schema/enum-max-member.err index f77837f..06468f3 100644 --- a/tests/qapi-schema/enum-max-member.err +++ b/tests/qapi-schema/enum-max-member.err @@ -1 +1 @@ -tests/qapi-schema/enum-max-member.json:3: Enum 'MyEnum' member 'max' clashes with '(automatic)' +tests/qapi-schema/enum-max-member.json:3: Enum 'MyEnum' member 'MAX' clashes with '(automatic)' diff --git a/tests/qapi-schema/enum-max-member.json b/tests/qapi-schema/enum-max-member.json index 4bcda0b..9b16e39 100644 --- a/tests/qapi-schema/enum-max-member.json +++ b/tests/qapi-schema/enum-max-member.json @@ -1,3 +1,3 @@ -# we reject user-supplied 'max' for clashing with implicit enum end +# we reject user-supplied 'MAX' for clashing with implicit enum end # TODO: should we instead munge the implicit value to avoid the clash? -{ 'enum': 'MyEnum', 'data': [ 'max' ] } +{ 'enum': 'MyEnum', 'data': [ 'MAX' ] } diff --git a/tests/qapi-schema/union-bad-branch.err b/tests/qapi-schema/union-bad-branch.err index 8822735..923aa51 100644 --- a/tests/qapi-schema/union-bad-branch.err +++ b/tests/qapi-schema/union-bad-branch.err @@ -1 +1 @@ -tests/qapi-schema/union-bad-branch.json:6: Union 'MyUnion' member 'ONE' clashes with 'one' +tests/qapi-schema/union-bad-branch.json:6: Union 'MyUnion' member 'a_b' clashes with 'a-b' diff --git a/tests/qapi-schema/union-bad-branch.json b/tests/qapi-schema/union-bad-branch.json index 913aa38..615dee5 100644 --- a/tests/qapi-schema/union-bad-branch.json +++ b/tests/qapi-schema/union-bad-branch.json @@ -4,5 +4,5 @@ { 'struct': 'Two', 'data': { 'number': 'int' } } { 'union': 'MyUnion', - 'data': { 'one': 'One', - 'ONE': 'Two' } } + 'data': { 'a-b': 'One', + 'a_b': 'Two' } } diff --git a/tests/qapi-schema/union-max.err b/tests/qapi-schema/union-max.err index 55ce439..d4f28e7 100644 --- a/tests/qapi-schema/union-max.err +++ b/tests/qapi-schema/union-max.err @@ -1 +1 @@ -tests/qapi-schema/union-max.json:2: Union 'Union' member 'max' clashes with '(automatic)' +tests/qapi-schema/union-max.json:2: Union 'Union' member 'MAX' clashes with '(automatic)' diff --git a/tests/qapi-schema/union-max.json b/tests/qapi-schema/union-max.json index d6ad986..989030e 100644 --- a/tests/qapi-schema/union-max.json +++ b/tests/qapi-schema/union-max.json @@ -1,3 +1,3 @@ # we reject 'max' branch in a union, for collision with C enum { 'union': 'Union', - 'data': { 'max': 'int' } } + 'data': { 'MAX': 'int' } } diff --git a/tests/test-crypto-tlscredsx509.c b/tests/test-crypto-tlscredsx509.c index c70aa55..a1e2d51 100644 --- a/tests/test-crypto-tlscredsx509.c +++ b/tests/test-crypto-tlscredsx509.c @@ -48,7 +48,7 @@ static QCryptoTLSCreds *test_tls_creds_create(QCryptoTLSCredsEndpoint endpoint, parent, "testtlscreds", errp, - "endpoint", (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ? + "endpoint", (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server ? "server" : "client"), "dir", certdir, "verify-peer", "yes", @@ -111,8 +111,8 @@ static void test_tls_creds(const void *opaque) creds = test_tls_creds_create( (data->isServer ? - QCRYPTO_TLS_CREDS_ENDPOINT_SERVER : - QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT), + QCRYPTO_TLS_CREDS_ENDPOINT_server : + QCRYPTO_TLS_CREDS_ENDPOINT_client), CERT_DIR, &err); diff --git a/tests/test-crypto-tlssession.c b/tests/test-crypto-tlssession.c index 4524128..4620086 100644 --- a/tests/test-crypto-tlssession.c +++ b/tests/test-crypto-tlssession.c @@ -69,10 +69,10 @@ static QCryptoTLSCreds *test_tls_creds_create(QCryptoTLSCredsEndpoint endpoint, Object *creds = object_new_with_props( TYPE_QCRYPTO_TLS_CREDS_X509, parent, - (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ? + (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server ? "testtlscredsserver" : "testtlscredsclient"), &err, - "endpoint", (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ? + "endpoint", (endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_server ? "server" : "client"), "dir", certdir, "verify-peer", "yes", @@ -160,13 +160,13 @@ static void test_crypto_tls_session(const void *opaque) CLIENT_CERT_DIR QCRYPTO_TLS_CREDS_X509_CLIENT_KEY) == 0); clientCreds = test_tls_creds_create( - QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT, + QCRYPTO_TLS_CREDS_ENDPOINT_client, CLIENT_CERT_DIR, &err); g_assert(clientCreds != NULL); serverCreds = test_tls_creds_create( - QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, + QCRYPTO_TLS_CREDS_ENDPOINT_server, SERVER_CERT_DIR, &err); g_assert(serverCreds != NULL); @@ -182,11 +182,11 @@ static void test_crypto_tls_session(const void *opaque) /* Now the real part of the test, setup the sessions */ clientSess = qcrypto_tls_session_new( clientCreds, data->hostname, NULL, - QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT, &err); + QCRYPTO_TLS_CREDS_ENDPOINT_client, &err); serverSess = qcrypto_tls_session_new( serverCreds, NULL, data->wildcards ? "tlssessionacl" : NULL, - QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, &err); + QCRYPTO_TLS_CREDS_ENDPOINT_server, &err); g_assert(clientSess != NULL); g_assert(serverSess != NULL); diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index f23d8ea..af5984e 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -62,7 +62,7 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, { __org_qemu_x_Union1 *ret = g_new0(__org_qemu_x_Union1, 1); - ret->type = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; + ret->type = __org_qemu_x_Union1Kind___org_qemu_x_branch; ret->u.__org_qemu_x_branch = strdup("blah1"); return ret; diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 035c65c..394938b 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -212,12 +212,12 @@ static void test_event_d(TestEventData *data, struct1.integer = 2; struct1.string = g_strdup("test1"); struct1.has_enum1 = true; - struct1.enum1 = ENUM_ONE_VALUE1; + struct1.enum1 = EnumOne_value1; a.struct1 = &struct1; a.string = g_strdup("test2"); a.has_enum2 = true; - a.enum2 = ENUM_ONE_VALUE2; + a.enum2 = EnumOne_value2; d_struct1 = qdict_new(); qdict_put(d_struct1, "integer", qint_from_int(2)); @@ -238,7 +238,7 @@ static void test_event_d(TestEventData *data, qdict_put(d, "event", qstring_from_str("EVENT_D")); qdict_put(d, "data", d_data); - qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3, + qapi_event_send_event_d(&a, "test3", false, NULL, true, EnumOne_value3, &error_abort); g_free(struct1.string); diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index e9a66a7..86b825f 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -298,7 +298,7 @@ static void test_visitor_in_union_flat(TestInputVisitorData *data, "'boolean': true }"); visit_type_UserDefFlatUnion(v, &tmp, NULL, &error_abort); - g_assert_cmpint(tmp->enum1, ==, ENUM_ONE_VALUE1); + g_assert_cmpint(tmp->enum1, ==, EnumOne_value1); g_assert_cmpstr(tmp->string, ==, "str"); g_assert_cmpint(tmp->integer, ==, 41); g_assert_cmpint(tmp->u.value1->boolean, ==, true); @@ -317,13 +317,13 @@ static void test_visitor_in_alternate(TestInputVisitorData *data, v = visitor_input_test_init(data, "42"); visit_type_UserDefAlternate(v, &tmp, NULL, &error_abort); - g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_I); + g_assert_cmpint(tmp->type, ==, UserDefAlternateKind_i); g_assert_cmpint(tmp->u.i, ==, 42); qapi_free_UserDefAlternate(tmp); v = visitor_input_test_init(data, "'string'"); visit_type_UserDefAlternate(v, &tmp, NULL, &error_abort); - g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_S); + g_assert_cmpint(tmp->type, ==, UserDefAlternateKind_s); g_assert_cmpstr(tmp->u.s, ==, "string"); qapi_free_UserDefAlternate(tmp); @@ -355,32 +355,32 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, * parse the same as ans */ v = visitor_input_test_init(data, "42"); visit_type_AltStrNum(v, &asn, NULL, &data->err); - /* FIXME g_assert_cmpint(asn->type, == ALT_STR_NUM_KIND_N); */ + /* FIXME g_assert_cmpint(asn->type, == AltStrNumKind_n); */ /* FIXME g_assert_cmpfloat(asn->u.n, ==, 42); */ g_assert(data->err); qapi_free_AltStrNum(asn); v = visitor_input_test_init(data, "42"); visit_type_AltNumStr(v, &ans, NULL, &error_abort); - g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N); + g_assert_cmpint(ans->type, ==, AltNumStrKind_n); g_assert_cmpfloat(ans->u.n, ==, 42); qapi_free_AltNumStr(ans); v = visitor_input_test_init(data, "42"); visit_type_AltStrInt(v, &asi, NULL, &error_abort); - g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I); + g_assert_cmpint(asi->type, ==, AltStrIntKind_i); g_assert_cmpint(asi->u.i, ==, 42); qapi_free_AltStrInt(asi); v = visitor_input_test_init(data, "42"); visit_type_AltIntNum(v, &ain, NULL, &error_abort); - g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I); + g_assert_cmpint(ain->type, ==, AltIntNumKind_i); g_assert_cmpint(ain->u.i, ==, 42); qapi_free_AltIntNum(ain); v = visitor_input_test_init(data, "42"); visit_type_AltNumInt(v, &ani, NULL, &error_abort); - g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I); + g_assert_cmpint(ani->type, ==, AltNumIntKind_i); g_assert_cmpint(ani->u.i, ==, 42); qapi_free_AltNumInt(ani); @@ -393,13 +393,13 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, v = visitor_input_test_init(data, "42.5"); visit_type_AltStrNum(v, &asn, NULL, &error_abort); - g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N); + g_assert_cmpint(asn->type, ==, AltStrNumKind_n); g_assert_cmpfloat(asn->u.n, ==, 42.5); qapi_free_AltStrNum(asn); v = visitor_input_test_init(data, "42.5"); visit_type_AltNumStr(v, &ans, NULL, &error_abort); - g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N); + g_assert_cmpint(ans->type, ==, AltNumStrKind_n); g_assert_cmpfloat(ans->u.n, ==, 42.5); qapi_free_AltNumStr(ans); @@ -410,13 +410,13 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, v = visitor_input_test_init(data, "42.5"); visit_type_AltIntNum(v, &ain, NULL, &error_abort); - g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N); + g_assert_cmpint(ain->type, ==, AltIntNumKind_n); g_assert_cmpfloat(ain->u.n, ==, 42.5); qapi_free_AltIntNum(ain); v = visitor_input_test_init(data, "42.5"); visit_type_AltNumInt(v, &ani, NULL, &error_abort); - g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N); + g_assert_cmpint(ani->type, ==, AltNumIntKind_n); g_assert_cmpfloat(ani->u.n, ==, 42.5); qapi_free_AltNumInt(ani); } @@ -447,63 +447,63 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, g_assert_cmpint(cvalue->type, ==, kind); switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { + case UserDefNativeListUnionKind_integer: { intList *elem = NULL; for (i = 0, elem = cvalue->u.integer; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: { + case UserDefNativeListUnionKind_s8: { int8List *elem = NULL; for (i = 0, elem = cvalue->u.s8; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: { + case UserDefNativeListUnionKind_s16: { int16List *elem = NULL; for (i = 0, elem = cvalue->u.s16; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: { + case UserDefNativeListUnionKind_s32: { int32List *elem = NULL; for (i = 0, elem = cvalue->u.s32; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: { + case UserDefNativeListUnionKind_s64: { int64List *elem = NULL; for (i = 0, elem = cvalue->u.s64; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: { + case UserDefNativeListUnionKind_u8: { uint8List *elem = NULL; for (i = 0, elem = cvalue->u.u8; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: { + case UserDefNativeListUnionKind_u16: { uint16List *elem = NULL; for (i = 0, elem = cvalue->u.u16; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: { + case UserDefNativeListUnionKind_u32: { uint32List *elem = NULL; for (i = 0, elem = cvalue->u.u32; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: { + case UserDefNativeListUnionKind_u64: { uint64List *elem = NULL; for (i = 0, elem = cvalue->u.u64; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, i); @@ -523,63 +523,63 @@ static void test_visitor_in_native_list_int(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); + UserDefNativeListUnionKind_integer); } static void test_visitor_in_native_list_int8(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S8); + UserDefNativeListUnionKind_s8); } static void test_visitor_in_native_list_int16(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S16); + UserDefNativeListUnionKind_s16); } static void test_visitor_in_native_list_int32(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S32); + UserDefNativeListUnionKind_s32); } static void test_visitor_in_native_list_int64(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_S64); + UserDefNativeListUnionKind_s64); } static void test_visitor_in_native_list_uint8(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U8); + UserDefNativeListUnionKind_u8); } static void test_visitor_in_native_list_uint16(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U16); + UserDefNativeListUnionKind_u16); } static void test_visitor_in_native_list_uint32(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U32); + UserDefNativeListUnionKind_u32); } static void test_visitor_in_native_list_uint64(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, - USER_DEF_NATIVE_LIST_UNION_KIND_U64); + UserDefNativeListUnionKind_u64); } static void test_visitor_in_native_list_bool(TestInputVisitorData *data, @@ -605,7 +605,7 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + g_assert_cmpint(cvalue->type, ==, UserDefNativeListUnionKind_boolean); for (i = 0, elem = cvalue->u.boolean; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); @@ -638,7 +638,7 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + g_assert_cmpint(cvalue->type, ==, UserDefNativeListUnionKind_string); for (i = 0, elem = cvalue->u.string; elem; elem = elem->next, i++) { gchar str[8]; @@ -675,7 +675,7 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &error_abort); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + g_assert_cmpint(cvalue->type, ==, UserDefNativeListUnionKind_number); for (i = 0, elem = cvalue->u.number; elem; elem = elem->next, i++) { GString *double_expected = g_string_new(""); diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 0d0c859..bd33977 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -128,7 +128,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, QObject *obj; EnumOne i; - for (i = 0; i < ENUM_ONE_MAX; i++) { + for (i = 0; i < EnumOne_MAX; i++) { visit_type_EnumOne(data->ov, &i, "unused", &error_abort); obj = qmp_output_get_qobject(data->qov); @@ -143,7 +143,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, static void test_visitor_out_enum_errors(TestOutputVisitorData *data, const void *unused) { - EnumOne i, bad_values[] = { ENUM_ONE_MAX, -1 }; + EnumOne i, bad_values[] = { EnumOne_MAX, -1 }; Error *err; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { @@ -247,7 +247,7 @@ static void test_visitor_out_struct_nested(TestOutputVisitorData *data, static void test_visitor_out_struct_errors(TestOutputVisitorData *data, const void *unused) { - EnumOne bad_values[] = { ENUM_ONE_MAX, -1 }; + EnumOne bad_values[] = { EnumOne_MAX, -1 }; UserDefOne u = {0}; UserDefOne *pu = &u; Error *err; @@ -400,7 +400,7 @@ static void test_visitor_out_union_flat(TestOutputVisitorData *data, QDict *qdict; UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion)); - tmp->enum1 = ENUM_ONE_VALUE1; + tmp->enum1 = EnumOne_value1; tmp->string = g_strdup("str"); tmp->u.value1 = g_malloc0(sizeof(UserDefA)); tmp->integer = 41; @@ -428,7 +428,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data, UserDefAlternate *tmp; tmp = g_new0(UserDefAlternate, 1); - tmp->type = USER_DEF_ALTERNATE_KIND_I; + tmp->type = UserDefAlternateKind_i; tmp->u.i = 42; visit_type_UserDefAlternate(data->ov, &tmp, NULL, &error_abort); @@ -441,7 +441,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data, qobject_decref(arg); tmp = g_new0(UserDefAlternate, 1); - tmp->type = USER_DEF_ALTERNATE_KIND_S; + tmp->type = UserDefAlternateKind_s; tmp->u.s = g_strdup("hello"); visit_type_UserDefAlternate(data->ov, &tmp, NULL, &error_abort); @@ -468,7 +468,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) { int i; switch (cvalue->type) { - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { + case UserDefNativeListUnionKind_integer: { intList **list = &cvalue->u.integer; for (i = 0; i < 32; i++) { *list = g_new0(intList, 1); @@ -478,7 +478,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: { + case UserDefNativeListUnionKind_s8: { int8List **list = &cvalue->u.s8; for (i = 0; i < 32; i++) { *list = g_new0(int8List, 1); @@ -488,7 +488,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: { + case UserDefNativeListUnionKind_s16: { int16List **list = &cvalue->u.s16; for (i = 0; i < 32; i++) { *list = g_new0(int16List, 1); @@ -498,7 +498,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: { + case UserDefNativeListUnionKind_s32: { int32List **list = &cvalue->u.s32; for (i = 0; i < 32; i++) { *list = g_new0(int32List, 1); @@ -508,7 +508,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: { + case UserDefNativeListUnionKind_s64: { int64List **list = &cvalue->u.s64; for (i = 0; i < 32; i++) { *list = g_new0(int64List, 1); @@ -518,7 +518,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: { + case UserDefNativeListUnionKind_u8: { uint8List **list = &cvalue->u.u8; for (i = 0; i < 32; i++) { *list = g_new0(uint8List, 1); @@ -528,7 +528,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: { + case UserDefNativeListUnionKind_u16: { uint16List **list = &cvalue->u.u16; for (i = 0; i < 32; i++) { *list = g_new0(uint16List, 1); @@ -538,7 +538,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: { + case UserDefNativeListUnionKind_u32: { uint32List **list = &cvalue->u.u32; for (i = 0; i < 32; i++) { *list = g_new0(uint32List, 1); @@ -548,7 +548,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: { + case UserDefNativeListUnionKind_u64: { uint64List **list = &cvalue->u.u64; for (i = 0; i < 32; i++) { *list = g_new0(uint64List, 1); @@ -558,7 +558,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: { + case UserDefNativeListUnionKind_boolean: { boolList **list = &cvalue->u.boolean; for (i = 0; i < 32; i++) { *list = g_new0(boolList, 1); @@ -568,7 +568,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: { + case UserDefNativeListUnionKind_string: { strList **list = &cvalue->u.string; for (i = 0; i < 32; i++) { *list = g_new0(strList, 1); @@ -578,7 +578,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) } break; } - case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: { + case UserDefNativeListUnionKind_number: { numberList **list = &cvalue->u.number; for (i = 0; i < 32; i++) { *list = g_new0(numberList, 1); @@ -608,19 +608,19 @@ static void check_native_list(QObject *qobj, qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data"))); switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: - case USER_DEF_NATIVE_LIST_UNION_KIND_U8: - case USER_DEF_NATIVE_LIST_UNION_KIND_U16: - case USER_DEF_NATIVE_LIST_UNION_KIND_U32: - case USER_DEF_NATIVE_LIST_UNION_KIND_U64: + case UserDefNativeListUnionKind_s8: + case UserDefNativeListUnionKind_s16: + case UserDefNativeListUnionKind_s32: + case UserDefNativeListUnionKind_s64: + case UserDefNativeListUnionKind_u8: + case UserDefNativeListUnionKind_u16: + case UserDefNativeListUnionKind_u32: + case UserDefNativeListUnionKind_u64: /* all integer elements in JSON arrays get stored into QInts when * we convert to QObjects, so we can check them all in the same * fashion, so simply fall through here */ - case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: + case UserDefNativeListUnionKind_integer: for (i = 0; i < 32; i++) { QObject *tmp; QInt *qvalue; @@ -631,7 +631,7 @@ static void check_native_list(QObject *qobj, qobject_decref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN: + case UserDefNativeListUnionKind_boolean: for (i = 0; i < 32; i++) { QObject *tmp; QBool *qvalue; @@ -642,7 +642,7 @@ static void check_native_list(QObject *qobj, qobject_decref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_STRING: + case UserDefNativeListUnionKind_string: for (i = 0; i < 32; i++) { QObject *tmp; QString *qvalue; @@ -655,7 +655,7 @@ static void check_native_list(QObject *qobj, qobject_decref(qlist_pop(qlist)); } break; - case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: + case UserDefNativeListUnionKind_number: for (i = 0; i < 32; i++) { QObject *tmp; QFloat *qvalue; @@ -701,73 +701,73 @@ static void test_native_list(TestOutputVisitorData *data, static void test_visitor_out_native_list_int(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER); + test_native_list(data, unused, UserDefNativeListUnionKind_integer); } static void test_visitor_out_native_list_int8(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S8); + test_native_list(data, unused, UserDefNativeListUnionKind_s8); } static void test_visitor_out_native_list_int16(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S16); + test_native_list(data, unused, UserDefNativeListUnionKind_s16); } static void test_visitor_out_native_list_int32(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S32); + test_native_list(data, unused, UserDefNativeListUnionKind_s32); } static void test_visitor_out_native_list_int64(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S64); + test_native_list(data, unused, UserDefNativeListUnionKind_s64); } static void test_visitor_out_native_list_uint8(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U8); + test_native_list(data, unused, UserDefNativeListUnionKind_u8); } static void test_visitor_out_native_list_uint16(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U16); + test_native_list(data, unused, UserDefNativeListUnionKind_u16); } static void test_visitor_out_native_list_uint32(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U32); + test_native_list(data, unused, UserDefNativeListUnionKind_u32); } static void test_visitor_out_native_list_uint64(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_U64); + test_native_list(data, unused, UserDefNativeListUnionKind_u64); } static void test_visitor_out_native_list_bool(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + test_native_list(data, unused, UserDefNativeListUnionKind_boolean); } static void test_visitor_out_native_list_str(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + test_native_list(data, unused, UserDefNativeListUnionKind_string); } static void test_visitor_out_native_list_number(TestOutputVisitorData *data, const void *unused) { - test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + test_native_list(data, unused, UserDefNativeListUnionKind_number); } static void output_visitor_test_add(const char *testpath, diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c index fd5e67b..66a31ba 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -194,7 +194,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, char *str; EnumOne i; - for (i = 0; i < ENUM_ONE_MAX; i++) { + for (i = 0; i < EnumOne_MAX; i++) { char *str_human; visit_type_EnumOne(data->ov, &i, "unused", &err); @@ -217,7 +217,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data, static void test_visitor_out_enum_errors(TestOutputVisitorData *data, const void *unused) { - EnumOne i, bad_values[] = { ENUM_ONE_MAX, -1 }; + EnumOne i, bad_values[] = { EnumOne_MAX, -1 }; Error *err; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { diff --git a/tpm.c b/tpm.c index f2c59d1..1c77712 100644 --- a/tpm.c +++ b/tpm.c @@ -32,7 +32,7 @@ static TPMDriverOps const *be_drivers[TPM_MAX_DRIVERS] = { }; static enum TpmModel tpm_models[TPM_MAX_MODELS] = { - TPM_MODEL_MAX, + TpmModel_MAX, }; int tpm_register_model(enum TpmModel model) @@ -40,7 +40,7 @@ int tpm_register_model(enum TpmModel model) int i; for (i = 0; i < TPM_MAX_MODELS; i++) { - if (tpm_models[i] == TPM_MODEL_MAX) { + if (tpm_models[i] == TpmModel_MAX) { tpm_models[i] = model; return 0; } @@ -259,8 +259,8 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) res->options = g_new0(TpmTypeOptions, 1); switch (drv->ops->type) { - case TPM_TYPE_PASSTHROUGH: - res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; + case TpmType_passthrough: + res->options->type = TpmTypeOptionsKind_passthrough; tpo = g_new0(TPMPassthroughOptions, 1); res->options->u.passthrough = tpo; if (drv->path) { @@ -272,7 +272,7 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) tpo->has_cancel_path = true; } break; - case TPM_TYPE_MAX: + case TpmType_MAX: break; } @@ -311,7 +311,7 @@ TpmTypeList *qmp_query_tpm_types(Error **errp) unsigned int i = 0; TpmTypeList *head = NULL, *prev = NULL, *cur_item; - for (i = 0; i < TPM_TYPE_MAX; i++) { + for (i = 0; i < TpmType_MAX; i++) { if (!tpm_driver_find_by_type(i)) { continue; } @@ -335,7 +335,7 @@ TpmModelList *qmp_query_tpm_models(Error **errp) unsigned int i = 0; TpmModelList *head = NULL, *prev = NULL, *cur_item; - for (i = 0; i < TPM_MODEL_MAX; i++) { + for (i = 0; i < TpmModel_MAX; i++) { if (!tpm_model_is_registered(i)) { continue; } diff --git a/trace/qmp.c b/trace/qmp.c index 0b19489..9b836b5 100644 --- a/trace/qmp.c +++ b/trace/qmp.c @@ -24,11 +24,11 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name, Error **errp) elem->value = g_new(TraceEventInfo, 1); elem->value->name = g_strdup(trace_event_get_name(ev)); if (!trace_event_get_state_static(ev)) { - elem->value->state = TRACE_EVENT_STATE_UNAVAILABLE; + elem->value->state = TraceEventState_unavailable; } else if (!trace_event_get_state_dynamic(ev)) { - elem->value->state = TRACE_EVENT_STATE_DISABLED; + elem->value->state = TraceEventState_disabled; } else { - elem->value->state = TRACE_EVENT_STATE_ENABLED; + elem->value->state = TraceEventState_enabled; } elem->next = events; events = elem; diff --git a/ui/cocoa.m b/ui/cocoa.m index c0d6bb2..8830e78 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -725,12 +725,12 @@ QemuCocoaView *cocoaView; if (mouse_event) { if (last_buttons != buttons) { - static uint32_t bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, - [INPUT_BUTTON_WHEEL_UP] = MOUSE_EVENT_WHEELUP, - [INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN, + static uint32_t bmap[InputButton_MAX] = { + [InputButton_Left] = MOUSE_EVENT_LBUTTON, + [InputButton_Middle] = MOUSE_EVENT_MBUTTON, + [InputButton_Right] = MOUSE_EVENT_RBUTTON, + [InputButton_WheelUp] = MOUSE_EVENT_WHEELUP, + [InputButton_WheelDown] = MOUSE_EVENT_WHEELDN, }; qemu_input_update_buttons(dcl->con, bmap, last_buttons, buttons); last_buttons = buttons; @@ -742,12 +742,12 @@ QemuCocoaView *cocoaView; * clicks in the titlebar. */ if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, p.x, screen.width); - qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, screen.height - p.y, screen.height); + qemu_input_queue_abs(dcl->con, InputAxis_X, p.x, screen.width); + qemu_input_queue_abs(dcl->con, InputAxis_Y, screen.height - p.y, screen.height); } } else { - qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, (int)[event deltaX]); - qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, (int)[event deltaY]); + qemu_input_queue_rel(dcl->con, InputAxis_X, (int)[event deltaX]); + qemu_input_queue_rel(dcl->con, InputAxis_Y, (int)[event deltaY]); } } else { [NSApp sendEvent:event]; diff --git a/ui/console.c b/ui/console.c index f26544e..e183e46 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1108,16 +1108,16 @@ void kbd_put_keysym_console(QemuConsole *s, int keysym) } } -static const int qcode_to_keysym[Q_KEY_CODE_MAX] = { - [Q_KEY_CODE_UP] = QEMU_KEY_UP, - [Q_KEY_CODE_DOWN] = QEMU_KEY_DOWN, - [Q_KEY_CODE_RIGHT] = QEMU_KEY_RIGHT, - [Q_KEY_CODE_LEFT] = QEMU_KEY_LEFT, - [Q_KEY_CODE_HOME] = QEMU_KEY_HOME, - [Q_KEY_CODE_END] = QEMU_KEY_END, - [Q_KEY_CODE_PGUP] = QEMU_KEY_PAGEUP, - [Q_KEY_CODE_PGDN] = QEMU_KEY_PAGEDOWN, - [Q_KEY_CODE_DELETE] = QEMU_KEY_DELETE, +static const int qcode_to_keysym[QKeyCode_MAX] = { + [QKeyCode_up] = QEMU_KEY_UP, + [QKeyCode_down] = QEMU_KEY_DOWN, + [QKeyCode_right] = QEMU_KEY_RIGHT, + [QKeyCode_left] = QEMU_KEY_LEFT, + [QKeyCode_home] = QEMU_KEY_HOME, + [QKeyCode_end] = QEMU_KEY_END, + [QKeyCode_pgup] = QEMU_KEY_PAGEUP, + [QKeyCode_pgdn] = QEMU_KEY_PAGEDOWN, + [QKeyCode_delete] = QEMU_KEY_DELETE, }; bool kbd_put_qcode_console(QemuConsole *s, int qcode) @@ -2095,7 +2095,7 @@ static const TypeInfo qemu_console_info = { static void register_types(void) { type_register_static(&qemu_console_info); - register_char_driver("vc", CHARDEV_BACKEND_KIND_VC, qemu_chr_parse_vc, + register_char_driver("vc", ChardevBackendKind_vc, qemu_chr_parse_vc, vc_init); } diff --git a/ui/gtk.c b/ui/gtk.c index 47b37e1..556af4b 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -869,14 +869,14 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, y >= surface_height(vc->gfx.ds)) { return TRUE; } - qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_X, x, + qemu_input_queue_abs(vc->gfx.dcl.con, InputAxis_X, x, surface_width(vc->gfx.ds)); - qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_Y, y, + qemu_input_queue_abs(vc->gfx.dcl.con, InputAxis_Y, y, surface_height(vc->gfx.ds)); qemu_input_event_sync(); } else if (s->last_set && s->ptr_owner == vc) { - qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, x - s->last_x); - qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_Y, y - s->last_y); + qemu_input_queue_rel(vc->gfx.dcl.con, InputAxis_X, x - s->last_x); + qemu_input_queue_rel(vc->gfx.dcl.con, InputAxis_Y, y - s->last_y); qemu_input_event_sync(); } s->last_x = x; @@ -943,11 +943,11 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button, } if (button->button == 1) { - btn = INPUT_BUTTON_LEFT; + btn = InputButton_Left; } else if (button->button == 2) { - btn = INPUT_BUTTON_MIDDLE; + btn = InputButton_Middle; } else if (button->button == 3) { - btn = INPUT_BUTTON_RIGHT; + btn = InputButton_Right; } else { return TRUE; } @@ -965,9 +965,9 @@ static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll, InputButton btn; if (scroll->direction == GDK_SCROLL_UP) { - btn = INPUT_BUTTON_WHEEL_UP; + btn = InputButton_WheelUp; } else if (scroll->direction == GDK_SCROLL_DOWN) { - btn = INPUT_BUTTON_WHEEL_DOWN; + btn = InputButton_WheelDown; } else { return TRUE; } @@ -1049,7 +1049,7 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) } if (key->keyval == GDK_KEY_Pause) { - qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE, + qemu_input_event_send_key_qcode(vc->gfx.dcl.con, QKeyCode_pause, key->type == GDK_KEY_PRESS); return TRUE; } diff --git a/ui/input-keymap.c b/ui/input-keymap.c index d36be4b..624df17 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -3,146 +3,146 @@ #include "ui/input.h" static const int qcode_to_number[] = { - [Q_KEY_CODE_SHIFT] = 0x2a, - [Q_KEY_CODE_SHIFT_R] = 0x36, - - [Q_KEY_CODE_ALT] = 0x38, - [Q_KEY_CODE_ALT_R] = 0xb8, - [Q_KEY_CODE_ALTGR] = 0x64, - [Q_KEY_CODE_ALTGR_R] = 0xe4, - [Q_KEY_CODE_CTRL] = 0x1d, - [Q_KEY_CODE_CTRL_R] = 0x9d, - - [Q_KEY_CODE_META_L] = 0xdb, - [Q_KEY_CODE_META_R] = 0xdc, - [Q_KEY_CODE_MENU] = 0xdd, - - [Q_KEY_CODE_ESC] = 0x01, - - [Q_KEY_CODE_1] = 0x02, - [Q_KEY_CODE_2] = 0x03, - [Q_KEY_CODE_3] = 0x04, - [Q_KEY_CODE_4] = 0x05, - [Q_KEY_CODE_5] = 0x06, - [Q_KEY_CODE_6] = 0x07, - [Q_KEY_CODE_7] = 0x08, - [Q_KEY_CODE_8] = 0x09, - [Q_KEY_CODE_9] = 0x0a, - [Q_KEY_CODE_0] = 0x0b, - [Q_KEY_CODE_MINUS] = 0x0c, - [Q_KEY_CODE_EQUAL] = 0x0d, - [Q_KEY_CODE_BACKSPACE] = 0x0e, - - [Q_KEY_CODE_TAB] = 0x0f, - [Q_KEY_CODE_Q] = 0x10, - [Q_KEY_CODE_W] = 0x11, - [Q_KEY_CODE_E] = 0x12, - [Q_KEY_CODE_R] = 0x13, - [Q_KEY_CODE_T] = 0x14, - [Q_KEY_CODE_Y] = 0x15, - [Q_KEY_CODE_U] = 0x16, - [Q_KEY_CODE_I] = 0x17, - [Q_KEY_CODE_O] = 0x18, - [Q_KEY_CODE_P] = 0x19, - [Q_KEY_CODE_BRACKET_LEFT] = 0x1a, - [Q_KEY_CODE_BRACKET_RIGHT] = 0x1b, - [Q_KEY_CODE_RET] = 0x1c, - - [Q_KEY_CODE_A] = 0x1e, - [Q_KEY_CODE_S] = 0x1f, - [Q_KEY_CODE_D] = 0x20, - [Q_KEY_CODE_F] = 0x21, - [Q_KEY_CODE_G] = 0x22, - [Q_KEY_CODE_H] = 0x23, - [Q_KEY_CODE_J] = 0x24, - [Q_KEY_CODE_K] = 0x25, - [Q_KEY_CODE_L] = 0x26, - [Q_KEY_CODE_SEMICOLON] = 0x27, - [Q_KEY_CODE_APOSTROPHE] = 0x28, - [Q_KEY_CODE_GRAVE_ACCENT] = 0x29, - - [Q_KEY_CODE_BACKSLASH] = 0x2b, - [Q_KEY_CODE_Z] = 0x2c, - [Q_KEY_CODE_X] = 0x2d, - [Q_KEY_CODE_C] = 0x2e, - [Q_KEY_CODE_V] = 0x2f, - [Q_KEY_CODE_B] = 0x30, - [Q_KEY_CODE_N] = 0x31, - [Q_KEY_CODE_M] = 0x32, - [Q_KEY_CODE_COMMA] = 0x33, - [Q_KEY_CODE_DOT] = 0x34, - [Q_KEY_CODE_SLASH] = 0x35, - - [Q_KEY_CODE_ASTERISK] = 0x37, - - [Q_KEY_CODE_SPC] = 0x39, - [Q_KEY_CODE_CAPS_LOCK] = 0x3a, - [Q_KEY_CODE_F1] = 0x3b, - [Q_KEY_CODE_F2] = 0x3c, - [Q_KEY_CODE_F3] = 0x3d, - [Q_KEY_CODE_F4] = 0x3e, - [Q_KEY_CODE_F5] = 0x3f, - [Q_KEY_CODE_F6] = 0x40, - [Q_KEY_CODE_F7] = 0x41, - [Q_KEY_CODE_F8] = 0x42, - [Q_KEY_CODE_F9] = 0x43, - [Q_KEY_CODE_F10] = 0x44, - [Q_KEY_CODE_NUM_LOCK] = 0x45, - [Q_KEY_CODE_SCROLL_LOCK] = 0x46, - - [Q_KEY_CODE_KP_DIVIDE] = 0xb5, - [Q_KEY_CODE_KP_MULTIPLY] = 0x37, - [Q_KEY_CODE_KP_SUBTRACT] = 0x4a, - [Q_KEY_CODE_KP_ADD] = 0x4e, - [Q_KEY_CODE_KP_ENTER] = 0x9c, - [Q_KEY_CODE_KP_DECIMAL] = 0x53, - [Q_KEY_CODE_SYSRQ] = 0x54, - - [Q_KEY_CODE_KP_0] = 0x52, - [Q_KEY_CODE_KP_1] = 0x4f, - [Q_KEY_CODE_KP_2] = 0x50, - [Q_KEY_CODE_KP_3] = 0x51, - [Q_KEY_CODE_KP_4] = 0x4b, - [Q_KEY_CODE_KP_5] = 0x4c, - [Q_KEY_CODE_KP_6] = 0x4d, - [Q_KEY_CODE_KP_7] = 0x47, - [Q_KEY_CODE_KP_8] = 0x48, - [Q_KEY_CODE_KP_9] = 0x49, - - [Q_KEY_CODE_LESS] = 0x56, - - [Q_KEY_CODE_F11] = 0x57, - [Q_KEY_CODE_F12] = 0x58, - - [Q_KEY_CODE_PRINT] = 0xb7, - - [Q_KEY_CODE_HOME] = 0xc7, - [Q_KEY_CODE_PGUP] = 0xc9, - [Q_KEY_CODE_PGDN] = 0xd1, - [Q_KEY_CODE_END] = 0xcf, - - [Q_KEY_CODE_LEFT] = 0xcb, - [Q_KEY_CODE_UP] = 0xc8, - [Q_KEY_CODE_DOWN] = 0xd0, - [Q_KEY_CODE_RIGHT] = 0xcd, - - [Q_KEY_CODE_INSERT] = 0xd2, - [Q_KEY_CODE_DELETE] = 0xd3, - - [Q_KEY_CODE_RO] = 0x73, - [Q_KEY_CODE_KP_COMMA] = 0x7e, - - [Q_KEY_CODE_MAX] = 0, + [QKeyCode_shift] = 0x2a, + [QKeyCode_shift_r] = 0x36, + + [QKeyCode_alt] = 0x38, + [QKeyCode_alt_r] = 0xb8, + [QKeyCode_altgr] = 0x64, + [QKeyCode_altgr_r] = 0xe4, + [QKeyCode_ctrl] = 0x1d, + [QKeyCode_ctrl_r] = 0x9d, + + [QKeyCode_meta_l] = 0xdb, + [QKeyCode_meta_r] = 0xdc, + [QKeyCode_menu] = 0xdd, + + [QKeyCode_esc] = 0x01, + + [QKeyCode_1] = 0x02, + [QKeyCode_2] = 0x03, + [QKeyCode_3] = 0x04, + [QKeyCode_4] = 0x05, + [QKeyCode_5] = 0x06, + [QKeyCode_6] = 0x07, + [QKeyCode_7] = 0x08, + [QKeyCode_8] = 0x09, + [QKeyCode_9] = 0x0a, + [QKeyCode_0] = 0x0b, + [QKeyCode_minus] = 0x0c, + [QKeyCode_equal] = 0x0d, + [QKeyCode_backspace] = 0x0e, + + [QKeyCode_tab] = 0x0f, + [QKeyCode_q] = 0x10, + [QKeyCode_w] = 0x11, + [QKeyCode_e] = 0x12, + [QKeyCode_r] = 0x13, + [QKeyCode_t] = 0x14, + [QKeyCode_y] = 0x15, + [QKeyCode_u] = 0x16, + [QKeyCode_i] = 0x17, + [QKeyCode_o] = 0x18, + [QKeyCode_p] = 0x19, + [QKeyCode_bracket_left] = 0x1a, + [QKeyCode_bracket_right] = 0x1b, + [QKeyCode_ret] = 0x1c, + + [QKeyCode_a] = 0x1e, + [QKeyCode_s] = 0x1f, + [QKeyCode_d] = 0x20, + [QKeyCode_f] = 0x21, + [QKeyCode_g] = 0x22, + [QKeyCode_h] = 0x23, + [QKeyCode_j] = 0x24, + [QKeyCode_k] = 0x25, + [QKeyCode_l] = 0x26, + [QKeyCode_semicolon] = 0x27, + [QKeyCode_apostrophe] = 0x28, + [QKeyCode_grave_accent] = 0x29, + + [QKeyCode_backslash] = 0x2b, + [QKeyCode_z] = 0x2c, + [QKeyCode_x] = 0x2d, + [QKeyCode_c] = 0x2e, + [QKeyCode_v] = 0x2f, + [QKeyCode_b] = 0x30, + [QKeyCode_n] = 0x31, + [QKeyCode_m] = 0x32, + [QKeyCode_comma] = 0x33, + [QKeyCode_dot] = 0x34, + [QKeyCode_slash] = 0x35, + + [QKeyCode_asterisk] = 0x37, + + [QKeyCode_spc] = 0x39, + [QKeyCode_caps_lock] = 0x3a, + [QKeyCode_f1] = 0x3b, + [QKeyCode_f2] = 0x3c, + [QKeyCode_f3] = 0x3d, + [QKeyCode_f4] = 0x3e, + [QKeyCode_f5] = 0x3f, + [QKeyCode_f6] = 0x40, + [QKeyCode_f7] = 0x41, + [QKeyCode_f8] = 0x42, + [QKeyCode_f9] = 0x43, + [QKeyCode_f10] = 0x44, + [QKeyCode_num_lock] = 0x45, + [QKeyCode_scroll_lock] = 0x46, + + [QKeyCode_kp_divide] = 0xb5, + [QKeyCode_kp_multiply] = 0x37, + [QKeyCode_kp_subtract] = 0x4a, + [QKeyCode_kp_add] = 0x4e, + [QKeyCode_kp_enter] = 0x9c, + [QKeyCode_kp_decimal] = 0x53, + [QKeyCode_sysrq] = 0x54, + + [QKeyCode_kp_0] = 0x52, + [QKeyCode_kp_1] = 0x4f, + [QKeyCode_kp_2] = 0x50, + [QKeyCode_kp_3] = 0x51, + [QKeyCode_kp_4] = 0x4b, + [QKeyCode_kp_5] = 0x4c, + [QKeyCode_kp_6] = 0x4d, + [QKeyCode_kp_7] = 0x47, + [QKeyCode_kp_8] = 0x48, + [QKeyCode_kp_9] = 0x49, + + [QKeyCode_less] = 0x56, + + [QKeyCode_f11] = 0x57, + [QKeyCode_f12] = 0x58, + + [QKeyCode_print] = 0xb7, + + [QKeyCode_home] = 0xc7, + [QKeyCode_pgup] = 0xc9, + [QKeyCode_pgdn] = 0xd1, + [QKeyCode_end] = 0xcf, + + [QKeyCode_left] = 0xcb, + [QKeyCode_up] = 0xc8, + [QKeyCode_down] = 0xd0, + [QKeyCode_right] = 0xcd, + + [QKeyCode_insert] = 0xd2, + [QKeyCode_delete] = 0xd3, + + [QKeyCode_ro] = 0x73, + [QKeyCode_kp_comma] = 0x7e, + + [QKeyCode_MAX] = 0, }; static int number_to_qcode[0x100]; int qemu_input_key_value_to_number(const KeyValue *value) { - if (value->type == KEY_VALUE_KIND_QCODE) { + if (value->type == KeyValueKind_qcode) { return qcode_to_number[value->u.qcode]; } else { - assert(value->type == KEY_VALUE_KIND_NUMBER); + assert(value->type == KeyValueKind_number); return value->u.number; } } @@ -154,7 +154,7 @@ int qemu_input_key_number_to_qcode(uint8_t nr) if (first) { int qcode, number; first = false; - for (qcode = 0; qcode < Q_KEY_CODE_MAX; qcode++) { + for (qcode = 0; qcode < QKeyCode_MAX; qcode++) { number = qcode_to_number[qcode]; assert(number < ARRAY_SIZE(number_to_qcode)); number_to_qcode[number] = qcode; @@ -166,10 +166,10 @@ int qemu_input_key_number_to_qcode(uint8_t nr) int qemu_input_key_value_to_qcode(const KeyValue *value) { - if (value->type == KEY_VALUE_KIND_QCODE) { + if (value->type == KeyValueKind_qcode) { return value->u.qcode; } else { - assert(value->type == KEY_VALUE_KIND_NUMBER); + assert(value->type == KeyValueKind_number); return qemu_input_key_number_to_qcode(value->u.number); } } @@ -180,8 +180,8 @@ int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, int keycode = qemu_input_key_value_to_number(value); int count = 0; - if (value->type == KEY_VALUE_KIND_QCODE && - value->u.qcode == Q_KEY_CODE_PAUSE) { + if (value->type == KeyValueKind_qcode && + value->u.qcode == QKeyCode_pause) { /* specific case */ int v = down ? 0 : 0x80; codes[count++] = 0xe1; diff --git a/ui/input-legacy.c b/ui/input-legacy.c index a67ed32..661faf0 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -38,7 +38,7 @@ struct QEMUPutMouseEntry { /* new input core */ QemuInputHandler h; QemuInputHandlerState *s; - int axis[INPUT_AXIS_MAX]; + int axis[InputAxis_MAX]; int buttons; }; @@ -67,7 +67,7 @@ int index_from_key(const char *key) } } - /* Return Q_KEY_CODE_MAX if the key is invalid */ + /* Return QKeyCode_MAX if the key is invalid */ return i; } @@ -143,40 +143,40 @@ QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { - static const int bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON, + static const int bmap[InputButton_MAX] = { + [InputButton_Left] = MOUSE_EVENT_LBUTTON, + [InputButton_Middle] = MOUSE_EVENT_MBUTTON, + [InputButton_Right] = MOUSE_EVENT_RBUTTON, }; QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev; switch (evt->type) { - case INPUT_EVENT_KIND_BTN: + case InputEventKind_btn: if (evt->u.btn->down) { s->buttons |= bmap[evt->u.btn->button]; } else { s->buttons &= ~bmap[evt->u.btn->button]; } - if (evt->u.btn->down && evt->u.btn->button == INPUT_BUTTON_WHEEL_UP) { + if (evt->u.btn->down && evt->u.btn->button == InputButton_WheelUp) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, - s->axis[INPUT_AXIS_X], - s->axis[INPUT_AXIS_Y], + s->axis[InputAxis_X], + s->axis[InputAxis_Y], -1, s->buttons); } if (evt->u.btn->down && - evt->u.btn->button == INPUT_BUTTON_WHEEL_DOWN) { + evt->u.btn->button == InputButton_WheelDown) { s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, - s->axis[INPUT_AXIS_X], - s->axis[INPUT_AXIS_Y], + s->axis[InputAxis_X], + s->axis[InputAxis_Y], 1, s->buttons); } break; - case INPUT_EVENT_KIND_ABS: + case InputEventKind_abs: s->axis[evt->u.abs->axis] = evt->u.abs->value; break; - case INPUT_EVENT_KIND_REL: + case InputEventKind_rel: s->axis[evt->u.rel->axis] += evt->u.rel->value; break; default: @@ -189,14 +189,14 @@ static void legacy_mouse_sync(DeviceState *dev) QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev; s->qemu_put_mouse_event(s->qemu_put_mouse_event_opaque, - s->axis[INPUT_AXIS_X], - s->axis[INPUT_AXIS_Y], + s->axis[InputAxis_X], + s->axis[InputAxis_Y], 0, s->buttons); if (!s->qemu_put_mouse_event_absolute) { - s->axis[INPUT_AXIS_X] = 0; - s->axis[INPUT_AXIS_Y] = 0; + s->axis[InputAxis_X] = 0; + s->axis[InputAxis_Y] = 0; } } diff --git a/ui/input.c b/ui/input.c index 643f885..28af744 100644 --- a/ui/input.c +++ b/ui/input.c @@ -85,7 +85,7 @@ void qemu_input_handler_bind(QemuInputHandlerState *s, dev = qdev_find_recursive(sysbus_get_default(), device_id); if (dev == NULL) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, ErrorClass_DeviceNotFound, "Device '%s' not found", device_id); return; } @@ -139,7 +139,7 @@ void qmp_x_input_send_event(bool has_console, int64_t console, } } - if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { + if (!runstate_is_running() && !runstate_check(RunState_suspended)) { error_setg(errp, "VM not running"); return; } @@ -168,10 +168,10 @@ static void qemu_input_transform_abs_rotate(InputEvent *evt) { switch (graphic_rotate) { case 90: - if (evt->u.abs->axis == INPUT_AXIS_X) { - evt->u.abs->axis = INPUT_AXIS_Y; - } else if (evt->u.abs->axis == INPUT_AXIS_Y) { - evt->u.abs->axis = INPUT_AXIS_X; + if (evt->u.abs->axis == InputAxis_X) { + evt->u.abs->axis = InputAxis_Y; + } else if (evt->u.abs->axis == InputAxis_Y) { + evt->u.abs->axis = InputAxis_X; evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value; } break; @@ -179,11 +179,11 @@ static void qemu_input_transform_abs_rotate(InputEvent *evt) evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value; break; case 270: - if (evt->u.abs->axis == INPUT_AXIS_X) { - evt->u.abs->axis = INPUT_AXIS_Y; + if (evt->u.abs->axis == InputAxis_X) { + evt->u.abs->axis = InputAxis_Y; evt->u.abs->value = INPUT_EVENT_ABS_SIZE - 1 - evt->u.abs->value; - } else if (evt->u.abs->axis == INPUT_AXIS_Y) { - evt->u.abs->axis = INPUT_AXIS_X; + } else if (evt->u.abs->axis == InputAxis_Y) { + evt->u.abs->axis = InputAxis_X; } break; } @@ -198,36 +198,36 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) idx = qemu_console_get_index(src); } switch (evt->type) { - case INPUT_EVENT_KIND_KEY: + case InputEventKind_key: switch (evt->u.key->key->type) { - case KEY_VALUE_KIND_NUMBER: + case KeyValueKind_number: qcode = qemu_input_key_number_to_qcode(evt->u.key->key->u.number); name = QKeyCode_lookup[qcode]; trace_input_event_key_number(idx, evt->u.key->key->u.number, name, evt->u.key->down); break; - case KEY_VALUE_KIND_QCODE: + case KeyValueKind_qcode: name = QKeyCode_lookup[evt->u.key->key->u.qcode]; trace_input_event_key_qcode(idx, name, evt->u.key->down); break; - case KEY_VALUE_KIND_MAX: + case KeyValueKind_MAX: /* keep gcc happy */ break; } break; - case INPUT_EVENT_KIND_BTN: + case InputEventKind_btn: name = InputButton_lookup[evt->u.btn->button]; trace_input_event_btn(idx, name, evt->u.btn->down); break; - case INPUT_EVENT_KIND_REL: + case InputEventKind_rel: name = InputAxis_lookup[evt->u.rel->axis]; trace_input_event_rel(idx, name, evt->u.rel->value); break; - case INPUT_EVENT_KIND_ABS: + case InputEventKind_abs: name = InputAxis_lookup[evt->u.abs->axis]; trace_input_event_abs(idx, name, evt->u.abs->value); break; - case INPUT_EVENT_KIND_MAX: + case InputEventKind_MAX: /* keep gcc happy */ break; } @@ -304,14 +304,14 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) { QemuInputHandlerState *s; - if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { + if (!runstate_is_running() && !runstate_check(RunState_suspended)) { return; } qemu_input_event_trace(src, evt); /* pre processing */ - if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) { + if (graphic_rotate && (evt->type == InputEventKind_abs)) { qemu_input_transform_abs_rotate(evt); } @@ -328,7 +328,7 @@ void qemu_input_event_sync(void) { QemuInputHandlerState *s; - if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { + if (!runstate_is_running() && !runstate_check(RunState_suspended)) { return; } @@ -349,7 +349,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->u.key = g_new0(InputKeyEvent, 1); - evt->type = INPUT_EVENT_KIND_KEY; + evt->type = InputEventKind_key; evt->u.key->key = key; evt->u.key->down = down; return evt; @@ -372,7 +372,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { KeyValue *key = g_new0(KeyValue, 1); - key->type = KEY_VALUE_KIND_NUMBER; + key->type = KeyValueKind_number; key->u.number = num; qemu_input_event_send_key(src, key, down); } @@ -380,7 +380,7 @@ void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down) { KeyValue *key = g_new0(KeyValue, 1); - key->type = KEY_VALUE_KIND_QCODE; + key->type = KeyValueKind_qcode; key->u.qcode = q; qemu_input_event_send_key(src, key, down); } @@ -399,7 +399,7 @@ InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->u.btn = g_new0(InputBtnEvent, 1); - evt->type = INPUT_EVENT_KIND_BTN; + evt->type = InputEventKind_btn; evt->u.btn->button = btn; evt->u.btn->down = down; return evt; @@ -419,7 +419,7 @@ void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, InputButton btn; uint32_t mask; - for (btn = 0; btn < INPUT_BUTTON_MAX; btn++) { + for (btn = 0; btn < InputButton_MAX; btn++) { mask = button_map[btn]; if ((button_old & mask) == (button_new & mask)) { continue; @@ -461,7 +461,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value) { InputEvent *evt; - evt = qemu_input_event_new_move(INPUT_EVENT_KIND_REL, axis, value); + evt = qemu_input_event_new_move(InputEventKind_rel, axis, value); qemu_input_event_send(src, evt); qapi_free_InputEvent(evt); } @@ -470,7 +470,7 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value, int size) { InputEvent *evt; int scaled = qemu_input_scale_axis(value, size, INPUT_EVENT_ABS_SIZE); - evt = qemu_input_event_new_move(INPUT_EVENT_KIND_ABS, axis, scaled); + evt = qemu_input_event_new_move(InputEventKind_abs, axis, scaled); qemu_input_event_send(src, evt); qapi_free_InputEvent(evt); } diff --git a/ui/sdl.c b/ui/sdl.c index 3be2910..d038b62 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -305,7 +305,7 @@ static void sdl_process_key(SDL_KeyboardEvent *ev) if (ev->keysym.sym == SDLK_PAUSE) { /* specific case */ - qemu_input_event_send_key_qcode(dcl->con, Q_KEY_CODE_PAUSE, + qemu_input_event_send_key_qcode(dcl->con, QKeyCode_pause, ev->type == SDL_KEYDOWN); return; } @@ -465,12 +465,12 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data) static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state) { - static uint32_t bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = SDL_BUTTON(SDL_BUTTON_LEFT), - [INPUT_BUTTON_MIDDLE] = SDL_BUTTON(SDL_BUTTON_MIDDLE), - [INPUT_BUTTON_RIGHT] = SDL_BUTTON(SDL_BUTTON_RIGHT), - [INPUT_BUTTON_WHEEL_UP] = SDL_BUTTON(SDL_BUTTON_WHEELUP), - [INPUT_BUTTON_WHEEL_DOWN] = SDL_BUTTON(SDL_BUTTON_WHEELDOWN), + static uint32_t bmap[InputButton_MAX] = { + [InputButton_Left] = SDL_BUTTON(SDL_BUTTON_LEFT), + [InputButton_Middle] = SDL_BUTTON(SDL_BUTTON_MIDDLE), + [InputButton_Right] = SDL_BUTTON(SDL_BUTTON_RIGHT), + [InputButton_WheelUp] = SDL_BUTTON(SDL_BUTTON_WHEELUP), + [InputButton_WheelDown] = SDL_BUTTON(SDL_BUTTON_WHEELDOWN), }; static uint32_t prev_state; @@ -480,9 +480,9 @@ static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state) } if (qemu_input_is_absolute()) { - qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, x, + qemu_input_queue_abs(dcl->con, InputAxis_X, x, real_screen->w); - qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, y, + qemu_input_queue_abs(dcl->con, InputAxis_Y, y, real_screen->h); } else { if (guest_cursor) { @@ -493,8 +493,8 @@ static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state) dx = x; dy = y; } - qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, dx); - qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, dy); + qemu_input_queue_rel(dcl->con, InputAxis_X, dx); + qemu_input_queue_rel(dcl->con, InputAxis_Y, dy); } qemu_input_event_sync(); } diff --git a/ui/sdl2-keymap.h b/ui/sdl2-keymap.h index cbedaa4..b34a26c 100644 --- a/ui/sdl2-keymap.h +++ b/ui/sdl2-keymap.h @@ -2,266 +2,266 @@ /* map SDL2 scancodes to QKeyCode */ static const int sdl2_scancode_to_qcode[SDL_NUM_SCANCODES] = { - [SDL_SCANCODE_A] = Q_KEY_CODE_A, - [SDL_SCANCODE_B] = Q_KEY_CODE_B, - [SDL_SCANCODE_C] = Q_KEY_CODE_C, - [SDL_SCANCODE_D] = Q_KEY_CODE_D, - [SDL_SCANCODE_E] = Q_KEY_CODE_E, - [SDL_SCANCODE_F] = Q_KEY_CODE_F, - [SDL_SCANCODE_G] = Q_KEY_CODE_G, - [SDL_SCANCODE_H] = Q_KEY_CODE_H, - [SDL_SCANCODE_I] = Q_KEY_CODE_I, - [SDL_SCANCODE_J] = Q_KEY_CODE_J, - [SDL_SCANCODE_K] = Q_KEY_CODE_K, - [SDL_SCANCODE_L] = Q_KEY_CODE_L, - [SDL_SCANCODE_M] = Q_KEY_CODE_M, - [SDL_SCANCODE_N] = Q_KEY_CODE_N, - [SDL_SCANCODE_O] = Q_KEY_CODE_O, - [SDL_SCANCODE_P] = Q_KEY_CODE_P, - [SDL_SCANCODE_Q] = Q_KEY_CODE_Q, - [SDL_SCANCODE_R] = Q_KEY_CODE_R, - [SDL_SCANCODE_S] = Q_KEY_CODE_S, - [SDL_SCANCODE_T] = Q_KEY_CODE_T, - [SDL_SCANCODE_U] = Q_KEY_CODE_U, - [SDL_SCANCODE_V] = Q_KEY_CODE_V, - [SDL_SCANCODE_W] = Q_KEY_CODE_W, - [SDL_SCANCODE_X] = Q_KEY_CODE_X, - [SDL_SCANCODE_Y] = Q_KEY_CODE_Y, - [SDL_SCANCODE_Z] = Q_KEY_CODE_Z, + [SDL_SCANCODE_A] = QKeyCode_a, + [SDL_SCANCODE_B] = QKeyCode_b, + [SDL_SCANCODE_C] = QKeyCode_c, + [SDL_SCANCODE_D] = QKeyCode_d, + [SDL_SCANCODE_E] = QKeyCode_e, + [SDL_SCANCODE_F] = QKeyCode_f, + [SDL_SCANCODE_G] = QKeyCode_g, + [SDL_SCANCODE_H] = QKeyCode_h, + [SDL_SCANCODE_I] = QKeyCode_i, + [SDL_SCANCODE_J] = QKeyCode_j, + [SDL_SCANCODE_K] = QKeyCode_k, + [SDL_SCANCODE_L] = QKeyCode_l, + [SDL_SCANCODE_M] = QKeyCode_m, + [SDL_SCANCODE_N] = QKeyCode_n, + [SDL_SCANCODE_O] = QKeyCode_o, + [SDL_SCANCODE_P] = QKeyCode_p, + [SDL_SCANCODE_Q] = QKeyCode_q, + [SDL_SCANCODE_R] = QKeyCode_r, + [SDL_SCANCODE_S] = QKeyCode_s, + [SDL_SCANCODE_T] = QKeyCode_t, + [SDL_SCANCODE_U] = QKeyCode_u, + [SDL_SCANCODE_V] = QKeyCode_v, + [SDL_SCANCODE_W] = QKeyCode_w, + [SDL_SCANCODE_X] = QKeyCode_x, + [SDL_SCANCODE_Y] = QKeyCode_y, + [SDL_SCANCODE_Z] = QKeyCode_z, - [SDL_SCANCODE_1] = Q_KEY_CODE_1, - [SDL_SCANCODE_2] = Q_KEY_CODE_2, - [SDL_SCANCODE_3] = Q_KEY_CODE_3, - [SDL_SCANCODE_4] = Q_KEY_CODE_4, - [SDL_SCANCODE_5] = Q_KEY_CODE_5, - [SDL_SCANCODE_6] = Q_KEY_CODE_6, - [SDL_SCANCODE_7] = Q_KEY_CODE_7, - [SDL_SCANCODE_8] = Q_KEY_CODE_8, - [SDL_SCANCODE_9] = Q_KEY_CODE_9, - [SDL_SCANCODE_0] = Q_KEY_CODE_0, + [SDL_SCANCODE_1] = QKeyCode_1, + [SDL_SCANCODE_2] = QKeyCode_2, + [SDL_SCANCODE_3] = QKeyCode_3, + [SDL_SCANCODE_4] = QKeyCode_4, + [SDL_SCANCODE_5] = QKeyCode_5, + [SDL_SCANCODE_6] = QKeyCode_6, + [SDL_SCANCODE_7] = QKeyCode_7, + [SDL_SCANCODE_8] = QKeyCode_8, + [SDL_SCANCODE_9] = QKeyCode_9, + [SDL_SCANCODE_0] = QKeyCode_0, - [SDL_SCANCODE_RETURN] = Q_KEY_CODE_RET, - [SDL_SCANCODE_ESCAPE] = Q_KEY_CODE_ESC, - [SDL_SCANCODE_BACKSPACE] = Q_KEY_CODE_BACKSPACE, - [SDL_SCANCODE_TAB] = Q_KEY_CODE_TAB, - [SDL_SCANCODE_SPACE] = Q_KEY_CODE_SPC, - [SDL_SCANCODE_MINUS] = Q_KEY_CODE_MINUS, - [SDL_SCANCODE_EQUALS] = Q_KEY_CODE_EQUAL, - [SDL_SCANCODE_LEFTBRACKET] = Q_KEY_CODE_BRACKET_LEFT, - [SDL_SCANCODE_RIGHTBRACKET] = Q_KEY_CODE_BRACKET_RIGHT, - [SDL_SCANCODE_BACKSLASH] = Q_KEY_CODE_BACKSLASH, + [SDL_SCANCODE_RETURN] = QKeyCode_ret, + [SDL_SCANCODE_ESCAPE] = QKeyCode_esc, + [SDL_SCANCODE_BACKSPACE] = QKeyCode_backspace, + [SDL_SCANCODE_TAB] = QKeyCode_tab, + [SDL_SCANCODE_SPACE] = QKeyCode_spc, + [SDL_SCANCODE_MINUS] = QKeyCode_minus, + [SDL_SCANCODE_EQUALS] = QKeyCode_equal, + [SDL_SCANCODE_LEFTBRACKET] = QKeyCode_bracket_left, + [SDL_SCANCODE_RIGHTBRACKET] = QKeyCode_bracket_right, + [SDL_SCANCODE_BACKSLASH] = QKeyCode_backslash, #if 0 - [SDL_SCANCODE_NONUSHASH] = Q_KEY_CODE_NONUSHASH, + [SDL_SCANCODE_NONUSHASH] = QKeyCode_nonushash, #endif - [SDL_SCANCODE_SEMICOLON] = Q_KEY_CODE_SEMICOLON, - [SDL_SCANCODE_APOSTROPHE] = Q_KEY_CODE_APOSTROPHE, - [SDL_SCANCODE_GRAVE] = Q_KEY_CODE_GRAVE_ACCENT, - [SDL_SCANCODE_COMMA] = Q_KEY_CODE_COMMA, - [SDL_SCANCODE_PERIOD] = Q_KEY_CODE_DOT, - [SDL_SCANCODE_SLASH] = Q_KEY_CODE_SLASH, - [SDL_SCANCODE_CAPSLOCK] = Q_KEY_CODE_CAPS_LOCK, + [SDL_SCANCODE_SEMICOLON] = QKeyCode_semicolon, + [SDL_SCANCODE_APOSTROPHE] = QKeyCode_apostrophe, + [SDL_SCANCODE_GRAVE] = QKeyCode_grave_accent, + [SDL_SCANCODE_COMMA] = QKeyCode_comma, + [SDL_SCANCODE_PERIOD] = QKeyCode_dot, + [SDL_SCANCODE_SLASH] = QKeyCode_slash, + [SDL_SCANCODE_CAPSLOCK] = QKeyCode_caps_lock, - [SDL_SCANCODE_F1] = Q_KEY_CODE_F1, - [SDL_SCANCODE_F2] = Q_KEY_CODE_F2, - [SDL_SCANCODE_F3] = Q_KEY_CODE_F3, - [SDL_SCANCODE_F4] = Q_KEY_CODE_F4, - [SDL_SCANCODE_F5] = Q_KEY_CODE_F5, - [SDL_SCANCODE_F6] = Q_KEY_CODE_F6, - [SDL_SCANCODE_F7] = Q_KEY_CODE_F7, - [SDL_SCANCODE_F8] = Q_KEY_CODE_F8, - [SDL_SCANCODE_F9] = Q_KEY_CODE_F9, - [SDL_SCANCODE_F10] = Q_KEY_CODE_F10, - [SDL_SCANCODE_F11] = Q_KEY_CODE_F11, - [SDL_SCANCODE_F12] = Q_KEY_CODE_F12, + [SDL_SCANCODE_F1] = QKeyCode_f1, + [SDL_SCANCODE_F2] = QKeyCode_f2, + [SDL_SCANCODE_F3] = QKeyCode_f3, + [SDL_SCANCODE_F4] = QKeyCode_f4, + [SDL_SCANCODE_F5] = QKeyCode_f5, + [SDL_SCANCODE_F6] = QKeyCode_f6, + [SDL_SCANCODE_F7] = QKeyCode_f7, + [SDL_SCANCODE_F8] = QKeyCode_f8, + [SDL_SCANCODE_F9] = QKeyCode_f9, + [SDL_SCANCODE_F10] = QKeyCode_f10, + [SDL_SCANCODE_F11] = QKeyCode_f11, + [SDL_SCANCODE_F12] = QKeyCode_f12, - [SDL_SCANCODE_PRINTSCREEN] = Q_KEY_CODE_PRINT, - [SDL_SCANCODE_SCROLLLOCK] = Q_KEY_CODE_SCROLL_LOCK, - [SDL_SCANCODE_PAUSE] = Q_KEY_CODE_PAUSE, - [SDL_SCANCODE_INSERT] = Q_KEY_CODE_INSERT, - [SDL_SCANCODE_HOME] = Q_KEY_CODE_HOME, - [SDL_SCANCODE_PAGEUP] = Q_KEY_CODE_PGUP, - [SDL_SCANCODE_DELETE] = Q_KEY_CODE_DELETE, - [SDL_SCANCODE_END] = Q_KEY_CODE_END, - [SDL_SCANCODE_PAGEDOWN] = Q_KEY_CODE_PGDN, - [SDL_SCANCODE_RIGHT] = Q_KEY_CODE_RIGHT, - [SDL_SCANCODE_LEFT] = Q_KEY_CODE_LEFT, - [SDL_SCANCODE_DOWN] = Q_KEY_CODE_DOWN, - [SDL_SCANCODE_UP] = Q_KEY_CODE_UP, - [SDL_SCANCODE_NUMLOCKCLEAR] = Q_KEY_CODE_NUM_LOCK, + [SDL_SCANCODE_PRINTSCREEN] = QKeyCode_print, + [SDL_SCANCODE_SCROLLLOCK] = QKeyCode_scroll_lock, + [SDL_SCANCODE_PAUSE] = QKeyCode_pause, + [SDL_SCANCODE_INSERT] = QKeyCode_insert, + [SDL_SCANCODE_HOME] = QKeyCode_home, + [SDL_SCANCODE_PAGEUP] = QKeyCode_pgup, + [SDL_SCANCODE_DELETE] = QKeyCode_delete, + [SDL_SCANCODE_END] = QKeyCode_end, + [SDL_SCANCODE_PAGEDOWN] = QKeyCode_pgdn, + [SDL_SCANCODE_RIGHT] = QKeyCode_right, + [SDL_SCANCODE_LEFT] = QKeyCode_left, + [SDL_SCANCODE_DOWN] = QKeyCode_down, + [SDL_SCANCODE_UP] = QKeyCode_up, + [SDL_SCANCODE_NUMLOCKCLEAR] = QKeyCode_num_lock, - [SDL_SCANCODE_KP_DIVIDE] = Q_KEY_CODE_KP_DIVIDE, - [SDL_SCANCODE_KP_MULTIPLY] = Q_KEY_CODE_KP_MULTIPLY, - [SDL_SCANCODE_KP_MINUS] = Q_KEY_CODE_KP_SUBTRACT, - [SDL_SCANCODE_KP_PLUS] = Q_KEY_CODE_KP_ADD, - [SDL_SCANCODE_KP_ENTER] = Q_KEY_CODE_KP_ENTER, - [SDL_SCANCODE_KP_1] = Q_KEY_CODE_KP_1, - [SDL_SCANCODE_KP_2] = Q_KEY_CODE_KP_2, - [SDL_SCANCODE_KP_3] = Q_KEY_CODE_KP_3, - [SDL_SCANCODE_KP_4] = Q_KEY_CODE_KP_4, - [SDL_SCANCODE_KP_5] = Q_KEY_CODE_KP_5, - [SDL_SCANCODE_KP_6] = Q_KEY_CODE_KP_6, - [SDL_SCANCODE_KP_7] = Q_KEY_CODE_KP_7, - [SDL_SCANCODE_KP_8] = Q_KEY_CODE_KP_8, - [SDL_SCANCODE_KP_9] = Q_KEY_CODE_KP_9, - [SDL_SCANCODE_KP_0] = Q_KEY_CODE_KP_0, - [SDL_SCANCODE_KP_PERIOD] = Q_KEY_CODE_KP_DECIMAL, + [SDL_SCANCODE_KP_DIVIDE] = QKeyCode_kp_divide, + [SDL_SCANCODE_KP_MULTIPLY] = QKeyCode_kp_multiply, + [SDL_SCANCODE_KP_MINUS] = QKeyCode_kp_subtract, + [SDL_SCANCODE_KP_PLUS] = QKeyCode_kp_add, + [SDL_SCANCODE_KP_ENTER] = QKeyCode_kp_enter, + [SDL_SCANCODE_KP_1] = QKeyCode_kp_1, + [SDL_SCANCODE_KP_2] = QKeyCode_kp_2, + [SDL_SCANCODE_KP_3] = QKeyCode_kp_3, + [SDL_SCANCODE_KP_4] = QKeyCode_kp_4, + [SDL_SCANCODE_KP_5] = QKeyCode_kp_5, + [SDL_SCANCODE_KP_6] = QKeyCode_kp_6, + [SDL_SCANCODE_KP_7] = QKeyCode_kp_7, + [SDL_SCANCODE_KP_8] = QKeyCode_kp_8, + [SDL_SCANCODE_KP_9] = QKeyCode_kp_9, + [SDL_SCANCODE_KP_0] = QKeyCode_kp_0, + [SDL_SCANCODE_KP_PERIOD] = QKeyCode_kp_decimal, - [SDL_SCANCODE_NONUSBACKSLASH] = Q_KEY_CODE_LESS, - [SDL_SCANCODE_APPLICATION] = Q_KEY_CODE_MENU, + [SDL_SCANCODE_NONUSBACKSLASH] = QKeyCode_less, + [SDL_SCANCODE_APPLICATION] = QKeyCode_menu, #if 0 - [SDL_SCANCODE_POWER] = Q_KEY_CODE_POWER, - [SDL_SCANCODE_KP_EQUALS] = Q_KEY_CODE_KP_EQUALS, + [SDL_SCANCODE_POWER] = QKeyCode_power, + [SDL_SCANCODE_KP_EQUALS] = QKeyCode_kp_equals, - [SDL_SCANCODE_F13] = Q_KEY_CODE_F13, - [SDL_SCANCODE_F14] = Q_KEY_CODE_F14, - [SDL_SCANCODE_F15] = Q_KEY_CODE_F15, - [SDL_SCANCODE_F16] = Q_KEY_CODE_F16, - [SDL_SCANCODE_F17] = Q_KEY_CODE_F17, - [SDL_SCANCODE_F18] = Q_KEY_CODE_F18, - [SDL_SCANCODE_F19] = Q_KEY_CODE_F19, - [SDL_SCANCODE_F20] = Q_KEY_CODE_F20, - [SDL_SCANCODE_F21] = Q_KEY_CODE_F21, - [SDL_SCANCODE_F22] = Q_KEY_CODE_F22, - [SDL_SCANCODE_F23] = Q_KEY_CODE_F23, - [SDL_SCANCODE_F24] = Q_KEY_CODE_F24, + [SDL_SCANCODE_F13] = QKeyCode_f13, + [SDL_SCANCODE_F14] = QKeyCode_f14, + [SDL_SCANCODE_F15] = QKeyCode_f15, + [SDL_SCANCODE_F16] = QKeyCode_f16, + [SDL_SCANCODE_F17] = QKeyCode_f17, + [SDL_SCANCODE_F18] = QKeyCode_f18, + [SDL_SCANCODE_F19] = QKeyCode_f19, + [SDL_SCANCODE_F20] = QKeyCode_f20, + [SDL_SCANCODE_F21] = QKeyCode_f21, + [SDL_SCANCODE_F22] = QKeyCode_f22, + [SDL_SCANCODE_F23] = QKeyCode_f23, + [SDL_SCANCODE_F24] = QKeyCode_f24, - [SDL_SCANCODE_EXECUTE] = Q_KEY_CODE_EXECUTE, + [SDL_SCANCODE_EXECUTE] = QKeyCode_execute, #endif - [SDL_SCANCODE_HELP] = Q_KEY_CODE_HELP, - [SDL_SCANCODE_MENU] = Q_KEY_CODE_MENU, + [SDL_SCANCODE_HELP] = QKeyCode_help, + [SDL_SCANCODE_MENU] = QKeyCode_menu, #if 0 - [SDL_SCANCODE_SELECT] = Q_KEY_CODE_SELECT, + [SDL_SCANCODE_SELECT] = QKeyCode_select, #endif - [SDL_SCANCODE_STOP] = Q_KEY_CODE_STOP, - [SDL_SCANCODE_AGAIN] = Q_KEY_CODE_AGAIN, - [SDL_SCANCODE_UNDO] = Q_KEY_CODE_UNDO, - [SDL_SCANCODE_CUT] = Q_KEY_CODE_CUT, - [SDL_SCANCODE_COPY] = Q_KEY_CODE_COPY, - [SDL_SCANCODE_PASTE] = Q_KEY_CODE_PASTE, - [SDL_SCANCODE_FIND] = Q_KEY_CODE_FIND, + [SDL_SCANCODE_STOP] = QKeyCode_stop, + [SDL_SCANCODE_AGAIN] = QKeyCode_again, + [SDL_SCANCODE_UNDO] = QKeyCode_undo, + [SDL_SCANCODE_CUT] = QKeyCode_cut, + [SDL_SCANCODE_COPY] = QKeyCode_copy, + [SDL_SCANCODE_PASTE] = QKeyCode_paste, + [SDL_SCANCODE_FIND] = QKeyCode_find, #if 0 - [SDL_SCANCODE_MUTE] = Q_KEY_CODE_MUTE, - [SDL_SCANCODE_VOLUMEUP] = Q_KEY_CODE_VOLUMEUP, - [SDL_SCANCODE_VOLUMEDOWN] = Q_KEY_CODE_VOLUMEDOWN, + [SDL_SCANCODE_MUTE] = QKeyCode_mute, + [SDL_SCANCODE_VOLUMEUP] = QKeyCode_volumeup, + [SDL_SCANCODE_VOLUMEDOWN] = QKeyCode_volumedown, - [SDL_SCANCODE_KP_COMMA] = Q_KEY_CODE_KP_COMMA, - [SDL_SCANCODE_KP_EQUALSAS400] = Q_KEY_CODE_KP_EQUALSAS400, + [SDL_SCANCODE_KP_COMMA] = QKeyCode_kp_comma, + [SDL_SCANCODE_KP_EQUALSAS400] = QKeyCode_kp_equalsas400, - [SDL_SCANCODE_INTERNATIONAL1] = Q_KEY_CODE_INTERNATIONAL1, - [SDL_SCANCODE_INTERNATIONAL2] = Q_KEY_CODE_INTERNATIONAL2, - [SDL_SCANCODE_INTERNATIONAL3] = Q_KEY_CODE_INTERNATIONAL3, - [SDL_SCANCODE_INTERNATIONAL4] = Q_KEY_CODE_INTERNATIONAL4, - [SDL_SCANCODE_INTERNATIONAL5] = Q_KEY_CODE_INTERNATIONAL5, - [SDL_SCANCODE_INTERNATIONAL6] = Q_KEY_CODE_INTERNATIONAL6, - [SDL_SCANCODE_INTERNATIONAL7] = Q_KEY_CODE_INTERNATIONAL7, - [SDL_SCANCODE_INTERNATIONAL8] = Q_KEY_CODE_INTERNATIONAL8, - [SDL_SCANCODE_INTERNATIONAL9] = Q_KEY_CODE_INTERNATIONAL9, - [SDL_SCANCODE_LANG1] = Q_KEY_CODE_LANG1, - [SDL_SCANCODE_LANG2] = Q_KEY_CODE_LANG2, - [SDL_SCANCODE_LANG3] = Q_KEY_CODE_LANG3, - [SDL_SCANCODE_LANG4] = Q_KEY_CODE_LANG4, - [SDL_SCANCODE_LANG5] = Q_KEY_CODE_LANG5, - [SDL_SCANCODE_LANG6] = Q_KEY_CODE_LANG6, - [SDL_SCANCODE_LANG7] = Q_KEY_CODE_LANG7, - [SDL_SCANCODE_LANG8] = Q_KEY_CODE_LANG8, - [SDL_SCANCODE_LANG9] = Q_KEY_CODE_LANG9, - [SDL_SCANCODE_ALTERASE] = Q_KEY_CODE_ALTERASE, + [SDL_SCANCODE_INTERNATIONAL1] = QKeyCode_international1, + [SDL_SCANCODE_INTERNATIONAL2] = QKeyCode_international2, + [SDL_SCANCODE_INTERNATIONAL3] = QKeyCode_international3, + [SDL_SCANCODE_INTERNATIONAL4] = QKeyCode_international4, + [SDL_SCANCODE_INTERNATIONAL5] = QKeyCode_international5, + [SDL_SCANCODE_INTERNATIONAL6] = QKeyCode_international6, + [SDL_SCANCODE_INTERNATIONAL7] = QKeyCode_international7, + [SDL_SCANCODE_INTERNATIONAL8] = QKeyCode_international8, + [SDL_SCANCODE_INTERNATIONAL9] = QKeyCode_international9, + [SDL_SCANCODE_LANG1] = QKeyCode_lang1, + [SDL_SCANCODE_LANG2] = QKeyCode_lang2, + [SDL_SCANCODE_LANG3] = QKeyCode_lang3, + [SDL_SCANCODE_LANG4] = QKeyCode_lang4, + [SDL_SCANCODE_LANG5] = QKeyCode_lang5, + [SDL_SCANCODE_LANG6] = QKeyCode_lang6, + [SDL_SCANCODE_LANG7] = QKeyCode_lang7, + [SDL_SCANCODE_LANG8] = QKeyCode_lang8, + [SDL_SCANCODE_LANG9] = QKeyCode_lang9, + [SDL_SCANCODE_ALTERASE] = QKeyCode_alterase, #endif - [SDL_SCANCODE_SYSREQ] = Q_KEY_CODE_SYSRQ, + [SDL_SCANCODE_SYSREQ] = QKeyCode_sysrq, #if 0 - [SDL_SCANCODE_CANCEL] = Q_KEY_CODE_CANCEL, - [SDL_SCANCODE_CLEAR] = Q_KEY_CODE_CLEAR, - [SDL_SCANCODE_PRIOR] = Q_KEY_CODE_PRIOR, - [SDL_SCANCODE_RETURN2] = Q_KEY_CODE_RETURN2, - [SDL_SCANCODE_SEPARATOR] = Q_KEY_CODE_SEPARATOR, - [SDL_SCANCODE_OUT] = Q_KEY_CODE_OUT, - [SDL_SCANCODE_OPER] = Q_KEY_CODE_OPER, - [SDL_SCANCODE_CLEARAGAIN] = Q_KEY_CODE_CLEARAGAIN, - [SDL_SCANCODE_CRSEL] = Q_KEY_CODE_CRSEL, - [SDL_SCANCODE_EXSEL] = Q_KEY_CODE_EXSEL, - [SDL_SCANCODE_KP_00] = Q_KEY_CODE_KP_00, - [SDL_SCANCODE_KP_000] = Q_KEY_CODE_KP_000, - [SDL_SCANCODE_THOUSANDSSEPARATOR] = Q_KEY_CODE_THOUSANDSSEPARATOR, - [SDL_SCANCODE_DECIMALSEPARATOR] = Q_KEY_CODE_DECIMALSEPARATOR, - [SDL_SCANCODE_CURRENCYUNIT] = Q_KEY_CODE_CURRENCYUNIT, - [SDL_SCANCODE_CURRENCYSUBUNIT] = Q_KEY_CODE_CURRENCYSUBUNIT, - [SDL_SCANCODE_KP_LEFTPAREN] = Q_KEY_CODE_KP_LEFTPAREN, - [SDL_SCANCODE_KP_RIGHTPAREN] = Q_KEY_CODE_KP_RIGHTPAREN, - [SDL_SCANCODE_KP_LEFTBRACE] = Q_KEY_CODE_KP_LEFTBRACE, - [SDL_SCANCODE_KP_RIGHTBRACE] = Q_KEY_CODE_KP_RIGHTBRACE, - [SDL_SCANCODE_KP_TAB] = Q_KEY_CODE_KP_TAB, - [SDL_SCANCODE_KP_BACKSPACE] = Q_KEY_CODE_KP_BACKSPACE, - [SDL_SCANCODE_KP_A] = Q_KEY_CODE_KP_A, - [SDL_SCANCODE_KP_B] = Q_KEY_CODE_KP_B, - [SDL_SCANCODE_KP_C] = Q_KEY_CODE_KP_C, - [SDL_SCANCODE_KP_D] = Q_KEY_CODE_KP_D, - [SDL_SCANCODE_KP_E] = Q_KEY_CODE_KP_E, - [SDL_SCANCODE_KP_F] = Q_KEY_CODE_KP_F, - [SDL_SCANCODE_KP_XOR] = Q_KEY_CODE_KP_XOR, - [SDL_SCANCODE_KP_POWER] = Q_KEY_CODE_KP_POWER, - [SDL_SCANCODE_KP_PERCENT] = Q_KEY_CODE_KP_PERCENT, - [SDL_SCANCODE_KP_LESS] = Q_KEY_CODE_KP_LESS, - [SDL_SCANCODE_KP_GREATER] = Q_KEY_CODE_KP_GREATER, - [SDL_SCANCODE_KP_AMPERSAND] = Q_KEY_CODE_KP_AMPERSAND, - [SDL_SCANCODE_KP_DBLAMPERSAND] = Q_KEY_CODE_KP_DBLAMPERSAND, - [SDL_SCANCODE_KP_VERTICALBAR] = Q_KEY_CODE_KP_VERTICALBAR, - [SDL_SCANCODE_KP_DBLVERTICALBAR] = Q_KEY_CODE_KP_DBLVERTICALBAR, - [SDL_SCANCODE_KP_COLON] = Q_KEY_CODE_KP_COLON, - [SDL_SCANCODE_KP_HASH] = Q_KEY_CODE_KP_HASH, - [SDL_SCANCODE_KP_SPACE] = Q_KEY_CODE_KP_SPACE, - [SDL_SCANCODE_KP_AT] = Q_KEY_CODE_KP_AT, - [SDL_SCANCODE_KP_EXCLAM] = Q_KEY_CODE_KP_EXCLAM, - [SDL_SCANCODE_KP_MEMSTORE] = Q_KEY_CODE_KP_MEMSTORE, - [SDL_SCANCODE_KP_MEMRECALL] = Q_KEY_CODE_KP_MEMRECALL, - [SDL_SCANCODE_KP_MEMCLEAR] = Q_KEY_CODE_KP_MEMCLEAR, - [SDL_SCANCODE_KP_MEMADD] = Q_KEY_CODE_KP_MEMADD, - [SDL_SCANCODE_KP_MEMSUBTRACT] = Q_KEY_CODE_KP_MEMSUBTRACT, - [SDL_SCANCODE_KP_MEMMULTIPLY] = Q_KEY_CODE_KP_MEMMULTIPLY, - [SDL_SCANCODE_KP_MEMDIVIDE] = Q_KEY_CODE_KP_MEMDIVIDE, - [SDL_SCANCODE_KP_PLUSMINUS] = Q_KEY_CODE_KP_PLUSMINUS, - [SDL_SCANCODE_KP_CLEAR] = Q_KEY_CODE_KP_CLEAR, - [SDL_SCANCODE_KP_CLEARENTRY] = Q_KEY_CODE_KP_CLEARENTRY, - [SDL_SCANCODE_KP_BINARY] = Q_KEY_CODE_KP_BINARY, - [SDL_SCANCODE_KP_OCTAL] = Q_KEY_CODE_KP_OCTAL, - [SDL_SCANCODE_KP_DECIMAL] = Q_KEY_CODE_KP_DECIMAL, - [SDL_SCANCODE_KP_HEXADECIMAL] = Q_KEY_CODE_KP_HEXADECIMAL, + [SDL_SCANCODE_CANCEL] = QKeyCode_cancel, + [SDL_SCANCODE_CLEAR] = QKeyCode_clear, + [SDL_SCANCODE_PRIOR] = QKeyCode_prior, + [SDL_SCANCODE_RETURN2] = QKeyCode_return2, + [SDL_SCANCODE_SEPARATOR] = QKeyCode_separator, + [SDL_SCANCODE_OUT] = QKeyCode_out, + [SDL_SCANCODE_OPER] = QKeyCode_oper, + [SDL_SCANCODE_CLEARAGAIN] = QKeyCode_clearagain, + [SDL_SCANCODE_CRSEL] = QKeyCode_crsel, + [SDL_SCANCODE_EXSEL] = QKeyCode_exsel, + [SDL_SCANCODE_KP_00] = QKeyCode_kp_00, + [SDL_SCANCODE_KP_000] = QKeyCode_kp_000, + [SDL_SCANCODE_THOUSANDSSEPARATOR] = QKeyCode_thousandsseparator, + [SDL_SCANCODE_DECIMALSEPARATOR] = QKeyCode_decimalseparator, + [SDL_SCANCODE_CURRENCYUNIT] = QKeyCode_currencyunit, + [SDL_SCANCODE_CURRENCYSUBUNIT] = QKeyCode_currencysubunit, + [SDL_SCANCODE_KP_LEFTPAREN] = QKeyCode_kp_leftparen, + [SDL_SCANCODE_KP_RIGHTPAREN] = QKeyCode_kp_rightparen, + [SDL_SCANCODE_KP_LEFTBRACE] = QKeyCode_kp_leftbrace, + [SDL_SCANCODE_KP_RIGHTBRACE] = QKeyCode_kp_rightbrace, + [SDL_SCANCODE_KP_TAB] = QKeyCode_kp_tab, + [SDL_SCANCODE_KP_BACKSPACE] = QKeyCode_kp_backspace, + [SDL_SCANCODE_KP_A] = QKeyCode_kp_a, + [SDL_SCANCODE_KP_B] = QKeyCode_kp_b, + [SDL_SCANCODE_KP_C] = QKeyCode_kp_c, + [SDL_SCANCODE_KP_D] = QKeyCode_kp_d, + [SDL_SCANCODE_KP_E] = QKeyCode_kp_e, + [SDL_SCANCODE_KP_F] = QKeyCode_kp_f, + [SDL_SCANCODE_KP_XOR] = QKeyCode_kp_xor, + [SDL_SCANCODE_KP_POWER] = QKeyCode_kp_power, + [SDL_SCANCODE_KP_PERCENT] = QKeyCode_kp_percent, + [SDL_SCANCODE_KP_LESS] = QKeyCode_kp_less, + [SDL_SCANCODE_KP_GREATER] = QKeyCode_kp_greater, + [SDL_SCANCODE_KP_AMPERSAND] = QKeyCode_kp_ampersand, + [SDL_SCANCODE_KP_DBLAMPERSAND] = QKeyCode_kp_dblampersand, + [SDL_SCANCODE_KP_VERTICALBAR] = QKeyCode_kp_verticalbar, + [SDL_SCANCODE_KP_DBLVERTICALBAR] = QKeyCode_kp_dblverticalbar, + [SDL_SCANCODE_KP_COLON] = QKeyCode_kp_colon, + [SDL_SCANCODE_KP_HASH] = QKeyCode_kp_hash, + [SDL_SCANCODE_KP_SPACE] = QKeyCode_kp_space, + [SDL_SCANCODE_KP_AT] = QKeyCode_kp_at, + [SDL_SCANCODE_KP_EXCLAM] = QKeyCode_kp_exclam, + [SDL_SCANCODE_KP_MEMSTORE] = QKeyCode_kp_memstore, + [SDL_SCANCODE_KP_MEMRECALL] = QKeyCode_kp_memrecall, + [SDL_SCANCODE_KP_MEMCLEAR] = QKeyCode_kp_memclear, + [SDL_SCANCODE_KP_MEMADD] = QKeyCode_kp_memadd, + [SDL_SCANCODE_KP_MEMSUBTRACT] = QKeyCode_kp_memsubtract, + [SDL_SCANCODE_KP_MEMMULTIPLY] = QKeyCode_kp_memmultiply, + [SDL_SCANCODE_KP_MEMDIVIDE] = QKeyCode_kp_memdivide, + [SDL_SCANCODE_KP_PLUSMINUS] = QKeyCode_kp_plusminus, + [SDL_SCANCODE_KP_CLEAR] = QKeyCode_kp_clear, + [SDL_SCANCODE_KP_CLEARENTRY] = QKeyCode_kp_clearentry, + [SDL_SCANCODE_KP_BINARY] = QKeyCode_kp_binary, + [SDL_SCANCODE_KP_OCTAL] = QKeyCode_kp_octal, + [SDL_SCANCODE_KP_DECIMAL] = QKeyCode_kp_decimal, + [SDL_SCANCODE_KP_HEXADECIMAL] = QKeyCode_kp_hexadecimal, #endif - [SDL_SCANCODE_LCTRL] = Q_KEY_CODE_CTRL, - [SDL_SCANCODE_LSHIFT] = Q_KEY_CODE_SHIFT, - [SDL_SCANCODE_LALT] = Q_KEY_CODE_ALT, - [SDL_SCANCODE_LGUI] = Q_KEY_CODE_META_L, - [SDL_SCANCODE_RCTRL] = Q_KEY_CODE_CTRL_R, - [SDL_SCANCODE_RSHIFT] = Q_KEY_CODE_SHIFT_R, - [SDL_SCANCODE_RALT] = Q_KEY_CODE_ALT_R, - [SDL_SCANCODE_RGUI] = Q_KEY_CODE_META_R, + [SDL_SCANCODE_LCTRL] = QKeyCode_ctrl, + [SDL_SCANCODE_LSHIFT] = QKeyCode_shift, + [SDL_SCANCODE_LALT] = QKeyCode_alt, + [SDL_SCANCODE_LGUI] = QKeyCode_meta_l, + [SDL_SCANCODE_RCTRL] = QKeyCode_ctrl_r, + [SDL_SCANCODE_RSHIFT] = QKeyCode_shift_r, + [SDL_SCANCODE_RALT] = QKeyCode_alt_r, + [SDL_SCANCODE_RGUI] = QKeyCode_meta_r, #if 0 - [SDL_SCANCODE_MODE] = Q_KEY_CODE_MODE, - [SDL_SCANCODE_AUDIONEXT] = Q_KEY_CODE_AUDIONEXT, - [SDL_SCANCODE_AUDIOPREV] = Q_KEY_CODE_AUDIOPREV, - [SDL_SCANCODE_AUDIOSTOP] = Q_KEY_CODE_AUDIOSTOP, - [SDL_SCANCODE_AUDIOPLAY] = Q_KEY_CODE_AUDIOPLAY, - [SDL_SCANCODE_AUDIOMUTE] = Q_KEY_CODE_AUDIOMUTE, - [SDL_SCANCODE_MEDIASELECT] = Q_KEY_CODE_MEDIASELECT, - [SDL_SCANCODE_WWW] = Q_KEY_CODE_WWW, - [SDL_SCANCODE_MAIL] = Q_KEY_CODE_MAIL, - [SDL_SCANCODE_CALCULATOR] = Q_KEY_CODE_CALCULATOR, - [SDL_SCANCODE_COMPUTER] = Q_KEY_CODE_COMPUTER, - [SDL_SCANCODE_AC_SEARCH] = Q_KEY_CODE_AC_SEARCH, - [SDL_SCANCODE_AC_HOME] = Q_KEY_CODE_AC_HOME, - [SDL_SCANCODE_AC_BACK] = Q_KEY_CODE_AC_BACK, - [SDL_SCANCODE_AC_FORWARD] = Q_KEY_CODE_AC_FORWARD, - [SDL_SCANCODE_AC_STOP] = Q_KEY_CODE_AC_STOP, - [SDL_SCANCODE_AC_REFRESH] = Q_KEY_CODE_AC_REFRESH, - [SDL_SCANCODE_AC_BOOKMARKS] = Q_KEY_CODE_AC_BOOKMARKS, - [SDL_SCANCODE_BRIGHTNESSDOWN] = Q_KEY_CODE_BRIGHTNESSDOWN, - [SDL_SCANCODE_BRIGHTNESSUP] = Q_KEY_CODE_BRIGHTNESSUP, - [SDL_SCANCODE_DISPLAYSWITCH] = Q_KEY_CODE_DISPLAYSWITCH, - [SDL_SCANCODE_KBDILLUMTOGGLE] = Q_KEY_CODE_KBDILLUMTOGGLE, - [SDL_SCANCODE_KBDILLUMDOWN] = Q_KEY_CODE_KBDILLUMDOWN, - [SDL_SCANCODE_KBDILLUMUP] = Q_KEY_CODE_KBDILLUMUP, - [SDL_SCANCODE_EJECT] = Q_KEY_CODE_EJECT, - [SDL_SCANCODE_SLEEP] = Q_KEY_CODE_SLEEP, - [SDL_SCANCODE_APP1] = Q_KEY_CODE_APP1, - [SDL_SCANCODE_APP2] = Q_KEY_CODE_APP2, + [SDL_SCANCODE_MODE] = QKeyCode_mode, + [SDL_SCANCODE_AUDIONEXT] = QKeyCode_audionext, + [SDL_SCANCODE_AUDIOPREV] = QKeyCode_audioprev, + [SDL_SCANCODE_AUDIOSTOP] = QKeyCode_audiostop, + [SDL_SCANCODE_AUDIOPLAY] = QKeyCode_audioplay, + [SDL_SCANCODE_AUDIOMUTE] = QKeyCode_audiomute, + [SDL_SCANCODE_MEDIASELECT] = QKeyCode_mediaselect, + [SDL_SCANCODE_WWW] = QKeyCode_www, + [SDL_SCANCODE_MAIL] = QKeyCode_mail, + [SDL_SCANCODE_CALCULATOR] = QKeyCode_calculator, + [SDL_SCANCODE_COMPUTER] = QKeyCode_computer, + [SDL_SCANCODE_AC_SEARCH] = QKeyCode_ac_search, + [SDL_SCANCODE_AC_HOME] = QKeyCode_ac_home, + [SDL_SCANCODE_AC_BACK] = QKeyCode_ac_back, + [SDL_SCANCODE_AC_FORWARD] = QKeyCode_ac_forward, + [SDL_SCANCODE_AC_STOP] = QKeyCode_ac_stop, + [SDL_SCANCODE_AC_REFRESH] = QKeyCode_ac_refresh, + [SDL_SCANCODE_AC_BOOKMARKS] = QKeyCode_ac_bookmarks, + [SDL_SCANCODE_BRIGHTNESSDOWN] = QKeyCode_brightnessdown, + [SDL_SCANCODE_BRIGHTNESSUP] = QKeyCode_brightnessup, + [SDL_SCANCODE_DISPLAYSWITCH] = QKeyCode_displayswitch, + [SDL_SCANCODE_KBDILLUMTOGGLE] = QKeyCode_kbdillumtoggle, + [SDL_SCANCODE_KBDILLUMDOWN] = QKeyCode_kbdillumdown, + [SDL_SCANCODE_KBDILLUMUP] = QKeyCode_kbdillumup, + [SDL_SCANCODE_EJECT] = QKeyCode_eject, + [SDL_SCANCODE_SLEEP] = QKeyCode_sleep, + [SDL_SCANCODE_APP1] = QKeyCode_app1, + [SDL_SCANCODE_APP2] = QKeyCode_app2, #endif }; diff --git a/ui/sdl2.c b/ui/sdl2.c index 5cb75aa..9a4a5ca 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -256,10 +256,10 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data) static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy, int x, int y, int state) { - static uint32_t bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = SDL_BUTTON(SDL_BUTTON_LEFT), - [INPUT_BUTTON_MIDDLE] = SDL_BUTTON(SDL_BUTTON_MIDDLE), - [INPUT_BUTTON_RIGHT] = SDL_BUTTON(SDL_BUTTON_RIGHT), + static uint32_t bmap[InputButton_MAX] = { + [InputButton_Left] = SDL_BUTTON(SDL_BUTTON_LEFT), + [InputButton_Middle] = SDL_BUTTON(SDL_BUTTON_MIDDLE), + [InputButton_Right] = SDL_BUTTON(SDL_BUTTON_RIGHT), }; static uint32_t prev_state; @@ -293,8 +293,8 @@ static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy, } } } - qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X, off_x + x, max_w); - qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y, off_y + y, max_h); + qemu_input_queue_abs(scon->dcl.con, InputAxis_X, off_x + x, max_w); + qemu_input_queue_abs(scon->dcl.con, InputAxis_Y, off_y + y, max_h); } else { if (guest_cursor) { x -= guest_x; @@ -304,8 +304,8 @@ static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy, dx = x; dy = y; } - qemu_input_queue_rel(scon->dcl.con, INPUT_AXIS_X, dx); - qemu_input_queue_rel(scon->dcl.con, INPUT_AXIS_Y, dy); + qemu_input_queue_rel(scon->dcl.con, InputAxis_X, dx); + qemu_input_queue_rel(scon->dcl.con, InputAxis_Y, dy); } qemu_input_event_sync(); } @@ -504,9 +504,9 @@ static void handle_mousewheel(SDL_Event *ev) InputButton btn; if (wev->y > 0) { - btn = INPUT_BUTTON_WHEEL_UP; + btn = InputButton_WheelUp; } else if (wev->y < 0) { - btn = INPUT_BUTTON_WHEEL_DOWN; + btn = InputButton_WheelDown; } else { return; } diff --git a/ui/spice-core.c b/ui/spice-core.c index 6a62d71..e62a6f7 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -547,8 +547,8 @@ SpiceInfo *qmp_query_spice(Error **errp) } info->mouse_mode = spice_server_is_server_mouse(spice_server) ? - SPICE_QUERY_MOUSE_MODE_SERVER : - SPICE_QUERY_MOUSE_MODE_CLIENT; + SpiceQueryMouseMode_server : + SpiceQueryMouseMode_client; /* for compatibility with the original command */ info->has_channels = true; diff --git a/ui/spice-input.c b/ui/spice-input.c index c342e0d..5dc2bb2 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -107,12 +107,12 @@ typedef struct QemuSpicePointer { static void spice_update_buttons(QemuSpicePointer *pointer, int wheel, uint32_t button_mask) { - static uint32_t bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = 0x01, - [INPUT_BUTTON_MIDDLE] = 0x04, - [INPUT_BUTTON_RIGHT] = 0x02, - [INPUT_BUTTON_WHEEL_UP] = 0x10, - [INPUT_BUTTON_WHEEL_DOWN] = 0x20, + static uint32_t bmap[InputButton_MAX] = { + [InputButton_Left] = 0x01, + [InputButton_Middle] = 0x04, + [InputButton_Right] = 0x02, + [InputButton_WheelUp] = 0x10, + [InputButton_WheelDown] = 0x20, }; if (wheel < 0) { @@ -134,8 +134,8 @@ static void mouse_motion(SpiceMouseInstance *sin, int dx, int dy, int dz, { QemuSpicePointer *pointer = container_of(sin, QemuSpicePointer, mouse); spice_update_buttons(pointer, dz, buttons_state); - qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx); - qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy); + qemu_input_queue_rel(NULL, InputAxis_X, dx); + qemu_input_queue_rel(NULL, InputAxis_Y, dy); qemu_input_event_sync(); } @@ -175,8 +175,8 @@ static void tablet_position(SpiceTabletInstance* sin, int x, int y, QemuSpicePointer *pointer = container_of(sin, QemuSpicePointer, tablet); spice_update_buttons(pointer, 0, buttons_state); - qemu_input_queue_abs(NULL, INPUT_AXIS_X, x, pointer->width); - qemu_input_queue_abs(NULL, INPUT_AXIS_Y, y, pointer->height); + qemu_input_queue_abs(NULL, InputAxis_X, x, pointer->width); + qemu_input_queue_abs(NULL, InputAxis_Y, y, pointer->height); qemu_input_event_sync(); } diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c index 44ac2fa..201cfc9 100644 --- a/ui/vnc-auth-vencrypt.c +++ b/ui/vnc-auth-vencrypt.c @@ -132,7 +132,7 @@ static int protocol_client_vencrypt_auth(VncState *vs, uint8_t *data, size_t len vs->tls = qcrypto_tls_session_new(vs->vd->tlscreds, NULL, vs->vd->tlsaclname, - QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, + QCRYPTO_TLS_CREDS_ENDPOINT_server, &err); if (!vs->tls) { VNC_DEBUG("Failed to setup TLS %s\n", diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c index 175ea50..3804b73 100644 --- a/ui/vnc-ws.c +++ b/ui/vnc-ws.c @@ -68,7 +68,7 @@ void vncws_tls_handshake_io(void *opaque) vs->tls = qcrypto_tls_session_new(vs->vd->tlscreds, NULL, vs->vd->tlsaclname, - QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, + QCRYPTO_TLS_CREDS_ENDPOINT_server, &err); if (!vs->tls) { VNC_DEBUG("Failed to setup TLS %s\n", diff --git a/ui/vnc.c b/ui/vnc.c index 7b37e3b..0cd19f6 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -324,14 +324,14 @@ static void vnc_qmp_event(VncState *vs, QAPIEvent event) } switch (event) { - case QAPI_EVENT_VNC_CONNECTED: + case QAPIEvent_VNC_CONNECTED: qapi_event_send_vnc_connected(si, qapi_VncClientInfo_base(vs->info), &error_abort); break; - case QAPI_EVENT_VNC_INITIALIZED: + case QAPIEvent_VNC_INITIALIZED: qapi_event_send_vnc_initialized(si, vs->info, &error_abort); break; - case QAPI_EVENT_VNC_DISCONNECTED: + case QAPIEvent_VNC_DISCONNECTED: qapi_event_send_vnc_disconnected(si, vs->info, &error_abort); break; default: @@ -500,53 +500,53 @@ static void qmp_query_auth(VncDisplay *vd, VncInfo2 *info) { switch (vd->auth) { case VNC_AUTH_VNC: - info->auth = VNC_PRIMARY_AUTH_VNC; + info->auth = VncPrimaryAuth_vnc; break; case VNC_AUTH_RA2: - info->auth = VNC_PRIMARY_AUTH_RA2; + info->auth = VncPrimaryAuth_ra2; break; case VNC_AUTH_RA2NE: - info->auth = VNC_PRIMARY_AUTH_RA2NE; + info->auth = VncPrimaryAuth_ra2ne; break; case VNC_AUTH_TIGHT: - info->auth = VNC_PRIMARY_AUTH_TIGHT; + info->auth = VncPrimaryAuth_tight; break; case VNC_AUTH_ULTRA: - info->auth = VNC_PRIMARY_AUTH_ULTRA; + info->auth = VncPrimaryAuth_ultra; break; case VNC_AUTH_TLS: - info->auth = VNC_PRIMARY_AUTH_TLS; + info->auth = VncPrimaryAuth_tls; break; case VNC_AUTH_VENCRYPT: - info->auth = VNC_PRIMARY_AUTH_VENCRYPT; + info->auth = VncPrimaryAuth_vencrypt; info->has_vencrypt = true; switch (vd->subauth) { case VNC_AUTH_VENCRYPT_PLAIN: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_PLAIN; + info->vencrypt = VncVencryptSubAuth_plain; break; case VNC_AUTH_VENCRYPT_TLSNONE: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_NONE; + info->vencrypt = VncVencryptSubAuth_tls_none; break; case VNC_AUTH_VENCRYPT_TLSVNC: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_VNC; + info->vencrypt = VncVencryptSubAuth_tls_vnc; break; case VNC_AUTH_VENCRYPT_TLSPLAIN: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_PLAIN; + info->vencrypt = VncVencryptSubAuth_tls_plain; break; case VNC_AUTH_VENCRYPT_X509NONE: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_NONE; + info->vencrypt = VncVencryptSubAuth_x509_none; break; case VNC_AUTH_VENCRYPT_X509VNC: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_VNC; + info->vencrypt = VncVencryptSubAuth_x509_vnc; break; case VNC_AUTH_VENCRYPT_X509PLAIN: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_PLAIN; + info->vencrypt = VncVencryptSubAuth_x509_plain; break; case VNC_AUTH_VENCRYPT_TLSSASL: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_TLS_SASL; + info->vencrypt = VncVencryptSubAuth_tls_sasl; break; case VNC_AUTH_VENCRYPT_X509SASL: - info->vencrypt = VNC_VENCRYPT_SUB_AUTH_X509_SASL; + info->vencrypt = VncVencryptSubAuth_x509_sasl; break; default: info->has_vencrypt = false; @@ -554,11 +554,11 @@ static void qmp_query_auth(VncDisplay *vd, VncInfo2 *info) } break; case VNC_AUTH_SASL: - info->auth = VNC_PRIMARY_AUTH_SASL; + info->auth = VncPrimaryAuth_sasl; break; case VNC_AUTH_NONE: default: - info->auth = VNC_PRIMARY_AUTH_NONE; + info->auth = VncPrimaryAuth_none; break; } } @@ -1185,7 +1185,7 @@ void vnc_disconnect_finish(VncState *vs) vnc_jobs_join(vs); /* Wait encoding jobs */ vnc_lock_output(vs); - vnc_qmp_event(vs, QAPI_EVENT_VNC_DISCONNECTED); + vnc_qmp_event(vs, QAPIEvent_VNC_DISCONNECTED); buffer_free(&vs->input); buffer_free(&vs->output); @@ -1630,12 +1630,12 @@ static void check_pointer_type_change(Notifier *notifier, void *data) static void pointer_event(VncState *vs, int button_mask, int x, int y) { - static uint32_t bmap[INPUT_BUTTON_MAX] = { - [INPUT_BUTTON_LEFT] = 0x01, - [INPUT_BUTTON_MIDDLE] = 0x02, - [INPUT_BUTTON_RIGHT] = 0x04, - [INPUT_BUTTON_WHEEL_UP] = 0x08, - [INPUT_BUTTON_WHEEL_DOWN] = 0x10, + static uint32_t bmap[InputButton_MAX] = { + [InputButton_Left] = 0x01, + [InputButton_Middle] = 0x02, + [InputButton_Right] = 0x04, + [InputButton_WheelUp] = 0x08, + [InputButton_WheelDown] = 0x10, }; QemuConsole *con = vs->vd->dcl.con; int width = pixman_image_get_width(vs->vd->server); @@ -1647,15 +1647,15 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y) } if (vs->absolute) { - qemu_input_queue_abs(con, INPUT_AXIS_X, x, width); - qemu_input_queue_abs(con, INPUT_AXIS_Y, y, height); + qemu_input_queue_abs(con, InputAxis_X, x, width); + qemu_input_queue_abs(con, InputAxis_Y, y, height); } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) { - qemu_input_queue_rel(con, INPUT_AXIS_X, x - 0x7FFF); - qemu_input_queue_rel(con, INPUT_AXIS_Y, y - 0x7FFF); + qemu_input_queue_rel(con, InputAxis_X, x - 0x7FFF); + qemu_input_queue_rel(con, InputAxis_Y, y - 0x7FFF); } else { if (vs->last_x != -1) { - qemu_input_queue_rel(con, INPUT_AXIS_X, x - vs->last_x); - qemu_input_queue_rel(con, INPUT_AXIS_Y, y - vs->last_y); + qemu_input_queue_rel(con, InputAxis_X, x - vs->last_x); + qemu_input_queue_rel(con, InputAxis_Y, y - vs->last_y); } vs->last_x = x; vs->last_y = y; @@ -2458,7 +2458,7 @@ static int protocol_client_init(VncState *vs, uint8_t *data, size_t len) vnc_flush(vs); vnc_client_cache_auth(vs); - vnc_qmp_event(vs, QAPI_EVENT_VNC_INITIALIZED); + vnc_qmp_event(vs, QAPIEvent_VNC_INITIALIZED); vnc_read_when(vs, protocol_client_msg, 1); @@ -3008,7 +3008,7 @@ static void vnc_connect(VncDisplay *vd, int csock, } vnc_client_cache_addr(vs); - vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); + vnc_qmp_event(vs, QAPIEvent_VNC_CONNECTED); vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); if (!vs->websocket) { @@ -3524,7 +3524,7 @@ void vnc_display_open(const char *id, Error **errp) } if (strncmp(vnc, "unix:", 5) == 0) { - saddr->type = SOCKET_ADDRESS_KIND_UNIX; + saddr->type = SocketAddressKind_unix; saddr->u.q_unix = g_new0(UnixSocketAddress, 1); saddr->u.q_unix->path = g_strdup(vnc + 5); @@ -3534,7 +3534,7 @@ void vnc_display_open(const char *id, Error **errp) } } else { unsigned long long baseport; - saddr->type = SOCKET_ADDRESS_KIND_INET; + saddr->type = SocketAddressKind_inet; saddr->u.inet = g_new0(InetSocketAddress, 1); if (vnc[0] == '[' && vnc[hlen - 1] == ']') { saddr->u.inet->host = g_strndup(vnc + 1, hlen - 2); @@ -3561,7 +3561,7 @@ void vnc_display_open(const char *id, Error **errp) saddr->u.inet->ipv6 = saddr->u.inet->has_ipv6 = has_ipv6; if (vs->ws_enabled) { - wsaddr->type = SOCKET_ADDRESS_KIND_INET; + wsaddr->type = SocketAddressKind_inet; wsaddr->u.inet = g_new0(InetSocketAddress, 1); wsaddr->u.inet->host = g_strdup(saddr->u.inet->host); wsaddr->u.inet->port = g_strdup(websocket); @@ -3634,7 +3634,7 @@ void vnc_display_open(const char *id, Error **errp) } object_ref(OBJECT(vs->tlscreds)); - if (vs->tlscreds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { + if (vs->tlscreds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_server) { error_setg(errp, "Expecting TLS credentials with a server endpoint"); goto fail; @@ -3770,7 +3770,7 @@ void vnc_display_open(const char *id, Error **errp) if (csock < 0) { goto fail; } - vs->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX; + vs->is_unix = saddr->type == SocketAddressKind_unix; vnc_connect(vs, csock, false, false); } else { /* listen for connects */ @@ -3778,7 +3778,7 @@ void vnc_display_open(const char *id, Error **errp) if (vs->lsock < 0) { goto fail; } - vs->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX; + vs->is_unix = saddr->type == SocketAddressKind_unix; if (vs->ws_enabled) { vs->lwebsock = socket_listen(wsaddr, errp); if (vs->lwebsock < 0) { diff --git a/util/error.c b/util/error.c index 8b86490..8631612 100644 --- a/util/error.c +++ b/util/error.c @@ -85,7 +85,7 @@ void error_setg_internal(Error **errp, va_list ap; va_start(ap, fmt); - error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap); + error_setv(errp, src, line, func, ErrorClass_GenericError, fmt, ap); va_end(ap); } @@ -102,7 +102,7 @@ void error_setg_errno_internal(Error **errp, } va_start(ap, fmt); - error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap); + error_setv(errp, src, line, func, ErrorClass_GenericError, fmt, ap); va_end(ap); if (os_errno != 0) { @@ -158,7 +158,7 @@ void error_setg_win32_internal(Error **errp, } va_start(ap, fmt); - error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap); + error_setv(errp, src, line, func, ErrorClass_GenericError, fmt, ap); va_end(ap); if (win32_err != 0) { diff --git a/util/qemu-config.c b/util/qemu-config.c index 687fd34..932b81f 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -62,16 +62,16 @@ static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc) switch (desc[i].type) { case QEMU_OPT_STRING: - info->type = COMMAND_LINE_PARAMETER_TYPE_STRING; + info->type = CommandLineParameterType_string; break; case QEMU_OPT_BOOL: - info->type = COMMAND_LINE_PARAMETER_TYPE_BOOLEAN; + info->type = CommandLineParameterType_boolean; break; case QEMU_OPT_NUMBER: - info->type = COMMAND_LINE_PARAMETER_TYPE_NUMBER; + info->type = CommandLineParameterType_number; break; case QEMU_OPT_SIZE: - info->type = COMMAND_LINE_PARAMETER_TYPE_SIZE; + info->type = CommandLineParameterType_size; break; } diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index dfe4587..bd9de9b 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -107,11 +107,11 @@ static void inet_setport(struct addrinfo *e, int port) NetworkAddressFamily inet_netfamily(int family) { switch (family) { - case PF_INET6: return NETWORK_ADDRESS_FAMILY_IPV6; - case PF_INET: return NETWORK_ADDRESS_FAMILY_IPV4; - case PF_UNIX: return NETWORK_ADDRESS_FAMILY_UNIX; + case PF_INET6: return NetworkAddressFamily_ipv6; + case PF_INET: return NetworkAddressFamily_ipv4; + case PF_UNIX: return NetworkAddressFamily_unix; } - return NETWORK_ADDRESS_FAMILY_UNKNOWN; + return NetworkAddressFamily_unknown; } int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) @@ -918,7 +918,7 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid Unix socket address"); goto fail; } else { - addr->type = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SocketAddressKind_unix; addr->u.q_unix = g_new(UnixSocketAddress, 1); addr->u.q_unix->path = g_strdup(str + 5); } @@ -927,12 +927,12 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid file descriptor address"); goto fail; } else { - addr->type = SOCKET_ADDRESS_KIND_FD; + addr->type = SocketAddressKind_fd; addr->u.fd = g_new(String, 1); addr->u.fd->str = g_strdup(str + 3); } } else { - addr->type = SOCKET_ADDRESS_KIND_INET; + addr->type = SocketAddressKind_inet; addr->u.inet = inet_parse(str, errp); if (addr->u.inet == NULL) { goto fail; @@ -953,17 +953,17 @@ int socket_connect(SocketAddress *addr, Error **errp, opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (addr->type) { - case SOCKET_ADDRESS_KIND_INET: + case SocketAddressKind_inet: inet_addr_to_opts(opts, addr->u.inet); fd = inet_connect_opts(opts, errp, callback, opaque); break; - case SOCKET_ADDRESS_KIND_UNIX: + case SocketAddressKind_unix: qemu_opt_set(opts, "path", addr->u.q_unix->path, &error_abort); fd = unix_connect_opts(opts, errp, callback, opaque); break; - case SOCKET_ADDRESS_KIND_FD: + case SocketAddressKind_fd: fd = monitor_get_fd(cur_mon, addr->u.fd->str, errp); if (fd >= 0 && callback) { qemu_set_nonblock(fd); @@ -985,17 +985,17 @@ int socket_listen(SocketAddress *addr, Error **errp) opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (addr->type) { - case SOCKET_ADDRESS_KIND_INET: + case SocketAddressKind_inet: inet_addr_to_opts(opts, addr->u.inet); fd = inet_listen_opts(opts, 0, errp); break; - case SOCKET_ADDRESS_KIND_UNIX: + case SocketAddressKind_unix: qemu_opt_set(opts, "path", addr->u.q_unix->path, &error_abort); fd = unix_listen_opts(opts, errp); break; - case SOCKET_ADDRESS_KIND_FD: + case SocketAddressKind_fd: fd = monitor_get_fd(cur_mon, addr->u.fd->str, errp); break; @@ -1013,7 +1013,7 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (remote->type) { - case SOCKET_ADDRESS_KIND_INET: + case SocketAddressKind_inet: inet_addr_to_opts(opts, remote->u.inet); if (local) { qemu_opt_set(opts, "localaddr", local->u.inet->host, &error_abort); @@ -1052,7 +1052,7 @@ socket_sockaddr_to_address_inet(struct sockaddr_storage *sa, } addr = g_new0(SocketAddress, 1); - addr->type = SOCKET_ADDRESS_KIND_INET; + addr->type = SocketAddressKind_inet; addr->u.inet = g_new0(InetSocketAddress, 1); addr->u.inet->host = g_strdup(host); addr->u.inet->port = g_strdup(serv); @@ -1076,7 +1076,7 @@ socket_sockaddr_to_address_unix(struct sockaddr_storage *sa, struct sockaddr_un *su = (struct sockaddr_un *)sa; addr = g_new0(SocketAddress, 1); - addr->type = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SocketAddressKind_unix; addr->u.q_unix = g_new0(UnixSocketAddress, 1); if (su->sun_path[0]) { addr->u.q_unix->path = g_strndup(su->sun_path, diff --git a/vl.c b/vl.c index f5f7c3f..3e90205 100644 --- a/vl.c +++ b/vl.c @@ -560,10 +560,10 @@ static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp) /***********************************************************/ /* QEMU state */ -static RunState current_run_state = RUN_STATE_PRELAUNCH; +static RunState current_run_state = RunState_prelaunch; -/* We use RUN_STATE_MAX but any invalid value will do */ -static RunState vmstop_requested = RUN_STATE_MAX; +/* We use RunState_MAX but any invalid value will do */ +static RunState vmstop_requested = RunState_MAX; static QemuMutex vmstop_lock; typedef struct { @@ -573,71 +573,71 @@ typedef struct { static const RunStateTransition runstate_transitions_def[] = { /* from -> to */ - { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, - { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, + { RunState_debug, RunState_running }, + { RunState_debug, RunState_finish_migrate }, - { RUN_STATE_INMIGRATE, RUN_STATE_INTERNAL_ERROR }, - { RUN_STATE_INMIGRATE, RUN_STATE_IO_ERROR }, - { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, - { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, - { RUN_STATE_INMIGRATE, RUN_STATE_SHUTDOWN }, - { RUN_STATE_INMIGRATE, RUN_STATE_SUSPENDED }, - { RUN_STATE_INMIGRATE, RUN_STATE_WATCHDOG }, - { RUN_STATE_INMIGRATE, RUN_STATE_GUEST_PANICKED }, - { RUN_STATE_INMIGRATE, RUN_STATE_FINISH_MIGRATE }, + { RunState_inmigrate, RunState_internal_error }, + { RunState_inmigrate, RunState_io_error }, + { RunState_inmigrate, RunState_paused }, + { RunState_inmigrate, RunState_running }, + { RunState_inmigrate, RunState_shutdown }, + { RunState_inmigrate, RunState_suspended }, + { RunState_inmigrate, RunState_watchdog }, + { RunState_inmigrate, RunState_guest_panicked }, + { RunState_inmigrate, RunState_finish_migrate }, - { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, - { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, + { RunState_internal_error, RunState_paused }, + { RunState_internal_error, RunState_finish_migrate }, - { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, - { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, + { RunState_io_error, RunState_running }, + { RunState_io_error, RunState_finish_migrate }, - { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, - { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, + { RunState_paused, RunState_running }, + { RunState_paused, RunState_finish_migrate }, - { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, - { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, + { RunState_postmigrate, RunState_running }, + { RunState_postmigrate, RunState_finish_migrate }, - { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, - { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + { RunState_prelaunch, RunState_running }, + { RunState_prelaunch, RunState_finish_migrate }, + { RunState_prelaunch, RunState_inmigrate }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, + { RunState_finish_migrate, RunState_running }, + { RunState_finish_migrate, RunState_postmigrate }, - { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, + { RunState_restore_vm, RunState_running }, - { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, - { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, - { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR }, - { RUN_STATE_RUNNING, RUN_STATE_PAUSED }, - { RUN_STATE_RUNNING, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_RUNNING, RUN_STATE_RESTORE_VM }, - { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, - { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, - { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, - { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, + { RunState_running, RunState_debug }, + { RunState_running, RunState_internal_error }, + { RunState_running, RunState_io_error }, + { RunState_running, RunState_paused }, + { RunState_running, RunState_finish_migrate }, + { RunState_running, RunState_restore_vm }, + { RunState_running, RunState_save_vm }, + { RunState_running, RunState_shutdown }, + { RunState_running, RunState_watchdog }, + { RunState_running, RunState_guest_panicked }, - { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, + { RunState_save_vm, RunState_running }, - { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, - { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, + { RunState_shutdown, RunState_paused }, + { RunState_shutdown, RunState_finish_migrate }, - { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED }, - { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED }, - { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING }, - { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, + { RunState_debug, RunState_suspended }, + { RunState_running, RunState_suspended }, + { RunState_suspended, RunState_running }, + { RunState_suspended, RunState_finish_migrate }, - { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, - { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, + { RunState_watchdog, RunState_running }, + { RunState_watchdog, RunState_finish_migrate }, - { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, - { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, + { RunState_guest_panicked, RunState_running }, + { RunState_guest_panicked, RunState_finish_migrate }, - { RUN_STATE_MAX, RUN_STATE_MAX }, + { RunState_MAX, RunState_MAX }, }; -static bool runstate_valid_transitions[RUN_STATE_MAX][RUN_STATE_MAX]; +static bool runstate_valid_transitions[RunState_MAX][RunState_MAX]; bool runstate_check(RunState state) { @@ -661,7 +661,7 @@ static void runstate_init(void) const RunStateTransition *p; memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitions)); - for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) { + for (p = &runstate_transitions_def[0]; p->from != RunState_MAX; p++) { runstate_valid_transitions[p->from][p->to] = true; } @@ -671,7 +671,7 @@ static void runstate_init(void) /* This function will abort() on invalid state transitions */ void runstate_set(RunState new_state) { - assert(new_state < RUN_STATE_MAX); + assert(new_state < RunState_MAX); if (!runstate_valid_transitions[current_run_state][new_state]) { fprintf(stderr, "ERROR: invalid runstate transition: '%s' -> '%s'\n", @@ -685,13 +685,13 @@ void runstate_set(RunState new_state) int runstate_is_running(void) { - return runstate_check(RUN_STATE_RUNNING); + return runstate_check(RunState_running); } bool runstate_needs_reset(void) { - return runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN); + return runstate_check(RunState_internal_error) || + runstate_check(RunState_shutdown); } StatusInfo *qmp_query_status(Error **errp) @@ -709,9 +709,9 @@ static bool qemu_vmstop_requested(RunState *r) { qemu_mutex_lock(&vmstop_lock); *r = vmstop_requested; - vmstop_requested = RUN_STATE_MAX; + vmstop_requested = RunState_MAX; qemu_mutex_unlock(&vmstop_lock); - return *r < RUN_STATE_MAX; + return *r < RunState_MAX; } void qemu_system_vmstop_request_prepare(void) @@ -731,7 +731,7 @@ void vm_start(void) RunState requested; qemu_vmstop_requested(&requested); - if (runstate_is_running() && requested == RUN_STATE_MAX) { + if (runstate_is_running() && requested == RunState_MAX) { return; } @@ -744,8 +744,8 @@ void vm_start(void) qapi_event_send_stop(&error_abort); } else { cpu_enable_ticks(); - runstate_set(RUN_STATE_RUNNING); - vm_state_notify(1, RUN_STATE_RUNNING); + runstate_set(RunState_running); + vm_state_notify(1, RunState_running); resume_all_vcpus(); } @@ -1724,8 +1724,8 @@ void qemu_system_guest_panicked(void) if (current_cpu) { current_cpu->crash_occurred = true; } - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); - vm_stop(RUN_STATE_GUEST_PANICKED); + qapi_event_send_guest_panicked(GuestPanicAction_pause, &error_abort); + vm_stop(RunState_guest_panicked); } void qemu_system_reset_request(void) @@ -1743,13 +1743,13 @@ static void qemu_system_suspend(void) { pause_all_vcpus(); notifier_list_notify(&suspend_notifiers, NULL); - runstate_set(RUN_STATE_SUSPENDED); + runstate_set(RunState_suspended); qapi_event_send_suspend(&error_abort); } void qemu_system_suspend_request(void) { - if (runstate_check(RUN_STATE_SUSPENDED)) { + if (runstate_check(RunState_suspended)) { return; } suspend_requested = 1; @@ -1766,13 +1766,13 @@ void qemu_system_wakeup_request(WakeupReason reason) { trace_system_wakeup_request(reason); - if (!runstate_check(RUN_STATE_SUSPENDED)) { + if (!runstate_check(RunState_suspended)) { return; } if (!(wakeup_reason_mask & (1 << reason))) { return; } - runstate_set(RUN_STATE_RUNNING); + runstate_set(RunState_running); wakeup_reason = reason; qemu_notify_event(); } @@ -1834,7 +1834,7 @@ static bool main_loop_should_exit(void) { RunState r; if (qemu_debug_requested()) { - vm_stop(RUN_STATE_DEBUG); + vm_stop(RunState_debug); } if (qemu_suspend_requested()) { qemu_system_suspend(); @@ -1843,7 +1843,7 @@ static bool main_loop_should_exit(void) qemu_kill_report(); qapi_event_send_shutdown(&error_abort); if (no_shutdown) { - vm_stop(RUN_STATE_SHUTDOWN); + vm_stop(RunState_shutdown); } else { return true; } @@ -1854,7 +1854,7 @@ static bool main_loop_should_exit(void) qemu_system_reset(VMRESET_REPORT); resume_all_vcpus(); if (runstate_needs_reset()) { - runstate_set(RUN_STATE_PAUSED); + runstate_set(RunState_paused); } } if (qemu_wakeup_requested()) { @@ -3024,7 +3024,7 @@ int main(int argc, char **argv, char **envp) cpu_model = NULL; snapshot = 0; cyls = heads = secs = 0; - translation = BIOS_ATA_TRANSLATION_AUTO; + translation = BiosAtaTranslation_auto; nb_nics = 0; @@ -3095,9 +3095,9 @@ int main(int argc, char **argv, char **envp) snprintf(buf, sizeof(buf), "%s,cyls=%d,heads=%d,secs=%d%s", HD_OPTS , cyls, heads, secs, - translation == BIOS_ATA_TRANSLATION_LBA ? + translation == BiosAtaTranslation_lba ? ",trans=lba" : - translation == BIOS_ATA_TRANSLATION_NONE ? + translation == BiosAtaTranslation_none ? ",trans=none" : ""); drive_add(IF_DEFAULT, 0, optarg, buf); break; @@ -3155,15 +3155,15 @@ int main(int argc, char **argv, char **envp) if (*p == ',') { p++; if (!strcmp(p, "large")) { - translation = BIOS_ATA_TRANSLATION_LARGE; + translation = BiosAtaTranslation_large; } else if (!strcmp(p, "rechs")) { - translation = BIOS_ATA_TRANSLATION_RECHS; + translation = BiosAtaTranslation_rechs; } else if (!strcmp(p, "none")) { - translation = BIOS_ATA_TRANSLATION_NONE; + translation = BiosAtaTranslation_none; } else if (!strcmp(p, "lba")) { - translation = BIOS_ATA_TRANSLATION_LBA; + translation = BiosAtaTranslation_lba; } else if (!strcmp(p, "auto")) { - translation = BIOS_ATA_TRANSLATION_AUTO; + translation = BiosAtaTranslation_auto; } else { goto chs_fail; } @@ -3179,16 +3179,16 @@ int main(int argc, char **argv, char **envp) &error_abort); qemu_opt_set_number(hda_opts, "secs", secs, &error_abort); - if (translation == BIOS_ATA_TRANSLATION_LARGE) { + if (translation == BiosAtaTranslation_large) { qemu_opt_set(hda_opts, "trans", "large", &error_abort); - } else if (translation == BIOS_ATA_TRANSLATION_RECHS) { + } else if (translation == BiosAtaTranslation_rechs) { qemu_opt_set(hda_opts, "trans", "rechs", &error_abort); - } else if (translation == BIOS_ATA_TRANSLATION_LBA) { + } else if (translation == BiosAtaTranslation_lba) { qemu_opt_set(hda_opts, "trans", "lba", &error_abort); - } else if (translation == BIOS_ATA_TRANSLATION_NONE) { + } else if (translation == BiosAtaTranslation_none) { qemu_opt_set(hda_opts, "trans", "none", &error_abort); } @@ -3851,7 +3851,7 @@ int main(int argc, char **argv, char **envp) break; case QEMU_OPTION_incoming: if (!incoming) { - runstate_set(RUN_STATE_INMIGRATE); + runstate_set(RunState_inmigrate); } incoming = optarg; break; diff --git a/xen-hvm.c b/xen-hvm.c index 3d78a0c..7ae87ce 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -244,7 +244,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr) xen_pfn_t *pfn_list; int i; - if (runstate_check(RUN_STATE_INMIGRATE)) { + if (runstate_check(RunState_inmigrate)) { /* RAM already populated in Xen */ fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRATE\n", @@ -1124,7 +1124,7 @@ static void xen_hvm_change_state_handler(void *opaque, int running, xen_set_ioreq_server_state(xen_xc, xen_domid, state->ioservid, - (rstate == RUN_STATE_RUNNING)); + (rstate == RunState_running)); } static void xen_exit_notifier(Notifier *n, void *data) -- 2.4.3