From nobody Thu Nov 14 18:03:51 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=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1629794830; cv=pass; d=zohomail.com; s=zohoarc; b=YiTx5421cZhBZvvKzwO+bKdJ+T4LyMgEztRpGyt+80xbEn7yla4/YGgZph7GYNUjUEf3c+pTsD1jn/R0Jl9sleTTB2nENI9aG1cZidsqlaLrHH0xScvPKd6+NOk9sPRpkk0710LgkKBGWmlr+FyKxtfNr19x4ArTWBqogbES+KU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629794830; 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=WJuVZ1kuk0Wl5cOGUuwIXKMMuQ9XY9UDNeImIl4AjmM=; b=isU/gjlsfycD+zMip0mVHRVIk3X5qK2gUeZZhaYL0+Bkrfyg+hhzKKZAQLOGXr6r889zGLOnDqlWJeeFFn/ghMtHUiEJEkYmIwlywWBaMFz/oA+SnpUqVcS5Ek+oDvJVjRyU3+u6ypn7VOol2yGEY+YdOBkjbsYNmsqYtbD8Cf4= 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=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629794830378570.8378278781539; Tue, 24 Aug 2021 01:47:10 -0700 (PDT) Received: from localhost ([::1]:46052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIS5N-0002py-9u for importer@patchew.org; Tue, 24 Aug 2021 04:47:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIRyU-0003Iz-P5; Tue, 24 Aug 2021 04:40:02 -0400 Received: from mail-db8eur05on2134.outbound.protection.outlook.com ([40.107.20.134]:13121 helo=EUR05-DB8-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 1mIRyS-0007US-OM; Tue, 24 Aug 2021 04:40:02 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM7PR08MB5333.eurprd08.prod.outlook.com (2603:10a6:20b:104::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 08:39:51 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::3c5e:7829:362d:1423]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::3c5e:7829:362d:1423%2]) with mapi id 15.20.4436.025; Tue, 24 Aug 2021 08:39:51 +0000 Received: from localhost.localdomain (185.215.60.249) by HE1PR05CA0178.eurprd05.prod.outlook.com (2603:10a6:3:f8::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Tue, 24 Aug 2021 08:39:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bZAfzH9rE61wd1lJSwRGgzzqmYb1r+bTocPPflDM+64hKovNXWeaEQK5X7ZJgHjmSyOkb3CaA+bSWs4+3mbQ8+aLOldyanVRajvCUhy9oLW6h1QwMsd6F435yrglyIrX68bM8nRCV6cjWqw8YdE9u2SzrhdbiW9BjBvmVtEz66qaY5q9tKsm8SWxRT3ZJWjSAduqt6x+r4nTlbxYmZuWF6OZIg6pahAT3IVEGA/oXZm9JSVwFf+bX2K5MGdTT5+sbH9KNz1Ncd7h2M7zmN2w2BOX5mCiLU/BVIpS3vM+5w4F+jWFi8DwpR9Mldxk0M9BUwiE2EpdRqm63q/BRYGk+A== 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=WJuVZ1kuk0Wl5cOGUuwIXKMMuQ9XY9UDNeImIl4AjmM=; b=hOuQiIt3+bJxbriKNpuuNR14U6uaeIGK2iMam5PhiTHRR0CjwtPuuKdf5zBwUrmhAwu0GqTfFKocyIV2Cet9+26BSY9GV2nFGO9IOgT/amAi0sWtuX7+jMusOElrE3EIdDIuLMRsDXUmRueqMlwbMxBxjuLZLzKOsiMN4P7nSqTuV2ywCvUkyKtk6GyD7glafBinnfsEmBhv6x9RFw9qU30EIk3wCq4AKJ+fcROs+SsDKhMwnhYV/ylMuNsR2zKE6qRmX9Vymo5jVSU9aMzfeGioMZoQldywjFoJ64fnZ96hPrUdjRqstj8q7bJOPAHCtPC1U7x7kAOLkYOCKU17ag== 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=WJuVZ1kuk0Wl5cOGUuwIXKMMuQ9XY9UDNeImIl4AjmM=; b=dAuv8AN5Y8wQ1boqkeyYhNS4knc9YnrDMJ68n54ijyLdnO/y2X4ZXLZl5dhDtvgd5iAjIREH5nH4RRRhV0NUePU0YGbN2H+7mWHFGVh+jJcpKV9OFop/OVUHtxOLN1qrduycG64zj/F1J3JIgDLsJirOzeU96OyOLtcTedwVNZM= 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, hreitz@redhat.com, kwolf@redhat.com, Max Reitz Subject: [PATCH v8 24/34] python/qemu/machine: QEMUMachine: improve qmp() method Date: Tue, 24 Aug 2021 11:38:46 +0300 Message-Id: <20210824083856.17408-25-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210824083856.17408-1-vsementsov@virtuozzo.com> References: <20210824083856.17408-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0178.eurprd05.prod.outlook.com (2603:10a6:3:f8::26) 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: fed0eaee-a1e0-4892-fbb6-08d966dabcff X-MS-TrafficTypeDiagnostic: AM7PR08MB5333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1148; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +Dhv+RgylPKQSdKblwNPmLcoIEd+rGHWdUDCyQFAxAsx4BjNJOyUzou4JKxC8HbIsIJFlXk/TPAipCzt9/OJdwRbqWZwQiEZZNrH7rNE3JLTN9MOh7NIJD8oLf0QbxpNhm9l/YwNjZoacD384pwXMRAFXXVnMswq1EKdODFX7Gk658do4U3PnoNAyH+zCOfNqPBBwP2QzpoO42NP7NFwdfDNzxTlmJ/0oIJaSdNSS7bh3mZ3+8YDN8Mu3OC4MV89ftruI/peKwOFVgljSbq3etJ/Z1YfU3IDHc/jCxRLjxoYYReuNDEnE2yHQI9aOpu6k7lrRycomGLVZC37E9tnCuSZBcKTkZgucgpUGa19aWqP7pwjH7/AMuVTVgHa0LY8F0XoMmmPyOnfOw7tMXAll4gTbX11dvOi66cXi9mSGBBpNMKvmSlUj3PMEihmS+QpMgZr0RF1dnbqSxj2Z4mGtXxPYA3wDGAKdcPIX/ngHuVLUhAZ9RNdzCDn+WlcGiA0B7ViBXm+I5cEwrqzxAoW56Dawi3DHTdDs8Fj0MrnqEr0OvsBn3t6q7pD+62Uj0HPlATQEtRi6W3oP40aJzcXKPbZ1P6X4ANyFaHSccBRwarw9wk6Ix16KARzr7N8awlDWOicsQ+58CHPKL4woy3H1Rob1srxt2o3tPmY0nRxREb/oDktuycQVHXodH3280Q48XVizhDbfUIwCPVF+f+3/A== 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)(136003)(39840400004)(346002)(396003)(366004)(376002)(38100700002)(8676002)(4326008)(6666004)(86362001)(52116002)(38350700002)(83380400001)(7416002)(8936002)(6916009)(5660300002)(478600001)(26005)(1076003)(6506007)(6512007)(186003)(2616005)(66556008)(36756003)(66476007)(66946007)(956004)(316002)(6486002)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6iQBjEPlHIz/uzsP/HKb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6mfJqgBdgNi?= =?us-ascii?Q?Yutg6YuHFWhD/nY6IIl9MQgnE7oxutrJ4JFBId7PtGbHJsaVBNrJ07BEruEr?= =?us-ascii?Q?m8h2f4fvu3E0wcgNxkhS2v+vBiBb6Uvvaf3r26sNysbfDlI9Z1qF5WVfTEIv?= =?us-ascii?Q?o70dz0JZNX1NZCWt+bD4ujBBloYrQcTCcCbiWPc20wsPNLU02ZCkYhflsmWD?= =?us-ascii?Q?TLt65CEfdHX0PlyaMKalhQfChzfCQSI5MiXINFfKqjKmouPdub7pyAY32mNt?= =?us-ascii?Q?G6FIV7eijzVnMYOqrCwZPUXYMf60YXNYh+HPAh8ARdAgPPiOpVWlKl8moaPg?= =?us-ascii?Q?nr7g5aG1r9Ml1F1mBnKTKVxrVWs4jNaLBlLOAZU35Rw7dJdU8Q4elNXMZpkI?= =?us-ascii?Q?CGy8mpKXrVgRTToeh3ECBGI5UHLJIZKKoSW5by3VjINqt+Iu9WeETZRPQNtV?= =?us-ascii?Q?JNagdzW3vgYv04Pu8459J6V8?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fed0eaee-a1e0-4892-fbb6-08d966dabcff X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2021 08:39:51.0656 (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: m9QLMsqfdUESBp8B2PeUIAiGpCkY/pRERfuSffTj4vwJVi/NJif9xAy+Fjp49Z0SCYhUIdWi8DQs5c55Q4XZIvg+0OVROoU0CC0NFOYYDtI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5333 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.20.134; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-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) X-ZM-MESSAGEID: 1629794831721100001 Content-Type: text/plain; charset="utf-8" We often call qmp() with unpacking dict, like qmp('foo', **{...}). mypy don't really like it, it thinks 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 passing dict directly, simplifying interface, and giving a way to satisfy mypy. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Reviewed-by: John Snow --- python/qemu/machine/machine.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 5eab31aeec..ce1e130c13 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -572,11 +572,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, object]] =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