From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075084782122.3943721716305; Tue, 12 Oct 2021 14:44:44 -0700 (PDT) Received: from localhost ([::1]:51290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPZj-00068A-E6 for importer@patchew.org; Tue, 12 Oct 2021 17:44:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPXn-00047J-Vo for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:42:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPXm-0008LC-Fs for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:42:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-522-d6OrDgV-OCuzBpxUBokcgw-1; Tue, 12 Oct 2021 17:42:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7BCC10A8E08; Tue, 12 Oct 2021 21:42:38 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3571C5D6A8; Tue, 12 Oct 2021 21:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634074961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fIku1dT1BCZE/yp0Syj+eaTkXNerprru01g/5AhWtqA=; b=ZeYvxGKsNhSUSK26AOQpDM4/YXVjqQMo/olENxJgEqPjSsd3aKTckoI/mi4SSV41bPIjs+ jSRGroaBGi8W9tfE+d5vS7efsXmLRfwyi05BQql5aDIUoQcedMpk8+ZrpzrGCQ5NmS6JPw Jo4cHsvcFi3H5rY/UIoPHiHZ3PMHbYI= X-MC-Unique: d6OrDgV-OCuzBpxUBokcgw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 01/10] python/aqmp: add greeting property to QMPClient Date: Tue, 12 Oct 2021 17:41:43 -0400 Message-Id: <20211012214152.802483-2-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075086358100001 Content-Type: text/plain; charset="utf-8" Expose the greeting as a read-only property of QMPClient so it can be retrieved at-will. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini Message-id: 20210923004938.3999963-2-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/qmp_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py index 82e9dab124c..d2ad7459f9f 100644 --- a/python/qemu/aqmp/qmp_client.py +++ b/python/qemu/aqmp/qmp_client.py @@ -224,6 +224,11 @@ def __init__(self, name: Optional[str] =3D None) -> No= ne: 'asyncio.Queue[QMPClient._PendingT]' ] =3D {} =20 + @property + def greeting(self) -> Optional[Greeting]: + """The `Greeting` from the QMP server, if any.""" + return self._greeting + @upper_half async def _establish_session(self) -> None: """ --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075256579578.9287583841742; Tue, 12 Oct 2021 14:47:36 -0700 (PDT) Received: from localhost ([::1]:57740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPcT-00028a-Gq for importer@patchew.org; Tue, 12 Oct 2021 17:47:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPY3-0004lu-05 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:42:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPY0-0008TR-1H for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:42:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-xfs0pyCqMW6264KNCDfgfw-1; Tue, 12 Oct 2021 17:42:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58AE21006AA2; Tue, 12 Oct 2021 21:42:50 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE4905D6A8; Tue, 12 Oct 2021 21:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634074975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0AD1Y+EG93KjbPXq649/ERVjoahBAHdSJDykccernNs=; b=WsUm1pg5RSf6GndwiO55o16PDxbl7dpAiU3zRTs8d1pvcxkxLOINucGfNDuVhEl+xvNRsu WxjTKPvyE4ndzXvFElnGwZuPqGBNJL+Cedi4C1ND1ccZDDFe08wW02BjWbCQbBRmf+l4Yz 5lp4VNeb5sPzqYtn+dxpUGDpvQvdBxQ= X-MC-Unique: xfs0pyCqMW6264KNCDfgfw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 02/10] python/aqmp: add .empty() method to EventListener Date: Tue, 12 Oct 2021 17:41:44 -0400 Message-Id: <20211012214152.802483-3-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075256788100001 Content-Type: text/plain; charset="utf-8" Synchronous clients may want to know if they're about to block waiting for an event or not. A method such as this is necessary to implement a compatible interface for the old QEMUMonitorProtocol using the new async internals. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini Message-id: 20210923004938.3999963-3-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/events.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/qemu/aqmp/events.py b/python/qemu/aqmp/events.py index fb81d216102..271899f6b82 100644 --- a/python/qemu/aqmp/events.py +++ b/python/qemu/aqmp/events.py @@ -556,6 +556,12 @@ async def get(self) -> Message: """ return await self._queue.get() =20 + def empty(self) -> bool: + """ + Return `True` if there are no pending events. + """ + return self._queue.empty() + def clear(self) -> None: """ Clear this listener of all pending events. --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075309386517.1039771310805; Tue, 12 Oct 2021 14:48:29 -0700 (PDT) Received: from localhost ([::1]:59800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPdL-0003Xf-76 for importer@patchew.org; Tue, 12 Oct 2021 17:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYD-0005Ey-Fv for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYB-00009V-K2 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-Z2NVOMEdNRi_pyIouo0ypg-1; Tue, 12 Oct 2021 17:43:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7302F362F8; Tue, 12 Oct 2021 21:43:02 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EB395D6A8; Tue, 12 Oct 2021 21:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634074987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DVMnDAoN7oI+8cXKvxSCHjEjU5qvmhv68lJA1kwCxEQ=; b=F3tuHaZtHp48zUYR0RE5tDG7owIk3h4VRFMqEI/IsRcERuL+RYMvazEOY20ofQ0s/lmEXi WVfV6LyHyqM6qWbidk9Sd31ihoXF18RJ9/W97moLpfT8X/ajlZJRYUEo1f3tbV8zr/YFld asdHrFhJS0MAxc+Znncd01de8extzNM= X-MC-Unique: Z2NVOMEdNRi_pyIouo0ypg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 03/10] python/aqmp: Return cleared events from EventListener.clear() Date: Tue, 12 Oct 2021 17:41:45 -0400 Message-Id: <20211012214152.802483-4-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075309897100003 Content-Type: text/plain; charset="utf-8" This serves two purposes: (1) It is now possible to discern whether or not clear() removed any event(s) from the queue with absolute certainty, and (2) It is now very easy to get a List of all pending events in one chunk, which is useful for the sync bridge. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini Message-id: 20210923004938.3999963-4-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/events.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/qemu/aqmp/events.py b/python/qemu/aqmp/events.py index 271899f6b82..5f7150c78d4 100644 --- a/python/qemu/aqmp/events.py +++ b/python/qemu/aqmp/events.py @@ -562,7 +562,7 @@ def empty(self) -> bool: """ return self._queue.empty() =20 - def clear(self) -> None: + def clear(self) -> List[Message]: """ Clear this listener of all pending events. =20 @@ -570,17 +570,22 @@ def clear(self) -> None: pending FIFO queue synchronously. It can be also be used to manually clear any pending events, if desired. =20 + :return: The cleared events, if any. + .. warning:: Take care when discarding events. Cleared events will be silently tossed on the floor. All events that were ever accepted by this listener are visible in `history()`. """ + events =3D [] while True: try: - self._queue.get_nowait() + events.append(self._queue.get_nowait()) except asyncio.QueueEmpty: break =20 + return events + def __aiter__(self) -> AsyncIterator[Message]: return self =20 --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075179858588.4204732472958; Tue, 12 Oct 2021 14:46:19 -0700 (PDT) Received: from localhost ([::1]:54856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPbG-0000Ct-G6 for importer@patchew.org; Tue, 12 Oct 2021 17:46:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYF-0005HE-Ma for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYD-0000Al-2C for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-5M0ka2H3M9ysUpgPLui2Tw-1; Tue, 12 Oct 2021 17:43:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48FE81006AA2; Tue, 12 Oct 2021 21:43:04 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 990695D6A8; Tue, 12 Oct 2021 21:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634074988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3cObBRMQphyn29U3tGO/4DWuh7E5gTFgokPzSEt9Ig=; b=FtOtHcMEzMCtkvd8UqNLxuA4BoMlXS57J+UlYxIS71btFVqc/UeGcRS8/RPvRVwigc/3Rm OQJdV2LA4JFjs1/3PvxsXfOvIXydMkVWDXuRrksVfKuORDchcoNR2rwpnAlXXIj27O7Kaz fckeNaMsjnT5tPAkF9JEyxzLQ0pB/PI= X-MC-Unique: 5M0ka2H3M9ysUpgPLui2Tw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 04/10] python/aqmp: add send_fd_scm Date: Tue, 12 Oct 2021 17:41:46 -0400 Message-Id: <20211012214152.802483-5-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075180826100001 Content-Type: text/plain; charset="utf-8" Add an implementation for send_fd_scm to the async QMP implementation. Like socket_scm_helper mentions, a non-empty payload is required for QEMU to process the ancillary data. A space is most useful because it does not disturb the parsing of subsequent JSON objects. A note on "voiding the warranty": Python 3.11 removes support for calling sendmsg directly from a transport's socket. There is no other interface for doing this, our use case is, I suspect, "quite unique". As far as I can tell, this is safe to do -- send_fd_scm is a synchronous function and we can be guaranteed that the async coroutines will *not* be running when it is invoked. In testing, it works correctly. I investigated quite thoroughly the possibility of creating my own asyncio Transport (The class that ultimately manages the raw socket object) so that I could manage the socket myself, but this is so wildly invasive and unportable I scrapped the idea. It would involve a lot of copy-pasting of various python utilities and classes just to re-create the same infrastructure, and for extremely little benefit. Nah. Just boldly void the warranty instead, while I try to follow up on https://bugs.python.org/issue43232 Signed-off-by: John Snow Reviewed-by: Paolo Bonzini Reviewed-by: Eric Blake Message-id: 20210923004938.3999963-5-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/qmp_client.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py index d2ad7459f9f..f987da02eb0 100644 --- a/python/qemu/aqmp/qmp_client.py +++ b/python/qemu/aqmp/qmp_client.py @@ -9,6 +9,8 @@ =20 import asyncio import logging +import socket +import struct from typing import ( Dict, List, @@ -624,3 +626,23 @@ async def execute(self, cmd: str, """ msg =3D self.make_execute_msg(cmd, arguments, oob=3Doob) return await self.execute_msg(msg) + + @upper_half + @require(Runstate.RUNNING) + def send_fd_scm(self, fd: int) -> None: + """ + Send a file descriptor to the remote via SCM_RIGHTS. + """ + assert self._writer is not None + sock =3D self._writer.transport.get_extra_info('socket') + + if sock.family !=3D socket.AF_UNIX: + raise AQMPError("Sending file descriptors requires a UNIX sock= et.") + + # Void the warranty sticker. + # Access to sendmsg in asyncio is scheduled for removal in Python = 3.11. + sock =3D sock._sock # pylint: disable=3Dprotected-access + sock.sendmsg( + [b' '], + [(socket.SOL_SOCKET, socket.SCM_RIGHTS, struct.pack('@i', fd))] + ) --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075180845726.9188909467541; Tue, 12 Oct 2021 14:46:20 -0700 (PDT) Received: from localhost ([::1]:54948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPbH-0000GI-PX for importer@patchew.org; Tue, 12 Oct 2021 17:46:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYN-0005Mr-98 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYK-0000FU-Cw for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-yGd4QAvcNsq63JXVrhVKxw-1; Tue, 12 Oct 2021 17:43:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71518362FA; Tue, 12 Oct 2021 21:43:10 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FF445D6A8; Tue, 12 Oct 2021 21:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634074995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dI6iI5UgpxVhuCMO3m8cMQyqyjH7mWWgQtWgcanBtAI=; b=d2CSZSoTpTWBXVi5nW8XDW/iEYaVq3wiY4OCrtuihiaCX/n/VWjGbWQ3iH1Ex7bQOeJcgN 0fi/oLKusM1kMdouMP5XPILnP1n5uXxKtadoc8/g6x7BGrVSD+uchonEPqC+pS19EH4cao BfR21ay5PqF9qA4hHGZmIh71IaQXgpc= X-MC-Unique: yGd4QAvcNsq63JXVrhVKxw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 05/10] python/aqmp: Add dict conversion method to Greeting object Date: Tue, 12 Oct 2021 17:41:47 -0400 Message-Id: <20211012214152.802483-6-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075182773100003 Content-Type: text/plain; charset="utf-8" The iotests interface expects to return the greeting as a dict; AQMP offers it as a rich object. Signed-off-by: John Snow Reviewed-by: Paolo Bonzini Reviewed-by: Eric Blake Message-id: 20210923004938.3999963-6-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/qemu/aqmp/models.py b/python/qemu/aqmp/models.py index 24c94123ac0..de87f878047 100644 --- a/python/qemu/aqmp/models.py +++ b/python/qemu/aqmp/models.py @@ -8,8 +8,10 @@ # pylint: disable=3Dtoo-few-public-methods =20 from collections import abc +import copy from typing import ( Any, + Dict, Mapping, Optional, Sequence, @@ -66,6 +68,17 @@ def __init__(self, raw: Mapping[str, Any]): self._check_member('QMP', abc.Mapping, "JSON object") self.QMP =3D QMPGreeting(self._raw['QMP']) =20 + def _asdict(self) -> Dict[str, object]: + """ + For compatibility with the iotests sync QMP wrapper. + + The legacy QMP interface needs Greetings as a garden-variety Dict. + + This interface is private in the hopes that it will be able to + be dropped again in the near-future. Caller beware! + """ + return dict(copy.deepcopy(self._raw)) + =20 class QMPGreeting(Model): """ --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16340753556301005.9218456227317; Tue, 12 Oct 2021 14:49:15 -0700 (PDT) Received: from localhost ([::1]:35922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPe6-0006Q5-K2 for importer@patchew.org; Tue, 12 Oct 2021 17:49:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYP-0005Nt-6E for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYM-0000Hp-WB for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-73Gk0nQaMvS6hPI8lFN2vg-1; Tue, 12 Oct 2021 17:43:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B56B81808312; Tue, 12 Oct 2021 21:43:13 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96E485D6A8; Tue, 12 Oct 2021 21:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634074998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UNpyqlg6ZHgd6gwgEvCysMM+OiA2Km24Djn0s3fYwwQ=; b=jQddX3ai9zuw62qKO6jnOL41+TT+IytyYKdzqJi5vIsDTj4xqOiYG60s2UPkpiFo+XoYpI fwgVf36+LAk9nDL2eqsu77OqT/V8DF0xmFxXiNBn8eCf8mFtzq3hCf1CxMINT9fAvZdaoL eyyHNkpcU/qq795yuUv4luGwnqYCKxs= X-MC-Unique: 73Gk0nQaMvS6hPI8lFN2vg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 06/10] python/aqmp: Reduce severity of EOFError-caused loop terminations Date: Tue, 12 Oct 2021 17:41:48 -0400 Message-Id: <20211012214152.802483-7-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075356674100001 Content-Type: text/plain; charset="utf-8" When we encounter an EOFError, we don't know if it's an "error" in the perspective of the user of the library yet. Therefore, we should not log it as an error. Reduce the severity of this logging message to "INFO" to indicate that it's something that we expect to occur during the normal operation of the library. Signed-off-by: John Snow Reviewed-by: Paolo Bonzini Reviewed-by: Eric Blake Message-id: 20210923004938.3999963-7-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/protocol.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/aqmp/protocol.py index 32e78749c11..ae1df240260 100644 --- a/python/qemu/aqmp/protocol.py +++ b/python/qemu/aqmp/protocol.py @@ -721,8 +721,11 @@ async def _bh_loop_forever(self, async_fn: _TaskFN, na= me: str) -> None: self.logger.debug("Task.%s: cancelled.", name) return except BaseException as err: - self.logger.error("Task.%s: %s", - name, exception_summary(err)) + self.logger.log( + logging.INFO if isinstance(err, EOFError) else logging.ERR= OR, + "Task.%s: %s", + name, exception_summary(err) + ) self.logger.debug("Task.%s: failure:\n%s\n", name, pretty_traceback()) self._schedule_disconnect() --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075494156234.70927328400558; Tue, 12 Oct 2021 14:51:34 -0700 (PDT) Received: from localhost ([::1]:40810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPgL-0001KV-6E for importer@patchew.org; Tue, 12 Oct 2021 17:51:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYW-0005ag-7e for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYU-0000Lz-Ht for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:27 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-214-WaRZHM-wN-q_CmNl0OfXyQ-1; Tue, 12 Oct 2021 17:43:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0398310A8E00; Tue, 12 Oct 2021 21:43:21 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA6C55D6A8; Tue, 12 Oct 2021 21:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634075005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+wQcW8FZflS0cOptxPHY9cg3ipTQJcc3YaplF3JJRHI=; b=HhgZ+e3igdUUA5pY1NImiE9OMatEaXeJLKFYfcsGyAlsNv71eCFMk3jumTcLohL1m7MPmI Q3yXfs3CcJghfB2Ze0aVUKTSwMFnN766Tpu1qt0f982vqsoateNfqtaE7UylhybcIHE1gF IjtLcwxdjHSpu21WQmGmBDkhtn/+n0Y= X-MC-Unique: WaRZHM-wN-q_CmNl0OfXyQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 07/10] python/aqmp: Disable logging messages by default Date: Tue, 12 Oct 2021 17:41:49 -0400 Message-Id: <20211012214152.802483-8-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075495144100001 Content-Type: text/plain; charset="utf-8" AQMP is a library, and ideally it should not print error diagnostics unless a user opts into seeing them. By default, Python will print all WARNING, ERROR or CRITICAL messages to screen if no logging configuration has been created by a client application. In AQMP's case, ERROR logging statements are used to report additional detail about runtime failures that will also eventually be reported to the client library via an Exception, so these messages should not be rendered by default. (Why bother to have them at all, then? In async contexts, there may be multiple Exceptions and we are only able to report one of them back to the client application. It is not reasonably easy to predict ahead of time if one or more of these Exceptions will be squelched. Therefore, it's useful to log intermediate failures to help make sense of the ultimate, resulting failure.) Add a NullHandler that will suppress these messages until a client application opts into logging via logging.basicConfig or similar. Note that upon calling basicConfig(), this handler will *not* suppress these messages from being displayed by the client's configuration. Signed-off-by: John Snow Reviewed-by: Paolo Bonzini Reviewed-by: Eric Blake Message-id: 20210923004938.3999963-8-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/qemu/aqmp/__init__.py b/python/qemu/aqmp/__init__.py index ab1782999cf..d1b0e4dc3d3 100644 --- a/python/qemu/aqmp/__init__.py +++ b/python/qemu/aqmp/__init__.py @@ -21,6 +21,7 @@ # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. =20 +import logging import warnings =20 from .error import AQMPError @@ -41,6 +42,9 @@ =20 warnings.warn(_WMSG, FutureWarning) =20 +# Suppress logging unless an application engages it. +logging.getLogger('qemu.aqmp').addHandler(logging.NullHandler()) + =20 # The order of these fields impact the Sphinx documentation order. __all__ =3D ( --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16340753498559.433287135689397; Tue, 12 Oct 2021 14:49:09 -0700 (PDT) Received: from localhost ([::1]:35286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPe0-00060C-Rb for importer@patchew.org; Tue, 12 Oct 2021 17:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYY-0005kS-ID for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYV-0000Ni-Ur for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-229-NI_oZCCcPh60hsPFCCmyqQ-1; Tue, 12 Oct 2021 17:43:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB6D51006AA3; Tue, 12 Oct 2021 21:43:22 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A9A25D6A8; Tue, 12 Oct 2021 21:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634075007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qXVooBOJhc1dqjKnlIcYof0LO1f01Sb4+qPppmLy1DM=; b=Ta9mqICCB/vOHIh2yG5EfTBIs6di+7b5EmnT7fRvLiQWULRYT0mw6vsTRpcYNuAI9H30Ub gq+Jw4QgZ0IxgVRWNVv62LvFLWcp5bfY9OPBTU/Vj6g9c2ECmzc7qDA74ZSQQ9xE9brbI3 ZcpSXoDadAt1fH1YVgmEdRuZOisP4LQ= X-MC-Unique: NI_oZCCcPh60hsPFCCmyqQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 08/10] python/qmp: clear events on get_events() call Date: Tue, 12 Oct 2021 17:41:50 -0400 Message-Id: <20211012214152.802483-9-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075350270100001 Content-Type: text/plain; charset="utf-8" All callers in the tree *already* clear the events after a call to get_events(). Do it automatically instead and update callsites to remove the manual clear call. These semantics are quite a bit easier to emulate with async QMP, and nobody appears to be abusing some emergent properties of what happens if you decide not to clear them, so let's dial down to the dumber, simpler thing. Specifically: callers of clear() right after a call to get_events() are more likely expressing their desire to not see any events they just retrieved, whereas callers of clear_events() not in relation to a recent call to pull_event/get_events are likely expressing their desire to simply drop *all* pending events straight onto the floor. In the sync world, this is safe enough; in the async world it's nearly impossible to promise that nothing happens between getting and clearing the events. Making the retrieval also clear the queue is vastly simpler. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini Message-id: 20210923004938.3999963-9-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 1 - python/qemu/qmp/__init__.py | 6 ++++-- python/qemu/qmp/qmp_shell.py | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 34131884a57..ae945ca3c94 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -631,7 +631,6 @@ def get_qmp_events(self, wait: bool =3D False) -> List[= QMPMessage]: events =3D self._qmp.get_events(wait=3Dwait) events.extend(self._events) del self._events[:] - self._qmp.clear_events() return events =20 @staticmethod diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 269516a79b9..c27594b66a2 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -361,7 +361,7 @@ def pull_event(self, =20 def get_events(self, wait: bool =3D False) -> List[QMPMessage]: """ - Get a list of available QMP events. + Get a list of available QMP events and clear all pending events. =20 @param wait (bool): block until an event is available. @param wait (float): If wait is a float, treat it as a timeout val= ue. @@ -374,7 +374,9 @@ def get_events(self, wait: bool =3D False) -> List[QMPM= essage]: @return The list of available QMP events. """ self.__get_events(wait) - return self.__events + events =3D self.__events + self.__events =3D [] + return events =20 def clear_events(self) -> None: """ diff --git a/python/qemu/qmp/qmp_shell.py b/python/qemu/qmp/qmp_shell.py index 337acfce2d2..e7d7eb18f19 100644 --- a/python/qemu/qmp/qmp_shell.py +++ b/python/qemu/qmp/qmp_shell.py @@ -381,7 +381,6 @@ def read_exec_command(self) -> bool: if cmdline =3D=3D '': for event in self.get_events(): print(event) - self.clear_events() return True =20 return self._execute_cmd(cmdline) --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16340755918571019.0587570489655; Tue, 12 Oct 2021 14:53:11 -0700 (PDT) Received: from localhost ([::1]:45266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPhu-0004Ku-QQ for importer@patchew.org; Tue, 12 Oct 2021 17:53:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYa-0005px-8D for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYY-0000Pr-Dq for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-m1IsMVzsOnCr-uGMN29xHg-1; Tue, 12 Oct 2021 17:43:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92EE8802588; Tue, 12 Oct 2021 21:43:24 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2C3D5D6A8; Tue, 12 Oct 2021 21:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634075009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L6wF5o38BapHI3wQa9EHYU5L1He/kjVjqsvwBeHRsIY=; b=Q4h9JuPHbReTsuv1tChBAvrewK4zXozQpeA9//m88jBUsbLDgoTrsmigwJfbEoqiigXpiB p5YtNv3YtwwaVNruqizio489+xi+Vmkmy8nVcxOEiKOZsottj9yytCrC1NOCsXyU8Gp6Ou WLt8e8Mbd71ENas2LHpAA0zQhk4FYC0= X-MC-Unique: m1IsMVzsOnCr-uGMN29xHg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 09/10] python/qmp: add send_fd_scm directly to QEMUMonitorProtocol Date: Tue, 12 Oct 2021 17:41:51 -0400 Message-Id: <20211012214152.802483-10-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075592792100001 Content-Type: text/plain; charset="utf-8" It turns out you can do this directly from Python ... and because of this, you don't need to worry about setting the inheritability of the fds or spawning another process. Doing this is helpful because it allows QEMUMonitorProtocol to keep its file descriptor and socket object as private implementation details. /that/ is helpful in turn because it allows me to write a compatible, alternative implementation. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini Message-id: 20210923004938.3999963-10-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 44 +++++++--------------------------- python/qemu/qmp/__init__.py | 21 +++++++--------- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index ae945ca3c94..1c6532a3d68 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -213,48 +213,22 @@ def add_fd(self: _T, fd: int, fdset: int, def send_fd_scm(self, fd: Optional[int] =3D None, file_path: Optional[str] =3D None) -> int: """ - Send an fd or file_path to socket_scm_helper. + Send an fd or file_path to the remote via SCM_RIGHTS. =20 - Exactly one of fd and file_path must be given. - If it is file_path, the helper will open that file and pass its ow= n fd. + Exactly one of fd and file_path must be given. If it is + file_path, the file will be opened read-only and the new file + descriptor will be sent to the remote. """ - # In iotest.py, the qmp should always use unix socket. - assert self._qmp.is_scm_available() - if self._socket_scm_helper is None: - raise QEMUMachineError("No path to socket_scm_helper set") - if not os.path.exists(self._socket_scm_helper): - raise QEMUMachineError("%s does not exist" % - self._socket_scm_helper) - - # This did not exist before 3.4, but since then it is - # mandatory for our purpose - if hasattr(os, 'set_inheritable'): - os.set_inheritable(self._qmp.get_sock_fd(), True) - if fd is not None: - os.set_inheritable(fd, True) - - fd_param =3D ["%s" % self._socket_scm_helper, - "%d" % self._qmp.get_sock_fd()] - if file_path is not None: assert fd is None - fd_param.append(file_path) + with open(file_path, "rb") as passfile: + fd =3D passfile.fileno() + self._qmp.send_fd_scm(fd) else: assert fd is not None - fd_param.append(str(fd)) + self._qmp.send_fd_scm(fd) =20 - proc =3D subprocess.run( - fd_param, - stdin=3Dsubprocess.DEVNULL, - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT, - check=3DFalse, - close_fds=3DFalse, - ) - if proc.stdout: - LOG.debug(proc.stdout) - - return proc.returncode + return 0 =20 @staticmethod def _remove_if_exists(path: str) -> None: diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index c27594b66a2..358c0971d06 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -21,6 +21,7 @@ import json import logging import socket +import struct from types import TracebackType from typing import ( Any, @@ -408,18 +409,14 @@ def settimeout(self, timeout: Optional[float]) -> Non= e: raise ValueError(msg) self.__sock.settimeout(timeout) =20 - def get_sock_fd(self) -> int: + def send_fd_scm(self, fd: int) -> None: """ - Get the socket file descriptor. - - @return The file descriptor number. - """ - return self.__sock.fileno() - - def is_scm_available(self) -> bool: + Send a file descriptor to the remote via SCM_RIGHTS. """ - Check if the socket allows for SCM_RIGHTS. + if self.__sock.family !=3D socket.AF_UNIX: + raise RuntimeError("Can't use SCM_RIGHTS on non-AF_UNIX socket= .") =20 - @return True if SCM_RIGHTS is available, otherwise False. - """ - return self.__sock.family =3D=3D socket.AF_UNIX + self.__sock.sendmsg( + [b' '], + [(socket.SOL_SOCKET, socket.SCM_RIGHTS, struct.pack('@i', fd))] + ) --=20 2.31.1 From nobody Fri Apr 19 14:42:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634075494715930.7207433010515; Tue, 12 Oct 2021 14:51:34 -0700 (PDT) Received: from localhost ([::1]:40884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maPgL-0001NT-MW for importer@patchew.org; Tue, 12 Oct 2021 17:51:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYf-00063q-Oa for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maPYc-0000T0-J9 for qemu-devel@nongnu.org; Tue, 12 Oct 2021 17:43:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-1x9YnXSKMRWwdyasHZj_jA-1; Tue, 12 Oct 2021 17:43:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 884CA800FF0; Tue, 12 Oct 2021 21:43:29 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.16.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id B92A05D6A8; Tue, 12 Oct 2021 21:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634075014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OmNmlMU+lMrXtw7ojfZ4dpUPDyEE5IsCQi4bwPQDLI8=; b=bBoJRD8he98PBbfGz++O15A0iWYsjhTyz3+qHxf5/GY9JGLTwCtv3MUzn1n/FXJd4it9PZ IfSN5aBssh+2o5fr9GnE9FwcehpRrw/fXl6a1dbBum4Q8oQEOEEZ1ONmJQGaSVFTfi7VUW 4p90TDjcQr9uSJCTMsbRIIk2qgJOpAY= X-MC-Unique: 1x9YnXSKMRWwdyasHZj_jA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 10/10] python, iotests: remove socket_scm_helper Date: Tue, 12 Oct 2021 17:41:52 -0400 Message-Id: <20211012214152.802483-11-jsnow@redhat.com> In-Reply-To: <20211012214152.802483-1-jsnow@redhat.com> References: <20211012214152.802483-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1634075495179100002 Content-Type: text/plain; charset="utf-8" It's not used anymore, now. Signed-off-by: John Snow Reviewed-by: Hanna Reitz Reviewed-by: Paolo Bonzini Message-id: 20210923004938.3999963-11-jsnow@redhat.com Signed-off-by: John Snow --- tests/qemu-iotests/socket_scm_helper.c | 136 ------------------------- python/qemu/machine/machine.py | 3 - python/qemu/machine/qtest.py | 2 - tests/Makefile.include | 1 - tests/meson.build | 4 - tests/qemu-iotests/iotests.py | 3 - tests/qemu-iotests/meson.build | 5 - tests/qemu-iotests/testenv.py | 8 +- 8 files changed, 1 insertion(+), 161 deletions(-) delete mode 100644 tests/qemu-iotests/socket_scm_helper.c delete mode 100644 tests/qemu-iotests/meson.build diff --git a/tests/qemu-iotests/socket_scm_helper.c b/tests/qemu-iotests/so= cket_scm_helper.c deleted file mode 100644 index eb76d31aa94..00000000000 --- a/tests/qemu-iotests/socket_scm_helper.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * SCM_RIGHTS with unix socket help program for test - * - * Copyright IBM, Inc. 2013 - * - * Authors: - * Wenchao Xia - * - * This work is licensed under the terms of the GNU LGPL, version 2 or lat= er. - * See the COPYING.LIB file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include -#include - -/* #define SOCKET_SCM_DEBUG */ - -/* - * @fd and @fd_to_send will not be checked for validation in this function, - * a blank will be sent as iov data to notify qemu. - */ -static int send_fd(int fd, int fd_to_send) -{ - struct msghdr msg; - struct iovec iov[1]; - int ret; - char control[CMSG_SPACE(sizeof(int))]; - struct cmsghdr *cmsg; - - memset(&msg, 0, sizeof(msg)); - memset(control, 0, sizeof(control)); - - /* Send a blank to notify qemu */ - iov[0].iov_base =3D (void *)" "; - iov[0].iov_len =3D 1; - - msg.msg_iov =3D iov; - msg.msg_iovlen =3D 1; - - msg.msg_control =3D control; - msg.msg_controllen =3D sizeof(control); - - cmsg =3D CMSG_FIRSTHDR(&msg); - - cmsg->cmsg_len =3D CMSG_LEN(sizeof(int)); - cmsg->cmsg_level =3D SOL_SOCKET; - cmsg->cmsg_type =3D SCM_RIGHTS; - memcpy(CMSG_DATA(cmsg), &fd_to_send, sizeof(int)); - - do { - ret =3D sendmsg(fd, &msg, 0); - } while (ret < 0 && errno =3D=3D EINTR); - - if (ret < 0) { - fprintf(stderr, "Failed to send msg, reason: %s\n", strerror(errno= )); - } - - return ret; -} - -/* Convert string to fd number. */ -static int get_fd_num(const char *fd_str, bool silent) -{ - int sock; - char *err; - - errno =3D 0; - sock =3D strtol(fd_str, &err, 10); - if (errno) { - if (!silent) { - fprintf(stderr, "Failed in strtol for socket fd, reason: %s\n", - strerror(errno)); - } - return -1; - } - if (!*fd_str || *err || sock < 0) { - if (!silent) { - fprintf(stderr, "bad numerical value for socket fd '%s'\n", fd= _str); - } - return -1; - } - - return sock; -} - -/* - * To make things simple, the caller needs to specify: - * 1. socket fd. - * 2. path of the file to be sent. - */ -int main(int argc, char **argv, char **envp) -{ - int sock, fd, ret; - -#ifdef SOCKET_SCM_DEBUG - int i; - for (i =3D 0; i < argc; i++) { - fprintf(stderr, "Parameter %d: %s\n", i, argv[i]); - } -#endif - - if (argc !=3D 3) { - fprintf(stderr, - "Usage: %s < socket-fd > < file-path >\n", - argv[0]); - return EXIT_FAILURE; - } - - - sock =3D get_fd_num(argv[1], false); - if (sock < 0) { - return EXIT_FAILURE; - } - - fd =3D get_fd_num(argv[2], true); - if (fd < 0) { - /* Now only open a file in readonly mode for test purpose. If more - precise control is needed, use python script in file operation,= which - is supposed to fork and exec this program. */ - fd =3D open(argv[2], O_RDONLY); - if (fd < 0) { - fprintf(stderr, "Failed to open file '%s'\n", argv[2]); - return EXIT_FAILURE; - } - } - - ret =3D send_fd(sock, fd); - if (ret < 0) { - close(fd); - return EXIT_FAILURE; - } - - close(fd); - return EXIT_SUCCESS; -} diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 1c6532a3d68..056d340e355 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -98,7 +98,6 @@ def __init__(self, name: Optional[str] =3D None, base_temp_dir: str =3D "/var/tmp", monitor_address: Optional[SocketAddrT] =3D None, - socket_scm_helper: Optional[str] =3D None, sock_dir: Optional[str] =3D None, drain_console: bool =3D False, console_log: Optional[str] =3D None, @@ -113,7 +112,6 @@ def __init__(self, @param name: prefix for socket and log file names (default: qemu-P= ID) @param base_temp_dir: default location where temp files are created @param monitor_address: address for QMP monitor - @param socket_scm_helper: helper program, required for send_fd_scm= () @param sock_dir: where to create socket (defaults to base_temp_dir) @param drain_console: (optional) True to drain console socket to b= uffer @param console_log: (optional) path to console log file @@ -134,7 +132,6 @@ def __init__(self, self._base_temp_dir =3D base_temp_dir self._sock_dir =3D sock_dir or self._base_temp_dir self._log_dir =3D log_dir - self._socket_scm_helper =3D socket_scm_helper =20 if monitor_address is not None: self._monitor_address =3D monitor_address diff --git a/python/qemu/machine/qtest.py b/python/qemu/machine/qtest.py index 395cc8fbfe9..f2f9aaa5e50 100644 --- a/python/qemu/machine/qtest.py +++ b/python/qemu/machine/qtest.py @@ -115,7 +115,6 @@ def __init__(self, wrapper: Sequence[str] =3D (), name: Optional[str] =3D None, base_temp_dir: str =3D "/var/tmp", - socket_scm_helper: Optional[str] =3D None, sock_dir: Optional[str] =3D None, qmp_timer: Optional[float] =3D None): # pylint: disable=3Dtoo-many-arguments @@ -126,7 +125,6 @@ def __init__(self, sock_dir =3D base_temp_dir super().__init__(binary, args, wrapper=3Dwrapper, name=3Dname, base_temp_dir=3Dbase_temp_dir, - socket_scm_helper=3Dsocket_scm_helper, sock_dir=3Dsock_dir, qmp_timer=3Dqmp_timer) self._qtest: Optional[QEMUQtestProtocol] =3D None self._qtest_path =3D os.path.join(sock_dir, name + "-qtest.sock") diff --git a/tests/Makefile.include b/tests/Makefile.include index 7426522bbed..7bb8961515c 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -148,7 +148,6 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-v= m-images check: =20 ifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy) -QEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) =3D tests/qemu-iotests/socket_scm_hel= per$(EXESUF) check: check-block export PYTHON check-block: $(SRC_PATH)/tests/check-block.sh qemu-img$(EXESUF) \ diff --git a/tests/meson.build b/tests/meson.build index 55a7b082751..3f3882748ae 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -67,10 +67,6 @@ if have_tools and 'CONFIG_VHOST_USER' in config_host and= 'CONFIG_LINUX' in confi dependencies: [qemuutil, vhost_user]) endif =20 -if have_system and 'CONFIG_POSIX' in config_host - subdir('qemu-iotests') -endif - test('decodetree', sh, args: [ files('decode/check.sh'), config_host['PYTHON'], files('../sc= ripts/decodetree.py') ], workdir: meson.current_source_dir() / 'decode', diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b06ad76e0c5..e5fff6ddcfc 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -107,8 +107,6 @@ =20 qemu_valgrind =3D ['valgrind', valgrind_logfile, '--error-exitcode=3D9= 9'] =20 -socket_scm_helper =3D os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_help= er') - luks_default_secret_object =3D 'secret,id=3Dkeysec0,data=3D' + \ os.environ.get('IMGKEYSECRET', '') luks_default_key_secret_opt =3D 'key-secret=3Dkeysec0' @@ -598,7 +596,6 @@ def __init__(self, path_suffix=3D''): super().__init__(qemu_prog, qemu_opts, wrapper=3Dwrapper, name=3Dname, base_temp_dir=3Dtest_dir, - socket_scm_helper=3Dsocket_scm_helper, sock_dir=3Dsock_dir, qmp_timer=3Dtimer) self._num_drives =3D 0 =20 diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build deleted file mode 100644 index 67aed1e4927..00000000000 --- a/tests/qemu-iotests/meson.build +++ /dev/null @@ -1,5 +0,0 @@ -if 'CONFIG_LINUX' in config_host - socket_scm_helper =3D executable('socket_scm_helper', 'socket_scm_help= er.c') -else - socket_scm_helper =3D [] -endif diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index 99a57a69f3a..c33454fa685 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -68,7 +68,7 @@ class TestEnv(ContextManager['TestEnv']): env_variables =3D ['PYTHONPATH', 'TEST_DIR', 'SOCK_DIR', 'SAMPLE_IMG_D= IR', 'OUTPUT_DIR', 'PYTHON', 'QEMU_PROG', 'QEMU_IMG_PROG', 'QEMU_IO_PROG', 'QEMU_NBD_PROG', 'QSD_PROG', - 'SOCKET_SCM_HELPER', 'QEMU_OPTIONS', 'QEMU_IMG_OPTION= S', + 'QEMU_OPTIONS', 'QEMU_IMG_OPTIONS', 'QEMU_IO_OPTIONS', 'QEMU_IO_OPTIONS_NO_FMT', 'QEMU_NBD_OPTIONS', 'IMGOPTS', 'IMGFMT', 'IMGPROTO', 'AIOMODE', 'CACHEMODE', 'VALGRIND_QEMU', @@ -140,7 +140,6 @@ def init_binaries(self) -> None: """Init binary path variables: PYTHON (for bash tests) QEMU_PROG, QEMU_IMG_PROG, QEMU_IO_PROG, QEMU_NBD_PROG, QSD_PR= OG - SOCKET_SCM_HELPER """ self.python =3D sys.executable =20 @@ -174,10 +173,6 @@ def root(*names: str) -> str: if not isxfile(b): sys.exit('Not executable: ' + b) =20 - helper_path =3D os.path.join(self.build_iotests, 'socket_scm_helpe= r') - if isxfile(helper_path): - self.socket_scm_helper =3D helper_path # SOCKET_SCM_HELPER - def __init__(self, imgfmt: str, imgproto: str, aiomode: str, cachemode: Optional[str] =3D None, imgopts: Optional[str] =3D None, @@ -303,7 +298,6 @@ def print_env(self) -> None: PLATFORM -- {platform} TEST_DIR -- {TEST_DIR} SOCK_DIR -- {SOCK_DIR} -SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER} GDB_OPTIONS -- {GDB_OPTIONS} VALGRIND_QEMU -- {VALGRIND_QEMU} PRINT_QEMU_OUTPUT -- {PRINT_QEMU} --=20 2.31.1