Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging

* remotes/qmp-unstable/queue/qmp:
  monitor: fix qmp_getfd() fd leak in error case
  HMP: support specifying dump format for dump-guest-memory
  HMP: fix doc of dump-guest-memory
  qmp: object-add: Validate class before creating object
  monitor: Add device_add and device_del completion.
  monitor: Add command_completion callback to mon_cmd_t.
  monitor: Fix drive_del id argument type completion.
  error: Remove some unused headers
  qerror.h: Replace QERR_NOT_SUPPORTED with QERR_UNSUPPORTED
  qerror.h: Remove QERR defines that are only used once
  qerror.h: Remove unused error classes
  error: Print error_report() to stderr if using qmp
  monitor: Remove unused monitor_print_filename
  error: Privatize error_print_loc
  vnc: Remove default_mon usage
  slirp: Remove default_mon usage

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2014-04-28 12:56:33 +01:00
commit 13de54eedd
31 changed files with 153 additions and 209 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

@ -1523,14 +1523,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;
} }
} }
@ -2222,7 +2224,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

@ -88,7 +88,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
Error *local_err = NULL; Error *local_err = NULL;
if (!job->driver->set_speed) { if (!job->driver->set_speed) {
error_set(errp, QERR_NOT_SUPPORTED); error_set(errp, QERR_UNSUPPORTED);
return; return;
} }
job->driver->set_speed(job, speed, &local_err); job->driver->set_speed(job, speed, &local_err);

View file

@ -176,7 +176,7 @@ ETEXI
{ {
.name = "drive_del", .name = "drive_del",
.args_type = "id:s", .args_type = "id:B",
.params = "device", .params = "device",
.help = "remove host block device", .help = "remove host block device",
.user_print = monitor_user_noop, .user_print = monitor_user_noop,
@ -658,6 +658,7 @@ ETEXI
.help = "add device, like -device on the command line", .help = "add device, like -device on the command line",
.user_print = monitor_user_noop, .user_print = monitor_user_noop,
.mhandler.cmd_new = do_device_add, .mhandler.cmd_new = do_device_add,
.command_completion = device_add_completion,
}, },
STEXI STEXI
@ -673,6 +674,7 @@ ETEXI
.params = "device", .params = "device",
.help = "remove device", .help = "remove device",
.mhandler.cmd = hmp_device_del, .mhandler.cmd = hmp_device_del,
.command_completion = device_del_completion,
}, },
STEXI STEXI
@ -998,26 +1000,34 @@ ETEXI
{ {
.name = "dump-guest-memory", .name = "dump-guest-memory",
.args_type = "paging:-p,filename:F,begin:i?,length:i?", .args_type = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
.params = "[-p] filename [begin] [length]", .params = "[-p] [-z|-l|-s] filename [begin length]",
.help = "dump guest memory to file" .help = "dump guest memory into file 'filename'.\n\t\t\t"
"\n\t\t\t begin(optional): the starting physical address" "-p: do paging to get guest's memory mapping.\n\t\t\t"
"\n\t\t\t length(optional): the memory size, in bytes", "-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t"
"-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t"
"-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t"
"begin: the starting physical address.\n\t\t\t"
"length: the memory size, in bytes.",
.mhandler.cmd = hmp_dump_guest_memory, .mhandler.cmd = hmp_dump_guest_memory,
}, },
STEXI STEXI
@item dump-guest-memory [-p] @var{protocol} @var{begin} @var{length} @item dump-guest-memory [-p] @var{filename} @var{begin} @var{length}
@item dump-guest-memory [-z|-l|-s] @var{filename}
@findex dump-guest-memory @findex dump-guest-memory
Dump guest memory to @var{protocol}. The file can be processed with crash or Dump guest memory to @var{protocol}. The file can be processed with crash or
gdb. gdb. Without -z|-l|-s, the dump format is ELF.
filename: dump file name -p: do paging to get guest's memory mapping.
paging: do paging to get guest's memory mapping -z: dump in kdump-compressed format, with zlib compression.
-l: dump in kdump-compressed format, with lzo compression.
-s: dump in kdump-compressed format, with snappy compression.
filename: dump file name.
begin: the starting physical address. It's optional, and should be begin: the starting physical address. It's optional, and should be
specified with length together. specified together with length.
length: the memory size, in bytes. It's optional, and should be specified length: the memory size, in bytes. It's optional, and should be specified
with begin together. together with begin.
ETEXI ETEXI
{ {
@ -1254,6 +1264,7 @@ ETEXI
.params = "[qom-type=]type,id=str[,prop=value][,...]", .params = "[qom-type=]type,id=str[,prop=value][,...]",
.help = "create QOM object", .help = "create QOM object",
.mhandler.cmd = hmp_object_add, .mhandler.cmd = hmp_object_add,
.command_completion = object_add_completion,
}, },
STEXI STEXI
@ -1268,6 +1279,7 @@ ETEXI
.params = "id", .params = "id",
.help = "destroy QOM object", .help = "destroy QOM object",
.mhandler.cmd = hmp_object_del, .mhandler.cmd = hmp_object_del,
.command_completion = object_del_completion,
}, },
STEXI STEXI

25
hmp.c
View file

@ -1308,16 +1308,35 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *errp = NULL;
int paging = qdict_get_try_bool(qdict, "paging", 0); int paging = qdict_get_try_bool(qdict, "paging", 0);
int zlib = qdict_get_try_bool(qdict, "zlib", 0);
int lzo = qdict_get_try_bool(qdict, "lzo", 0);
int snappy = qdict_get_try_bool(qdict, "snappy", 0);
const char *file = qdict_get_str(qdict, "filename"); const char *file = qdict_get_str(qdict, "filename");
bool has_begin = qdict_haskey(qdict, "begin"); bool has_begin = qdict_haskey(qdict, "begin");
bool has_length = qdict_haskey(qdict, "length"); bool has_length = qdict_haskey(qdict, "length");
/* kdump-compressed format is not supported for HMP */
bool has_format = false;
int64_t begin = 0; int64_t begin = 0;
int64_t length = 0; int64_t length = 0;
enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF; enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
char *prot; char *prot;
if (zlib + lzo + snappy > 1) {
error_setg(&errp, "only one of '-z|-l|-s' can be set");
hmp_handle_error(mon, &errp);
return;
}
if (zlib) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
}
if (lzo) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
}
if (snappy) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
}
if (has_begin) { if (has_begin) {
begin = qdict_get_int(qdict, "begin"); begin = qdict_get_int(qdict, "begin");
} }
@ -1328,7 +1347,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
prot = g_strconcat("file:", file, NULL); prot = g_strconcat("file:", file, NULL);
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length, qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
has_format, dump_format, &errp); true, dump_format, &errp);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &errp);
g_free(prot); g_free(prot);
} }

5
hmp.h
View file

@ -15,6 +15,7 @@
#define HMP_H #define HMP_H
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu/readline.h"
#include "qapi-types.h" #include "qapi-types.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
@ -92,5 +93,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict);
void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_cpu_add(Monitor *mon, const QDict *qdict);
void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict);
void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict);
void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
void device_del_completion(ReadLineState *rs, int nb_args, const char *str);
#endif #endif

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

@ -79,7 +79,6 @@ int monitor_handle_fd_param(Monitor *mon, const char *fdname);
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
GCC_FMT_ATTR(2, 0); GCC_FMT_ATTR(2, 0);
void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
void monitor_print_filename(Monitor *mon, const char *filename);
void monitor_flush(Monitor *mon); void monitor_flush(Monitor *mon);
int monitor_set_cpu(int cpu_index); int monitor_set_cpu(int cpu_index);
int monitor_get_cpu_index(void); int monitor_get_cpu_index(void);

View file

@ -12,7 +12,6 @@
#ifndef QERROR_H #ifndef QERROR_H
#define QERROR_H #define QERROR_H
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qapi/error.h" #include "qapi/error.h"
@ -35,51 +34,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_ADD_CLIENT_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Could not add client"
#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"
@ -92,15 +70,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"
@ -113,12 +82,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"
@ -131,15 +94,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"
@ -152,9 +109,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"
@ -164,45 +118,21 @@ 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 \
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 ")"
#define QERR_QGA_COMMAND_FAILED \ #define QERR_QGA_COMMAND_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'" ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
#define QERR_QGA_LOGGING_FAILED \
ERROR_CLASS_GENERIC_ERROR, "Guest agent failed to log non-optional log statement"
#define QERR_QMP_BAD_INPUT_OBJECT \ #define QERR_QMP_BAD_INPUT_OBJECT \
ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input" ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
@ -212,15 +142,9 @@ 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"
#define QERR_TOO_MANY_FILES \
ERROR_CLASS_GENERIC_ERROR, "Too many open files"
#define QERR_UNDEFINED_ERROR \ #define QERR_UNDEFINED_ERROR \
ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred" ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
@ -230,9 +154,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

@ -37,7 +37,6 @@ void loc_set_file(const char *fname, int lno);
void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_print_loc(void);
void error_set_progname(const char *argv0); void error_set_progname(const char *argv0);
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
const char *error_get_progname(void); const char *error_get_progname(void);

View file

@ -137,6 +137,7 @@ typedef struct mon_cmd_t {
* used, and mhandler of 1st level plays the role of help function. * used, and mhandler of 1st level plays the role of help function.
*/ */
struct mon_cmd_t *sub_table; struct mon_cmd_t *sub_table;
void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
} mon_cmd_t; } mon_cmd_t;
/* file descriptors passed via SCM_RIGHTS */ /* file descriptors passed via SCM_RIGHTS */
@ -352,33 +353,6 @@ void monitor_printf(Monitor *mon, const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void monitor_print_filename(Monitor *mon, const char *filename)
{
int i;
for (i = 0; filename[i]; i++) {
switch (filename[i]) {
case ' ':
case '"':
case '\\':
monitor_printf(mon, "\\%c", filename[i]);
break;
case '\t':
monitor_printf(mon, "\\t");
break;
case '\r':
monitor_printf(mon, "\\r");
break;
case '\n':
monitor_printf(mon, "\\n");
break;
default:
monitor_printf(mon, "%c", filename[i]);
break;
}
}
}
static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
const char *fmt, ...) const char *fmt, ...)
{ {
@ -2254,6 +2228,7 @@ void qmp_getfd(const char *fdname, Error **errp)
} }
if (qemu_isdigit(fdname[0])) { if (qemu_isdigit(fdname[0])) {
close(fd);
error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdname", error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdname",
"a name not starting with a digit"); "a name not starting with a digit");
return; return;
@ -4277,11 +4252,15 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr); return (p != NULL ? ++p : typestr);
} }
static void device_add_completion(ReadLineState *rs, const char *str) void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
{ {
GSList *list, *elt; GSList *list, *elt;
size_t len; size_t len;
if (nb_args != 2) {
return;
}
len = strlen(str); len = strlen(str);
readline_set_completion_index(rs, len); readline_set_completion_index(rs, len);
list = elt = object_class_get_list(TYPE_DEVICE, false); list = elt = object_class_get_list(TYPE_DEVICE, false);
@ -4290,7 +4269,9 @@ static void device_add_completion(ReadLineState *rs, const char *str)
DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data, DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
TYPE_DEVICE); TYPE_DEVICE);
name = object_class_get_name(OBJECT_CLASS(dc)); name = object_class_get_name(OBJECT_CLASS(dc));
if (!strncmp(name, str, len)) {
if (!dc->cannot_instantiate_with_device_add_yet
&& !strncmp(name, str, len)) {
readline_add_completion(rs, name); readline_add_completion(rs, name);
} }
elt = elt->next; elt = elt->next;
@ -4298,11 +4279,15 @@ static void device_add_completion(ReadLineState *rs, const char *str)
g_slist_free(list); g_slist_free(list);
} }
static void object_add_completion(ReadLineState *rs, const char *str) void object_add_completion(ReadLineState *rs, int nb_args, const char *str)
{ {
GSList *list, *elt; GSList *list, *elt;
size_t len; size_t len;
if (nb_args != 2) {
return;
}
len = strlen(str); len = strlen(str);
readline_set_completion_index(rs, len); readline_set_completion_index(rs, len);
list = elt = object_class_get_list(TYPE_USER_CREATABLE, false); list = elt = object_class_get_list(TYPE_USER_CREATABLE, false);
@ -4318,8 +4303,8 @@ static void object_add_completion(ReadLineState *rs, const char *str)
g_slist_free(list); g_slist_free(list);
} }
static void device_del_completion(ReadLineState *rs, BusState *bus, static void device_del_bus_completion(ReadLineState *rs, BusState *bus,
const char *str, size_t len) const char *str, size_t len)
{ {
BusChild *kid; BusChild *kid;
@ -4332,16 +4317,32 @@ static void device_del_completion(ReadLineState *rs, BusState *bus,
} }
QLIST_FOREACH(dev_child, &dev->child_bus, sibling) { QLIST_FOREACH(dev_child, &dev->child_bus, sibling) {
device_del_completion(rs, dev_child, str, len); device_del_bus_completion(rs, dev_child, str, len);
} }
} }
} }
static void object_del_completion(ReadLineState *rs, const char *str) void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
{
size_t len;
if (nb_args != 2) {
return;
}
len = strlen(str);
readline_set_completion_index(rs, len);
device_del_bus_completion(rs, sysbus_get_default(), str, len);
}
void object_del_completion(ReadLineState *rs, int nb_args, const char *str)
{ {
ObjectPropertyInfoList *list, *start; ObjectPropertyInfoList *list, *start;
size_t len; size_t len;
if (nb_args != 2) {
return;
}
len = strlen(str); len = strlen(str);
readline_set_completion_index(rs, len); readline_set_completion_index(rs, len);
@ -4395,6 +4396,9 @@ static void monitor_find_completion_by_table(Monitor *mon,
return monitor_find_completion_by_table(mon, cmd->sub_table, return monitor_find_completion_by_table(mon, cmd->sub_table,
&args[1], nb_args - 1); &args[1], nb_args - 1);
} }
if (cmd->command_completion) {
return cmd->command_completion(mon->rs, nb_args, args[nb_args - 1]);
}
ptype = next_arg_type(cmd->args_type); ptype = next_arg_type(cmd->args_type);
for(i = 0; i < nb_args - 2; i++) { for(i = 0; i < nb_args - 2; i++) {
@ -4421,13 +4425,6 @@ static void monitor_find_completion_by_table(Monitor *mon,
readline_set_completion_index(mon->rs, strlen(str)); readline_set_completion_index(mon->rs, strlen(str));
bdrv_iterate(block_completion_it, &mbs); bdrv_iterate(block_completion_it, &mbs);
break; break;
case 'O':
if (!strcmp(cmd->name, "device_add") && nb_args == 2) {
device_add_completion(mon->rs, str);
} else if (!strcmp(cmd->name, "object_add") && nb_args == 2) {
object_add_completion(mon->rs, str);
}
break;
case 's': case 's':
case 'S': case 'S':
if (!strcmp(cmd->name, "sendkey")) { if (!strcmp(cmd->name, "sendkey")) {
@ -4441,12 +4438,6 @@ static void monitor_find_completion_by_table(Monitor *mon,
} else if (!strcmp(cmd->name, "help|?")) { } else if (!strcmp(cmd->name, "help|?")) {
monitor_find_completion_by_table(mon, cmd_table, monitor_find_completion_by_table(mon, cmd_table,
&args[1], nb_args - 1); &args[1], nb_args - 1);
} else if (!strcmp(cmd->name, "device_del") && nb_args == 2) {
size_t len = strlen(str);
readline_set_completion_index(mon->rs, len);
device_del_completion(mon->rs, sysbus_get_default(), str, len);
} else if (!strcmp(cmd->name, "object_del") && nb_args == 2) {
object_del_completion(mon->rs, str);
} }
break; break;
default: default:

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;
} }

23
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;
@ -540,14 +540,27 @@ void object_add(const char *type, const char *id, const QDict *qdict,
Visitor *v, Error **errp) Visitor *v, Error **errp)
{ {
Object *obj; Object *obj;
ObjectClass *klass;
const QDictEntry *e; const QDictEntry *e;
Error *local_err = NULL; Error *local_err = NULL;
if (!object_class_by_name(type)) { klass = object_class_by_name(type);
if (!klass) {
error_setg(errp, "invalid class name"); error_setg(errp, "invalid class name");
return; return;
} }
if (!object_class_dynamic_cast(klass, TYPE_USER_CREATABLE)) {
error_setg(errp, "object type '%s' isn't supported by object-add",
type);
return;
}
if (object_class_is_abstract(klass)) {
error_setg(errp, "object type '%s' is abstract", type);
return;
}
obj = object_new(type); obj = object_new(type);
if (qdict) { if (qdict) {
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
@ -558,12 +571,6 @@ void object_add(const char *type, const char *id, const QDict *qdict,
} }
} }
if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
error_setg(&local_err, "object type '%s' isn't supported by object-add",
type);
goto out;
}
user_creatable_complete(obj, &local_err); user_creatable_complete(obj, &local_err);
if (local_err) { if (local_err) {
goto out; goto out;

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

@ -136,7 +136,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 || if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
bind(s, (struct sockaddr *)&addr, addrlen) < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
listen(s, 1) < 0) { listen(s, 1) < 0) {
lprint("Error: inet socket: %s\n", strerror(errno)); error_report("Error: inet socket: %s", strerror(errno));
closesocket(s); closesocket(s);
return 0; return 0;
@ -146,7 +146,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
pid = fork(); pid = fork();
switch(pid) { switch(pid) {
case -1: case -1:
lprint("Error: fork failed: %s\n", strerror(errno)); error_report("Error: fork failed: %s", strerror(errno));
close(s); close(s);
return 0; return 0;
@ -242,15 +242,6 @@ strdup(str)
} }
#endif #endif
void lprint(const char *format, ...)
{
va_list args;
va_start(args, format);
monitor_vprintf(default_mon, format, args);
va_end(args);
}
void slirp_connection_info(Slirp *slirp, Monitor *mon) void slirp_connection_info(Slirp *slirp, Monitor *mon)
{ {
const char * const tcpstates[] = { const char * const tcpstates[] = {

View file

@ -139,7 +139,7 @@ int get_dns_addr(struct in_addr *pdns_addr)
return -1; return -1;
#ifdef DEBUG #ifdef DEBUG
lprint("IP address of your DNS(s): "); fprintf(stderr, "IP address of your DNS(s): ");
#endif #endif
while (fgets(buff, 512, f) != NULL) { while (fgets(buff, 512, f) != NULL) {
if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) { if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
@ -153,17 +153,17 @@ int get_dns_addr(struct in_addr *pdns_addr)
} }
#ifdef DEBUG #ifdef DEBUG
else else
lprint(", "); fprintf(stderr, ", ");
#endif #endif
if (++found > 3) { if (++found > 3) {
#ifdef DEBUG #ifdef DEBUG
lprint("(more)"); fprintf(stderr, "(more)");
#endif #endif
break; break;
} }
#ifdef DEBUG #ifdef DEBUG
else else
lprint("%s", inet_ntoa(tmp_addr)); fprintf(stderr, "%s", inet_ntoa(tmp_addr));
#endif #endif
} }
} }

View file

@ -287,8 +287,6 @@ void if_start(struct ttys *);
long gethostid(void); long gethostid(void);
#endif #endif
void lprint(const char *, ...) GCC_FMT_ATTR(1, 2);
#ifndef _WIN32 #ifndef _WIN32
#include <netdb.h> #include <netdb.h>
#endif #endif

View file

@ -14,7 +14,6 @@ stub-obj-y += iothread-lock.o
stub-obj-y += migr-blocker.o stub-obj-y += migr-blocker.o
stub-obj-y += mon-is-qmp.o stub-obj-y += mon-is-qmp.o
stub-obj-y += mon-printf.o stub-obj-y += mon-printf.o
stub-obj-y += mon-print-filename.o
stub-obj-y += mon-protocol-event.o stub-obj-y += mon-protocol-event.o
stub-obj-y += mon-set-error.o stub-obj-y += mon-set-error.o
stub-obj-y += pci-drive-hot-add.o stub-obj-y += pci-drive-hot-add.o

View file

@ -4,6 +4,6 @@
CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
{ {
error_set(errp, QERR_NOT_SUPPORTED); error_set(errp, QERR_UNSUPPORTED);
return NULL; return NULL;
} }

View file

@ -1,6 +0,0 @@
#include "qemu-common.h"
#include "monitor/monitor.h"
void monitor_print_filename(Monitor *mon, const char *filename)
{
}

View file

@ -996,7 +996,7 @@ static void audio_add(VncState *vs)
struct audio_capture_ops ops; struct audio_capture_ops ops;
if (vs->audio_cap) { if (vs->audio_cap) {
monitor_printf(default_mon, "audio already running\n"); error_report("audio already running");
return; return;
} }
@ -1006,7 +1006,7 @@ static void audio_add(VncState *vs)
vs->audio_cap = AUD_add_capture(&vs->as, &ops, vs); vs->audio_cap = AUD_add_capture(&vs->as, &ops, vs);
if (!vs->audio_cap) { if (!vs->audio_cap) {
monitor_printf(default_mon, "Failed to add audio capture\n"); error_report("Failed to add audio capture");
} }
} }

View file

@ -12,10 +12,7 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp/qjson.h" #include "qemu/error-report.h"
#include "qapi/qmp/qdict.h"
#include "qapi-types.h"
#include "qapi/qmp/qerror.h"
struct Error struct Error
{ {

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

@ -20,7 +20,7 @@
*/ */
void error_vprintf(const char *fmt, va_list ap) void error_vprintf(const char *fmt, va_list ap)
{ {
if (cur_mon) { if (cur_mon && !monitor_cur_is_qmp()) {
monitor_vprintf(cur_mon, fmt, ap); monitor_vprintf(cur_mon, fmt, ap);
} else { } else {
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
@ -165,7 +165,7 @@ const char *error_get_progname(void)
/* /*
* Print current location to current monitor if we have one, else to stderr. * Print current location to current monitor if we have one, else to stderr.
*/ */
void error_print_loc(void) static void error_print_loc(void)
{ {
const char *sep = ""; const char *sep = "";
int i; int 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;