Struct and union type members are generally named alike in QMP and C, except for a simple union's implicit tag member, which is "type" in QMP, and "kind" in C. Can't change QMP, so rename it in C.
Since the implicit enumeration type is still called *Kind, this doesn't clean up the type vs. kind mess completely. Signed-off-by: Markus Armbruster <arm...@redhat.com> --- block/nbd.c | 6 +++--- block/qcow2.c | 2 +- block/vmdk.c | 2 +- blockdev.c | 17 +++++++++-------- hmp.c | 12 ++++++------ hw/char/escc.c | 2 +- hw/input/hid.c | 2 +- hw/input/ps2.c | 2 +- hw/input/virtio-input-hid.c | 2 +- hw/mem/pc-dimm.c | 2 +- net/dump.c | 2 +- net/hub.c | 2 +- net/l2tpv3.c | 2 +- net/net.c | 20 ++++++++++---------- net/slirp.c | 2 +- net/socket.c | 2 +- net/tap-win32.c | 2 +- net/tap.c | 4 ++-- net/vde.c | 2 +- net/vhost-user.c | 2 +- numa.c | 4 ++-- qemu-char.c | 24 ++++++++++++------------ qemu-nbd.c | 4 ++-- scripts/qapi-types.py | 12 ++++-------- scripts/qapi-visit.py | 15 ++++----------- tests/test-qmp-commands.c | 2 +- tests/test-qmp-input-visitor.c | 30 +++++++++++++++--------------- tests/test-qmp-output-visitor.c | 8 ++++---- tpm.c | 2 +- ui/input-keymap.c | 10 +++++----- ui/input-legacy.c | 2 +- ui/input.c | 22 +++++++++++----------- util/qemu-sockets.c | 12 ++++++------ 33 files changed, 113 insertions(+), 123 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index c2a87e9..207a83e 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->kind = SOCKET_ADDRESS_KIND_UNIX; + saddr->type = SOCKET_ADDRESS_KIND_UNIX; saddr->q_unix = g_new0(UnixSocketAddress, 1); saddr->q_unix->path = g_strdup(qdict_get_str(options, "path")); qdict_del(options, "path"); } else { - saddr->kind = SOCKET_ADDRESS_KIND_INET; + saddr->type = SOCKET_ADDRESS_KIND_INET; saddr->inet = g_new0(InetSocketAddress, 1); saddr->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->kind == SOCKET_ADDRESS_KIND_UNIX; + s->client.is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX; *export = g_strdup(qdict_get_try_str(options, "export")); if (*export) { diff --git a/block/qcow2.c b/block/qcow2.c index 56ad808..28aa74d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2736,7 +2736,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ - .kind = IMAGE_INFO_SPECIFIC_KIND_QCOW2, + .type = IMAGE_INFO_SPECIFIC_KIND_QCOW2, { .qcow2 = g_new(ImageInfoSpecificQCow2, 1), }, diff --git a/block/vmdk.c b/block/vmdk.c index be0d640..695780c 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2156,7 +2156,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) ImageInfoList **next; *spec_info = (ImageInfoSpecific){ - .kind = IMAGE_INFO_SPECIFIC_KIND_VMDK, + .type = IMAGE_INFO_SPECIFIC_KIND_VMDK, { .vmdk = g_new0(ImageInfoSpecificVmdk, 1), }, diff --git a/blockdev.c b/blockdev.c index 32b04b4..f0479f7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1052,12 +1052,13 @@ void hmp_commit(Monitor *mon, const QDict *qdict) } } -static void blockdev_do_action(int kind, void *data, Error **errp) +static void blockdev_do_action(TransactionActionKind kind, void *data, + Error **errp) { TransactionAction action; TransactionActionList list; - action.kind = kind; + action.type = kind; action.data = data; list.value = &action; list.next = NULL; @@ -1297,7 +1298,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common, InternalSnapshotState *state; int ret1; - g_assert(common->action->kind == + g_assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC); internal = common->action->blockdev_snapshot_internal_sync; state = DO_UPCAST(InternalSnapshotState, common, common); @@ -1439,7 +1440,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, TransactionAction *action = common->action; /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); + g_assert(action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); has_device = action->blockdev_snapshot_sync->has_device; device = action->blockdev_snapshot_sync->device; @@ -1579,7 +1580,7 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) DriveBackup *backup; Error *local_err = NULL; - assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); + assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); backup = common->action->drive_backup; blk = blk_by_name(backup->device); @@ -1647,7 +1648,7 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) BlockBackend *blk; Error *local_err = NULL; - assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); + assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); backup = common->action->blockdev_backup; blk = blk_by_name(backup->device); @@ -1774,9 +1775,9 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) dev_info = dev_entry->value; dev_entry = dev_entry->next; - assert(dev_info->kind < ARRAY_SIZE(actions)); + assert(dev_info->type < ARRAY_SIZE(actions)); - ops = &actions[dev_info->kind]; + ops = &actions[dev_info->type]; assert(ops->instance_size > 0); state = g_malloc0(ops->instance_size); diff --git a/hmp.c b/hmp.c index 5048eee..1e51a2c 100644 --- a/hmp.c +++ b/hmp.c @@ -841,9 +841,9 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) c, TpmModel_lookup[ti->model]); monitor_printf(mon, " \\ %s: type=%s", - ti->id, TpmTypeOptionsKind_lookup[ti->options->kind]); + ti->id, TpmTypeOptionsKind_lookup[ti->options->type]); - switch (ti->options->kind) { + switch (ti->options->type) { case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: tpo = ti->options->passthrough; monitor_printf(mon, "%s%s%s%s", @@ -1735,14 +1735,14 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) if (*endp != '\0') { goto err_out; } - keylist->value->kind = KEY_VALUE_KIND_NUMBER; + keylist->value->type = KEY_VALUE_KIND_NUMBER; keylist->value->number = value; } else { int idx = index_from_key(keyname_buf); if (idx == Q_KEY_CODE_MAX) { goto err_out; } - keylist->value->kind = KEY_VALUE_KIND_QCODE; + keylist->value->type = KEY_VALUE_KIND_QCODE; keylist->value->qcode = idx; } @@ -1958,12 +1958,12 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: di = value->dimm; monitor_printf(mon, "Memory device [%s]: \"%s\"\n", - MemoryDeviceInfoKind_lookup[value->kind], + MemoryDeviceInfoKind_lookup[value->type], di->id ? di->id : ""); monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr); monitor_printf(mon, " slot: %" PRId64 "\n", di->slot); diff --git a/hw/char/escc.c b/hw/char/escc.c index ba653ef..2e5b5eb 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -842,7 +842,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src, ChannelState *s = (ChannelState *)dev; int qcode, keycode; - assert(evt->kind == INPUT_EVENT_KIND_KEY); + assert(evt->type == INPUT_EVENT_KIND_KEY); qcode = qemu_input_key_value_to_qcode(evt->key->key); trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode], evt->key->down); diff --git a/hw/input/hid.c b/hw/input/hid.c index 21ebd9e..ac02f88 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -119,7 +119,7 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src, assert(hs->n < QUEUE_LENGTH); e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK]; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_REL: if (evt->rel->axis == INPUT_AXIS_X) { e->xdx += evt->rel->value; diff --git a/hw/input/ps2.c b/hw/input/ps2.c index fdbe565..58decf2 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -393,7 +393,7 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) return; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_REL: if (evt->rel->axis == INPUT_AXIS_X) { s->mouse_dx += evt->rel->value; diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 4d85dad..362dad3 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -191,7 +191,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, virtio_input_event event; int qcode; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_KEY: qcode = qemu_input_key_value_to_qcode(evt->key->key); if (qcode && keymap_qcode[qcode]) { diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 6cc6ac3..7a0b8b3 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -197,7 +197,7 @@ ram_addr_t get_current_ram_size(void) MemoryDeviceInfo *value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: size += value->dimm->size; break; diff --git a/net/dump.c b/net/dump.c index 08259af..4941299 100644 --- a/net/dump.c +++ b/net/dump.c @@ -154,7 +154,7 @@ int net_init_dump(const NetClientOptions *opts, const char *name, char def_file[128]; const NetdevDumpOptions *dump; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_DUMP); dump = opts->dump; assert(peer); diff --git a/net/hub.c b/net/hub.c index 3047f12..2dce788 100644 --- a/net/hub.c +++ b/net/hub.c @@ -285,7 +285,7 @@ int net_init_hubport(const NetClientOptions *opts, const char *name, { const NetdevHubPortOptions *hubport; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT); assert(!peer); hubport = opts->hubport; diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 4f9bcee..7c6c57f 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -545,7 +545,7 @@ int net_init_l2tpv3(const NetClientOptions *opts, s->queue_tail = 0; s->header_mismatch = false; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_L2TPV3); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_L2TPV3); l2tpv3 = opts->l2tpv3; if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { diff --git a/net/net.c b/net/net.c index 28a5597..36da3f4 100644 --- a/net/net.c +++ b/net/net.c @@ -820,7 +820,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, NICInfo *nd; const NetLegacyNicOptions *nic; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_NIC); nic = opts->nic; idx = nic_get_free_idx(); @@ -922,9 +922,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) opts = netdev->opts; name = netdev->id; - if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || - opts->kind == NET_CLIENT_OPTIONS_KIND_NIC || - !net_client_init_fun[opts->kind]) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_DUMP || + opts->type == NET_CLIENT_OPTIONS_KIND_NIC || + !net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1; @@ -935,16 +935,16 @@ 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->kind == NET_CLIENT_OPTIONS_KIND_NONE) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_NONE) { return 0; /* nothing to do */ } - if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net type"); return -1; } - if (!net_client_init_fun[opts->kind]) { + if (!net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net backend type (maybe it is not compiled " "into this binary)"); @@ -952,17 +952,17 @@ 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->kind != NET_CLIENT_OPTIONS_KIND_NIC || + if (opts->type != NET_CLIENT_OPTIONS_KIND_NIC || !opts->nic->has_netdev) { peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); } } - if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) { + if (net_client_init_fun[opts->type](opts, name, peer, errp) < 0) { /* FIXME drop when all init functions store an Error */ if (errp && !*errp) { error_setg(errp, QERR_DEVICE_INIT_FAILED, - NetClientOptionsKind_lookup[opts->kind]); + NetClientOptionsKind_lookup[opts->type]); } return -1; } diff --git a/net/slirp.c b/net/slirp.c index 7657b38..cd06a30 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -746,7 +746,7 @@ int net_init_slirp(const NetClientOptions *opts, const char *name, const NetdevUserOptions *user; const char **dnssearch; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_USER); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_USER); user = opts->user; vnet = user->has_net ? g_strdup(user->net) : diff --git a/net/socket.c b/net/socket.c index b1e3b1c..faf2823 100644 --- a/net/socket.c +++ b/net/socket.c @@ -706,7 +706,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, Error *err = NULL; const NetdevSocketOptions *sock; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_SOCKET); sock = opts->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 625d53c..997b314 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -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->kind == NET_CLIENT_OPTIONS_KIND_TAP); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP); tap = opts->tap; if (!tap->has_ifname) { diff --git a/net/tap.c b/net/tap.c index bd01590..3cf540b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -565,7 +565,7 @@ int net_init_bridge(const NetClientOptions *opts, const char *name, TAPState *s; int fd, vnet_hdr; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_BRIDGE); bridge = opts->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->kind == NET_CLIENT_OPTIONS_KIND_TAP); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_TAP); tap = opts->tap; queues = tap->has_queues ? tap->queues : 1; vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL; diff --git a/net/vde.c b/net/vde.c index dacaa64..96c939f 100644 --- a/net/vde.c +++ b/net/vde.c @@ -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->kind == NET_CLIENT_OPTIONS_KIND_VDE); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_VDE); vde = opts->vde; /* missing optional values have been initialized to "all bits zero" */ diff --git a/net/vhost-user.c b/net/vhost-user.c index 8f354eb..756bcb9 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -273,7 +273,7 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name, const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; - assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(opts->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); vhost_user_opts = opts->vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); diff --git a/numa.c b/numa.c index e9b18f5..16a8c41 100644 --- a/numa.c +++ b/numa.c @@ -226,7 +226,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) goto error; } - switch (object->kind) { + switch (object->type) { case NUMA_OPTIONS_KIND_NODE: numa_node_parse(object->node, opts, &err); if (err) { @@ -487,7 +487,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[]) MemoryDeviceInfo *value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: node_mem[value->dimm->node] += value->dimm->size; break; diff --git a/qemu-char.c b/qemu-char.c index 653ea10..a0379f2 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -122,7 +122,7 @@ static int SocketAddress_to_str(char *dest, int max_len, const char *prefix, SocketAddress *addr, bool is_listen, bool is_telnet) { - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: return snprintf(dest, max_len, "%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", addr->inet->host, @@ -3567,11 +3567,11 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, addr = g_new0(SocketAddress, 1); if (path) { - addr->kind = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->q_unix = g_new0(UnixSocketAddress, 1); addr->q_unix->path = g_strdup(path); } else { - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(host); addr->inet->port = g_strdup(port); @@ -3616,7 +3616,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, backend->udp = g_new0(ChardevUdp, 1); addr = g_new0(SocketAddress, 1); - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(host); addr->inet->port = g_strdup(port); @@ -3629,7 +3629,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, if (has_local) { backend->udp->has_local = true; addr = g_new0(SocketAddress, 1); - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(localaddr); addr->inet->port = g_strdup(localport); @@ -3701,7 +3701,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, } chr = NULL; - backend->kind = cd->kind; + backend->type = cd->kind; if (cd->parse) { cd->parse(opts, backend, &local_err); if (local_err) { @@ -3719,7 +3719,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, qapi_free_ChardevReturn(ret); backend = g_new0(ChardevBackend, 1); backend->mux = g_new0(ChardevMux, 1); - backend->kind = CHARDEV_BACKEND_KIND_MUX; + backend->type = CHARDEV_BACKEND_KIND_MUX; backend->mux->chardev = g_strdup(bid); ret = qmp_chardev_add(id, backend, errp); if (!ret) { @@ -4148,7 +4148,7 @@ static CharDriverState *qmp_chardev_open_socket(ChardevSocket *sock, s->fd = -1; s->listen_fd = -1; - s->is_unix = addr->kind == SOCKET_ADDRESS_KIND_UNIX; + s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX; s->is_listen = is_listen; s->is_telnet = is_telnet; s->do_nodelay = do_nodelay; @@ -4222,7 +4222,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, return NULL; } - switch (backend->kind) { + switch (backend->type) { case CHARDEV_BACKEND_KIND_FILE: chr = qmp_chardev_open_file(backend->file, errp); break; @@ -4293,7 +4293,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, chr = qemu_chr_open_ringbuf(backend->ringbuf, errp); break; default: - error_setg(errp, "unknown chardev backend (%d)", backend->kind); + error_setg(errp, "unknown chardev backend (%d)", backend->type); break; } @@ -4309,9 +4309,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, if (chr) { chr->label = g_strdup(id); chr->avail_connections = - (backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; + (backend->type == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; if (!chr->filename) { - chr->filename = g_strdup(ChardevBackendKind_lookup[backend->kind]); + chr->filename = g_strdup(ChardevBackendKind_lookup[backend->type]); } if (!chr->explicit_be_open) { qemu_chr_be_event(chr, CHR_EVENT_OPENED); diff --git a/qemu-nbd.c b/qemu-nbd.c index 6428c15..ccf846b 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -364,11 +364,11 @@ static SocketAddress *nbd_build_socket_address(const char *sockpath, saddr = g_new0(SocketAddress, 1); if (sockpath) { - saddr->kind = SOCKET_ADDRESS_KIND_UNIX; + saddr->type = SOCKET_ADDRESS_KIND_UNIX; saddr->q_unix = g_new0(UnixSocketAddress, 1); saddr->q_unix->path = g_strdup(sockpath); } else { - saddr->kind = SOCKET_ADDRESS_KIND_INET; + saddr->type = SOCKET_ADDRESS_KIND_INET; saddr->inet = g_new0(InetSocketAddress, 1); saddr->inet->host = g_strdup(bindto); if (port) { diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 227ea5c..10d8ac0 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -135,10 +135,9 @@ struct %(c_name)s { /* Own members: */ ''') else: - ret += mcgen(''' - %(c_type)s kind; -''', - c_type=c_name(variants.tag_member.type.name)) + ret += gen_struct_field(variants.tag_member.name, + variants.tag_member.type, + False); # FIXME: What purpose does data serve, besides preventing a union that # has a branch named 'data'? We use it in qapi-visit.py to decide @@ -152,10 +151,7 @@ struct %(c_name)s { union { /* union tag is @%(c_name)s */ void *data; ''', - # TODO ugly special case for simple union - # Use same tag name in C as on the wire to get rid of - # it, then: c_name=c_name(variants.tag_member.name) - c_name=c_name(variants.tag_name or 'kind')) + c_name=c_name(variants.tag_member.name)) for var in variants.variants: # Ugly special case for simple union TODO get rid of it diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 56b8390..092191c 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -179,11 +179,11 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error if (err) { goto out; } - visit_get_next_type(v, (int*) &(*obj)->kind, %(c_name)s_qtypes, name, &err); + visit_get_next_type(v, (int*) &(*obj)->type, %(c_name)s_qtypes, name, &err); if (err) { goto out_obj; } - switch ((*obj)->kind) { + switch ((*obj)->type) { ''', c_name=c_name(name)) @@ -249,10 +249,6 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error c_name=c_name(name)) ret += gen_err_check(label='out_obj') - tag_key = variants.tag_member.name - if not variants.tag_name: - # we pointlessly use a different key for simple unions - tag_key = 'type' ret += mcgen(''' visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err); if (err) { @@ -264,11 +260,8 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error switch ((*obj)->%(c_name)s) { ''', c_type=variants.tag_member.type.c_name(), - # TODO ugly special case for simple union - # Use same tag name in C as on the wire to get rid of - # it, then: c_name=c_name(variants.tag_member.name) - c_name=c_name(variants.tag_name or 'kind'), - name=tag_key) + c_name=c_name(variants.tag_member.name), + name=variants.tag_member.name) for var in variants.variants: # TODO ugly special case for simple union diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 8d5249e..6a67e73 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -64,7 +64,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->kind = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; + ret->type = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; ret->__org_qemu_x_branch = strdup("blah1"); return ret; diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index 183a9ec..54163ad 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -372,14 +372,14 @@ 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->kind, ==, USER_DEF_ALTERNATE_KIND_I); + g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_I); g_assert_cmpint(tmp->i, ==, 42); qapi_free_UserDefAlternate(tmp); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "'string'"); visit_type_UserDefAlternate(v, &tmp, NULL, &error_abort); - g_assert_cmpint(tmp->kind, ==, USER_DEF_ALTERNATE_KIND_S); + g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_S); g_assert_cmpstr(tmp->s, ==, "string"); qapi_free_UserDefAlternate(tmp); visitor_input_teardown(data, NULL); @@ -419,7 +419,7 @@ 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, &err); - /* FIXME g_assert_cmpint(asn->kind, == ALT_STR_NUM_KIND_N); */ + /* FIXME g_assert_cmpint(asn->type, == ALT_STR_NUM_KIND_N); */ /* FIXME g_assert_cmpfloat(asn->n, ==, 42); */ g_assert(err); error_free(err); @@ -429,28 +429,28 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data, v = visitor_input_test_init(data, "42"); visit_type_AltNumStr(v, &ans, NULL, &error_abort); - g_assert_cmpint(ans->kind, ==, ALT_NUM_STR_KIND_N); + g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N); g_assert_cmpfloat(ans->n, ==, 42); qapi_free_AltNumStr(ans); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltStrInt(v, &asi, NULL, &error_abort); - g_assert_cmpint(asi->kind, ==, ALT_STR_INT_KIND_I); + g_assert_cmpint(asi->type, ==, ALT_STR_INT_KIND_I); g_assert_cmpint(asi->i, ==, 42); qapi_free_AltStrInt(asi); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltIntNum(v, &ain, NULL, &error_abort); - g_assert_cmpint(ain->kind, ==, ALT_INT_NUM_KIND_I); + g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_I); g_assert_cmpint(ain->i, ==, 42); qapi_free_AltIntNum(ain); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42"); visit_type_AltNumInt(v, &ani, NULL, &error_abort); - g_assert_cmpint(ani->kind, ==, ALT_NUM_INT_KIND_I); + g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_I); g_assert_cmpint(ani->i, ==, 42); qapi_free_AltNumInt(ani); visitor_input_teardown(data, NULL); @@ -467,14 +467,14 @@ 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->kind, ==, ALT_STR_NUM_KIND_N); + g_assert_cmpint(asn->type, ==, ALT_STR_NUM_KIND_N); g_assert_cmpfloat(asn->n, ==, 42.5); qapi_free_AltStrNum(asn); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltNumStr(v, &ans, NULL, &error_abort); - g_assert_cmpint(ans->kind, ==, ALT_NUM_STR_KIND_N); + g_assert_cmpint(ans->type, ==, ALT_NUM_STR_KIND_N); g_assert_cmpfloat(ans->n, ==, 42.5); qapi_free_AltNumStr(ans); visitor_input_teardown(data, NULL); @@ -489,14 +489,14 @@ 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->kind, ==, ALT_INT_NUM_KIND_N); + g_assert_cmpint(ain->type, ==, ALT_INT_NUM_KIND_N); g_assert_cmpfloat(ain->n, ==, 42.5); qapi_free_AltIntNum(ain); visitor_input_teardown(data, NULL); v = visitor_input_test_init(data, "42.5"); visit_type_AltNumInt(v, &ani, NULL, &error_abort); - g_assert_cmpint(ani->kind, ==, ALT_NUM_INT_KIND_N); + g_assert_cmpint(ani->type, ==, ALT_NUM_INT_KIND_N); g_assert_cmpint(ani->n, ==, 42.5); qapi_free_AltNumInt(ani); visitor_input_teardown(data, NULL); @@ -527,7 +527,7 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, kind); + g_assert_cmpint(cvalue->type, ==, kind); switch (kind) { case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { @@ -690,7 +690,7 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); for (i = 0, elem = cvalue->boolean; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); @@ -725,7 +725,7 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); for (i = 0, elem = cvalue->string; elem; elem = elem->next, i++) { gchar str[8]; @@ -764,7 +764,7 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); for (i = 0, elem = cvalue->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 c84002e..bc210b6 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -517,7 +517,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data, Error *err = NULL; UserDefAlternate *tmp = g_malloc0(sizeof(UserDefAlternate)); - tmp->kind = USER_DEF_ALTERNATE_KIND_I; + tmp->type = USER_DEF_ALTERNATE_KIND_I; tmp->i = 42; visit_type_UserDefAlternate(data->ov, &tmp, NULL, &err); @@ -543,7 +543,7 @@ static void test_visitor_out_empty(TestOutputVisitorData *data, static void init_native_list(UserDefNativeListUnion *cvalue) { int i; - switch (cvalue->kind) { + switch (cvalue->type) { case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { intList **list = &cvalue->integer; for (i = 0; i < 32; i++) { @@ -764,14 +764,14 @@ static void test_native_list(TestOutputVisitorData *data, Error *err = NULL; QObject *obj; - cvalue->kind = kind; + cvalue->type = kind; init_native_list(cvalue); visit_type_UserDefNativeListUnion(data->ov, &cvalue, NULL, &err); g_assert(err == NULL); obj = qmp_output_get_qobject(data->qov); - check_native_list(obj, cvalue->kind); + check_native_list(obj, cvalue->type); qapi_free_UserDefNativeListUnion(cvalue); qobject_decref(obj); } diff --git a/tpm.c b/tpm.c index 4e9b109..fcab81c 100644 --- a/tpm.c +++ b/tpm.c @@ -260,7 +260,7 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) switch (drv->ops->type) { case TPM_TYPE_PASSTHROUGH: - res->options->kind = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; + res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; tpo = g_new0(TPMPassthroughOptions, 1); res->options->passthrough = tpo; if (drv->path) { diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 7635cb0..088523d 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -139,10 +139,10 @@ static int number_to_qcode[0x100]; int qemu_input_key_value_to_number(const KeyValue *value) { - if (value->kind == KEY_VALUE_KIND_QCODE) { + if (value->type == KEY_VALUE_KIND_QCODE) { return qcode_to_number[value->qcode]; } else { - assert(value->kind == KEY_VALUE_KIND_NUMBER); + assert(value->type == KEY_VALUE_KIND_NUMBER); return value->number; } } @@ -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->kind == KEY_VALUE_KIND_QCODE) { + if (value->type == KEY_VALUE_KIND_QCODE) { return value->qcode; } else { - assert(value->kind == KEY_VALUE_KIND_NUMBER); + assert(value->type == KEY_VALUE_KIND_NUMBER); return qemu_input_key_number_to_qcode(value->number); } } @@ -180,7 +180,7 @@ 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->kind == KEY_VALUE_KIND_QCODE && + if (value->type == KEY_VALUE_KIND_QCODE && value->qcode == Q_KEY_CODE_PAUSE) { /* specific case */ int v = down ? 0 : 0x80; diff --git a/ui/input-legacy.c b/ui/input-legacy.c index e50f296..6149648 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -150,7 +150,7 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, }; QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_BTN: if (evt->btn->down) { s->buttons |= bmap[evt->btn->button]; diff --git a/ui/input.c b/ui/input.c index 1a552d1..fd86571 100644 --- a/ui/input.c +++ b/ui/input.c @@ -147,10 +147,10 @@ void qmp_x_input_send_event(bool has_console, int64_t console, for (e = events; e != NULL; e = e->next) { InputEvent *event = e->value; - if (!qemu_input_find_handler(1 << event->kind, con)) { + if (!qemu_input_find_handler(1 << event->type, con)) { error_setg(errp, "Input handler not found for " "event type %s", - InputEventKind_lookup[event->kind]); + InputEventKind_lookup[event->type]); return; } } @@ -197,9 +197,9 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) if (src) { idx = qemu_console_get_index(src); } - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_KEY: - switch (evt->key->key->kind) { + switch (evt->key->key->type) { case KEY_VALUE_KIND_NUMBER: qcode = qemu_input_key_number_to_qcode(evt->key->key->number); name = QKeyCode_lookup[qcode]; @@ -311,12 +311,12 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) qemu_input_event_trace(src, evt); /* pre processing */ - if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) { + if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) { qemu_input_transform_abs_rotate(evt); } /* send event */ - s = qemu_input_find_handler(1 << evt->kind, src); + s = qemu_input_find_handler(1 << evt->type, src); if (!s) { return; } @@ -349,7 +349,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->key = g_new0(InputKeyEvent, 1); - evt->kind = INPUT_EVENT_KIND_KEY; + evt->type = INPUT_EVENT_KIND_KEY; evt->key->key = key; evt->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->kind = KEY_VALUE_KIND_NUMBER; + key->type = KEY_VALUE_KIND_NUMBER; key->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->kind = KEY_VALUE_KIND_QCODE; + key->type = KEY_VALUE_KIND_QCODE; key->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->btn = g_new0(InputBtnEvent, 1); - evt->kind = INPUT_EVENT_KIND_BTN; + evt->type = INPUT_EVENT_KIND_BTN; evt->btn->button = btn; evt->btn->down = down; return evt; @@ -451,7 +451,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, InputEvent *evt = g_new0(InputEvent, 1); InputMoveEvent *move = g_new0(InputMoveEvent, 1); - evt->kind = kind; + evt->type = kind; evt->data = move; move->axis = axis; move->value = value; diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 2add83a..277b139 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -904,7 +904,7 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid Unix socket address"); goto fail; } else { - addr->kind = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->q_unix = g_new(UnixSocketAddress, 1); addr->q_unix->path = g_strdup(str + 5); } @@ -913,12 +913,12 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid file descriptor address"); goto fail; } else { - addr->kind = SOCKET_ADDRESS_KIND_FD; + addr->type = SOCKET_ADDRESS_KIND_FD; addr->fd = g_new(String, 1); addr->fd->str = g_strdup(str + 3); } } else { - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = inet_parse(str, errp); if (addr->inet == NULL) { goto fail; @@ -938,7 +938,7 @@ int socket_connect(SocketAddress *addr, Error **errp, int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_connect_opts(opts, errp, callback, opaque); @@ -970,7 +970,7 @@ int socket_listen(SocketAddress *addr, Error **errp) int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_listen_opts(opts, 0, errp); @@ -998,7 +998,7 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (remote->kind) { + switch (remote->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, remote->inet); if (local) { -- 2.4.3