All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Delevoryas <peter@pjd.dev>
Cc: Peter Delevoryas <peter@pjd.dev>, John Snow <jsnow@redhat.com>,
	Cleber Rosa <crosa@redhat.com>, Beraldo Leal <bleal@redhat.com>,
	qemu-devel@nongnu.org
Subject: [PATCH RESEND] python/machine: Fix AF_UNIX path too long on macOS
Date: Tue,  5 Jul 2022 14:46:59 -0700	[thread overview]
Message-ID: <20220705214659.73369-1-peter@pjd.dev> (raw)

I noticed that I can't run any avocado tests on macOS because the QMP
unix socket path is too long:

$ ./configure --target-list=arm-softmmu
$ make
$ make check-avocado AVOCADO_TESTS=tests/avocado/boot_linux_console.py
changing dir to build for /Library/Developer/CommandLineTools/usr/bin/make "check-avocado"...
  GIT     ui/keycodemapdb meson tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 dtc slirp
  AVOCADO tests/avocado
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_virt
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_emcraft_sf2
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_emcraft_sf2
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_exynos4210_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_exynos4210_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_cubieboard_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_cubieboard_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_cubieboard_sata
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_cubieboard_sata
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_quanta_gsj
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_quanta_gsj_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_quanta_gsj_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_quanta_gsj_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_initrd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_sd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_sd
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9
Fetching asset from tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_ast2600_debian
JOB ID     : 84bd26125345c6f12c92d118e98acde6aacfea57
JOB LOG    : /Users/pdel/qemu/build/tests/results/job-2022-07-02T11.24-84bd261/job.log
 (01/16) tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_virt: ERROR: ConnectError: Failed to establish connection: AF_UNIX path too lo
ng\n    Command: \n     Output: None\n (0.11 s)
Interrupting job (failfast).
RESULTS    : PASS 0 | ERROR 1 | FAIL 0 | SKIP 15 | WARN 0 | INTERRUPT 0 | CANCEL 0

The job log shows a backtrace that points to the QMP monitor's unix socket path:

2022-07-02 11:24:05,906 protocol         L0554 DEBUG| Awaiting connection on /var/folders/d7/rz20f6hd709c1ty8f6_6y_z40000gn/T/avo_qemu_sock_uh3w_dgc/qemu-37331-10bacf110-monitor.sock ...
2022-07-02 11:24:05,907 protocol         L0426 ERROR| Failed to establish connection: OSError: AF_UNIX path too long

I think the path limit for unix sockets on macOS might be 104 [1]

/*
 * [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) */
};

The path we're using is exactly 105 characters:

$ python
Python 2.7.10 (default, Jan 19 2016, 22:24:01)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> len('/var/folders/d7/rz20f6hd709c1ty8f6_6y_z40000gn/T/avo_qemu_sock_uh3w_dgc/qemu-37331-10bacf110-monitor.sock')
105

In this change I removed some of the unnecessary elements of the path, to keep
us under the limit. This seemed like the simplest thing to do, and I imagine
the extra human-readable elements were just added to make it easier to identify
left-over sockets or something else related to debugging.

[1]: /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/sys/un.h

Signed-off-by: Peter Delevoryas <peter@pjd.dev>
---
 python/qemu/machine/machine.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index 37191f433b..93451774e3 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -157,7 +157,7 @@ def __init__(self,
         self._wrapper = wrapper
         self._qmp_timer = qmp_timer
 
-        self._name = name or f"qemu-{os.getpid()}-{id(self):02x}"
+        self._name = name or f"{os.getpid()}{id(self):02x}"
         self._temp_dir: Optional[str] = None
         self._base_temp_dir = base_temp_dir
         self._sock_dir = sock_dir
@@ -167,7 +167,7 @@ def __init__(self,
             self._monitor_address = monitor_address
         else:
             self._monitor_address = os.path.join(
-                self.sock_dir, f"{self._name}-monitor.sock"
+                self.sock_dir, f"{self._name}.sock"
             )
 
         self._console_log_path = console_log
-- 
2.37.0



             reply	other threads:[~2022-07-05 21:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 21:46 Peter Delevoryas [this message]
2022-07-06  8:02 ` [PATCH RESEND] python/machine: Fix AF_UNIX path too long on macOS Daniel P. Berrangé
2022-07-06 16:46   ` Peter Delevoryas
2022-07-07  0:52     ` Peter Delevoryas
2022-07-07 18:46       ` Peter Delevoryas
2022-07-11 20:56         ` John Snow
2022-07-12  1:46           ` Peter Delevoryas
2022-07-12 15:14             ` John Snow
2022-07-12  8:16           ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220705214659.73369-1-peter@pjd.dev \
    --to=peter@pjd.dev \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.