From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FORGED_SPF_HELO,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.3 Received: by atuin.qyliss.net (Postfix, from userid 496) id 9382A1A358; Wed, 8 Jul 2020 15:44:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 84BEF1A34A; Wed, 8 Jul 2020 15:44:04 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id D8BBD1A347; Wed, 8 Jul 2020 15:44:02 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11olkn2078.outbound.protection.outlook.com [40.92.18.78]) by atuin.qyliss.net (Postfix) with ESMTPS id B80C01A3E1 for ; Wed, 8 Jul 2020 15:43:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WkuXlg5rNoZHqd0nnuxz2D3vtjBKwhRPRpNd5im31Oeab2BRBhYdLC1tLj81upXzxNfwatx0jC8V6GUUZmo0lyjxHnSHo4aNGlulBy/1nZ7T2UTdV3v4WL/ZapN3RTSUjMZawKYy8jDGQmkIyb9SF3d13Soke9DTPhmw7zgVlwCDtVIBPqsr7o838BbX2yRKyvgeSW+Rjt8h8PrxOlT0ws1qW15DeC5y1NWP2Ir4p5uhQKKhsm1rUEFBro9Eaka4iJ7mXRA6VQLMFMshwOBvOHLhM2B/Rmvsxpx6FGbhWO4ErNBI080tP0yEpmErojubhcvboB9FSqZ3B0hg8xkNSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hqe7Gc/gQXt6zQVtyl1gIMB0kMu8ce2gZjVj07ufNO0=; b=Z9yop066hQxOFeCeOMGuDkAZUhHonXhYKO7/YnqkGEo3ZfWRjwObN/+hNIbTP60xjTVDBcJPvjsAYruG86jSbP27XmRkIqAtYsd8mRCXkns0C1VWd9cLlQO9MvqbD/Xv4HqzlijGQSJmezi2DP6OwRxppNGqOhdxNF60rSo1eyZrhRFrVBKDotsi+TyU56XzWTLvdQOA3vKhAVUsYSp4RUsS6nTq+54gy5u+wCSc8/s6I4OJctnnyWUJ3Z3QEs52vOKLVZbEgGmhlF2JqrXH4M92h7Rz9zipeHJtYWsMSBVVv2r36TbFfC4Edhimk+nW24h702xQLZJK6cruWHtLdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hqe7Gc/gQXt6zQVtyl1gIMB0kMu8ce2gZjVj07ufNO0=; b=uTKU5b45uf9cDpPBn1lDGjLzBc7Zzge6YwtziYtnn8CzHtZcz1YiWgefVTdpp+5J394w2c4PjyHgGB54GzDIvc/zQmaPCZNrHUHLs9/6QeUaoRUQog9L6PzRnb3vUryCruDP31AxPKdAAhU3Guz64k3BnOWD7S2y2NYkoFD8KgmjFJJNEUG8q+/oXAnsnxF99yztYDlu3bYZg1M3xMFr7+hECRfsUdh0/79qvmWIPMONVQdElNW3uj+GhVQnhGDLzs++BOOtduXXGMHDRYUWY0+rPaXfcVnaZIvDnaVXiJVd4fTPVVmXP6VfVLo7tEFRNm1YAbirWgPO7gWht+ncSg== Received: from CO1NAM11FT045.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::50) by CO1NAM11HT051.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::264) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Wed, 8 Jul 2020 15:43:55 +0000 Received: from SJ0PR03MB5581.namprd03.prod.outlook.com (2a01:111:e400:3861::47) by CO1NAM11FT045.mail.protection.outlook.com (2a01:111:e400:3861::437) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 15:43:55 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:780A144F7B735E0A8DEBE1DE1F0560B97043EDDA8D04C7D3CFB079FD499AF72C;UpperCasedChecksum:29F2E719B2A6D76F51000880B470196AF40AA276111B8D64AA8226AB75DC862E;SizeAsReceived:8540;Count:46 Received: from SJ0PR03MB5581.namprd03.prod.outlook.com ([fe80::61c9:c99c:bd8f:cbd6]) by SJ0PR03MB5581.namprd03.prod.outlook.com ([fe80::61c9:c99c:bd8f:cbd6%7]) with mapi id 15.20.3174.022; Wed, 8 Jul 2020 15:43:55 +0000 From: Cole Helbling To: Alyssa Ross , devel@spectrum-os.org Subject: Re: [PATCH wayland] Support virtio_wl display sockets In-Reply-To: <20200708151600.10607-1-hi@alyssa.is> References: <20200708151600.10607-1-hi@alyssa.is> Date: Wed, 08 Jul 2020 08:43:54 -0700 Message-ID: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BYAPR05CA0036.namprd05.prod.outlook.com (2603:10b6:a03:c0::49) To SJ0PR03MB5581.namprd03.prod.outlook.com (2603:10b6:a03:27b::20) X-Microsoft-Original-Message-ID: <87wo3e3tc5.fsf@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (67.187.170.40) by BYAPR05CA0036.namprd05.prod.outlook.com (2603:10b6:a03:c0::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.15 via Frontend Transport; Wed, 8 Jul 2020 15:43:55 +0000 X-Microsoft-Original-Message-ID: <87wo3e3tc5.fsf@outlook.com> X-TMN: [f4vEoOe4weG76GUi+cpHRMopewSnqQRp] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 2c67492d-c7cd-4618-e467-08d82355b8ca X-MS-TrafficTypeDiagnostic: CO1NAM11HT051: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S92UrqlkCnvCJoJpOnmNoCpoANqj8EAubsF3hbv9xn5AgOH4/fQ9Z4vXTHauGrS7sF3i9gTEkfXgx0rXFkJQPbFAnuPRBYcmR6+3W2tEnP8gKicvw6+5zAtpaDDYj2kRPj6EE1mTPZVztcPW6jyAjbqmgg9B9BYNAmoTRH4tXl2jJURDIdMZLy8yuG45CF2qDBha37N5j/hEPpS2pPlk9Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB5581.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: CYzOTtWE/na5kaZCIfIx0hVhoI2ooKc4T8kLSVdPfFWP43c4S/Ro0H/3CePyV+WKHKCJCuebWHKEMYz/AfyfPKQPaike7G97az/2OPLaGXAdFNxnqVceslPliMt5KtNZsDctgA1D+L9TP3AuO6v9RA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c67492d-c7cd-4618-e467-08d82355b8ca X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 15:43:55.4642 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM11HT051 Message-ID-Hash: OUYTNFBS2YIFOHLDLMLIUHFMR4XWWUGJ X-Message-ID-Hash: OUYTNFBS2YIFOHLDLMLIUHFMR4XWWUGJ X-MailFrom: cole.e.helbling@outlook.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.3.1 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Alyssa Ross writes: > src/connection.c | 4 + > src/meson.build | 16 +- > src/virtio_wl.c | 344 +++++++++++++++++++++++ > src/virtio_wl.h | 23 ++ > src/wayland-os.c | 23 ++ > src/wayland-os.h | 3 + > src/wayland-server.c | 20 +- > src/wayland-shm.c | 24 +- > tests/meson.build | 1 + > tests/virtio_wl-test.c | 615 +++++++++++++++++++++++++++++++++++++++++ > 10 files changed, 1064 insertions(+), 9 deletions(-) > create mode 100644 src/virtio_wl.c > create mode 100644 src/virtio_wl.h > create mode 100644 tests/virtio_wl-test.c > > diff --git a/src/virtio_wl.c b/src/virtio_wl.c > new file mode 100644 > index 0000000..a1ee8ee > --- /dev/null > +++ b/src/virtio_wl.c (snip) > +static size_t > +fdbuf_to_cmsg(struct msghdr *msg, const int *buf, size_t buflen) > +{ > + // Check msg->msg_control is long enough to fit at least one fd. > + if (msg->msg_controllen < CMSG_SPACE(sizeof(int))) { > + > + // If there's at least one fd in buf, set MSG_CTRUNC. > + size_t i =3D 0; > + while (i < buflen && !(msg->msg_flags & MSG_CTRUNC)) > + if (buf[i++] !=3D -1) > + msg->msg_flags |=3D MSG_CTRUNC; > + > + return 0; > + } > + > + // cmsg(3): > + // > When initializing a buffer that will contain a series of cmsghdr > + // > structures (e.g., to be sent with sendmsg(2)), that buffer = should > + // > first be zero-initialized to en=E2=80=90 sure the correct o= peration of > + // > CMSG_NXTHDR(). This comment looks weird -- both the misalignment (tabs vs spaces, it seems) and "en- sure" (probably reflow mistake). > + memset(msg->msg_control, 0, msg->msg_controllen); > + > + // Set up the cmsg. > + struct cmsghdr *cmsg =3D CMSG_FIRSTHDR(msg); > + cmsg->cmsg_level =3D SOL_SOCKET; > + cmsg->cmsg_type =3D SCM_RIGHTS; > + > + // Copy as many fds as fit into cmsg. > + size_t len =3D 0; > + for (size_t i =3D 0; i < buflen; i++) { > + if (buf[i] =3D=3D -1) > + continue; > + > + if (CMSG_LEN((len + 1) * sizeof(int)) > msg->msg_controllen) { > + msg->msg_flags |=3D MSG_CTRUNC; > + break; > + } > + > + memcpy(CMSG_DATA(cmsg) + sizeof(int) * len, &buf[i], sizeof(int)); > + len++; > + } > + > + cmsg->cmsg_len =3D CMSG_LEN(len * sizeof(int)); > + return len; > +} I can't comment on the code itself, as I'm unfamiliar with both Wayland and C. :D Cole