From nobody Fri Apr 26 16:52:01 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 1637635257334388.00213694256104; Mon, 22 Nov 2021 18:40:57 -0800 (PST) Received: from localhost ([::1]:35708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLjr-00018R-3v for importer@patchew.org; Mon, 22 Nov 2021 21:40:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhQ-00050e-25 for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhN-0006BK-KR for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-UzCaAhqUMceCPifI7Gg9iA-1; Mon, 22 Nov 2021 21:38:17 -0500 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 747AA8066EC; Tue, 23 Nov 2021 02:38:16 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A63564188; Tue, 23 Nov 2021 02:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635101; 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=PWsqW3Q4twvuXt/vTrLGmfjEypIknSpoksPOB4JxVGU=; b=VIcL8zFQ3lT6yeOCmRJm6wREZi9mZbHkedKcdnDcAgohkzx6zoeDcbZ0idNX9r1ePZxM1M C5fcLVgawhKCREZnKRglAT70VeS8X55T3Rh0kQ1BoEcMqv9p5fWr8iri5IGCNtmKnBPArY yMEebLCRU7qgSMPimsa2F+mV7UfgB9U= X-MC-Unique: UzCaAhqUMceCPifI7Gg9iA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 1/7] python/machine: add @sock_dir property Date: Mon, 22 Nov 2021 21:37:59 -0500 Message-Id: <20211123023805.2745382-2-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635258754100001 Content-Type: text/plain; charset="utf-8" Analogous to temp_dir and log_dir, add a sock_dir property that defaults to @temp_dir -- instead of base_temp_dir -- when the user hasn't overridden the sock dir value in the initializer. This gives us a much more unique directory to put sockfiles in by default. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Message-id: 20211118204620.1897674-2-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index a487c39745..b1dd77b538 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -134,8 +134,9 @@ def __init__(self, self._qmp_timer =3D qmp_timer =20 self._name =3D name or "qemu-%d" % os.getpid() + self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir - self._sock_dir =3D sock_dir or self._base_temp_dir + self._sock_dir =3D sock_dir self._log_dir =3D log_dir =20 if monitor_address is not None: @@ -143,7 +144,7 @@ def __init__(self, self._remove_monitor_sockfile =3D False else: self._monitor_address =3D os.path.join( - self._sock_dir, f"{self._name}-monitor.sock" + self.sock_dir, f"{self._name}-monitor.sock" ) self._remove_monitor_sockfile =3D True =20 @@ -163,14 +164,13 @@ def __init__(self, self._qmp_set =3D True # Enable QMP monitor by default. self._qmp_connection: Optional[QEMUMonitorProtocol] =3D None self._qemu_full_args: Tuple[str, ...] =3D () - self._temp_dir: Optional[str] =3D None self._launched =3D False self._machine: Optional[str] =3D None self._console_index =3D 0 self._console_set =3D False self._console_device_type: Optional[str] =3D None self._console_address =3D os.path.join( - self._sock_dir, f"{self._name}-console.sock" + self.sock_dir, f"{self._name}-console.sock" ) self._console_socket: Optional[socket.socket] =3D None self._remove_files: List[str] =3D [] @@ -816,6 +816,15 @@ def temp_dir(self) -> str: dir=3Dself._base_temp_dir) return self._temp_dir =20 + @property + def sock_dir(self) -> str: + """ + Returns the directory used for sockfiles by this machine. + """ + if self._sock_dir: + return self._sock_dir + return self.temp_dir + @property def log_dir(self) -> str: """ --=20 2.31.1 From nobody Fri Apr 26 16:52:01 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 1637635202159798.7514116373535; Mon, 22 Nov 2021 18:40:02 -0800 (PST) Received: from localhost ([::1]:60968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLix-0007XG-Pv for importer@patchew.org; Mon, 22 Nov 2021 21:39:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhU-0005Bc-1D for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhQ-0006Bt-RU for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-76-wJA8zicXPiCMqPY89LecOA-1; Mon, 22 Nov 2021 21:38:21 -0500 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 DF89387D541; Tue, 23 Nov 2021 02:38:19 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0DC45F4EA; Tue, 23 Nov 2021 02:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635104; 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=n9HQ4UN8/xFDtrauRYyNk1XCHVdLPXJcVGLwxcNfAUY=; b=YNa7fe9zDebdPZ3GsewrucuyKpWLRkh9906ma3Q0fb21Zn+DzOsuJu6z1U8qL5O+XUNDyQ qYspwEQCuJ8qPVjMTjPaO32arLPSWB4lIuwUxF71hrcx5z9tljTOfk/TkRWi/+z6k8oQIL z50sKJsl98ShG7x27EDrIxxdaNAU/aM= X-MC-Unique: wJA8zicXPiCMqPY89LecOA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 2/7] python/machine: remove _remove_monitor_sockfile property Date: Mon, 22 Nov 2021 21:38:00 -0500 Message-Id: <20211123023805.2745382-3-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635204008100003 Content-Type: text/plain; charset="utf-8" It doesn't matter if it was the user or the class itself that specified where the sockfile should be created; the fact is that if we are using a sockfile here, we created it and we can clean it up. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Message-id: 20211118204620.1897674-3-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index b1dd77b538..ea9e07805d 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -141,12 +141,10 @@ def __init__(self, =20 if monitor_address is not None: self._monitor_address =3D monitor_address - self._remove_monitor_sockfile =3D False else: self._monitor_address =3D os.path.join( self.sock_dir, f"{self._name}-monitor.sock" ) - self._remove_monitor_sockfile =3D True =20 self._console_log_path =3D console_log if self._console_log_path: @@ -315,8 +313,7 @@ def _pre_launch(self) -> None: self._remove_files.append(self._console_address) =20 if self._qmp_set: - if self._remove_monitor_sockfile: - assert isinstance(self._monitor_address, str) + if isinstance(self._monitor_address, str): self._remove_files.append(self._monitor_address) self._qmp_connection =3D QEMUMonitorProtocol( self._monitor_address, --=20 2.31.1 From nobody Fri Apr 26 16:52:01 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 1637635337708959.914081016292; Mon, 22 Nov 2021 18:42:17 -0800 (PST) Received: from localhost ([::1]:38026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLl9-0002hn-LB for importer@patchew.org; Mon, 22 Nov 2021 21:42:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhX-0005Mk-NR for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhV-0006CK-Hr for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-165-O1VovuwfMDS5MYE8ZMKzdg-1; Mon, 22 Nov 2021 21:38:25 -0500 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 E87218066F2; Tue, 23 Nov 2021 02:38:23 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1673E64188; Tue, 23 Nov 2021 02:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635108; 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=cKj7SqSJIa2GkhoRKrJZ8L8/PKfPWCYU5pIEus/Y/gg=; b=PNYknD0tMsJHoNTA5uZdgKKxMyy8LI7jDq6cgC92QzXu63jvS7IKAHywLL0q6BD15+oqYJ XwK1Q1ki447ZDI5bZwIUYCGVUgUjv27E5a7S8oTJIvTZazvqLC2H+MgkOOpsAKtfos+Eru DKLOx4gDuDUZvW3MbBaXZqqFFn9hu4I= X-MC-Unique: O1VovuwfMDS5MYE8ZMKzdg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 3/7] python/machine: add instance disambiguator to default nickname Date: Mon, 22 Nov 2021 21:38:01 -0500 Message-Id: <20211123023805.2745382-4-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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-Type: text/plain; charset="utf-8" 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.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635341697100001 If you create two instances of QEMUMachine(), they'll both create the same nickname by default -- which is not that helpful. Luckily, they'll both create unique temporary directories ... but due to user configuration, they may share logging and sockfile directories, meaning two instances can collide. The Python logging will also be quite confusing, with no differentiation between the two instances. Add an instance disambiguator (The memory address of the instance) to the default nickname to foolproof this in all cases. Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Willian Rampazzo Message-id: 20211118204620.1897674-4-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index ea9e07805d..ad529fd92a 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -133,7 +133,7 @@ def __init__(self, self._wrapper =3D wrapper self._qmp_timer =3D qmp_timer =20 - self._name =3D name or "qemu-%d" % os.getpid() + self._name =3D name or f"qemu-{os.getpid()}-{id(self):02x}" self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir self._sock_dir =3D sock_dir --=20 2.31.1 From nobody Fri Apr 26 16:52:01 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 1637635392732483.8677591442155; Mon, 22 Nov 2021 18:43:12 -0800 (PST) Received: from localhost ([::1]:40156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLm2-00048K-QJ for importer@patchew.org; Mon, 22 Nov 2021 21:43:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhl-00061K-Em for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhh-0006D3-0D for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-dZrzCmnrNSuJqpWIs7EjwQ-1; Mon, 22 Nov 2021 21:38:37 -0500 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 0AA3718414A1; Tue, 23 Nov 2021 02:38:36 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2094A56A8B; Tue, 23 Nov 2021 02:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635120; 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=0MPTfkSUtJ8e06jEWH63eHWQq8DnMH8hhJMrCrPhXSk=; b=VOB3PUrFw8WXZ1rUr2BhDAOEhGP61HoI25Q8OS52WcWNRxJQRZDW8ufRUz/neU6hK+JzSM hY0fHR/ucVEvr7ESnKaggISIg2mzV/S2ped8cbMjSdL1jUf6PrZV8Mi6ei3BmYSN4qDOkH nkf6GFNRppTfe9Q2oVl3owAOtfh0OvU= X-MC-Unique: dZrzCmnrNSuJqpWIs7EjwQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 4/7] python/machine: move more variable initializations to _pre_launch Date: Mon, 22 Nov 2021 21:38:02 -0500 Message-Id: <20211123023805.2745382-5-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635393547100001 Content-Type: text/plain; charset="utf-8" No need to clear them only to set them later. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Message-id: 20211118204620.1897674-5-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index ad529fd92a..f92e73de40 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -327,6 +327,14 @@ def _pre_launch(self) -> None: self._qemu_log_path =3D os.path.join(self.log_dir, self._name + ".= log") self._qemu_log_file =3D open(self._qemu_log_path, 'wb') =20 + self._iolog =3D None + self._qemu_full_args =3D tuple(chain( + self._wrapper, + [self._binary], + self._base_args, + self._args + )) + def _post_launch(self) -> None: if self._qmp_connection: self._qmp.accept(self._qmp_timer) @@ -390,8 +398,6 @@ def launch(self) -> None: if self._launched: raise QEMUMachineError('VM already launched') =20 - self._iolog =3D None - self._qemu_full_args =3D () try: self._launch() self._launched =3D True @@ -410,12 +416,6 @@ def _launch(self) -> None: Launch the VM and establish a QMP connection """ self._pre_launch() - self._qemu_full_args =3D tuple( - chain(self._wrapper, - [self._binary], - self._base_args, - self._args) - ) LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args)) =20 # Cleaning up of this subprocess is guaranteed by _do_shutdown. --=20 2.31.1 From nobody Fri Apr 26 16:52:01 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 163763556732982.91888639515037; Mon, 22 Nov 2021 18:46:07 -0800 (PST) Received: from localhost ([::1]:44420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLor-00072l-6u for importer@patchew.org; Mon, 22 Nov 2021 21:46:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLht-0006Sx-KG for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43178) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhj-0006DJ-2s for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-415-qH0rI7tlNbuafsqrPBbj3A-1; Mon, 22 Nov 2021 21:38:39 -0500 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 1AB1087D542; Tue, 23 Nov 2021 02:38:38 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3772C64188; Tue, 23 Nov 2021 02:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635122; 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=u46cL6e7L4YqdxgdOmmzu7aT6PMqDkckNqgMiPnO73I=; b=g5jMn2h73aonPCTi3dwtkQGD8oURx94GQplcs5+0ENW9hM7l4KK1+dYy70gjSvXm5ZmhYw uGFvdkQRPrK7vwNuQqoy2yKubjmSDEpow7ircAgT+UJNq+ceDg9gcuH+xvThLf46mlMRjI 1Faf3hIzVUlEMNurtkvsvhCc1rwlmRI= X-MC-Unique: qH0rI7tlNbuafsqrPBbj3A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 5/7] python/machine: handle "fast" QEMU terminations Date: Mon, 22 Nov 2021 21:38:03 -0500 Message-Id: <20211123023805.2745382-6-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635569050100001 Content-Type: text/plain; charset="utf-8" In the case that the QEMU process actually launches -- but then dies so quickly that we can't establish a QMP connection to it -- QEMUMachine currently calls _post_shutdown() assuming that it never launched the VM process. This isn't true, though: it "merely" may have failed to establish a QMP connection and the process is in the middle of its own exit path. If we don't wait for the subprocess, the caller may get a bogus `None` return for .exitcode(). This behavior was observed from device-crash-test; after the switch to Async QMP, the timings were changed such that it was now seemingly possible to witness the failure of "vm.launch()" *prior* to the exitcode becoming available. The semantic of the `_launched` property is changed in this patch. Instead of representing the condition "launch() executed successfully", it will now represent "has forked a child process successfully". This way, wait() when called in the exit path won't become a no-op. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Message-id: 20211118204620.1897674-6-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index f92e73de40..67ab06ca2b 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -349,9 +349,6 @@ def _post_shutdown(self) -> None: Called to cleanup the VM instance after the process has exited. May also be called after a failed launch. """ - # Comprehensive reset for the failed launch case: - self._early_cleanup() - try: self._close_qmp_connection() except Exception as err: # pylint: disable=3Dbroad-except @@ -400,9 +397,16 @@ def launch(self) -> None: =20 try: self._launch() - self._launched =3D True except: - self._post_shutdown() + # We may have launched the process but it may + # have exited before we could connect via QMP. + # Assume the VM didn't launch or is exiting. + # If we don't wait for the process, exitcode() may still be + # 'None' by the time control is ceded back to the caller. + if self._launched: + self.wait() + else: + self._post_shutdown() =20 LOG.debug('Error launching VM') if self._qemu_full_args: @@ -426,6 +430,7 @@ def _launch(self) -> None: stderr=3Dsubprocess.STDOUT, shell=3DFalse, close_fds=3DFalse) + self._launched =3D True self._post_launch() =20 def _close_qmp_connection(self) -> None: @@ -457,8 +462,8 @@ def _early_cleanup(self) -> None: """ Perform any cleanup that needs to happen before the VM exits. =20 - May be invoked by both soft and hard shutdown in failover scenario= s. - Called additionally by _post_shutdown for comprehensive cleanup. + This method may be called twice upon shutdown, once each by soft + and hard shutdown in failover scenarios. """ # If we keep the console socket open, we may deadlock waiting # for QEMU to exit, while QEMU is waiting for the socket to --=20 2.31.1 From nobody Fri Apr 26 16:52:01 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 1637635470212506.9221005694044; Mon, 22 Nov 2021 18:44:30 -0800 (PST) Received: from localhost ([::1]:42278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLnI-0005ZX-BH for importer@patchew.org; Mon, 22 Nov 2021 21:44:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhm-00064t-LG for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhl-0006Dm-4x for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-qmcuTuPbPca-cOUl1_ujOw-1; Mon, 22 Nov 2021 21:38:41 -0500 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 19337425C8; Tue, 23 Nov 2021 02:38:40 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46B3756A8B; Tue, 23 Nov 2021 02:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635124; 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=8+GTZSvctCBccGSoZcytnr/ai9XcAGGv85l+9WkFHIw=; b=N2Q3t46JGwjII/wUwL5lQEnV/VtJPCB3s2Rap8lPimjoPivDsYdLWwQ/JM8+tPmi8lj42O GhnzF3ebmjOnpOunZHFIrOlutQP4StglsL3ychNiqpZP7VRiHjYyBBPh0tzvq2YArcInAg MfUF0gjQWuDXS4QZWhWBlG+n+E7oAF0= X-MC-Unique: qmcuTuPbPca-cOUl1_ujOw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 6/7] scripts/device-crash-test: Use a QMP timeout Date: Mon, 22 Nov 2021 21:38:04 -0500 Message-Id: <20211123023805.2745382-7-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635472355100001 Content-Type: text/plain; charset="utf-8" Despite all the previous fixes, it's still possible for device-crash-test to wedge itself in the case that QEMU terminates *so quickly* that it doesn't even begin a connection attempt to our QMP client. Python will just joyfully wait ad infinitum for a connection that will now never arrive. The real fix is to use asyncio to simultaneously poll both the health of the launched process AND the connection attempt. That's quite a bit more invasive than just setting a connection timeout, though. Do the very simplest thing for now. Signed-off-by: John Snow Message-id: 20211118204620.1897674-7-jsnow@redhat.com Signed-off-by: John Snow --- scripts/device-crash-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/device-crash-test b/scripts/device-crash-test index 1c73dac93e..7fbd99158b 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -353,7 +353,7 @@ def checkOneCase(args, testcase): '-device', qemuOptsEscape(device)] cmdline =3D ' '.join([binary] + args) dbg("will launch QEMU: %s", cmdline) - vm =3D QEMUMachine(binary=3Dbinary, args=3Dargs) + vm =3D QEMUMachine(binary=3Dbinary, args=3Dargs, qmp_timer=3D15) =20 exc =3D None exc_traceback =3D None --=20 2.31.1 From nobody Fri Apr 26 16:52:01 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 1637635636568803.3036526327434; Mon, 22 Nov 2021 18:47:16 -0800 (PST) Received: from localhost ([::1]:46654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpLpy-0000C3-Bl for importer@patchew.org; Mon, 22 Nov 2021 21:47:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhw-0006en-J8 for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpLhu-0006Ec-3w for qemu-devel@nongnu.org; Mon, 22 Nov 2021 21:38:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-AIOv-_-JPLS1X6lffIwMyA-1; Mon, 22 Nov 2021 21:38:43 -0500 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 25A891023F4D; Tue, 23 Nov 2021 02:38:42 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.32.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C5A64188; Tue, 23 Nov 2021 02:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637635133; 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=BmKhJlmTMFOh8oz4coCKQMEtDBnyVKL9nKTyCeC2BEA=; b=WybkWMOOAWrU0X2y05GLZbN1PXjsotMPJw5+JHuf27Om1XPTVPctcr069Y6+TbUwYIx7ev bz54KAoOGV4KabzmaQ/zVt5TXLToNweFL72t0vLj+psH7b1yQ6dMDYQC/L+FQ3fUzYfHXI h/AMyHN7j4CEz+iCUVUrxhS3jnNQHsw= X-MC-Unique: AIOv-_-JPLS1X6lffIwMyA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PULL 7/7] python/aqmp: fix send_fd_scm for python 3.6.x Date: Mon, 22 Nov 2021 21:38:05 -0500 Message-Id: <20211123023805.2745382-8-jsnow@redhat.com> In-Reply-To: <20211123023805.2745382-1-jsnow@redhat.com> References: <20211123023805.2745382-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.129.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.709, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , Vladimir Sementsov-Ogievskiy , Daniel Berrange , Eduardo Habkost , qemu-block@nongnu.org, John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Markus Armbruster , Willian Rampazzo , Hanna Reitz , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= 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: 1637635638045100001 Content-Type: text/plain; charset="utf-8" 3.6 doesn't play keepaway with the socket object, so we don't need to go fishing for it on this version. In fact, so long as 'sendmsg' is still available, it's probably preferable to just use that method and only go fishing for forbidden details when we absolutely have to. Reported-by: Thomas Huth Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Message-id: 20211118204620.1897674-8-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/qmp_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/qemu/aqmp/qmp_client.py b/python/qemu/aqmp/qmp_client.py index f987da02eb..8105e29fa8 100644 --- a/python/qemu/aqmp/qmp_client.py +++ b/python/qemu/aqmp/qmp_client.py @@ -639,9 +639,12 @@ def send_fd_scm(self, fd: int) -> None: if sock.family !=3D socket.AF_UNIX: raise AQMPError("Sending file descriptors requires a UNIX sock= et.") =20 - # 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 + if not hasattr(sock, 'sendmsg'): + # We need to void the warranty sticker. + # Access to sendmsg is scheduled for removal in Python 3.11. + # Find the real backing socket to use it anyway. + 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