From patchwork Wed Jul 12 12:57:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 9836687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E46F560363 for ; Wed, 12 Jul 2017 13:15:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D19D7269DA for ; Wed, 12 Jul 2017 13:15:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3BCE285B5; Wed, 12 Jul 2017 13:15:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 791CA269DA for ; Wed, 12 Jul 2017 13:15:37 +0000 (UTC) Received: from localhost ([::1]:52691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHUO-0003yM-7V for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Jul 2017 09:15:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHDN-0006ZP-9M for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVHDH-00010m-Fp for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:58:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVHDH-0000zx-5q for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:57:55 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6CCsRl2087089 for ; Wed, 12 Jul 2017 08:57:54 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bncj51wjy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Jul 2017 08:57:53 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Jul 2017 13:57:51 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 12 Jul 2017 13:57:47 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6CCvlqx34013188; Wed, 12 Jul 2017 12:57:47 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 097A64203F; Wed, 12 Jul 2017 13:55:11 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5FFB42047; Wed, 12 Jul 2017 13:55:10 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 12 Jul 2017 13:55:10 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id B3C3720F69C; Wed, 12 Jul 2017 14:57:46 +0200 (CEST) From: Christian Borntraeger To: qemu-devel Date: Wed, 12 Jul 2017 14:57:38 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> References: <1499864265-144136-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071212-0040-0000-0000-000003E27179 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071212-0041-0000-0000-0000207D9890 Message-Id: <1499864265-144136-5-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-12_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120211 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 04/11] s390x/migration: Monitor commands for storage attributes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Claudio Imbrenda , Cornelia Huck , Alexander Graf , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Claudio Imbrenda Add an "info" monitor command to non-destructively inspect the state of the storage attributes of the guest, and a normal command to toggle migration mode (useful for debugging). Signed-off-by: Claudio Imbrenda Acked-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- hmp-commands-info.hx | 16 +++++++++ hmp-commands.hx | 16 +++++++++ hw/s390x/s390-stattrib.c | 62 +++++++++++++++++++++++++++++++++++ include/hw/s390x/storage-attributes.h | 4 +++ monitor.c | 1 + 5 files changed, 99 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 07500ef..d9df238 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -777,6 +777,22 @@ STEXI Display the value of a storage key (s390 only) ETEXI +#if defined(TARGET_S390X) + { + .name = "cmma", + .args_type = "addr:l,count:l?", + .params = "address [count]", + .help = "Display the values of the CMMA storage attributes for a range of pages", + .cmd = hmp_info_cmma, + }, +#endif + +STEXI +@item info cmma @var{address} +@findex cmma +Display the values of the CMMA storage attributes for a range of pages (s390 only) +ETEXI + { .name = "dump", .args_type = "", diff --git a/hmp-commands.hx b/hmp-commands.hx index 275ccdf..eec9cc2 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1153,6 +1153,22 @@ STEXI Save guest storage keys to a file. ETEXI +#if defined(TARGET_S390X) + { + .name = "migration_mode", + .args_type = "mode:i", + .params = "mode", + .help = "Enables or disables migration mode\n", + .cmd = hmp_migrationmode, + }, +#endif + +STEXI +@item migration_mode @var{mode} +@findex migration_mode +Enables or disables migration mode. +ETEXI + { .name = "snapshot_blkdev", .args_type = "reuse:-n,device:B,snapshot-file:s?,format:s?", diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index eb41fe9..0729882 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "hw/boards.h" +#include "qmp-commands.h" #include "migration/qemu-file.h" #include "migration/register.h" #include "hw/s390x/storage-attributes.h" @@ -26,6 +27,15 @@ #define STATTR_FLAG_ERROR 0x04ULL #define STATTR_FLAG_DONE 0x08ULL +static S390StAttribState *s390_get_stattrib_device(void) +{ + S390StAttribState *sas; + + sas = S390_STATTRIB(object_resolve_path_type("", TYPE_S390_STATTRIB, NULL)); + assert(sas); + return sas; +} + void s390_stattrib_init(void) { Object *obj; @@ -48,6 +58,58 @@ void s390_stattrib_init(void) qdev_init_nofail(DEVICE(obj)); } +/* Console commands: */ + +void hmp_migrationmode(Monitor *mon, const QDict *qdict) +{ + S390StAttribState *sas = s390_get_stattrib_device(); + S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); + uint64_t what = qdict_get_int(qdict, "mode"); + int r; + + r = sac->set_migrationmode(sas, what); + if (r < 0) { + monitor_printf(mon, "Error: %s", strerror(-r)); + } +} + +void hmp_info_cmma(Monitor *mon, const QDict *qdict) +{ + S390StAttribState *sas = s390_get_stattrib_device(); + S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); + uint64_t addr = qdict_get_int(qdict, "addr"); + uint64_t buflen = qdict_get_try_int(qdict, "count", 8); + uint8_t *vals; + int cx, len; + + vals = g_try_malloc(buflen); + if (!vals) { + monitor_printf(mon, "Error: %s\n", strerror(errno)); + return; + } + + len = sac->peek_stattr(sas, addr / TARGET_PAGE_SIZE, buflen, vals); + if (len < 0) { + monitor_printf(mon, "Error: %s", strerror(-len)); + goto out; + } + + monitor_printf(mon, " CMMA attributes, " + "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n", + addr / TARGET_PAGE_SIZE, len, addr & ~TARGET_PAGE_MASK); + for (cx = 0; cx < len; cx++) { + if (cx % 8 == 7) { + monitor_printf(mon, "%02x\n", vals[cx]); + } else { + monitor_printf(mon, "%02x", vals[cx]); + } + } + monitor_printf(mon, "\n"); + +out: + g_free(vals); +} + /* Migration support: */ static int cmma_load(QEMUFile *f, void *opaque, int version_id) diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/storage-attributes.h index 161440b..ccf4aa1 100644 --- a/include/hw/s390x/storage-attributes.h +++ b/include/hw/s390x/storage-attributes.h @@ -13,6 +13,7 @@ #define S390_STORAGE_ATTRIBUTES_H #include +#include "monitor/monitor.h" #define TYPE_S390_STATTRIB "s390-storage_attributes" #define TYPE_QEMU_S390_STATTRIB "s390-storage_attributes-qemu" @@ -65,4 +66,7 @@ typedef struct KVMS390StAttribState { void s390_stattrib_init(void); +void hmp_info_cmma(Monitor *mon, const QDict *qdict); +void hmp_migrationmode(Monitor *mon, const QDict *qdict); + #endif /* S390_STORAGE_ATTRIBUTES_H */ diff --git a/monitor.c b/monitor.c index d8ac20f..8e084f5 100644 --- a/monitor.c +++ b/monitor.c @@ -81,6 +81,7 @@ #if defined(TARGET_S390X) #include "hw/s390x/storage-keys.h" +#include "hw/s390x/storage-attributes.h" #endif /*