Commit 977c736f authored by Markus Armbruster's avatar Markus Armbruster

qapi: Mechanically convert FOO_lookup[...] to FOO_str(...)

Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-14-git-send-email-armbru@redhat.com>
Reviewed-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
parent 5b5f825d
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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]);
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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));
}
......
......@@ -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);