qerror.h: Remove QERR defines that are only used once

Just hardcode them in the callers

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Cole Robinson 2014-03-21 19:42:26 -04:00 committed by Luiz Capitulino
parent d73f0beadb
commit f231b88db1
15 changed files with 37 additions and 91 deletions

View File

@ -194,7 +194,7 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
if ((on_error == BLOCKDEV_ON_ERROR_STOP || if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
on_error == BLOCKDEV_ON_ERROR_ENOSPC) && on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) { !bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION); error_setg(errp, "Invalid parameter combination");
return; return;
} }

View File

@ -1520,14 +1520,16 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp)
return; return;
} }
if (!bdrv_dev_has_removable_media(bs)) { if (!bdrv_dev_has_removable_media(bs)) {
error_set(errp, QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); error_setg(errp, "Device '%s' is not removable",
bdrv_get_device_name(bs));
return; return;
} }
if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) { if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) {
bdrv_dev_eject_request(bs, force); bdrv_dev_eject_request(bs, force);
if (!force) { if (!force) {
error_set(errp, QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); error_setg(errp, "Device '%s' is locked",
bdrv_get_device_name(bs));
return; return;
} }
} }
@ -2219,7 +2221,8 @@ void qmp_block_job_cancel(const char *device,
return; return;
} }
if (job->paused && !force) { if (job->paused && !force) {
error_set(errp, QERR_BLOCK_JOB_PAUSED, device); error_setg(errp, "The block job for device '%s' is currently paused",
device);
return; return;
} }

View File

@ -987,8 +987,9 @@ static void v9fs_attach(void *opaque)
*/ */
if (!s->migration_blocker) { if (!s->migration_blocker) {
s->root_fid = fid; s->root_fid = fid;
error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, error_setg(&s->migration_blocker,
s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag); "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'",
s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag);
migrate_add_blocker(s->migration_blocker); migrate_add_blocker(s->migration_blocker);
} }
out: out:

View File

@ -587,8 +587,9 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
/* We rely on power-of-2 blocksizes for bitmasks */ /* We rely on power-of-2 blocksizes for bitmasks */
if ((value & (value - 1)) != 0) { if ((value & (value - 1)) != 0) {
error_set(errp, QERR_PROPERTY_VALUE_NOT_POWER_OF_2, error_setg(errp,
dev->id?:"", name, (int64_t)value); "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
dev->id ?: "", name, (int64_t)value);
return; return;
} }
@ -853,7 +854,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
{ {
switch (ret) { switch (ret) {
case -EEXIST: case -EEXIST:
error_set(errp, QERR_PROPERTY_VALUE_IN_USE, error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use",
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
default: default:
@ -862,7 +863,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
case -ENOENT: case -ENOENT:
error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND, error_setg(errp, "Property '%s.%s' can't find value '%s'",
object_get_typename(OBJECT(dev)), prop->name, value); object_get_typename(OBJECT(dev)), prop->name, value);
break; break;
case 0: case 0:

View File

@ -684,8 +684,8 @@ static int pci_ivshmem_init(PCIDevice *dev)
} }
if (s->role_val == IVSHMEM_PEER) { if (s->role_val == IVSHMEM_PEER) {
error_set(&s->migration_blocker, QERR_DEVICE_FEATURE_BLOCKS_MIGRATION, error_setg(&s->migration_blocker,
"peer mode", "ivshmem"); "Migration is disabled when using feature 'peer mode' in device 'ivshmem'");
migrate_add_blocker(s->migration_blocker); migrate_add_blocker(s->migration_blocker);
} }

View File

@ -35,48 +35,30 @@ void qerror_report_err(Error *err);
* Please keep the definitions in alphabetical order. * Please keep the definitions in alphabetical order.
* Use scripts/check-qerror.sh to check. * Use scripts/check-qerror.sh to check.
*/ */
#define QERR_AMBIGUOUS_PATH \
ERROR_CLASS_GENERIC_ERROR, "Path '%s' does not uniquely identify an object"
#define QERR_BAD_BUS_FOR_DEVICE \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' can't go on a %s bus"
#define QERR_BASE_NOT_FOUND \ #define QERR_BASE_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found" ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
#define QERR_BLOCK_JOB_NOT_ACTIVE \ #define QERR_BLOCK_JOB_NOT_ACTIVE \
ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'" ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'"
#define QERR_BLOCK_JOB_PAUSED \
ERROR_CLASS_GENERIC_ERROR, "The block job for device '%s' is currently paused"
#define QERR_BLOCK_JOB_NOT_READY \ #define QERR_BLOCK_JOB_NOT_READY \
ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed" ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed"
#define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \ #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'" ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'"
#define QERR_BUFFER_OVERRUN \
ERROR_CLASS_GENERIC_ERROR, "An internal buffer overran"
#define QERR_BUS_NO_HOTPLUG \ #define QERR_BUS_NO_HOTPLUG \
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging" ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
#define QERR_BUS_NOT_FOUND \ #define QERR_BUS_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found" ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
#define QERR_COMMAND_DISABLED \
ERROR_CLASS_GENERIC_ERROR, "The command %s has been disabled for this instance"
#define QERR_COMMAND_NOT_FOUND \ #define QERR_COMMAND_NOT_FOUND \
ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found" ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found"
#define QERR_DEVICE_ENCRYPTED \ #define QERR_DEVICE_ENCRYPTED \
ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted" ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted"
#define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when using feature '%s' in device '%s'"
#define QERR_DEVICE_HAS_NO_MEDIUM \ #define QERR_DEVICE_HAS_NO_MEDIUM \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium" ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
@ -89,15 +71,6 @@ void qerror_report_err(Error *err);
#define QERR_DEVICE_IS_READ_ONLY \ #define QERR_DEVICE_IS_READ_ONLY \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only" ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only"
#define QERR_DEVICE_LOCKED \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is locked"
#define QERR_DEVICE_MULTIPLE_BUSSES \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' has multiple child busses"
#define QERR_DEVICE_NO_BUS \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no child bus"
#define QERR_DEVICE_NO_HOTPLUG \ #define QERR_DEVICE_NO_HOTPLUG \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging" ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
@ -110,12 +83,6 @@ void qerror_report_err(Error *err);
#define QERR_DEVICE_NOT_FOUND \ #define QERR_DEVICE_NOT_FOUND \
ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found" ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
#define QERR_DEVICE_NOT_REMOVABLE \
ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not removable"
#define QERR_DUPLICATE_ID \
ERROR_CLASS_GENERIC_ERROR, "Duplicate ID '%s' for %s"
#define QERR_FD_NOT_FOUND \ #define QERR_FD_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found" ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
@ -128,15 +95,9 @@ void qerror_report_err(Error *err);
#define QERR_INVALID_BLOCK_FORMAT \ #define QERR_INVALID_BLOCK_FORMAT \
ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'" ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
#define QERR_INVALID_OPTION_GROUP \
ERROR_CLASS_GENERIC_ERROR, "There is no option group '%s'"
#define QERR_INVALID_PARAMETER \ #define QERR_INVALID_PARAMETER \
ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'" ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
#define QERR_INVALID_PARAMETER_COMBINATION \
ERROR_CLASS_GENERIC_ERROR, "Invalid parameter combination"
#define QERR_INVALID_PARAMETER_TYPE \ #define QERR_INVALID_PARAMETER_TYPE \
ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s" ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
@ -149,9 +110,6 @@ void qerror_report_err(Error *err);
#define QERR_IO_ERROR \ #define QERR_IO_ERROR \
ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred" ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
#define QERR_JSON_PARSE_ERROR \
ERROR_CLASS_GENERIC_ERROR, "JSON parse error, %s"
#define QERR_JSON_PARSING \ #define QERR_JSON_PARSING \
ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax" ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
@ -161,36 +119,18 @@ void qerror_report_err(Error *err);
#define QERR_MIGRATION_ACTIVE \ #define QERR_MIGRATION_ACTIVE \
ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress" ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
#define QERR_MIGRATION_NOT_SUPPORTED \
ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'"
#define QERR_MISSING_PARAMETER \ #define QERR_MISSING_PARAMETER \
ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing" ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
#define QERR_NO_BUS_FOR_DEVICE \
ERROR_CLASS_GENERIC_ERROR, "No '%s' bus found for device '%s'"
#define QERR_NOT_SUPPORTED \ #define QERR_NOT_SUPPORTED \
ERROR_CLASS_GENERIC_ERROR, "Not supported" ERROR_CLASS_GENERIC_ERROR, "Not supported"
#define QERR_PERMISSION_DENIED \ #define QERR_PERMISSION_DENIED \
ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation" ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
#define QERR_PROPERTY_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' not found"
#define QERR_PROPERTY_VALUE_BAD \ #define QERR_PROPERTY_VALUE_BAD \
ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'" ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
#define QERR_PROPERTY_VALUE_IN_USE \
ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't take value '%s', it's in use"
#define QERR_PROPERTY_VALUE_NOT_FOUND \
ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't find value '%s'"
#define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2"
#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \ #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")" ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
@ -206,9 +146,6 @@ void qerror_report_err(Error *err);
#define QERR_QMP_EXTRA_MEMBER \ #define QERR_QMP_EXTRA_MEMBER \
ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected" ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
#define QERR_RESET_REQUIRED \
ERROR_CLASS_GENERIC_ERROR, "Resetting the Virtual Machine is required"
#define QERR_SET_PASSWD_FAILED \ #define QERR_SET_PASSWD_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Could not set password" ERROR_CLASS_GENERIC_ERROR, "Could not set password"
@ -221,9 +158,6 @@ void qerror_report_err(Error *err);
#define QERR_UNSUPPORTED \ #define QERR_UNSUPPORTED \
ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported" ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
#define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'"
#define QERR_SOCKET_CONNECT_FAILED \ #define QERR_SOCKET_CONNECT_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket" ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket"

View File

@ -80,7 +80,8 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
return NULL; return NULL;
} }
if (!cmd->enabled) { if (!cmd->enabled) {
error_set(errp, QERR_COMMAND_DISABLED, command); error_setg(errp, "The command %s has been disabled for this instance",
command);
return NULL; return NULL;
} }

View File

@ -71,7 +71,7 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp)
GHashTable *h; GHashTable *h;
if (qiv->nb_stack >= QIV_STACK_SIZE) { if (qiv->nb_stack >= QIV_STACK_SIZE) {
error_set(errp, QERR_BUFFER_OVERRUN); error_setg(errp, "An internal buffer overran");
return; return;
} }

View File

@ -422,12 +422,14 @@ static BusState *qbus_find(const char *path)
* one child bus accept it nevertheless */ * one child bus accept it nevertheless */
switch (dev->num_child_bus) { switch (dev->num_child_bus) {
case 0: case 0:
qerror_report(QERR_DEVICE_NO_BUS, elem); qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has no child bus", elem);
return NULL; return NULL;
case 1: case 1:
return QLIST_FIRST(&dev->child_bus); return QLIST_FIRST(&dev->child_bus);
default: default:
qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem); qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' has multiple child busses", elem);
if (!monitor_cur_is_qmp()) { if (!monitor_cur_is_qmp()) {
qbus_list_bus(dev); qbus_list_bus(dev);
} }
@ -505,14 +507,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return NULL; return NULL;
} }
if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) { if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
qerror_report(QERR_BAD_BUS_FOR_DEVICE, qerror_report(ERROR_CLASS_GENERIC_ERROR,
"Device '%s' can't go on a %s bus",
driver, object_get_typename(OBJECT(bus))); driver, object_get_typename(OBJECT(bus)));
return NULL; return NULL;
} }
} else if (dc->bus_type != NULL) { } else if (dc->bus_type != NULL) {
bus = qbus_find_recursive(sysbus_get_default(), NULL, dc->bus_type); bus = qbus_find_recursive(sysbus_get_default(), NULL, dc->bus_type);
if (!bus) { if (!bus) {
qerror_report(QERR_NO_BUS_FOR_DEVICE, qerror_report(ERROR_CLASS_GENERIC_ERROR,
"No '%s' bus found for device '%s'",
dc->bus_type, driver); dc->bus_type, driver);
return NULL; return NULL;
} }

2
qmp.c
View File

@ -166,7 +166,7 @@ void qmp_cont(Error **errp)
Error *local_err = NULL; Error *local_err = NULL;
if (runstate_needs_reset()) { if (runstate_needs_reset()) {
error_set(errp, QERR_RESET_REQUIRED); error_setg(errp, "Resetting the Virtual Machine is required");
return; return;
} else if (runstate_check(RUN_STATE_SUSPENDED)) { } else if (runstate_check(RUN_STATE_SUSPENDED)) {
return; return;

View File

@ -110,7 +110,7 @@ static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt,
error_free(ctxt->err); error_free(ctxt->err);
ctxt->err = NULL; ctxt->err = NULL;
} }
error_set(&ctxt->err, QERR_JSON_PARSE_ERROR, message); error_setg(&ctxt->err, "JSON parse error, %s", message);
} }
/** /**

View File

@ -768,7 +768,7 @@ ObjectProperty *object_property_find(Object *obj, const char *name,
} }
} }
error_set(errp, QERR_PROPERTY_NOT_FOUND, "", name); error_setg(errp, "Property '.%s' not found", name);
return NULL; return NULL;
} }
@ -1075,7 +1075,8 @@ static Object *object_resolve_link(Object *obj, const char *name,
target = object_resolve_path_type(path, target_type, &ambiguous); target = object_resolve_path_type(path, target_type, &ambiguous);
if (ambiguous) { if (ambiguous) {
error_set(errp, QERR_AMBIGUOUS_PATH, path); error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"Path '%s' does not uniquely identify an object", path);
} else if (!target) { } else if (!target) {
target = object_resolve_path(path, &ambiguous); target = object_resolve_path(path, &ambiguous);
if (target || ambiguous) { if (target || ambiguous) {

View File

@ -453,7 +453,8 @@ bool qemu_savevm_state_blocked(Error **errp)
QTAILQ_FOREACH(se, &savevm_handlers, entry) { QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (se->no_migrate) { if (se->no_migrate) {
error_set(errp, QERR_MIGRATION_NOT_SUPPORTED, se->idstr); error_setg(errp, "State blocked by non-migratable device '%s'",
se->idstr);
return true; return true;
} }
} }

View File

@ -20,7 +20,7 @@ static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
break; break;
} }
if (lists[i] == NULL) { if (lists[i] == NULL) {
error_set(errp, QERR_INVALID_OPTION_GROUP, group); error_setg(errp, "There is no option group '%s'", group);
} }
return lists[i]; return lists[i];
} }

View File

@ -819,7 +819,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
opts = qemu_opts_find(list, id); opts = qemu_opts_find(list, id);
if (opts != NULL) { if (opts != NULL) {
if (fail_if_exists && !list->merge_lists) { if (fail_if_exists && !list->merge_lists) {
error_set(errp, QERR_DUPLICATE_ID, id, list->name); error_setg(errp, "Duplicate ID '%s' for %s", id, list->name);
return NULL; return NULL;
} else { } else {
return opts; return opts;