From nobody Mon May 6 20:35:53 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1566436796; cv=none; d=zoho.com; s=zohoarc; b=iiTShdIBMLk5vLEcAiGzR1p9DnmA37jI4WCagzX1Vez835uBAFOEjNlqM5SqoAnW+vTeIbT5G3zRH6mrbOtcQmYz/Dh8zWUcLdnV8K3cmd9I1KGWsOOO94oM7edSDi/8q6GY4cQs81pXPAbUIwJg+kJGMzUGkSQ9HO64dko6DRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566436796; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=4J0Ceb4oruHbmfQdEmrB0qXhE+XbO0vQuwIdFzFR1DY=; b=F+1ssGb6kw8nOrSlgPQMlpd1X3Wlc50JEwChSA7Air6dN95Vy0KFEADK+a0C91nme+tDrBde0heEg20D8LWtSJVt2UN9ABXZy0khHch03GSFyqQY3iTP002DmU3NJr4qrDfj66pouXoUs/HDGmJ3jNxwJdV58fNWKV4TAElUTvU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566436795752127.32128810858819; Wed, 21 Aug 2019 18:19:55 -0700 (PDT) Received: from localhost ([::1]:37490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0bla-0006AS-43 for importer@patchew.org; Wed, 21 Aug 2019 21:19:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60481) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0bik-0003aV-NK for qemu-devel@nongnu.org; Wed, 21 Aug 2019 21:17:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0bii-0002UM-TT for qemu-devel@nongnu.org; Wed, 21 Aug 2019 21:16:58 -0400 Received: from ozlabs.ru ([107.173.13.209]:42962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i0bii-0002Tn-NF for qemu-devel@nongnu.org; Wed, 21 Aug 2019 21:16:56 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 5F817AE80024; Wed, 21 Aug 2019 21:16:04 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 22 Aug 2019 11:16:20 +1000 Message-Id: <20190822011620.106337-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [RFC PATCH qemu] qapi: Add query-memory-checksum 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: Alexey Kardashevskiy , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This returns MD5 checksum of all RAM blocks for migration debugging as this is way faster than saving the entire RAM to a file and checking that. Signed-off-by: Alexey Kardashevskiy --- I am actually wondering if there is an easier way of getting these checksums and I just do not see it, it cannot be that we fixed all memory migration bugs :) --- qapi/misc.json | 27 +++++++++++++++++++++++++++ include/exec/cpu-common.h | 1 + exec.c | 16 ++++++++++++++++ monitor/qmp-cmds.c | 9 +++++++++ 4 files changed, 53 insertions(+) diff --git a/qapi/misc.json b/qapi/misc.json index a7fba7230cfa..e7475f30a844 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1194,6 +1194,33 @@ ## { 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' } =20 +## +# @MemoryChecksum: +# +# A string with MD5 checksum of all RAMBlocks. +# +# @checksum: the checksum. +# +# Since: 3.2.0 +## +{ 'struct': 'MemoryChecksum', + 'data' : { 'checksum': 'str' } } + +## +# @query-memory-checksum: +# +# Return the MD5 checksum of all RAMBlocks. +# +# Example: +# +# -> { "execute": "query-memory-checksum" } +# <- { "return": { "checksum": "a0880304994f64cb2edad77b9a1cd58f" } } +# +# Since: 3.2.0 +## +{ 'command': 'query-memory-checksum', + 'returns': 'MemoryChecksum' } + =20 ## # @AddfdInfo: diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index f7dbe75fbc38..15dbf18c2d5d 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -57,6 +57,7 @@ void qemu_ram_set_idstr(RAMBlock *block, const char *name= , DeviceState *dev); void qemu_ram_unset_idstr(RAMBlock *block); const char *qemu_ram_get_idstr(RAMBlock *rb); void *qemu_ram_get_host_addr(RAMBlock *rb); +gchar *qemu_ram_chksum(void); ram_addr_t qemu_ram_get_offset(RAMBlock *rb); ram_addr_t qemu_ram_get_used_length(RAMBlock *rb); bool qemu_ram_is_shared(RAMBlock *rb); diff --git a/exec.c b/exec.c index 3e78de3b8f8b..76f7f63cf71b 100644 --- a/exec.c +++ b/exec.c @@ -2050,6 +2050,22 @@ void *qemu_ram_get_host_addr(RAMBlock *rb) return rb->host; } =20 +gchar *qemu_ram_chksum(void) +{ + struct RAMBlock *rb; + GChecksum *chksum =3D g_checksum_new(G_CHECKSUM_MD5); + gchar *ret; + + RAMBLOCK_FOREACH(rb) { + g_checksum_update(chksum, qemu_ram_get_host_addr(rb), + qemu_ram_get_used_length(rb)); + } + ret =3D g_strdup(g_checksum_get_string(chksum)); + g_checksum_free(chksum); + + return ret; +} + ram_addr_t qemu_ram_get_offset(RAMBlock *rb) { return rb->offset; diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index b9ae40eec751..ec52bd82588e 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -413,3 +413,12 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) =20 return mem_info; } + +MemoryChecksum *qmp_query_memory_checksum(Error **errp) +{ + MemoryChecksum *chk =3D g_malloc0(sizeof(MemoryChecksum)); + + chk->checksum =3D qemu_ram_chksum(); + + return chk; +} --=20 2.17.1