Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into st…
Browse files Browse the repository at this point in the history
…aging

* 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>
  • Loading branch information
pm215 committed Apr 28, 2014
2 parents a41b2c9 + 0b9f0e2 commit 13de54e
Show file tree
Hide file tree
Showing 31 changed files with 153 additions and 209 deletions.
2 changes: 1 addition & 1 deletion block/commit.c
Expand Up @@ -194,7 +194,7 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
if ((on_error == BLOCKDEV_ON_ERROR_STOP ||
on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
!bdrv_iostatus_is_enabled(bs)) {
error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
error_setg(errp, "Invalid parameter combination");
return;
}

Expand Down
9 changes: 6 additions & 3 deletions blockdev.c
Expand Up @@ -1523,14 +1523,16 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp)
return;
}
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;
}

if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) {
bdrv_dev_eject_request(bs, 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;
}
}
Expand Down Expand Up @@ -2222,7 +2224,8 @@ void qmp_block_job_cancel(const char *device,
return;
}
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;
}

Expand Down
2 changes: 1 addition & 1 deletion blockjob.c
Expand Up @@ -88,7 +88,7 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
Error *local_err = NULL;

if (!job->driver->set_speed) {
error_set(errp, QERR_NOT_SUPPORTED);
error_set(errp, QERR_UNSUPPORTED);
return;
}
job->driver->set_speed(job, speed, &local_err);
Expand Down
36 changes: 24 additions & 12 deletions hmp-commands.hx
Expand Up @@ -176,7 +176,7 @@ ETEXI

{
.name = "drive_del",
.args_type = "id:s",
.args_type = "id:B",
.params = "device",
.help = "remove host block device",
.user_print = monitor_user_noop,
Expand Down Expand Up @@ -658,6 +658,7 @@ ETEXI
.help = "add device, like -device on the command line",
.user_print = monitor_user_noop,
.mhandler.cmd_new = do_device_add,
.command_completion = device_add_completion,
},

STEXI
Expand All @@ -673,6 +674,7 @@ ETEXI
.params = "device",
.help = "remove device",
.mhandler.cmd = hmp_device_del,
.command_completion = device_del_completion,
},

STEXI
Expand Down Expand Up @@ -998,26 +1000,34 @@ ETEXI
{
.name = "dump-guest-memory",
.args_type = "paging:-p,filename:F,begin:i?,length:i?",
.params = "[-p] filename [begin] [length]",
.help = "dump guest memory to file"
"\n\t\t\t begin(optional): the starting physical address"
"\n\t\t\t length(optional): the memory size, in bytes",
.args_type = "paging:-p,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?",
.params = "[-p] [-z|-l|-s] filename [begin length]",
.help = "dump guest memory into file 'filename'.\n\t\t\t"
"-p: do paging to get guest's memory mapping.\n\t\t\t"
"-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,
},


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
Dump guest memory to @var{protocol}. The file can be processed with crash or
gdb.
filename: dump file name
paging: do paging to get guest's memory mapping
gdb. Without -z|-l|-s, the dump format is ELF.
-p: 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
specified with length together.
specified together with length.
length: the memory size, in bytes. It's optional, and should be specified
with begin together.
together with begin.
ETEXI

{
Expand Down Expand Up @@ -1254,6 +1264,7 @@ ETEXI
.params = "[qom-type=]type,id=str[,prop=value][,...]",
.help = "create QOM object",
.mhandler.cmd = hmp_object_add,
.command_completion = object_add_completion,
},

STEXI
Expand All @@ -1268,6 +1279,7 @@ ETEXI
.params = "id",
.help = "destroy QOM object",
.mhandler.cmd = hmp_object_del,
.command_completion = object_del_completion,
},

STEXI
Expand Down
25 changes: 22 additions & 3 deletions hmp.c
Expand Up @@ -1308,16 +1308,35 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{
Error *errp = NULL;
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");
bool has_begin = qdict_haskey(qdict, "begin");
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 length = 0;
enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
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) {
begin = qdict_get_int(qdict, "begin");
}
Expand All @@ -1328,7 +1347,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
prot = g_strconcat("file:", file, NULL);

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);
g_free(prot);
}
Expand Down
5 changes: 5 additions & 0 deletions hmp.h
Expand Up @@ -15,6 +15,7 @@
#define HMP_H

#include "qemu-common.h"
#include "qemu/readline.h"
#include "qapi-types.h"
#include "qapi/qmp/qdict.h"

Expand Down Expand Up @@ -92,5 +93,9 @@ void hmp_qemu_io(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_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
5 changes: 3 additions & 2 deletions hw/9pfs/virtio-9p.c
Expand Up @@ -987,8 +987,9 @@ static void v9fs_attach(void *opaque)
*/
if (!s->migration_blocker) {
s->root_fid = fid;
error_set(&s->migration_blocker, QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION,
s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag);
error_setg(&s->migration_blocker,
"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);
}
out:
Expand Down
9 changes: 5 additions & 4 deletions hw/core/qdev-properties.c
Expand Up @@ -587,8 +587,9 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,

/* We rely on power-of-2 blocksizes for bitmasks */
if ((value & (value - 1)) != 0) {
error_set(errp, QERR_PROPERTY_VALUE_NOT_POWER_OF_2,
dev->id?:"", name, (int64_t)value);
error_setg(errp,
"Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
dev->id ?: "", name, (int64_t)value);
return;
}

Expand Down Expand Up @@ -853,7 +854,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
{
switch (ret) {
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);
break;
default:
Expand All @@ -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);
break;
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);
break;
case 0:
Expand Down
4 changes: 2 additions & 2 deletions hw/misc/ivshmem.c
Expand Up @@ -684,8 +684,8 @@ static int pci_ivshmem_init(PCIDevice *dev)
}

if (s->role_val == IVSHMEM_PEER) {
error_set(&s->migration_blocker, QERR_DEVICE_FEATURE_BLOCKS_MIGRATION,
"peer mode", "ivshmem");
error_setg(&s->migration_blocker,
"Migration is disabled when using feature 'peer mode' in device 'ivshmem'");
migrate_add_blocker(s->migration_blocker);
}

Expand Down
1 change: 0 additions & 1 deletion include/monitor/monitor.h
Expand Up @@ -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)
GCC_FMT_ATTR(2, 0);
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);
int monitor_set_cpu(int cpu_index);
int monitor_get_cpu_index(void);
Expand Down

0 comments on commit 13de54e

Please sign in to comment.