From nobody Sat May 18 14:01:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658514385293901.9361672020314; Fri, 22 Jul 2022 11:26:25 -0700 (PDT) Received: from localhost ([::1]:51086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oExM0-0001xl-4x for importer@patchew.org; Fri, 22 Jul 2022 14:26:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oExKv-0000UF-P3 for qemu-devel@nongnu.org; Fri, 22 Jul 2022 14:25:17 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:44903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oExKt-0006Wj-TM for qemu-devel@nongnu.org; Fri, 22 Jul 2022 14:25:17 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 296B3580AF1; Fri, 22 Jul 2022 14:25:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 22 Jul 2022 14:25:15 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Jul 2022 14:25:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pjd.dev; h=cc:cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1658514315; x= 1658517915; bh=xjF3QlZZ8BhEp4tGWMNpXzqIf4D6XHDAwU26nTh6Dqc=; b=i nDw6MXJdQtCWNR5VpYRcKMnFdI3KZCrtN0f6NSlTWu7F4LidGAUkv8VqxhVAWC66 sDLOZafYSZnbZ1NZGtvdnD9jCqFqjMFgsZ7RYStbG03oDM19+9gQ+ZEId/rIUGOs VKyN66AhYub1fyhZlcTlvmF8k2dmqFU6bcFVJI8h0h4W9UTaKzsTOiU+1JBGUO19 Qo6MjCSNp3C/caRgFta9q/spzS6ytLZDGXK/wO5ELb/9TsqJzAlZhpG+V2owA0Zz 6z9GAagtsl+Z7VcVL6VI++Krtw1/cGx+zH+HNt1jhl0OZb8AW4sYZRmcPZZXBC3+ 5s/y0LFWXaupYGJdA+qKA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1658514315; x= 1658517915; bh=xjF3QlZZ8BhEp4tGWMNpXzqIf4D6XHDAwU26nTh6Dqc=; b=s btmCM5JKZIXQlNaqekngIfRjsEVYJUED4wKZS93/0tJSEdX764hf6zAt95dpL/po eyP1sIwkzJ0af3x80/YYlvuWvap5tVaQ9eXJTqJCvEZwIJ73FfuepjDfkHz8jhs7 wBCJQM8zb195g+v5KYLR1J+TYmwOSdu04dA4Repr+msGmr2sLiXasB0Z3nheyrtw xjGJG0SaLr1x7L9zsUhhRhnY96Bv2j3BPOqhgbixbdBro84WnvbVy9/cT3dyjWlD NsxNSA0kqsIIHQgwPVCdM/eGsZKPZn+xRaBxwTVhD2SboECaw296nzOdtwAeuBut 6tXDpSQeiyxBmqA7/pxCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddtvddguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecumhhishhsihhnghcuvffquchfihgvlhguucdlfe dtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhep rfgvthgvrhcuffgvlhgvvhhorhihrghsuceophgvthgvrhesphhjugdruggvvheqnecugg ftrfgrthhtvghrnhepvedtveffkeevuedthffgfeekvefffeduvdehiefhjeehuefhveeu leduteejjeetnecuffhomhgrihhnpehsthgrtghkvgigtghhrghnghgvrdgtohhmnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhes phhjugdruggvvh X-ME-Proxy: Feedback-ID: i9e814621:Fastmail From: Peter Delevoryas To: Cc: jsnow@redhat.com, crosa@redhat.com, bleal@redhat.com, f4bug@amsat.org, wainersm@redhat.com, qemu-devel@nongnu.org, berrange@redhat.com, peter@pjd.dev Subject: [PATCH v3 1/1] python/machine: Fix AF_UNIX path too long on macOS Date: Fri, 22 Jul 2022 11:25:08 -0700 Message-Id: <20220722182508.89761-2-peter@pjd.dev> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220722182508.89761-1-peter@pjd.dev> References: <20220722182508.89761-1-peter@pjd.dev> MIME-Version: 1.0 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=66.111.4.224; envelope-from=peter@pjd.dev; helo=new2-smtp.messagingengine.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_FMBLA_NEWDOM28=0.798, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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" X-ZM-MESSAGEID: 1658514387300100001 On macOS, private $TMPDIR's are the default. These $TMPDIR's are generated from a user's unix UID and UUID [1], which can create a relatively long path: /var/folders/d7/rz20f6hd709c1ty8f6_6y_z40000gn/T/ QEMU's avocado tests create a temporary directory prefixed by "avo_qemu_sock_", and create QMP sockets within _that_ as well. The QMP socket is unnecessarily long, because a temporary directory is created for every QEMUMachine object. /avo_qemu_sock_uh3w_dgc/qemu-37331-10bacf110-monitor.sock The path limit for unix sockets on macOS is 104: [2] /* * [XSI] Definitions for UNIX IPC domain. */ struct sockaddr_un { unsigned char sun_len; /* sockaddr len including null */ sa_family_t sun_family; /* [XSI] AF_UNIX */ char sun_path[104]; /* [XSI] path name (gag) */ }; This results in avocado tests failing on macOS because the QMP unix socket can't be created, because the path is too long: ERROR| Failed to establish connection: OSError: AF_UNIX path too long This change resolves by reducing the size of the socket directory prefix and the suffix on the QMP and console socket names. The result is paths like this: pdel@pdel-mbp:/var/folders/d7/rz20f6hd709c1ty8f6_6y_z40000gn/T $ tree qemu* qemu_df4evjeq qemu_jbxel3gy qemu_ml9s_gg7 qemu_oc7h7f3u qemu_oqb1yf97 =E2=94=9C=E2=94=80=E2=94=80 10a004050.con =E2=94=94=E2=94=80=E2=94=80 10a004050.qmp [1] https://apple.stackexchange.com/questions/353832/why-is-mac-osx-temp-di= rectory-in-weird-path [2] /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/sys= /un.h Signed-off-by: Peter Delevoryas Reviewed-by: Daniel P. Berrang=C3=A9 --- python/qemu/machine/machine.py | 6 +++--- tests/avocado/avocado_qemu/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 37191f433b..5df210c810 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -157,7 +157,7 @@ def __init__(self, self._wrapper =3D wrapper self._qmp_timer =3D qmp_timer =20 - self._name =3D name or f"qemu-{os.getpid()}-{id(self):02x}" + self._name =3D name or f"{id(self):x}" self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir self._sock_dir =3D sock_dir @@ -167,7 +167,7 @@ def __init__(self, self._monitor_address =3D monitor_address else: self._monitor_address =3D os.path.join( - self.sock_dir, f"{self._name}-monitor.sock" + self.sock_dir, f"{self._name}.qmp" ) =20 self._console_log_path =3D console_log @@ -192,7 +192,7 @@ def __init__(self, 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}.con" ) self._console_socket: Optional[socket.socket] =3D None self._remove_files: List[str] =3D [] diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado= _qemu/__init__.py index ed4853c805..43b8c8848c 100644 --- a/tests/avocado/avocado_qemu/__init__.py +++ b/tests/avocado/avocado_qemu/__init__.py @@ -296,7 +296,7 @@ def require_accelerator(self, accelerator): "available" % accelerator) =20 def _new_vm(self, name, *args): - self._sd =3D tempfile.TemporaryDirectory(prefix=3D"avo_qemu_sock_") + self._sd =3D tempfile.TemporaryDirectory(prefix=3D"qemu_") vm =3D QEMUMachine(self.qemu_bin, base_temp_dir=3Dself.workdir, sock_dir=3Dself._sd.name, log_dir=3Dself.logdir) self.log.debug('QEMUMachine "%s" created', name) --=20 2.37.0