From nobody Thu Nov 14 06:57:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1621522193; cv=pass; d=zohomail.com; s=zohoarc; b=H8rHDmnDX3lWu/CUGXRY3rot/A2FTrzRceHEY9XYi7W2BzofKx5v+blFgsnBI/c6Vq2zo16TPgAJNu0FDSm5jYv4mXwcBIpQBrGhvfoTMJ678XfraOfW9VeLE2Tvrsz1oBbf3mdTIzVjTdnYTULdFgbZeGyO7+TR5NsvpkU8yWM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621522193; 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; bh=zKA9a+imlpbK6vvzlMul+KVAuXATgW6Mc3WbFxYkqgA=; b=iOjcz7Ne83H5Oi0G1U0SY3rKt8egr0IpWxDQGpHIaPnPoc3rHbrWuag3gefTCILA166jk+YlZgi+e1/BLwo65+tKj9Wm+RlsvbFYaARvnyvDf8rFAArMku0cEhQI+SDbd01vFqOeX9MdUw6CTp7OHjJV11pVf5sSE8KhlSGEPEw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621522193448279.90011444017387; Thu, 20 May 2021 07:49:53 -0700 (PDT) Received: from localhost ([::1]:44518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljjzk-0007MR-F5 for importer@patchew.org; Thu, 20 May 2021 10:49:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljja5-0006o7-DS; Thu, 20 May 2021 10:23:21 -0400 Received: from mail-eopbgr10092.outbound.protection.outlook.com ([40.107.1.92]:6738 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljja3-0005se-O0; Thu, 20 May 2021 10:23:21 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4072.eurprd08.prod.outlook.com (2603:10a6:20b:a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Thu, 20 May 2021 14:22:57 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4129.033; Thu, 20 May 2021 14:22:57 +0000 Received: from localhost.localdomain (185.215.60.197) by HE1P190CA0034.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Thu, 20 May 2021 14:22:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nB4KF2ZFKShVWvO6dfA0A4a785DgtsBrMKu/8sKDMdcJUjviz56lKyglcjDZIBMLv+4Q5dtX0Mli0OwtCpHB5v2ZFu3uasEzEAEBeljSBxpfRWmCNu9KUS2tyl4L2DUo0tfsyQCRzk74JqqmxeNsLduv+DUyOJ0CXjwYIUAIFmUnT/Ec+SQmYb/AUK2o+UxIgxCRhs6OduijtgDctPKDEOiq+CrDMAC14DQhnzZ/0dMR8KiqjCJOInFVsH6lOFyUUWSOlv1VsVyKmBPXqSmzg2vn4c3Af7sWFOABzfyxMSbHGD9qylTtOFUquPIAPb8zB08dCM+AlXZvhoQRHu9/oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zKA9a+imlpbK6vvzlMul+KVAuXATgW6Mc3WbFxYkqgA=; b=Oyy3hmE2zbuzFI30ZOSx362KPY2klovSqTh2FsNjJ4Sh9zdHTJiqqJMsYxGk4s76JFuXZfls6sjvu6bzfGrRr0F8Mw7NJdK60smTuojOtC8P/EKKoSGf2nwX4uCOkb7VxWQeWhX0pnV0lSl4gPaWOVMTOaII97u/5LN6WtbY/w9Bjka9dgy2fT2+5ioNrOaWdqyqEmnkdEVvfamZHoN8so0TZRYLHGCGu95wtlsn7FehEBn6JET5I/1n93p1C+fvUayisinjqpCJj8meU1FcdUL5l5Ai93bg5SZIHbZvtlCQvuUHly0Qq6if4X1oVcujFpzsP+6Ugf7U4clOTnx0pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zKA9a+imlpbK6vvzlMul+KVAuXATgW6Mc3WbFxYkqgA=; b=V3OjDhNnFl5GpO99Bjc0qXHodz7oCfGacV5JM5bbZWXgvG/XPH/2j6TNdg+bpTwuGKb21xdDhbCY/RIBsjt7n+xV/D5SJJ5TgldxhZxUPtzHAZcmJz/WvqKDzbaa6cfgycHXYo0GDaO0y0tjtcZ07GEUHIy4VhyGJetkovnkAro= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, crosa@redhat.com, ehabkost@redhat.com, berrange@redhat.com, pbonzini@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v2 24/33] python/qemu/machine: QEMUMachine: improve qmp() method Date: Thu, 20 May 2021 17:21:56 +0300 Message-Id: <20210520142205.607501-25-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210520142205.607501-1-vsementsov@virtuozzo.com> References: <20210520142205.607501-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.197] X-ClientProxiedBy: HE1P190CA0034.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::23) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 907e13c6-d4ab-44c7-f823-08d91b9ac37c X-MS-TrafficTypeDiagnostic: AM6PR08MB4072: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VYEtP8IXyMLbzFpsH55HnVCIYwPyMyF/Tq5ZQyP9c4DPxKluTUN8HOSWTVW1D3N1CgcyLkLd8OuPp7mNRjjonhkbO7L9GXgOsUpr2nHwtqUzA8VLebSU/k6UnWQMzG2sWGEN82uAucOEr2iN56uJN19FPvZehLkgmMF2ok51HRZJrCbhDUO/9i5myRqQ3IRQle74XovyddAWi8eVkJO/e86To2e4yJgJH2GMP465jOS8hxRJZHOD8hicVPnra84ZoEn7WGRytDEBCPVY2FD1W0mCXk1YYytlYYbxPosFKV1IQcKht93gxkUqjpkdTrKqv5jVzN5gQGrbyVXB5UpMFRI1f4Z7lHA1FqKFnlL0fYO56jDJstQsQM+Tt6I0pGz+yPai0PmrMNlrJnfQgYH3FBNAmeTjDwP/30Un02HsKDIHyOhPmBSlZdXmcghJ45ZJRqm2xoIfjbLKkw/DJXS3a2rVtRWAAWydHorwwGF6aKI6iYP/EbhFkNi3XQeNycv3pVMylFYz53ccWHppWYAhceIZsIsqtw7Dl3tNtrPoh/rycwjZAF5lVO33W6x7jowrtGRgzaM6L8oYLOMEp/+n4Gh5nypC20uw8xQUcY16QqEvXMruHUVTduZ6wHg4PTHNkwwxssW+jQGLsQgq6gvuSdidruygKzaN9m8PzYmp44E9tRmEKPjpEMo6nQXA5F2f X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(136003)(366004)(39840400004)(396003)(346002)(38100700002)(478600001)(186003)(1076003)(38350700002)(2906002)(36756003)(4326008)(26005)(52116002)(6506007)(6486002)(66556008)(6512007)(66946007)(2616005)(66476007)(8676002)(16526019)(956004)(6916009)(8936002)(83380400001)(107886003)(86362001)(316002)(5660300002)(7416002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?cC9Sa3EiHq3CmqJ3j2vmv3+FzkoBMdGuXdkc6roirF2XnYzJLJtJqZSlqfUn?= =?us-ascii?Q?M2SwUzTk8D+I81lGrLfZoFaezF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l?= =?us-ascii?Q?1X/XBqoosUKX3QF3ZzNzqO73Zqkr+4GZpJqXNxQKA1BmWjabOVlUD4HWo69L?= =?us-ascii?Q?ffQFh1DiDFoywS4HEBvmy62Bu7Eir+ZlZZkdnMvDM3m4aJzVjcNY7Wgcwv8h?= =?us-ascii?Q?zkS+V0WAH+R4WQLRrD01WNTUJj0AnYG10oNC6TQDoZptHny7omEN6hYuFc+5?= =?us-ascii?Q?yLLbvez6oAZVm72rsmjvI25OmXjLAzzp9uCMen7pEDAf5ir3WgHiESR+H6eN?= =?us-ascii?Q?JNqKa4ZSgxLW6FAeS4V6dB/X0mNkUHZUHJwZy+M4j3CqMGkEmVw3gt8JPVk5?= =?us-ascii?Q?9j9xpcCM5rwn2uTOGtOU45iZR2CSeeLY5IMZRcm9y7KtQI2ASkUjildwiHKI?= =?us-ascii?Q?5AnolOfzpezRNNEvRTKON8f0?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 907e13c6-d4ab-44c7-f823-08d91b9ac37c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2021 14:22:57.0008 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: d01CIDhOnbU+tIcAp53oU7/llrXVwJn/FH51Xcvw7uUpqirrVeFJseD+KZef2NA32m9zgT7KXVTF433GkxCQNXn+++qTY9caT2m0xMmj7a8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4072 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=40.107.1.92; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We often call qmp() with unpacking dict, like qmp('foo', **{...}). mypy don't really like it, it things that passed unpacked dict is a positional argument and complains that it type should be bool (because second argument of qmp() is conv_keys: bool). Allow possing dict directly, simplifying interface, and giving a way to satisfy mypy. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- python/qemu/machine.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index ff35f2cd6c..7a14605040 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -549,11 +549,21 @@ def _qmp_args(cls, conv_keys: bool, return args =20 def qmp(self, cmd: str, - conv_keys: bool =3D True, + args_dict: Optional[Dict[str, Any]] =3D None, + conv_keys: Optional[bool] =3D None, **args: Any) -> QMPMessage: """ Invoke a QMP command and return the response dict """ + if args_dict is not None: + assert not args + assert conv_keys is None + args =3D args_dict + conv_keys =3D False + + if conv_keys is None: + conv_keys =3D True + qmp_args =3D self._qmp_args(conv_keys, args) return self._qmp.cmd(cmd, args=3Dqmp_args) =20 --=20 2.29.2