aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-08-24 10:46:08 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-09-04 13:09:13 +0200
commit977c736f80c232de7c6476d793ed575359c049d8 (patch)
tree986bf327e75929660aa367008574343e59818ee4
parent5b5f825d44306b18509cd10ba9ac6983e90d6e0f (diff)
qapi: Mechanically convert FOO_lookup[...] to FOO_str(...)
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-14-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--backends/hostmem.c2
-rw-r--r--block/backup.c2
-rw-r--r--block/file-posix.c4
-rw-r--r--block/file-win32.c2
-rw-r--r--block/gluster.c4
-rw-r--r--block/iscsi.c2
-rw-r--r--block/nfs.c2
-rw-r--r--block/qcow2.c4
-rw-r--r--block/qed.c2
-rw-r--r--block/rbd.c2
-rw-r--r--block/sheepdog.c2
-rw-r--r--blockdev.c4
-rw-r--r--blockjob.c6
-rw-r--r--chardev/char.c4
-rw-r--r--crypto/block-luks.c12
-rw-r--r--crypto/block.c4
-rw-r--r--crypto/cipher-afalg.c2
-rw-r--r--crypto/cipher-builtin.c8
-rw-r--r--crypto/cipher-gcrypt.c4
-rw-r--r--crypto/cipher-nettle.c8
-rw-r--r--crypto/hmac-gcrypt.c2
-rw-r--r--crypto/hmac-glib.c2
-rw-r--r--crypto/hmac-nettle.c2
-rw-r--r--crypto/pbkdf-gcrypt.c2
-rw-r--r--crypto/pbkdf-nettle.c2
-rw-r--r--hmp.c54
-rw-r--r--hw/block/fdc.c6
-rw-r--r--hw/char/escc.c2
-rw-r--r--hw/input/virtio-input-hid.c4
-rw-r--r--migration/colo-failover.c4
-rw-r--r--migration/colo.c14
-rw-r--r--migration/global_state.c2
-rw-r--r--monitor.c16
-rw-r--r--net/net.c4
-rw-r--r--qapi/qmp-dispatch.c2
-rw-r--r--tests/test-qapi-util.c2
-rw-r--r--tests/test-qobject-input-visitor.c4
-rw-r--r--tests/test-qobject-output-visitor.c2
-rw-r--r--tests/test-string-input-visitor.c2
-rw-r--r--tests/test-string-output-visitor.c4
-rw-r--r--tpm.c2
-rw-r--r--ui/input-legacy.c4
-rw-r--r--ui/input.c12
-rw-r--r--ui/vnc.c6
-rw-r--r--vl.c6
45 files changed, 121 insertions, 121 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 4606b73849..06e8898e40 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -304,7 +304,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
return;
} else if (maxnode == 0 && backend->policy != MPOL_DEFAULT) {
error_setg(errp, "host-nodes must be set for policy %s",
- HostMemPolicy_lookup[backend->policy]);
+ HostMemPolicy_str(backend->policy));
return;
}
diff --git a/block/backup.c b/block/backup.c
index 504a089150..517c300a49 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -596,7 +596,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
error_setg(errp,
"a sync_bitmap was provided to backup_run, "
"but received an incompatible sync_mode (%s)",
- MirrorSyncMode_lookup[sync_mode]);
+ MirrorSyncMode_str(sync_mode));
return NULL;
}
diff --git a/block/file-posix.c b/block/file-posix.c
index d81eccc191..bfef91db63 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1724,7 +1724,7 @@ static int raw_regular_truncate(int fd, int64_t offset, PreallocMode prealloc,
default:
result = -ENOTSUP;
error_setg(errp, "Unsupported preallocation mode: %s",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return result;
}
@@ -1759,7 +1759,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Preallocation mode '%s' unsupported for this "
- "non-regular file", PreallocMode_lookup[prealloc]);
+ "non-regular file", PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/file-win32.c b/block/file-win32.c
index 192ea819d9..f2a1830060 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -469,7 +469,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/gluster.c b/block/gluster.c
index 0614e0c8aa..29f9427e47 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -1047,7 +1047,7 @@ static int qemu_gluster_create(const char *filename,
default:
ret = -EINVAL;
error_setg(errp, "Unsupported preallocation mode: %s",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
break;
}
@@ -1099,7 +1099,7 @@ static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/iscsi.c b/block/iscsi.c
index d557c99668..8b47d30dcc 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2087,7 +2087,7 @@ static int iscsi_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/nfs.c b/block/nfs.c
index bec16b72a6..337fcd9c84 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -772,7 +772,7 @@ static int nfs_file_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/qcow2.c b/block/qcow2.c
index 3a93983e3f..cbe9681fb0 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2715,7 +2715,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
int64_t prealloc_size =
qcow2_calc_prealloc_size(total_size, cluster_size, refcount_order);
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, prealloc_size, &error_abort);
- qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_lookup[prealloc],
+ qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_str(prealloc),
&error_abort);
}
@@ -3080,7 +3080,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL)
{
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/qed.c b/block/qed.c
index dc54bf4a93..28e2ec89e8 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1399,7 +1399,7 @@ static int bdrv_qed_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/rbd.c b/block/rbd.c
index 9c3aa638e7..144f350e1f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -944,7 +944,7 @@ static int qemu_rbd_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/block/sheepdog.c b/block/sheepdog.c
index abb2e79065..1052098ec5 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2176,7 +2176,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset,
if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
- PreallocMode_lookup[prealloc]);
+ PreallocMode_str(prealloc));
return -ENOTSUP;
}
diff --git a/blockdev.c b/blockdev.c
index f90bc9399a..bfb2a95299 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1466,8 +1466,8 @@ static int action_check_completion_mode(BlkActionState *s, Error **errp)
error_setg(errp,
"Action '%s' does not support Transaction property "
"completion-mode = %s",
- TransactionActionKind_lookup[s->action->type],
- ActionCompletionMode_lookup[s->txn_props->completion_mode]);
+ TransactionActionKind_str(s->action->type),
+ ActionCompletionMode_str(s->txn_props->completion_mode));
return -1;
}
return 0;
diff --git a/blockjob.c b/blockjob.c
index 70a78188b7..3a0c49137e 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -208,7 +208,7 @@ static char *child_job_get_parent_desc(BdrvChild *c)
{
BlockJob *job = c->opaque;
return g_strdup_printf("%s job '%s'",
- BlockJobType_lookup[job->driver->job_type],
+ BlockJobType_str(job->driver->job_type),
job->id);
}
@@ -553,7 +553,7 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
return NULL;
}
info = g_new0(BlockJobInfo, 1);
- info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]);
+ info->type = g_strdup(BlockJobType_str(job->driver->job_type));
info->device = g_strdup(job->id);
info->len = job->len;
info->busy = job->busy;
@@ -666,7 +666,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
job->refcnt = 1;
error_setg(&job->blocker, "block device is in use by block job: %s",
- BlockJobType_lookup[driver->job_type]);
+ BlockJobType_str(driver->job_type));
block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort);
bs->job = job;
diff --git a/chardev/char.c b/chardev/char.c
index 5d283b90d3..b6fd5eb6a6 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -931,7 +931,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
ChardevReturn *ret;
Chardev *chr;
- cc = char_get_class(ChardevBackendKind_lookup[backend->type], errp);
+ cc = char_get_class(ChardevBackendKind_str(backend->type), errp);
if (!cc) {
return NULL;
}
@@ -989,7 +989,7 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
return NULL;
}
- cc = char_get_class(ChardevBackendKind_lookup[backend->type], errp);
+ cc = char_get_class(ChardevBackendKind_str(backend->type), errp);
if (!cc) {
return NULL;
}
diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index 84d189a426..4e828951d4 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -257,7 +257,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg,
}
error_setg(errp, "Algorithm '%s' not supported",
- QCryptoCipherAlgorithm_lookup[alg]);
+ QCryptoCipherAlgorithm_str(alg));
return NULL;
}
@@ -392,7 +392,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher,
break;
default:
error_setg(errp, "Cipher %s not supported with essiv",
- QCryptoCipherAlgorithm_lookup[cipher]);
+ QCryptoCipherAlgorithm_str(cipher));
return 0;
}
}
@@ -962,16 +962,16 @@ qcrypto_block_luks_create(QCryptoBlock *block,
goto error;
}
- cipher_mode = QCryptoCipherMode_lookup[luks_opts.cipher_mode];
- ivgen_alg = QCryptoIVGenAlgorithm_lookup[luks_opts.ivgen_alg];
+ cipher_mode = QCryptoCipherMode_str(luks_opts.cipher_mode);
+ ivgen_alg = QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg);
if (luks_opts.has_ivgen_hash_alg) {
- ivgen_hash_alg = QCryptoHashAlgorithm_lookup[luks_opts.ivgen_hash_alg];
+ ivgen_hash_alg = QCryptoHashAlgorithm_str(luks_opts.ivgen_hash_alg);
cipher_mode_spec = g_strdup_printf("%s-%s:%s", cipher_mode, ivgen_alg,
ivgen_hash_alg);
} else {
cipher_mode_spec = g_strdup_printf("%s-%s", cipher_mode, ivgen_alg);
}
- hash_alg = QCryptoHashAlgorithm_lookup[luks_opts.hash_alg];
+ hash_alg = QCryptoHashAlgorithm_str(luks_opts.hash_alg);
if (strlen(cipher_alg) >= QCRYPTO_BLOCK_LUKS_CIPHER_NAME_LEN) {
diff --git a/crypto/block.c b/crypto/block.c
index b097d451af..c382393d9a 100644
--- a/crypto/block.c
+++ b/crypto/block.c
@@ -61,7 +61,7 @@ QCryptoBlock *qcrypto_block_open(QCryptoBlockOpenOptions *options,
if (options->format >= G_N_ELEMENTS(qcrypto_block_drivers) ||
!qcrypto_block_drivers[options->format]) {
error_setg(errp, "Unsupported block driver %s",
- QCryptoBlockFormat_lookup[options->format]);
+ QCryptoBlockFormat_str(options->format));
g_free(block);
return NULL;
}
@@ -92,7 +92,7 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
if (options->format >= G_N_ELEMENTS(qcrypto_block_drivers) ||
!qcrypto_block_drivers[options->format]) {
error_setg(errp, "Unsupported block driver %s",
- QCryptoBlockFormat_lookup[options->format]);
+ QCryptoBlockFormat_str(options->format));
g_free(block);
return NULL;
}
diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c
index 01343b2b7c..cd72284690 100644
--- a/crypto/cipher-afalg.c
+++ b/crypto/cipher-afalg.c
@@ -52,7 +52,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg,
return NULL;
}
- mode_name = QCryptoCipherMode_lookup[mode];
+ mode_name = QCryptoCipherMode_str(mode);
name = g_strdup_printf("%s(%s)", mode_name, alg_name);
return name;
diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index 16a36d4532..d8c811fd33 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -247,7 +247,7 @@ qcrypto_cipher_init_aes(QCryptoCipherMode mode,
mode != QCRYPTO_CIPHER_MODE_ECB &&
mode != QCRYPTO_CIPHER_MODE_XTS) {
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[mode]);
+ QCryptoCipherMode_str(mode));
return NULL;
}
@@ -379,7 +379,7 @@ qcrypto_cipher_init_des_rfb(QCryptoCipherMode mode,
if (mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[mode]);
+ QCryptoCipherMode_str(mode));
return NULL;
}
@@ -440,7 +440,7 @@ static QCryptoCipherBuiltin *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[mode]);
+ QCryptoCipherMode_str(mode));
return NULL;
}
@@ -460,7 +460,7 @@ static QCryptoCipherBuiltin *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
default:
error_setg(errp,
"Unsupported cipher algorithm %s",
- QCryptoCipherAlgorithm_lookup[alg]);
+ QCryptoCipherAlgorithm_str(alg));
return NULL;
}
diff --git a/crypto/cipher-gcrypt.c b/crypto/cipher-gcrypt.c
index 0489147398..10d75da75d 100644
--- a/crypto/cipher-gcrypt.c
+++ b/crypto/cipher-gcrypt.c
@@ -105,7 +105,7 @@ static QCryptoCipherGcrypt *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[mode]);
+ QCryptoCipherMode_str(mode));
return NULL;
}
@@ -160,7 +160,7 @@ static QCryptoCipherGcrypt *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
default:
error_setg(errp, "Unsupported cipher algorithm %s",
- QCryptoCipherAlgorithm_lookup[alg]);
+ QCryptoCipherAlgorithm_str(alg));
return NULL;
}
diff --git a/crypto/cipher-nettle.c b/crypto/cipher-nettle.c
index c51f119cbc..3848cb3b3a 100644
--- a/crypto/cipher-nettle.c
+++ b/crypto/cipher-nettle.c
@@ -281,7 +281,7 @@ static QCryptoCipherNettle *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[mode]);
+ QCryptoCipherMode_str(mode));
return NULL;
}
@@ -420,7 +420,7 @@ static QCryptoCipherNettle *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
default:
error_setg(errp, "Unsupported cipher algorithm %s",
- QCryptoCipherAlgorithm_lookup[alg]);
+ QCryptoCipherAlgorithm_str(alg));
goto error;
}
@@ -491,7 +491,7 @@ qcrypto_nettle_cipher_encrypt(QCryptoCipher *cipher,
default:
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[cipher->mode]);
+ QCryptoCipherMode_str(cipher->mode));
return -1;
}
return 0;
@@ -537,7 +537,7 @@ qcrypto_nettle_cipher_decrypt(QCryptoCipher *cipher,
default:
error_setg(errp, "Unsupported cipher mode %s",
- QCryptoCipherMode_lookup[cipher->mode]);
+ QCryptoCipherMode_str(cipher->mode));
return -1;
}
return 0;
diff --git a/crypto/hmac-gcrypt.c b/crypto/hmac-gcrypt.c
index 76ca61ba24..0c6f979711 100644
--- a/crypto/hmac-gcrypt.c
+++ b/crypto/hmac-gcrypt.c
@@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,
if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
- QCryptoHashAlgorithm_lookup[alg]);
+ QCryptoHashAlgorithm_str(alg));
return NULL;
}
diff --git a/crypto/hmac-glib.c b/crypto/hmac-glib.c
index 8cf6b221ed..a6c1730291 100644
--- a/crypto/hmac-glib.c
+++ b/crypto/hmac-glib.c
@@ -58,7 +58,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,
if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
- QCryptoHashAlgorithm_lookup[alg]);
+ QCryptoHashAlgorithm_str(alg));
return NULL;
}
diff --git a/crypto/hmac-nettle.c b/crypto/hmac-nettle.c
index 1d5a915f03..ec2d61bdde 100644
--- a/crypto/hmac-nettle.c
+++ b/crypto/hmac-nettle.c
@@ -106,7 +106,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,
if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
- QCryptoHashAlgorithm_lookup[alg]);
+ QCryptoHashAlgorithm_str(alg));
return NULL;
}
diff --git a/crypto/pbkdf-gcrypt.c b/crypto/pbkdf-gcrypt.c
index 40289858bf..54ca0d9c75 100644
--- a/crypto/pbkdf-gcrypt.c
+++ b/crypto/pbkdf-gcrypt.c
@@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
hash_map[hash] == GCRY_MD_NONE) {
error_setg_errno(errp, ENOSYS,
"PBKDF does not support hash algorithm %s",
- QCryptoHashAlgorithm_lookup[hash]);
+ QCryptoHashAlgorithm_str(hash));
return -1;
}
diff --git a/crypto/pbkdf-nettle.c b/crypto/pbkdf-nettle.c
index 6fb2671656..212b3e816b 100644
--- a/crypto/pbkdf-nettle.c
+++ b/crypto/pbkdf-nettle.c
@@ -110,7 +110,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
default:
error_setg_errno(errp, ENOSYS,
"PBKDF does not support hash algorithm %s",
- QCryptoHashAlgorithm_lookup[hash]);
+ QCryptoHashAlgorithm_str(hash));
return -1;
}
return 0;
diff --git a/hmp.c b/hmp.c
index 5d980acb1e..30819fe602 100644
--- a/hmp.c
+++ b/hmp.c
@@ -106,7 +106,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict)
info->singlestep ? " (single step mode)" : "");
if (!info->running && info->status != RUN_STATE_PAUSED) {
- monitor_printf(mon, " (%s)", RunState_lookup[info->status]);
+ monitor_printf(mon, " (%s)", RunState_str(info->status));
}
monitor_printf(mon, "\n");
@@ -171,7 +171,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "capabilities: ");
for (cap = caps; cap; cap = cap->next) {
monitor_printf(mon, "%s: %s ",
- MigrationCapability_lookup[cap->value->capability],
+ MigrationCapability_str(cap->value->capability),
cap->value->state ? "on" : "off");
}
monitor_printf(mon, "\n");
@@ -179,7 +179,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
if (info->has_status) {
monitor_printf(mon, "Migration status: %s",
- MigrationStatus_lookup[info->status]);
+ MigrationStatus_str(info->status));
if (info->status == MIGRATION_STATUS_FAILED &&
info->has_error_desc) {
monitor_printf(mon, " (%s)\n", info->error_desc);
@@ -277,7 +277,7 @@ void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict)
if (caps) {
for (cap = caps; cap; cap = cap->next) {
monitor_printf(mon, "%s: %s\n",
- MigrationCapability_lookup[cap->value->capability],
+ MigrationCapability_str(cap->value->capability),
cap->value->state ? "on" : "off");
}
}
@@ -294,48 +294,48 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
if (params) {
assert(params->has_compress_level);
monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL],
+ MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL),
params->compress_level);
assert(params->has_compress_threads);
monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS],
+ MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS),
params->compress_threads);
assert(params->has_decompress_threads);
monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS],
+ MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS),
params->decompress_threads);
assert(params->has_cpu_throttle_initial);
monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL],
+ MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL),
params->cpu_throttle_initial);
assert(params->has_cpu_throttle_increment);
monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT],
+ MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT),
params->cpu_throttle_increment);
assert(params->has_tls_creds);
monitor_printf(mon, "%s: '%s'\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_CREDS],
+ MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS),
params->tls_creds);
assert(params->has_tls_hostname);
monitor_printf(mon, "%s: '%s'\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME],
+ MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME),
params->tls_hostname);
assert(params->has_max_bandwidth);
monitor_printf(mon, "%s: %" PRId64 " bytes/second\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH],
+ MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH),
params->max_bandwidth);
assert(params->has_downtime_limit);
monitor_printf(mon, "%s: %" PRId64 " milliseconds\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT],
+ MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),
params->downtime_limit);
assert(params->has_x_checkpoint_delay);
monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY],
+ MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY),
params->x_checkpoint_delay);
assert(params->has_block_incremental);
monitor_printf(mon, "%s: %s\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_BLOCK_INCREMENTAL],
- params->block_incremental ? "on" : "off");
+ MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL),
+ params->block_incremental ? "on" : "off");
}
qapi_free_MigrationParameters(params);
@@ -431,7 +431,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
}
if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
monitor_printf(mon, " I/O status: %s\n",
- BlockDeviceIoStatus_lookup[info->io_status]);
+ BlockDeviceIoStatus_str(info->io_status));
}
if (info->removable) {
@@ -461,7 +461,7 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
monitor_printf(mon, " Detect zeroes: %s\n",
- BlockdevDetectZeroesOptions_lookup[inserted->detect_zeroes]);
+ BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
}
if (inserted->bps || inserted->bps_rd || inserted->bps_wr ||
@@ -612,7 +612,7 @@ static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info,
name,
info->host,
info->service,
- NetworkAddressFamily_lookup[info->family],
+ NetworkAddressFamily_str(info->family),
info->websocket ? " (Websocket)" : "");
}
@@ -622,8 +622,8 @@ static void hmp_info_vnc_authcrypt(Monitor *mon, const char *indent,
VncVencryptSubAuth *vencrypt)
{
monitor_printf(mon, "%sAuth: %s (Sub: %s)\n", indent,
- VncPrimaryAuth_lookup[auth],
- vencrypt ? VncVencryptSubAuth_lookup[*vencrypt] : "none");
+ VncPrimaryAuth_str(auth),
+ vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none");
}
static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client)
@@ -738,7 +738,7 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
monitor_printf(mon, " auth: %s\n", info->auth);
monitor_printf(mon, " compiled: %s\n", info->compiled_version);
monitor_printf(mon, " mouse-mode: %s\n",
- SpiceQueryMouseMode_lookup[info->mouse_mode]);
+ SpiceQueryMouseMode_str(info->mouse_mode));
if (!info->has_channels || info->channels == NULL) {
monitor_printf(mon, "Channels: none\n");
@@ -1009,10 +1009,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
for (info = info_list; info; info = info->next) {
TPMInfo *ti = info->value;
monitor_printf(mon, " tpm%d: model=%s\n",
- c, TpmModel_lookup[ti->model]);
+ c, TpmModel_str(ti->model));
monitor_printf(mon, " \\ %s: type=%s",
- ti->id, TpmTypeOptionsKind_lookup[ti->options->type]);
+ ti->id, TpmTypeOptionsKind_str(ti->options->type));
switch (ti->options->type) {
case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH:
@@ -2368,7 +2368,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
monitor_printf(mon, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(mon, " policy: %s\n",
- HostMemPolicy_lookup[m->value->policy]);
+ HostMemPolicy_str(m->value->policy));
visit_complete(v, &str);
monitor_printf(mon, " host nodes: %s\n", str);
@@ -2399,7 +2399,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
di = value->u.dimm.data;
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
- MemoryDeviceInfoKind_lookup[value->type],
+ MemoryDeviceInfoKind_str(value->type),
di->id ? di->id : "");
monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
@@ -2793,7 +2793,7 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict)
DumpQueryResult *result = qmp_query_dump(NULL);
assert(result && result->status < DUMP_STATUS__MAX);
- monitor_printf(mon, "Status: %s\n", DumpStatus_lookup[result->status]);
+ monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status));
if (result->status == DUMP_STATUS_ACTIVE) {
float percent = 0;
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 401129073b..db40e174c9 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -392,9 +392,9 @@ static int pick_geometry(FDrive *drv)
FLOPPY_DPRINTF("User requested floppy drive type '%s', "
"but inserted medium appears to be a "
"%"PRId64" sector '%s' type\n",
- FloppyDriveType_lookup[drv->drive],
+ FloppyDriveType_str(drv->drive),
nb_sectors,
- FloppyDriveType_lookup[parse->drive]);
+ FloppyDriveType_str(parse->drive));
}
match = type_match;
}
@@ -403,7 +403,7 @@ static int pick_geometry(FDrive *drv)
if (match == -1) {
error_setg(&error_abort, "No candidate geometries present in table "
" for floppy drive type '%s'",
- FloppyDriveType_lookup[drv->drive]);
+ FloppyDriveType_str(drv->drive));
}
parse = &(fd_formats[match]);
diff --git a/hw/char/escc.c b/hw/char/escc.c
index 1aca564e33..3ab831a6a7 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -848,7 +848,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
assert(evt->type == INPUT_EVENT_KIND_KEY);
key = evt->u.key.data;
qcode = qemu_input_key_value_to_qcode(key->key);
- trace_escc_sunkbd_event_in(qcode, QKeyCode_lookup[qcode],
+ trace_escc_sunkbd_event_in(qcode, QKeyCode_str(qcode),
key->down);
if (qcode == Q_KEY_CODE_CAPS_LOCK) {
diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c
index 46c038110c..4d3afc1b14 100644
--- a/hw/input/virtio-input-hid.c
+++ b/hw/input/virtio-input-hid.c
@@ -209,7 +209,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
} else {
if (key->down) {
fprintf(stderr, "%s: unmapped key: %d [%s]\n", __func__,
- qcode, QKeyCode_lookup[qcode]);
+ qcode, QKeyCode_str(qcode));
}
}
break;
@@ -224,7 +224,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
if (btn->down) {
fprintf(stderr, "%s: unmapped button: %d [%s]\n", __func__,
btn->button,
- InputButton_lookup[btn->button]);
+ InputButton_str(btn->button));
}
}
break;
diff --git a/migration/colo-failover.c b/migration/colo-failover.c
index f9914869c5..6563862b36 100644
--- a/migration/colo-failover.c
+++ b/migration/colo-failover.c
@@ -34,7 +34,7 @@ static void colo_failover_bh(void *opaque)
FAILOVER_STATUS_ACTIVE);
if (old_state != FAILOVER_STATUS_REQUIRE) {
error_report("Unknown error for failover, old_state = %s",
- FailoverStatus_lookup[old_state]);
+ FailoverStatus_str(old_state));
return;
}
@@ -64,7 +64,7 @@ FailoverStatus failover_set_state(FailoverStatus old_state,
old = atomic_cmpxchg(&failover_state, old_state, new_state);
if (old == old_state) {
- trace_colo_failover_set_state(FailoverStatus_lookup[new_state]);
+ trace_colo_failover_set_state(FailoverStatus_str(new_state));
}
return old;
}
diff --git a/migration/colo.c b/migration/colo.c
index a4255432ac..dee3aa8bf7 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -61,7 +61,7 @@ static void secondary_vm_do_failover(void)
FAILOVER_STATUS_RELAUNCH);
if (old_state != FAILOVER_STATUS_ACTIVE) {
error_report("Unknown error while do failover for secondary VM,"
- "old_state: %s", FailoverStatus_lookup[old_state]);
+ "old_state: %s", FailoverStatus_str(old_state));
}
return;
}
@@ -91,7 +91,7 @@ static void secondary_vm_do_failover(void)
FAILOVER_STATUS_COMPLETED);
if (old_state != FAILOVER_STATUS_ACTIVE) {
error_report("Incorrect state (%s) while doing failover for "
- "secondary VM", FailoverStatus_lookup[old_state]);
+ "secondary VM", FailoverStatus_str(old_state));
return;
}
/* Notify COLO incoming thread that failover work is finished */
@@ -126,7 +126,7 @@ static void primary_vm_do_failover(void)
FAILOVER_STATUS_COMPLETED);
if (old_state != FAILOVER_STATUS_ACTIVE) {
error_report("Incorrect state (%s) while doing failover for Primary VM",
- FailoverStatus_lookup[old_state]);
+ FailoverStatus_str(old_state));
return;
}
/* Notify COLO thread that failover work is finished */
@@ -222,7 +222,7 @@ static void colo_send_message(QEMUFile *f, COLOMessage msg,
if (ret < 0) {
error_setg_errno(errp, -ret, "Can't send COLO message");
}
- trace_colo_send_message(COLOMessage_lookup[msg]);
+ trace_colo_send_message(COLOMessage_str(msg));
}
static void colo_send_message_value(QEMUFile *f, COLOMessage msg,
@@ -242,7 +242,7 @@ static void colo_send_message_value(QEMUFile *f, COLOMessage msg,
ret = qemu_file_get_error(f);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to send value for message:%s",
- COLOMessage_lookup[msg]);
+ COLOMessage_str(msg));
}
}
@@ -261,7 +261,7 @@ static COLOMessage colo_receive_message(QEMUFile *f, Error **errp)
error_setg(errp, "%s: Invalid message", __func__);
return msg;
}
- trace_colo_receive_message(COLOMessage_lookup[msg]);
+ trace_colo_receive_message(COLOMessage_str(msg));
return msg;
}
@@ -299,7 +299,7 @@ static uint64_t colo_receive_message_value(QEMUFile *f, uint32_t expect_msg,
ret = qemu_file_get_error(f);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to get value for COLO message: %s",
- COLOMessage_lookup[expect_msg]);
+ COLOMessage_str(expect_msg));
}
return value;
}
diff --git a/migration/global_state.c b/migration/global_state.c
index 76cd3a13d4..8db2f19459 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -41,7 +41,7 @@ int global_state_store(void)
void global_state_store_running(void)
{
- const char *state = RunState_lookup[RUN_STATE_RUNNING];
+ const char *state = RunState_str(RUN_STATE_RUNNING);
strncpy((char *)global_state.runstate,
state, sizeof(global_state.runstate));
}
diff --git a/monitor.c b/monitor.c
index 86438f4b75..9239f7adde 100644
--- a/monitor.c
+++ b/monitor.c
@@ -928,7 +928,7 @@ EventInfoList *qmp_query_events(Error **errp)
QAPIEvent e;
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
- const char *event_name = QAPIEvent_lookup[e];
+ const char *event_name = QAPIEvent_str(e);
assert(event_name != NULL);
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
@@ -3250,7 +3250,7 @@ void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str)
len = strlen(str);
readline_set_completion_index(rs, len);
for (i = 0; i < NET_CLIENT_DRIVER__MAX; i++) {
- add_completion_option(rs, str, NetClientDriver_lookup[i]);
+ add_completion_option(rs, str, NetClientDriver_str(i));
}
}
@@ -3434,8 +3434,8 @@ 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++) {
- if (!strncmp(str, QKeyCode_lookup[i], len)) {
- readline_add_completion(rs, QKeyCode_lookup[i]);
+ if (!strncmp(str, QKeyCode_str(i), len)) {
+ readline_add_completion(rs, QKeyCode_str(i));
}
}
}
@@ -3538,7 +3538,7 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)
}
readline_set_completion_index(rs, strlen(str));
for (i = 0; i < WATCHDOG_EXPIRATION_ACTION__MAX; i++) {
- add_completion_option(rs, str, WatchdogExpirationAction_lookup[i]);
+ add_completion_option(rs, str, WatchdogExpirationAction_str(i));
}
}
@@ -3552,7 +3552,7 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
if (nb_args == 2) {
int i;
for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
- const char *name = MigrationCapability_lookup[i];
+ const char *name = MigrationCapability_str(i);
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
}
@@ -3573,7 +3573,7 @@ void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
if (nb_args == 2) {
int i;
for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) {
- const char *name = MigrationParameter_lookup[i];
+ const char *name = MigrationParameter_str(i);
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
}
@@ -3852,7 +3852,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
qdict = qdict_get_qdict(qobject_to_qdict(rsp), "error");
if (qdict
&& !g_strcmp0(qdict_get_try_str(qdict, "class"),
- QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) {
+ QapiErrorClass_str(ERROR_CLASS_COMMAND_NOT_FOUND))) {
/* Provide a more useful error message */
qdict_del(qdict, "desc");
qdict_put_str(qdict, "desc", "Expecting capabilities negotiation"
diff --git a/net/net.c b/net/net.c
index 0e28099554..2fa99c0497 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1064,7 +1064,7 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
/* FIXME drop when all init functions store an Error */
if (errp && !*errp) {
error_setg(errp, QERR_DEVICE_INIT_FAILED,
- NetClientDriver_lookup[netdev->type]);
+ NetClientDriver_str(netdev->type));
}
return -1;
}
@@ -1288,7 +1288,7 @@ void print_net_client(Monitor *mon, NetClientState *nc)
monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name,
nc->queue_index,
- NetClientDriver_lookup[nc->info->type],
+ NetClientDriver_str(nc->info->type),
nc->info_str);
if (!QTAILQ_EMPTY(&nc->filters)) {
monitor_printf(mon, "filters:\n");
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 5ad36f8a09..b41fa174fe 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -118,7 +118,7 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
QObject *qmp_build_error_object(Error *err)
{
return qobject_from_jsonf("{ 'class': %s, 'desc': %s }",
- QapiErrorClass_lookup[error_get_class(err)],
+ QapiErrorClass_str(error_get_class(err)),
error_get_pretty(err));
}
diff --git a/tests/test-qapi-util.c b/tests/test-qapi-util.c
index 7e1be1d851..0992bdb218 100644
--- a/tests/test-qapi-util.c
+++ b/tests/test-qapi-util.c
@@ -31,7 +31,7 @@ static void test_qapi_enum_parse(void)
ret = qapi_enum_parse(QType_lookup, "none", -1, &error_abort);
g_assert_cmpint(ret, ==, QTYPE_NONE);
- ret = qapi_enum_parse(QType_lookup, QType_lookup[QTYPE__MAX - 1],
+ ret = qapi_enum_parse(QType_lookup, QType_str(QTYPE__MAX - 1),
QTYPE__MAX - 1, &error_abort);
g_assert_cmpint(ret, ==, QTYPE__MAX - 1);
}
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 5bbfb65a02..f8720aa5eb 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -385,7 +385,7 @@ static void test_visitor_in_enum(TestInputVisitorData *data,
for (i = 0; i < ENUM_ONE__MAX; i++) {
EnumOne res = -1;
- v = visitor_input_test_init(data, "%s", EnumOne_lookup[i]);
+ v = visitor_input_test_init(data, "%s", EnumOne_str(i));
visit_type_EnumOne(v, NULL, &res, &error_abort);
g_assert_cmpint(i, ==, res);
@@ -699,7 +699,7 @@ static void test_native_list_integer_helper(TestInputVisitorData *data,
}
}
g_string_append_printf(gstr_union, "{ 'type': '%s', 'data': [ %s ] }",
- UserDefNativeListUnionKind_lookup[kind],
+ UserDefNativeListUnionKind_str(kind),
gstr_list->str);
v = visitor_input_test_init_raw(data, gstr_union->str);
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index 7eb162059c..d375100a52 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -133,7 +133,7 @@ static void test_visitor_out_enum(TestOutputVisitorData *data,
qstr = qobject_to_qstring(visitor_get(data));
g_assert(qstr);
- g_assert_cmpstr(qstring_get_str(qstr), ==, EnumOne_lookup[i]);
+ g_assert_cmpstr(qstring_get_str(qstr), ==, EnumOne_str(i));
visitor_reset(data);
}
}
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index e7a7b80c92..4f9c36bef1 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -282,7 +282,7 @@ static void test_visitor_in_enum(TestInputVisitorData *data,
for (i = 0; i < ENUM_ONE__MAX; i++) {
EnumOne res = -1;
- v = visitor_input_test_init(data, EnumOne_lookup[i]);
+ v = visitor_input_test_init(data, EnumOne_str(i));
visit_type_EnumOne(v, NULL, &res, &err);
g_assert(!err);
diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index e736db3af8..385cddb5d9 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -194,12 +194,12 @@ static void test_visitor_out_enum(TestOutputVisitorData *data,
str = visitor_get(data);
if (data->human) {
- char *str_human = g_strdup_printf("\"%s\"", EnumOne_lookup[i]);
+ char *str_human = g_strdup_printf("\"%s\"", EnumOne_str(i));
g_assert_cmpstr(str, ==, str_human);
g_free(str_human);
} else {
- g_assert_cmpstr(str, ==, EnumOne_lookup[i]);
+ g_assert_cmpstr(str, ==, EnumOne_str(i));
}
visitor_reset(data);
}
diff --git a/tpm.c b/tpm.c
index 38f3eb827f..111f1ca63f 100644
--- a/tpm.c
+++ b/tpm.c
@@ -62,7 +62,7 @@ static void tpm_display_backend_drivers(void)
continue;
}
fprintf(stderr, "%12s %s\n",
- TpmType_lookup[i], be_drivers[i]->desc());
+ TpmType_str(i), be_drivers[i]->desc());
}
fprintf(stderr, "\n");
}
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index a5f1e829c3..6bc3525499 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -62,8 +62,8 @@ int index_from_key(const char *key, size_t key_length)
int i;
for (i = 0; i < Q_KEY_CODE__MAX; i++) {
- if (!strncmp(key, QKeyCode_lookup[i], key_length) &&
- !QKeyCode_lookup[i][key_length]) {
+ if (!strncmp(key, QKeyCode_str(i), key_length) &&
+ !QKeyCode_str(i)[key_length]) {
break;
}
}
diff --git a/ui/input.c b/ui/input.c
index af05f06368..3422d4a8ef 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -151,7 +151,7 @@ void qmp_input_send_event(bool has_device, const char *device,
if (!qemu_input_find_handler(1 << event->type, con)) {
error_setg(errp, "Input handler not found for "
"event type %s",
- InputEventKind_lookup[event->type]);
+ InputEventKind_str(event->type));
return;
}
}
@@ -213,12 +213,12 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
switch (key->key->type) {
case KEY_VALUE_KIND_NUMBER:
qcode = qemu_input_key_number_to_qcode(key->key->u.number.data);
- name = QKeyCode_lookup[qcode];
+ name = QKeyCode_str(qcode);
trace_input_event_key_number(idx, key->key->u.number.data,
name, key->down);
break;
case KEY_VALUE_KIND_QCODE:
- name = QKeyCode_lookup[key->key->u.qcode.data];
+ name = QKeyCode_str(key->key->u.qcode.data);
trace_input_event_key_qcode(idx, name, key->down);
break;
case KEY_VALUE_KIND__MAX:
@@ -228,17 +228,17 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
break;
case INPUT_EVENT_KIND_BTN:
btn = evt->u.btn.data;
- name = InputButton_lookup[btn->button];
+ name = InputButton_str(btn->button);
trace_input_event_btn(idx, name, btn->down);
break;
case INPUT_EVENT_KIND_REL:
move = evt->u.rel.data;
- name = InputAxis_lookup[move->axis];
+ name = InputAxis_str(move->axis);
trace_input_event_rel(idx, name, move->value);
break;
case INPUT_EVENT_KIND_ABS:
move = evt->u.abs.data;
- name = InputAxis_lookup[move->axis];
+ name = InputAxis_str(move->axis);
trace_input_event_abs(idx, name, move->value);
break;
case INPUT_EVENT_KIND__MAX:
diff --git a/ui/vnc.c b/ui/vnc.c
index fd43f9b983..0b5dbc62e4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -131,7 +131,7 @@ static void vnc_init_basic_info(SocketAddress *addr,
case SOCKET_ADDRESS_TYPE_VSOCK:
case SOCKET_ADDRESS_TYPE_FD:
error_setg(errp, "Unsupported socket address type %s",
- SocketAddressType_lookup[addr->type]);
+ SocketAddressType_str(addr->type));
break;
default:
abort();
@@ -416,7 +416,7 @@ VncInfo *qmp_query_vnc(Error **errp)
case SOCKET_ADDRESS_TYPE_VSOCK:
case SOCKET_ADDRESS_TYPE_FD:
error_setg(errp, "Unsupported socket address type %s",
- SocketAddressType_lookup[addr->type]);
+ SocketAddressType_str(addr->type));
goto out_error;
default:
abort();
@@ -1839,7 +1839,7 @@ static void vnc_release_modifiers(VncState *vs)
static const char *code2name(int keycode)
{
- return QKeyCode_lookup[qemu_input_key_number_to_qcode(keycode)];
+ return QKeyCode_str(qemu_input_key_number_to_qcode(keycode));
}
static void key_event(VncState *vs, int down, uint32_t sym)
diff --git a/vl.c b/vl.c
index 8e247cc2a2..0b45e1b6fa 100644
--- a/vl.c
+++ b/vl.c
@@ -688,7 +688,7 @@ bool runstate_check(RunState state)
bool runstate_store(char *str, size_t size)
{
- const char *state = RunState_lookup[current_run_state];
+ const char *state = RunState_str(current_run_state);
size_t len = strlen(state) + 1;
if (len > size) {
@@ -721,8 +721,8 @@ void runstate_set(RunState new_state)
if (!runstate_valid_transitions[current_run_state][new_state]) {
error_report("invalid runstate transition: '%s' -> '%s'",
- RunState_lookup[current_run_state],
- RunState_lookup[new_state]);
+ RunState_str(current_run_state),
+ RunState_str(new_state));
abort();
}
trace_runstate_set(new_state);