Commit 13de54ee authored by Peter Maydell's avatar Peter Maydell
Browse files

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: default avatarPeter Maydell <peter.maydell@linaro.org>
parents a41b2c99 0b9f0e2f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
    }

+6 −3
Original line number Diff line number Diff line
@@ -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;
        }
    }
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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);
+24 −12
Original line number Diff line number Diff line
@@ -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,
@@ -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
@@ -673,6 +674,7 @@ ETEXI
        .params     = "device",
        .help       = "remove device",
        .mhandler.cmd = hmp_device_del,
        .command_completion = device_del_completion,
    },

STEXI
@@ -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

    {
@@ -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
@@ -1268,6 +1279,7 @@ ETEXI
        .params     = "id",
        .help       = "destroy QOM object",
        .mhandler.cmd = hmp_object_del,
        .command_completion = object_del_completion,
    },

STEXI
+22 −3
Original line number Diff line number Diff line
@@ -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");
    }
@@ -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);
}
Loading