From nobody Tue Nov 11 04:59:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560975919; cv=none; d=zoho.com; s=zohoarc; b=jcsIqBsxw4NvoQCFLmZS/jZGv9mnH1P8+EUkTL+fy8cbgowQC98snHWGF54LiIzvj9qa7gR//SMCpRq8Lzoc8gzSw/9uvYAb2U/UK099Lxt94UvVrPgL0PPvfJV9ZMirAsz2lWS5+qGZtFFLMCsQFrGrydQXhlwUh3FQ9nAFVXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560975919; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ix0wMZdxpIsxtVkUViV0bDKiSLEDgi7M1QpKe1v9dsU=; b=NMXowgAOK0rI6ZUCLfm1CGa9sSglTOIgFNeDqm0nIBYg+5y/2w5mmoGSR/LWomiJEloe11QgT5rvO0J8kMMMNDXx9MR4q4J5tLQAtrfeDoVMjTI8UY8yC8HENlJnXvHtH/OI3j3201SOtgJLPi+6ib2PySYG+Qyuny6QcD6l5Ws= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560975919475364.75016398647733; Wed, 19 Jun 2019 13:25:19 -0700 (PDT) Received: from localhost ([::1]:41750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdh8r-0001DL-Hp for importer@patchew.org; Wed, 19 Jun 2019 16:25:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35404) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdgvC-0004Ku-Iu for qemu-devel@nongnu.org; Wed, 19 Jun 2019 16:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdgv7-00019R-5R for qemu-devel@nongnu.org; Wed, 19 Jun 2019 16:11:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdgv5-00015d-NN for qemu-devel@nongnu.org; Wed, 19 Jun 2019 16:11:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B12AE30C132E for ; Wed, 19 Jun 2019 20:10:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-85.ams2.redhat.com [10.36.116.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 340961001B3D; Wed, 19 Jun 2019 20:10:55 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 15E5E1136444; Wed, 19 Jun 2019 22:10:51 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 22:10:50 +0200 Message-Id: <20190619201050.19040-18-armbru@redhat.com> In-Reply-To: <20190619201050.19040-1-armbru@redhat.com> References: <20190619201050.19040-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 19 Jun 2019 20:10:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 17/17] dump: Move HMP command handlers to dump/ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Move the HMP handlers related to qapi/dump.json to dimp/dump-hmp-cmds.c, where they are covered by MAINTAINERS section "Dump", just like qapi/dump.json. Cc: Marc-Andr=C3=A9 Lureau Cc: "Dr. David Alan Gilbert" Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- Makefile.objs | 1 + dump/Makefile.objs | 1 + dump/dump-hmp-cmds.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ monitor/hmp-cmds.c | 76 -------------------------------------- 4 files changed, 90 insertions(+), 76 deletions(-) create mode 100644 dump/dump-hmp-cmds.c diff --git a/Makefile.objs b/Makefile.objs index 7494d6143b..c93d731047 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -45,6 +45,7 @@ io-obj-y =3D io/ ifeq ($(CONFIG_SOFTMMU),y) common-obj-y =3D blockdev.o blockdev-nbd.o block/ common-obj-y +=3D bootdevice.o iothread.o +common-obj-y +=3D dump/ common-obj-y +=3D job-qmp.o common-obj-y +=3D monitor/ common-obj-y +=3D net/ diff --git a/dump/Makefile.objs b/dump/Makefile.objs index ea6b074967..d2a5db3b81 100644 --- a/dump/Makefile.objs +++ b/dump/Makefile.objs @@ -1,2 +1,3 @@ obj-y +=3D dump.o +common-obj-y +=3D dump-hmp-cmds.o obj-$(TARGET_X86_64) +=3D win_dump.o diff --git a/dump/dump-hmp-cmds.c b/dump/dump-hmp-cmds.c new file mode 100644 index 0000000000..3dbf44372c --- /dev/null +++ b/dump/dump-hmp-cmds.c @@ -0,0 +1,88 @@ +/* + * Human Monitor Interface commands + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "monitor/hmp.h" +#include "monitor/monitor.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-dump.h" +#include "qapi/qmp/qdict.h" + +void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + bool win_dmp =3D qdict_get_try_bool(qdict, "windmp", false); + bool paging =3D qdict_get_try_bool(qdict, "paging", false); + bool zlib =3D qdict_get_try_bool(qdict, "zlib", false); + bool lzo =3D qdict_get_try_bool(qdict, "lzo", false); + bool snappy =3D qdict_get_try_bool(qdict, "snappy", false); + const char *file =3D qdict_get_str(qdict, "filename"); + bool has_begin =3D qdict_haskey(qdict, "begin"); + bool has_length =3D qdict_haskey(qdict, "length"); + bool has_detach =3D qdict_haskey(qdict, "detach"); + int64_t begin =3D 0; + int64_t length =3D 0; + bool detach =3D false; + enum DumpGuestMemoryFormat dump_format =3D DUMP_GUEST_MEMORY_FORMAT_EL= F; + char *prot; + + if (zlib + lzo + snappy + win_dmp > 1) { + error_setg(&err, "only one of '-z|-l|-s|-w' can be set"); + hmp_handle_error(mon, &err); + return; + } + + if (win_dmp) { + dump_format =3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; + } + + if (zlib) { + dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; + } + + if (lzo) { + dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; + } + + if (snappy) { + dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; + } + + if (has_begin) { + begin =3D qdict_get_int(qdict, "begin"); + } + if (has_length) { + length =3D qdict_get_int(qdict, "length"); + } + if (has_detach) { + detach =3D qdict_get_bool(qdict, "detach"); + } + + prot =3D g_strconcat("file:", file, NULL); + + qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin, + has_length, length, true, dump_format, &err); + hmp_handle_error(mon, &err); + g_free(prot); +} + +void hmp_info_dump(Monitor *mon, const QDict *qdict) +{ + DumpQueryResult *result =3D qmp_query_dump(NULL); + + assert(result && result->status < DUMP_STATUS__MAX); + monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status)); + + if (result->status =3D=3D DUMP_STATUS_ACTIVE) { + float percent =3D 0; + assert(result->total !=3D 0); + percent =3D 100.0 * result->completed / result->total; + monitor_printf(mon, "Finished: %.2f %%\n", percent); + } + + qapi_free_DumpQueryResult(result); +} diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 18ffeb7017..dc12ae6129 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -31,7 +31,6 @@ #include "qapi/qapi-builtin-visit.h" #include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-char.h" -#include "qapi/qapi-commands-dump.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-net.h" @@ -2160,64 +2159,6 @@ void hmp_device_del(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } =20 -void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) -{ - Error *err =3D NULL; - bool win_dmp =3D qdict_get_try_bool(qdict, "windmp", false); - bool paging =3D qdict_get_try_bool(qdict, "paging", false); - bool zlib =3D qdict_get_try_bool(qdict, "zlib", false); - bool lzo =3D qdict_get_try_bool(qdict, "lzo", false); - bool snappy =3D qdict_get_try_bool(qdict, "snappy", false); - const char *file =3D qdict_get_str(qdict, "filename"); - bool has_begin =3D qdict_haskey(qdict, "begin"); - bool has_length =3D qdict_haskey(qdict, "length"); - bool has_detach =3D qdict_haskey(qdict, "detach"); - int64_t begin =3D 0; - int64_t length =3D 0; - bool detach =3D false; - enum DumpGuestMemoryFormat dump_format =3D DUMP_GUEST_MEMORY_FORMAT_EL= F; - char *prot; - - if (zlib + lzo + snappy + win_dmp > 1) { - error_setg(&err, "only one of '-z|-l|-s|-w' can be set"); - hmp_handle_error(mon, &err); - return; - } - - if (win_dmp) { - dump_format =3D DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; - } - - if (zlib) { - dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB; - } - - if (lzo) { - dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO; - } - - if (snappy) { - dump_format =3D DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; - } - - if (has_begin) { - begin =3D qdict_get_int(qdict, "begin"); - } - if (has_length) { - length =3D qdict_get_int(qdict, "length"); - } - if (has_detach) { - detach =3D qdict_get_bool(qdict, "detach"); - } - - prot =3D g_strconcat("file:", file, NULL); - - qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin, - has_length, length, true, dump_format, &err); - hmp_handle_error(mon, &err); - g_free(prot); -} - void hmp_netdev_add(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; @@ -2949,23 +2890,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QD= ict *qdict) qapi_free_RockerOfDpaGroupList(list); } =20 -void hmp_info_dump(Monitor *mon, const QDict *qdict) -{ - DumpQueryResult *result =3D qmp_query_dump(NULL); - - assert(result && result->status < DUMP_STATUS__MAX); - monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status)); - - if (result->status =3D=3D DUMP_STATUS_ACTIVE) { - float percent =3D 0; - assert(result->total !=3D 0); - percent =3D 100.0 * result->completed / result->total; - monitor_printf(mon, "Finished: %.2f %%\n", percent); - } - - qapi_free_DumpQueryResult(result); -} - void hmp_info_ramblock(Monitor *mon, const QDict *qdict) { ram_block_dump(mon); --=20 2.21.0