From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689858338; cv=none; d=zohomail.com; s=zohoarc; b=lf5Y2ciEJaaVclaz6co/qLBFEuLAWm/rt57JNFWI7npqdZp/d/xB7cP3i8/mvcxjiumQhz1pC6vpBraLYzPSzgtNcMJ0q+5kxoZTcHHcVVlT8bGOVUbwQKBwOj8JRx7n9A1yYNNvncHonRjY9nLvTccv5ObwseiryqJFR1kZ/VE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689858338; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZQEjaImajQCAJb63at6vX9mIrvur84gIvRAOOVxPJco=; b=RepY7x6Dz6JJbVgstK5Rm4CS8Hha2EtUXlgHVw3ce3FqQ5VONOOJ3tQ7sXAYxvVcNIH1HoMXNvs78tynfkk0j2tnkTAIyiVa4dDe52fLoRiNENsPUPvNf/zFD69e1YrxjUW4PzfG2OQlZepWVgRHmQM+RwarVOoj/twu3aKcwoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689858338606876.7170829575346; Thu, 20 Jul 2023 06:05:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMTL8-0005nk-51; Thu, 20 Jul 2023 09:05:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTL0-0005lZ-S5 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTKz-00063y-0J for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:58 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-1WmH2b7POdOhvlR-QqiogQ-1; Thu, 20 Jul 2023 09:04:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B71F1C04B5F; Thu, 20 Jul 2023 13:04:49 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.18.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38E661121314; Thu, 20 Jul 2023 13:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689858292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZQEjaImajQCAJb63at6vX9mIrvur84gIvRAOOVxPJco=; b=ORtArClBKTY/oQ1tuJmwME2fThFZ79GuJc3fLIDRdEqW06xVgzn+IIeirTr7vZfMYkdPao alglFMrwc4FcY3k3GB4xZv4iy2iz9KnrgVHBAokEJqerhoRcB3i9V1KX9kRGt/O6aeIKzi YqEmk2F4KNJk9EdUpDKeEHL/kZatUnU= X-MC-Unique: 1WmH2b7POdOhvlR-QqiogQ-1 From: John Snow To: qemu-devel@nongnu.org Cc: John Snow , qemu-block@nongnu.org, Beraldo Leal , Hanna Reitz , Kevin Wolf , Peter Maydell , Daniel Berrange , Cleber Rosa Subject: [PATCH 1/4] python/machine: move socket setup out of _base_args property Date: Thu, 20 Jul 2023 09:04:45 -0400 Message-ID: <20230720130448.921356-2-jsnow@redhat.com> In-Reply-To: <20230720130448.921356-1-jsnow@redhat.com> References: <20230720130448.921356-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689858351471100001 Content-Type: text/plain; charset="utf-8" This property isn't meant to do much else besides return a list of strings, so move this setup back out into _pre_launch(). Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- python/qemu/machine/machine.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index c16a0b6fed..8be0f684fe 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -300,9 +300,7 @@ def _base_args(self) -> List[str]: =20 if self._qmp_set: if self._sock_pair: - fd =3D self._sock_pair[0].fileno() - os.set_inheritable(fd, True) - moncdev =3D f"socket,id=3Dmon,fd=3D{fd}" + moncdev =3D f"socket,id=3Dmon,fd=3D{self._sock_pair[0].fil= eno()}" elif isinstance(self._monitor_address, tuple): moncdev =3D "socket,id=3Dmon,host=3D{},port=3D{}".format( *self._monitor_address @@ -339,6 +337,7 @@ def _pre_launch(self) -> None: if self._qmp_set: if self._monitor_address is None: self._sock_pair =3D socket.socketpair() + os.set_inheritable(self._sock_pair[0].fileno(), True) sock =3D self._sock_pair[1] if isinstance(self._monitor_address, str): self._remove_files.append(self._monitor_address) --=20 2.41.0 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689858334; cv=none; d=zohomail.com; s=zohoarc; b=FCX4ITWIoT1DwoxY8ZRapwvRDYq3UlvZ2xQ6WP1UHKScP4yVWpGxyQtdGv9hheyC7Z6nHK04hcUDROR79JEsnMqErArQas3MnotGBv7I0sLBOr9KIjLOJG2fXAZjnFF7LmqP6uWXWzFvzV4Zqwnupf9oC31WWGAJRCZE/Zip+Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689858334; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qazoxsrJ4HHHfE3vWiM+JSDOo35GlxAWRvEti0riv3w=; b=ONjYvdQq4k/gc1/uHXMb8NURjNwPbKaXEJXnnOcMuJwlxKKz4El6tqDv6hsR5azBLgJIoR3KooqReVB7SpfrLE0ulwZHrhpH6OsVyIx5Y3oJYSPR53GLQEIo0nNwjD67jCxng/xYBxJJtED1FngPaxZ+LY1LW2i2+hgPlgufPQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168985833407626.67867399398733; Thu, 20 Jul 2023 06:05:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMTL4-0005mb-9E; Thu, 20 Jul 2023 09:05:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTKz-0005l8-IH for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTKw-00064A-Hz for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:57 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-sZpHHWxGM3-2WjRCSwtJwg-1; Thu, 20 Jul 2023 09:04:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F31BC29A9D47; Thu, 20 Jul 2023 13:04:49 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.18.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A60E1121315; Thu, 20 Jul 2023 13:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689858293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qazoxsrJ4HHHfE3vWiM+JSDOo35GlxAWRvEti0riv3w=; b=Ouww1Qk+4wPPEC3NG7VOZz1Q4+4RWi14/SeG78aVwGhJEQ6AfTRl2cLH3Np/aRTfQ8lptw UgesCXqzwgSxPrK4k191DKYLUVZnoEiGfBa0fHQtP/7hm8md+eJ1gZFe7TqCtqeIqNMOC0 /ubfLRw4u63gO7g1VylP4icpy4vnSb0= X-MC-Unique: sZpHHWxGM3-2WjRCSwtJwg-1 From: John Snow To: qemu-devel@nongnu.org Cc: John Snow , qemu-block@nongnu.org, Beraldo Leal , Hanna Reitz , Kevin Wolf , Peter Maydell , Daniel Berrange , Cleber Rosa Subject: [PATCH 2/4] python/console_socket: accept existing FD in initializer Date: Thu, 20 Jul 2023 09:04:46 -0400 Message-ID: <20230720130448.921356-3-jsnow@redhat.com> In-Reply-To: <20230720130448.921356-1-jsnow@redhat.com> References: <20230720130448.921356-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689858353007100003 Content-Type: text/plain; charset="utf-8" Useful if we want to use ConsoleSocket() for a socket created by socketpair(). Signed-off-by: John Snow --- python/qemu/machine/console_socket.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/qemu/machine/console_socket.py b/python/qemu/machine/co= nsole_socket.py index 4e28ba9bb2..42bfa12411 100644 --- a/python/qemu/machine/console_socket.py +++ b/python/qemu/machine/console_socket.py @@ -17,7 +17,7 @@ import socket import threading import time -from typing import Deque, Optional +from typing import Deque, Optional, Union =20 =20 class ConsoleSocket(socket.socket): @@ -30,13 +30,16 @@ class ConsoleSocket(socket.socket): Optionally a file path can be passed in and we will also dump the characters to this file for debugging purposes. """ - def __init__(self, address: str, file: Optional[str] =3D None, + def __init__(self, address: Union[str, int], file: Optional[str] =3D N= one, drain: bool =3D False): self._recv_timeout_sec =3D 300.0 self._sleep_time =3D 0.5 self._buffer: Deque[int] =3D deque() - socket.socket.__init__(self, socket.AF_UNIX, socket.SOCK_STREAM) - self.connect(address) + if isinstance(address, str): + socket.socket.__init__(self, socket.AF_UNIX, socket.SOCK_STREA= M) + self.connect(address) + else: + socket.socket.__init__(self, fileno=3Daddress) self._logfile =3D None if file: # pylint: disable=3Dconsider-using-with --=20 2.41.0 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689858334; cv=none; d=zohomail.com; s=zohoarc; b=XEE4j0cavHmew9wqeRevRsLNg21X4EVaMg8S7f0LIJGogLYPDyKsypDSGsG27W2v39PXtFPcbsKXPnJF64Fk264hGJ+9oFKBTiUTZXboA5FBwJSLvs4aPo413chGpkaTD16iDlqlaSh/Z2U6dCWWQcmb2x25zSYuwhLykDrV384= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689858334; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eMDGWhbtdYVP19O+g8+ImRur8UaDvtwh6fE5Y6B2SMw=; b=hsKD9ybkC5Zi/pKcDLbID8zGVkRFuZ8aE232hUKsNl8AK69FaIa9keLb2NvigUaHA9ukBMRSNqeYMDQLJVun6i5EWvdb29y9CiyCdKOPLxAwoYH2G/+9LGX6Rv6JFQ90LztevJLVhFRt6El01AcfY09+0XmrkS/v5yV7WWqBg+4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689858333771416.3332345781922; Thu, 20 Jul 2023 06:05:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMTLA-0005o4-Qj; Thu, 20 Jul 2023 09:05:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTKz-0005l7-EI for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTKw-000645-If for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613--ZPqpr-hO9ixpWCNZjk5QA-1; Thu, 20 Jul 2023 09:04:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60E04936D3F; Thu, 20 Jul 2023 13:04:50 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.18.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AB351121314; Thu, 20 Jul 2023 13:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689858293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eMDGWhbtdYVP19O+g8+ImRur8UaDvtwh6fE5Y6B2SMw=; b=Z3xDWUSLqIS9q3R/mk0bH2gUr9lu1T9GyWwUC2ZbrQq/l8QNaWcFBJEYlVKhrMa8MVlF01 EMnvCbgx9u3SWYUhkKe2H7zD5pnGyqnhmTV8y2jyYUedPrdSnGf+awVgDnMGWwFKY+Bo44 AegJosfyQJPsku8EtI0Zba027GNHnM4= X-MC-Unique: -ZPqpr-hO9ixpWCNZjk5QA-1 From: John Snow To: qemu-devel@nongnu.org Cc: John Snow , qemu-block@nongnu.org, Beraldo Leal , Hanna Reitz , Kevin Wolf , Peter Maydell , Daniel Berrange , Cleber Rosa Subject: [PATCH 3/4] python/machine: use socketpair() for console connections Date: Thu, 20 Jul 2023 09:04:47 -0400 Message-ID: <20230720130448.921356-4-jsnow@redhat.com> In-Reply-To: <20230720130448.921356-1-jsnow@redhat.com> References: <20230720130448.921356-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689858345407100001 Content-Type: text/plain; charset="utf-8" Create a socketpair for the console output. This should help eliminate race conditions around console text early in the boot process that might otherwise have been dropped on the floor before being able to connect to QEMU under "server,nowait". Signed-off-by: John Snow Reviewed-by: Daniel P. Berrang=C3=A9 --- python/qemu/machine/machine.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 8be0f684fe..ef9b2dc02e 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -159,6 +159,8 @@ def __init__(self, =20 self._name =3D name or f"{id(self):x}" self._sock_pair: Optional[Tuple[socket.socket, socket.socket]] =3D= None + self._cons_sock_pair: Optional[ + Tuple[socket.socket, socket.socket]] =3D None self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir self._sock_dir =3D sock_dir @@ -315,8 +317,9 @@ def _base_args(self) -> List[str]: for _ in range(self._console_index): args.extend(['-serial', 'null']) if self._console_set: - chardev =3D ('socket,id=3Dconsole,path=3D%s,server=3Don,wait= =3Doff' % - self._console_address) + assert self._cons_sock_pair is not None + fd =3D self._cons_sock_pair[0].fileno() + chardev =3D f"socket,id=3Dconsole,fd=3D{fd}" args.extend(['-chardev', chardev]) if self._console_device_type is None: args.extend(['-serial', 'chardev:console']) @@ -351,6 +354,10 @@ def _pre_launch(self) -> None: nickname=3Dself._name ) =20 + if self._console_set: + self._cons_sock_pair =3D socket.socketpair() + os.set_inheritable(self._cons_sock_pair[0].fileno(), True) + # NOTE: Make sure any opened resources are *definitely* freed in # _post_shutdown()! # pylint: disable=3Dconsider-using-with @@ -873,8 +880,12 @@ def console_socket(self) -> socket.socket: Returns a socket connected to the console """ if self._console_socket is None: + if not self._console_set: + raise QEMUMachineError( + "Attempt to access console socket with no connection") + assert self._cons_sock_pair is not None self._console_socket =3D console_socket.ConsoleSocket( - self._console_address, + self._cons_sock_pair[1].fileno(), file=3Dself._console_log_path, drain=3Dself._drain_console) return self._console_socket --=20 2.41.0 From nobody Fri May 17 11:58:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1689858349; cv=none; d=zohomail.com; s=zohoarc; b=gzMOs8m5Z48/nmT8YlIEvW9iB+g9SAL1LMb0ojK30PwS8sOBPZkFLeTTAu4Ht/fGcoF/OSxkhAK8S7f8JnL6rPzI8z8YqXFDmuDiuBCJ9TGdYg2JxWBz5qXo45sGIUaDzWHhINWQoIhR3XwrsXIUoXMT15CpciPVZSPTNLpk5aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689858349; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HGDdiyZFTeDU5P1FXRF8bWWCTt195umPtU7bV4rV+dA=; b=BGXuIiKqd+jL1DDLlZBc4XHgyB+ATMkWor46ptSBTtdyET9bgLVQg1wAyXLiiIiHLcv2oqt/nmEiJqeE6rPS5QxC0MUOrELQg5IPU39LLGjuehz06vWiybU8aIp8cUOdQRvF57NHhbBmyx8E/P7xV/wqqydD90NkNH+xsCJrt44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168985834912974.11542616393695; Thu, 20 Jul 2023 06:05:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMTLC-0005o6-KF; Thu, 20 Jul 2023 09:05:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTL1-0005lc-24 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTKx-00064f-It for qemu-devel@nongnu.org; Thu, 20 Jul 2023 09:04:58 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-NDOAPCJ_OKm9ADU4-QoGRg-1; Thu, 20 Jul 2023 09:04:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C2624936D2D; Thu, 20 Jul 2023 13:04:50 +0000 (UTC) Received: from scv.redhat.com (unknown [10.22.18.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E7391121314; Thu, 20 Jul 2023 13:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689858294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HGDdiyZFTeDU5P1FXRF8bWWCTt195umPtU7bV4rV+dA=; b=erEIR49AqvT8zgaOWVqnfaOinbgsbyaLB8C5n6mI/jkj/h36s6mDQLrsARqphlMpXZrV1Y WyuoH5+2GnnXgXYhquDybzhHyEGrZKVKDljBWVVT1VoiBEBMezDKk4YO5oktNBQS0rDVqL t8jyDPi0oCTJL69HPnR/X3ngdwyqCUA= X-MC-Unique: NDOAPCJ_OKm9ADU4-QoGRg-1 From: John Snow To: qemu-devel@nongnu.org Cc: John Snow , qemu-block@nongnu.org, Beraldo Leal , Hanna Reitz , Kevin Wolf , Peter Maydell , Daniel Berrange , Cleber Rosa Subject: [PATCH 4/4] python/machine: remove unused console socket configuration arguments Date: Thu, 20 Jul 2023 09:04:48 -0400 Message-ID: <20230720130448.921356-5-jsnow@redhat.com> In-Reply-To: <20230720130448.921356-1-jsnow@redhat.com> References: <20230720130448.921356-1-jsnow@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689858425664100001 Content-Type: text/plain; charset="utf-8" By using a socketpair for the console, we don't need the sock_dir argument for the base class anymore, remove it. The qtest subclass still uses the argument for the qtest socket for now. Signed-off-by: John Snow --- python/qemu/machine/machine.py | 18 ------------------ python/qemu/machine/qtest.py | 6 +++--- tests/qemu-iotests/tests/copy-before-write | 3 +-- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index ef9b2dc02e..350aa8bb26 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -127,7 +127,6 @@ def __init__(self, name: Optional[str] =3D None, base_temp_dir: str =3D "/var/tmp", monitor_address: Optional[SocketAddrT] =3D None, - sock_dir: Optional[str] =3D None, drain_console: bool =3D False, console_log: Optional[str] =3D None, log_dir: Optional[str] =3D None, @@ -141,7 +140,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 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 @param log_dir: where to create and keep log files @@ -163,7 +161,6 @@ def __init__(self, Tuple[socket.socket, socket.socket]] =3D None self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir - self._sock_dir =3D sock_dir self._log_dir =3D log_dir =20 self._monitor_address =3D monitor_address @@ -189,9 +186,6 @@ def __init__(self, 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}.con" - ) self._console_socket: Optional[socket.socket] =3D None self._remove_files: List[str] =3D [] self._user_killed =3D False @@ -334,9 +328,6 @@ def args(self) -> List[str]: return self._args =20 def _pre_launch(self) -> None: - if self._console_set: - self._remove_files.append(self._console_address) - if self._qmp_set: if self._monitor_address is None: self._sock_pair =3D socket.socketpair() @@ -900,15 +891,6 @@ 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: """ diff --git a/python/qemu/machine/qtest.py b/python/qemu/machine/qtest.py index 1c46138bd0..22f8045ef6 100644 --- a/python/qemu/machine/qtest.py +++ b/python/qemu/machine/qtest.py @@ -115,8 +115,8 @@ def __init__(self, wrapper: Sequence[str] =3D (), name: Optional[str] =3D None, base_temp_dir: str =3D "/var/tmp", - sock_dir: Optional[str] =3D None, - qmp_timer: Optional[float] =3D None): + qmp_timer: Optional[float] =3D None, + sock_dir: Optional[str] =3D None): # pylint: disable=3Dtoo-many-arguments =20 if name is None: @@ -125,7 +125,7 @@ def __init__(self, sock_dir =3D base_temp_dir super().__init__(binary, args, wrapper=3Dwrapper, name=3Dname, base_temp_dir=3Dbase_temp_dir, - sock_dir=3Dsock_dir, qmp_timer=3Dqmp_timer) + qmp_timer=3Dqmp_timer) self._qtest: Optional[QEMUQtestProtocol] =3D None self._qtest_path =3D os.path.join(sock_dir, name + "-qtest.sock") =20 diff --git a/tests/qemu-iotests/tests/copy-before-write b/tests/qemu-iotest= s/tests/copy-before-write index 2ffe092b31..d3987db942 100755 --- a/tests/qemu-iotests/tests/copy-before-write +++ b/tests/qemu-iotests/tests/copy-before-write @@ -44,8 +44,7 @@ class TestCbwError(iotests.QMPTestCase): =20 opts =3D ['-nodefaults', '-display', 'none', '-machine', 'none'] self.vm =3D QEMUMachine(iotests.qemu_prog, opts, - base_temp_dir=3Diotests.test_dir, - sock_dir=3Diotests.sock_dir) + base_temp_dir=3Diotests.test_dir) self.vm.launch() =20 def do_cbw_error(self, on_cbw_error): --=20 2.41.0