From nobody Mon Apr 29 14:13:52 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=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1650371053; cv=none; d=zohomail.com; s=zohoarc; b=ZunvCe3Pmd2/+jq+zYXZzmMjHbpuPqOQvdyODP8WhFRgaziPri96SAqqqBdVibwaZlFU8bsRnjiU4EFdnbYCWTtwoh+pMsHi0R4ips4ZdjYgobC/AYGEB42g2fyrOAFpSf8LvsOSEjERHOSOq+hSRVRj6vpWxLZYsnRNOJ8iVws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650371053; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=TICQYmVG2fGq8oMs38SR7J85rthZ4dIAGNyEZ4xB9iE=; b=PKeBu+TZwGzD0gBdX8ZxbaHzZYn8HrIGVln3aAMOUfHBempXg7QbXqabszcA1d1OcB4qmszZHJzMdT/5Of/Le+CNVCMYHA9HfzRj5ZEz0r64Oh5UkWotxTntFLZAo09cwvLeFbbjBDmHAFO1qRbJs1Q86dhsOSoHsDvP6pVN1Ng= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16503710531181018.2344190345447; Tue, 19 Apr 2022 05:24:13 -0700 (PDT) Received: from localhost ([::1]:37570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngmtw-0007Wj-6U for importer@patchew.org; Tue, 19 Apr 2022 08:24:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2a515431fdc02b0b2d3613f5d569305a32cfba30@lizzy.crudebyte.com>) id 1ngmqM-0002cn-8f; Tue, 19 Apr 2022 08:20:33 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:54949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2a515431fdc02b0b2d3613f5d569305a32cfba30@lizzy.crudebyte.com>) id 1ngmqK-0004hu-Jr; Tue, 19 Apr 2022 08:20:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=TICQYmVG2fGq8oMs38SR7J85rthZ4dIAGNyEZ4xB9iE=; b=Onh+6 PpM2JXXxqHN0Stx6CzLatDbj/92HqpWLvK25+0bZYpbM/nNprfqkP0emd7Ck+waA37jGpiIaXr3KK GMi/Ik1vusOHAa0XbfkeFwfriDWcY+SsNRo7iMy0Kgld1BpaNOxZ/JbmUr1gj4n/jmfDtBaPgRvN/ YXDlW5b0izHpPl4pbhk8HTOfLhPdHO4LcUyGviars7oVo4swC0jWqgNR/ulP/znG2IUvYSR95H8Ex Tfm9VPFIHeN2MD4ZMqtI2aR6B7Bki2FIYE4RHXH+R954DSBdrdHPttouV7oedDZiWn5v+JYD6Az8a IPftywauV543Sow2iy2wqgGg9gj2A==; Message-Id: <2a515431fdc02b0b2d3613f5d569305a32cfba30.1650370026.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 19 Apr 2022 13:40:48 +0200 Subject: [PATCH 1/5] 9pfs: fix qemu_mknodat(S_IFREG) on macOS To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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: none client-ip=91.194.90.13; envelope-from=2a515431fdc02b0b2d3613f5d569305a32cfba30@lizzy.crudebyte.com; helo=lizzy.crudebyte.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1650371055855100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mknod() on macOS does not support creating regular files, so divert to openat_file() if S_IFREG is passed with mode argument. Furthermore, 'man 2 mknodat' on Linux says: "Zero file type is equivalent to type S_IFREG". Link: https://lore.kernel.org/qemu-devel/17933734.zYzKuhC07K@silver/ Signed-off-by: Christian Schoenebeck Reviewed-by: Will Cohen --- hw/9pfs/9p-util-darwin.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index bec0253474..53e0625501 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -77,6 +77,10 @@ int fsetxattrat_nofollow(int dirfd, const char *filename= , const char *name, int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) { int preserved_errno, err; + + if (S_ISREG(mode) || !(mode & S_IFMT)) { + return openat_file(dirfd, filename, O_CREAT, mode); + } if (!pthread_fchdir_np) { error_report_once("pthread_fchdir_np() not available on this versi= on of macOS"); return -ENOTSUP; --=20 2.32.0 (Apple Git-132) From nobody Mon Apr 29 14:13:52 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=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1650371242; cv=none; d=zohomail.com; s=zohoarc; b=DV4CMW3KhAZ/7G/JN0WIfVnKR3clZesSm1oF0jCBLuoZYQtNW0eqUr7dsOY6lWgnTvDDcAPq11BCIk68DWN/KvGynLzj6TJN+UsN0j7z3ekphINQw5MjnfKn4NZEmoQ5MEhG84dkxnxBugQVCWMpgDeEwW5WbKBz0LDy14xArqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650371242; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=WQCfwkHY+6/tMntcSzJekfy666I4hevqfvOOEDczNNs=; b=U1y2N6b5zUy5I2mB/EJ0qyOaXrVNXK2lMxsY5CeGIogJ+RnUuPy1oC3s7MAAJpCJx3XchS2yfhQq/XJzXcPek8sJtfFIoG8oX84AHS2HtGN2gzVeS3x20kAyhVIBIEWRRAJ87/6TiAWSS48RPJhUqjUOykMFGULjxf8dACJh3kg= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650371242915243.35694275980245; Tue, 19 Apr 2022 05:27:22 -0700 (PDT) Received: from localhost ([::1]:48274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngmwz-00034k-Ne for importer@patchew.org; Tue, 19 Apr 2022 08:27:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2e88acab7b3f998ceff7232b5e3d6a8a6d2a6f8b@lizzy.crudebyte.com>) id 1ngmqU-0002sp-DO; Tue, 19 Apr 2022 08:20:38 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:34977) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2e88acab7b3f998ceff7232b5e3d6a8a6d2a6f8b@lizzy.crudebyte.com>) id 1ngmqS-0004if-Pt; Tue, 19 Apr 2022 08:20:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=WQCfwkHY+6/tMntcSzJekfy666I4hevqfvOOEDczNNs=; b=N1klY pnh5WXrScbpxb9SMNpPUf0ZGPjPOvLki8OZe0IuXQXp09KevdKKIDzJeM0bnxDWCOepVcm34DkBB/ +VqpLS/N1HHneyT5UQJfxetRf4XM83KVsgFzHSeSVrX8BWNfzZx8VVaUz/PRS7qpwJngRu+t1tOcj 3C2HB6MuNUD0XBGsMnckEao8rQNn0PjXQdTqrGdv7ts/QO4O0ct5oKjG/IXarr4p6fnCJ54ctQ29c DxXSVp+/x4g1K1XOAG1CB22sr29wNrh6FDeqtO/q55cPJE5bgUR0VkWJGqagKB1IDv8jqgPZCbX7Z YTNHIyWM3y2Eajk5O7gQqM6YvaL5A==; Message-Id: <2e88acab7b3f998ceff7232b5e3d6a8a6d2a6f8b.1650370026.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 19 Apr 2022 13:41:03 +0200 Subject: [PATCH 2/5] 9pfs: fix qemu_mknodat(S_IFSOCK) on macOS To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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: none client-ip=91.194.90.13; envelope-from=2e88acab7b3f998ceff7232b5e3d6a8a6d2a6f8b@lizzy.crudebyte.com; helo=lizzy.crudebyte.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1650371244207100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mknod() on macOS does not support creating sockets, so divert to call sequence socket(), bind() and chmod() respectively if S_IFSOCK was passed with mode argument. Link: https://lore.kernel.org/qemu-devel/17933734.zYzKuhC07K@silver/ Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p-util-darwin.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index 53e0625501..252a6fc5dd 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -74,6 +74,24 @@ int fsetxattrat_nofollow(int dirfd, const char *filename= , const char *name, */ #if defined CONFIG_PTHREAD_FCHDIR_NP =20 +static int create_socket_file_at_cwd(const char *filename, mode_t mode) { + int fd, err; + struct sockaddr_un addr =3D { + .sun_family =3D AF_UNIX + }; + + fd =3D socket(PF_UNIX, SOCK_DGRAM, 0); + if (fd < 0) { + return fd; + } + snprintf(addr.sun_path, sizeof(addr.sun_path), "./%s", filename); + err =3D bind(fd, (struct sockaddr *) &addr, sizeof(addr)); + if (err < 0) { + return err; + } + return chmod(addr.sun_path, mode); +} + int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) { int preserved_errno, err; @@ -88,7 +106,11 @@ int qemu_mknodat(int dirfd, const char *filename, mode_= t mode, dev_t dev) if (pthread_fchdir_np(dirfd) < 0) { return -1; } - err =3D mknod(filename, mode, dev); + if (S_ISSOCK(mode)) { + err =3D create_socket_file_at_cwd(filename, mode); + } else { + err =3D mknod(filename, mode, dev); + } preserved_errno =3D errno; /* Stop using the thread-local cwd */ pthread_fchdir_np(-1); --=20 2.32.0 (Apple Git-132) From nobody Mon Apr 29 14:13:52 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=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1650371457; cv=none; d=zohomail.com; s=zohoarc; b=YJDsqp7getR7S5F4dIXribv92zSGAbHv1nme5HM29svkiqL0Klz07ye4I8A5QnYFQ/F/MwmsXc172Q+MENlVZ/JkGbYksbdt1zSAN8Q/6B9VorDk0kJOtvvzR7KXitbMCo7EoDcPL0X3Nq0xStTbs2raMl1PRJkSCbr5pcZUPC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650371457; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=7I1gomcsbjvHa5W80FT6xNhuhvDH6UO1+WCQVHXH+oY=; b=R6xD/Stevx4YJvgKfz9NpnJLHxdsgIK/sLI4b8jiGnq9kBEFV3sRbd5s3iUSsKk+4Afe5efm4hUDkJ1GY5WbtP/9NtblJU6FuS1RWnbafIfdrnicMp9txVLhrUv4ydTSMDlbvmlHeSbJnrxRhA/SjZ0BTFDoX7cFJXx3fz+RC6A= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650371456910696.2746057709807; Tue, 19 Apr 2022 05:30:56 -0700 (PDT) Received: from localhost ([::1]:56650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngn0R-0006z4-HN for importer@patchew.org; Tue, 19 Apr 2022 08:30:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9db9268aac4eb87e1471ab8240109c7c29be3bef@lizzy.crudebyte.com>) id 1ngmqa-00037F-1y; Tue, 19 Apr 2022 08:20:47 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9db9268aac4eb87e1471ab8240109c7c29be3bef@lizzy.crudebyte.com>) id 1ngmqY-0004io-CK; Tue, 19 Apr 2022 08:20:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=7I1gomcsbjvHa5W80FT6xNhuhvDH6UO1+WCQVHXH+oY=; b=Nk/dB gXKIHjkLVgSCbBoWfisjhGEftbtKnHwnEDRCc/sgqOxGVw0w3qe8lG7mSzIrU9LDlEstVXV0Zb91N wuG1OGWT1s263Mij0E5HNyNUC3Rt9RTYuT3RWuss0s1u/dL+h+zLdeCFHN96Z6yQuVX6h1AVzbZFV 3Dlpttq3a2lN9HSS39sCR91yQe0bdqDUMSBouniGlXDh2p7cL15YJBrwGA6sjRTzoXeaWeJB8aGtC ZDeDhHO05RiPQVmhMYey7sYj3b3pqRH1yk/sTnEx04YNFRRMkOvmIF0sNRNKU9gNhrqWLptQJ/WZe mdExnvGLX0uJWw55WH1YawF4Q7zVw==; Message-Id: <9db9268aac4eb87e1471ab8240109c7c29be3bef.1650370027.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 19 Apr 2022 13:41:15 +0200 Subject: [PATCH 3/5] 9pfs: fix wrong encoding of rdev field in Rgetattr on macOS To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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: none client-ip=91.194.90.13; envelope-from=9db9268aac4eb87e1471ab8240109c7c29be3bef@lizzy.crudebyte.com; helo=lizzy.crudebyte.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1650371458213100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The 'rdev' field in 9p reponse 'Rgetattr' is of type dev_t, which is actually a system dependant type and therefore both the size and encoding of dev_t differ between macOS and Linux. So far we have sent 'rdev' to guest in host's dev_t format as-is, which caused devices to appear with wrong device numbers on guests running on macOS hosts, eventually leading to various misbehaviours on guest in conjunction with device files. This patch fixes this issue by converting the device number from host's dev_t format to Linux dev_t format. As 9p request 'Tgettattr' is exclusive to protocol version 9p2000.L, it should be fair to assume that 'rdev' field is assumed to be in Linux dev_t format by client as well. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 225f31fc31..d953035e1c 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1318,6 +1318,41 @@ static int32_t stat_to_iounit(const V9fsPDU *pdu, co= nst struct stat *stbuf) return blksize_to_iounit(pdu, stbuf->st_blksize); } =20 +#if !defined(CONFIG_LINUX) + +/* + * Generates a Linux device number (a.k.a. dev_t) for given device major + * and minor numbers. + */ +static uint64_t makedev_dotl(uint32_t dev_major, uint32_t dev_minor) +{ + uint64_t dev; + + // from glibc sysmacros.h: + dev =3D (((uint64_t) (dev_major & 0x00000fffu)) << 8); + dev |=3D (((uint64_t) (dev_major & 0xfffff000u)) << 32); + dev |=3D (((uint64_t) (dev_minor & 0x000000ffu)) << 0); + dev |=3D (((uint64_t) (dev_minor & 0xffffff00u)) << 12); + return dev; +} + +#endif + +/* + * Converts given device number from host's device number format to Linux + * device number format. As both the size of type dev_t and encoding of + * dev_t is system dependant, we have to convert them for Linux guests if + * host is not running Linux. + */ +static uint64_t host_dev_to_dotl_dev(dev_t dev) +{ +#ifdef CONFIG_LINUX + return dev; +#else + return makedev_dotl(major(dev), minor(dev)); +#endif +} + static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, V9fsStatDotl *v9lstat) { @@ -1327,7 +1362,7 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const st= ruct stat *stbuf, v9lstat->st_nlink =3D stbuf->st_nlink; v9lstat->st_uid =3D stbuf->st_uid; v9lstat->st_gid =3D stbuf->st_gid; - v9lstat->st_rdev =3D stbuf->st_rdev; + v9lstat->st_rdev =3D host_dev_to_dotl_dev(stbuf->st_rdev); v9lstat->st_size =3D stbuf->st_size; v9lstat->st_blksize =3D stat_to_iounit(pdu, stbuf); v9lstat->st_blocks =3D stbuf->st_blocks; --=20 2.32.0 (Apple Git-132) From nobody Mon Apr 29 14:13:52 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=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1650371673; cv=none; d=zohomail.com; s=zohoarc; b=gil5L7RWjRphnIlJjltQ0Di6naMyLZRRNOE94+39+hoOwuILV9OkrqO6j4zdwS1Xq1wq5JGOyIQMViqb4DK1aYI2LCg2lbo2VMQt6DOev5EAW/af6FhhGgc8KldZiy6wvyipnEnTzpO8oairRMxh36Q4uYMT3OpsOTNqSfUZ9kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650371673; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Tx6/QrIYQER4SdvAHvid97QHCi42Ac1AewU43DS53hQ=; b=lThMgumjN3EuMBNCUa51JXr5aAe1ieYJXh5EXsToLFjfjFc3CVhie6sd763z8XTHUpJ8NX7CHEU9m/UVZKPG1ZXLjkZ5TZK5vuGIYQL0X8IwSatVFhUzG62q8xX3XupoqftuN0SzZ3kKPGii0qn00YsfIoHhxeXXmHz1DEyD380= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650371673314537.8703807227764; Tue, 19 Apr 2022 05:34:33 -0700 (PDT) Received: from localhost ([::1]:35548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngn3v-0003SU-SL for importer@patchew.org; Tue, 19 Apr 2022 08:34:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngmqf-0003CI-Rm; Tue, 19 Apr 2022 08:20:49 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:48401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngmqe-0004jM-6G; Tue, 19 Apr 2022 08:20:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Tx6/QrIYQER4SdvAHvid97QHCi42Ac1AewU43DS53hQ=; b=DZnYs m0dZ0B9e0a2dfxFTnTecUuMsWeJvBq+ZjDWuZ6o3cYw7SSC6wWB4VFkv/mlmuoGyQq1NkzkiyTDu+ tAJMkwNHoqzwCGFMCnw6HV0/RRkLF5jKx06/Uc4P2jDkT3Wu0mBhLWG1ohcY4IrqhgJtcI03tC5jV 73zsMSt3jlixBcLRhwlQhkmht1DN3ioPghC6UBTQVzjT8gX0WBJcsmj+Rt/dVNIoWWZ8UkAlP9j4C H3QLOJu+6ddEIMDz/xwHU6MND96oFSW/dvNtF729nAg5XL4Dnh+kKN3equG+eyzVLFhO+blEV0nhA 7QR29NbB4kTWJnUZxqx+bgmMFkJYQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 19 Apr 2022 13:41:59 +0200 Subject: [PATCH 4/5] 9pfs: fix wrong errno being sent to Linux client on macOS host To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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: none client-ip=91.194.90.13; envelope-from=c32aafaa3f29424fc13ae86b369c9baf1ceb0ec6@lizzy.crudebyte.com; helo=lizzy.crudebyte.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1650371674490100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Linux and macOS only share some errno definitions with equal macro name and value. In fact most mappings for errno are completely different on the two systems. This patch converts some important errno values from macOS host to corresponding Linux errno values before eventually sending such error codes along with Tlerror replies (if 9p2000.L is used that is), which fixes a bunch of misbehaviours when running a Linux client on macOS host. For instance this patch fixes: mount -t 9p -o posixacl ... on Linux guest if security_mode=3Dmapped was used for 9p server, which refused to mount successfully, because macOS returned ENOATTR=3D=3D93 when client tried to retrieve POSIX ACL xattrs, because errno 93 is defined as EPROTONOSUPPORT=3D=3D93 on Linux, so Linux client believed that xattrs were not supported by filesystem on host in general. Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index d953035e1c..becc41cbfd 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -57,6 +57,31 @@ enum { =20 P9ARRAY_DEFINE_TYPE(V9fsPath, v9fs_path_free); =20 +/* Translates errno from host -> Linux if needed */ +static int errno_to_dotl(int err) { +#if defined(CONFIG_LINUX) + /* nothing to translate (Linux -> Linux) */ +#elif defined(CONFIG_DARWIN) + /* translation mandatory for macOS hosts */ + if (err =3D=3D ENAMETOOLONG) { + err =3D 36; /* =3D=3DENAMETOOLONG on Linux */ + } else if (err =3D=3D ENOTEMPTY) { + err =3D 39; /* =3D=3DENOTEMPTY on Linux */ + } else if (err =3D=3D ELOOP) { + err =3D 40; /* =3D=3DELOOP on Linux */ + } else if (err =3D=3D ENOATTR) { + err =3D 61; /* =3D=3DENODATA on Linux */ + } else if (err =3D=3D ENOTSUP) { + err =3D 95; /* =3D=3DEOPNOTSUPP on Linux */ + } else if (err =3D=3D EOPNOTSUPP) { + err =3D 95; /* =3D=3DEOPNOTSUPP on Linux */ + } +#else +#error Missing errno translation to Linux for this host system +#endif + return err; +} + static ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const char *fmt, .= ..) { ssize_t ret; @@ -1054,6 +1079,8 @@ static void coroutine_fn pdu_complete(V9fsPDU *pdu, s= size_t len) } len +=3D ret; id =3D P9_RERROR; + } else { + err =3D errno_to_dotl(err); } =20 ret =3D pdu_marshal(pdu, len, "d", err); --=20 2.32.0 (Apple Git-132) From nobody Mon Apr 29 14:13:52 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=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1650371821; cv=none; d=zohomail.com; s=zohoarc; b=HiA7j5/1VXMD2hhCRKIsd0UNlO7nr4V0620jEwgShCTB8m+bBto5o6z5iPP888AmA8ABaoklT0QeJ36Qp3TSpioQMa+CDT4/iWMc3gyov9T0r0Qqa30JRjjbYzVgCTHiaAa4NyjIVVyJTCnJ/cM1PpLVZ8IeTyJtZrLUdrpQ0gU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650371821; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=XX4vAZPK+i1VCEUgVN1ZDqJ7cSYFegRWNpXFl/BkX44=; b=EMQkSMseRlfdFNu1+2ZcvOU98WnBISQ0FDKhoY5Ogx1asQnyYNGvxZjreIG7DFSZ8kCNgdzxivQB7X6wlBbqjpAbTVkvmfgu6d8e8ttTEDSkNoxaehtGBVc/x4SQOgeSj0Cn9R0UyMGPgKVJbQWkPI8AsNhoEof7AiuoZSAIICw= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650371821353916.5620017445606; Tue, 19 Apr 2022 05:37:01 -0700 (PDT) Received: from localhost ([::1]:40556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngn6K-0006pu-9H for importer@patchew.org; Tue, 19 Apr 2022 08:37:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <284de6154d7ad57ac6539a7318aa2364261da105@lizzy.crudebyte.com>) id 1ngmqj-0003OP-FY; Tue, 19 Apr 2022 08:20:53 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:56073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <284de6154d7ad57ac6539a7318aa2364261da105@lizzy.crudebyte.com>) id 1ngmqh-0004jd-SY; Tue, 19 Apr 2022 08:20:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=XX4vAZPK+i1VCEUgVN1ZDqJ7cSYFegRWNpXFl/BkX44=; b=YsP2E k51azw51zOahjxrJW7yBipmKKibcnBQ6SHidv8f9S2LCOQ/ywQmZPTs3EE9JAuotGofSbL7qOPK7e cLNoiSfDkHNUgvP2zSHxL/SrNA+UnMMkAmpdcZJjSSVg+k1sChRQZecBLy7P8WSRoLMEos7DJS3BY iDMjn+9oDpPBIb/VDnvDDD6ko8qne7/n/4k6zNhmdPh4RrR2zUiQOrzQ0Q1Tl2dkstRg/JOJ8VDIE mW6mILcf0ujo9zWyiEJUFLRQymQ52qqnPPH9e3Dbb8D1c4wuBg5u6tCfftu0S3MP0pv+ULrcL0AtM DkrTbwUA6BeSijhasoBBVgAGPS9/w==; Message-Id: <284de6154d7ad57ac6539a7318aa2364261da105.1650370027.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 19 Apr 2022 13:43:30 +0200 Subject: [PATCH 5/5] 9pfs: fix removing non-existent POSIX ACL xattr on macOS host To: qemu-devel@nongnu.org Cc: Will Cohen , Greg Kurz , Michael Roitzsch , Keno Fischer , Akihiko Odaki , qemu-stable@nongnu.org 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: none client-ip=91.194.90.13; envelope-from=284de6154d7ad57ac6539a7318aa2364261da105@lizzy.crudebyte.com; helo=lizzy.crudebyte.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=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-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1650371823268100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When mapped POSIX ACL is used, we are ignoring errors when trying to remove a POSIX ACL xattr that does not exist. On Linux hosts we would get ENODATA in such cases, on macOS hosts however we get ENOATTR instead, so ignore ENOATTR errors as well. This patch fixes e.g. a command on Linux guest like: cp --preserve=3Dmode old new Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p-posix-acl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-posix-acl.c b/hw/9pfs/9p-posix-acl.c index eadae270dd..2bf155f941 100644 --- a/hw/9pfs/9p-posix-acl.c +++ b/hw/9pfs/9p-posix-acl.c @@ -65,7 +65,13 @@ static int mp_pacl_removexattr(FsContext *ctx, int ret; =20 ret =3D local_removexattr_nofollow(ctx, path, MAP_ACL_ACCESS); - if (ret =3D=3D -1 && errno =3D=3D ENODATA) { + if (ret =3D=3D -1 && + (errno =3D=3D ENODATA +#ifdef ENOATTR + || errno =3D=3D ENOATTR +#endif + ) + ) { /* * We don't get ENODATA error when trying to remove a * posix acl that is not present. So don't throw the error --=20 2.32.0 (Apple Git-132)