From nobody Thu May 9 11:54:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1706883813110133.09983969308655; Fri, 2 Feb 2024 06:23:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 086151D1A; Fri, 2 Feb 2024 09:23:31 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 516841CE7; Fri, 2 Feb 2024 09:20:51 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id BF7EC1C69; Fri, 2 Feb 2024 09:20:42 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0F8611C43 for ; Fri, 2 Feb 2024 09:20:39 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-tyzbTa2ZMv2V_Nh1-mBnZA-1; Fri, 02 Feb 2024 09:20:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20644835381 for ; Fri, 2 Feb 2024 14:20:37 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC942200A08E for ; Fri, 2 Feb 2024 14:20:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: tyzbTa2ZMv2V_Nh1-mBnZA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/5] virsocket: Drop unused #include and #define Date: Fri, 2 Feb 2024 15:20:30 +0100 Message-ID: <98869dcc4ce60d10419cb08408ed5631227b3dc6.1706883582.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: CNV4IZVKEK5JM4WPVSRP2PAUNPP4PGHV X-Message-ID-Hash: CNV4IZVKEK5JM4WPVSRP2PAUNPP4PGHV X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706883815164100001 Inside of virsocket.c there is an include of poll.h and PKT_TIMEOUT_MS macro definition. Neither of these is really needed and in fact it's a leftover after I reworked one of previously merged commits during review. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virsocket.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util/virsocket.c b/src/util/virsocket.c index 3b274a4eec..a4c646e759 100644 --- a/src/util/virsocket.c +++ b/src/util/virsocket.c @@ -26,9 +26,6 @@ #include "virlog.h" =20 #include -#include - -#define PKT_TIMEOUT_MS 500 /* ms */ =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 11:54:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1706884082746796.6462670457605; Fri, 2 Feb 2024 06:28:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 94CDE1C98; Fri, 2 Feb 2024 09:28:01 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AA6B11C9D; Fri, 2 Feb 2024 09:21:22 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 483D41C38; Fri, 2 Feb 2024 09:20:44 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 01AC21C46 for ; Fri, 2 Feb 2024 09:20:39 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-_ZqqznueOSWvHB5aIyIK4g-1; Fri, 02 Feb 2024 09:20:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD2C5811E81 for ; Fri, 2 Feb 2024 14:20:37 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55E59200A08E for ; Fri, 2 Feb 2024 14:20:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: _ZqqznueOSWvHB5aIyIK4g-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/5] virSocketSendMsgWithFDs: Don't report errors, just set errno Date: Fri, 2 Feb 2024 15:20:31 +0100 Message-ID: <755d43c57be9116c58d88f50c6819ac9d291b6f7.1706883582.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: KUGSRMCTI6VODH4XA44OQRJVAUFKCFTT X-Message-ID-Hash: KUGSRMCTI6VODH4XA44OQRJVAUFKCFTT X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706884084269100001 Currently, virSocketSendMsgWithFDs() reports two errors: 1) if CMSG_FIRSTHDR() fails, 2) if sendmsg() fails. Well, the latter sets an errno, so caller can just use virReportSystemError(). And the former - it is very unlikely to fail because memory for whole control message was allocated just a few lines above. The motivation is to unify behavior of virSocketSendMsgWithFDs() and virSocketSendFD() because the latter is just a subset of the former (will be addressed later). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- po/POTFILES | 1 - src/ch/ch_process.c | 6 ++++-- src/util/virsocket.c | 14 ++------------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/po/POTFILES b/po/POTFILES index e48b9023e2..428919815d 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -327,7 +327,6 @@ src/util/virscsi.c src/util/virscsihost.c src/util/virscsivhost.c src/util/virsecret.c -src/util/virsocket.c src/util/virsocketaddr.c src/util/virstoragefile.c src/util/virstring.c diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 86d3190324..3265ae90de 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -558,6 +558,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, g_autofree char *response =3D NULL; size_t j; size_t tapfd_len; + int saved_errno; int http_res; int rc; =20 @@ -597,6 +598,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, payload =3D virBufferContentAndReset(&buf); =20 rc =3D virSocketSendMsgWithFDs(mon_sockfd, payload, tapfds, tapfd_= len); + saved_errno =3D errno; =20 /* Close sent tap fds in Libvirt, as they have been dup()ed in CH = */ for (j =3D 0; j < tapfd_len; j++) { @@ -604,8 +606,8 @@ chProcessAddNetworkDevices(virCHDriver *driver, } =20 if (rc < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to send net-add request to CH")); + virReportSystemError(saved_errno, "%s", + _("Failed to send net-add request to CH")= ); return -1; } =20 diff --git a/src/util/virsocket.c b/src/util/virsocket.c index a4c646e759..ff06eb15f7 100644 --- a/src/util/virsocket.c +++ b/src/util/virsocket.c @@ -19,16 +19,12 @@ =20 #include =20 -#include "virerror.h" #include "virsocket.h" #include "virutil.h" #include "virfile.h" -#include "virlog.h" =20 #include =20 -#define VIR_FROM_THIS VIR_FROM_NONE - #ifdef WIN32 =20 # define FD2SK(fd) _get_osfhandle(fd) @@ -523,7 +519,7 @@ virSocketSendMsgWithFDs(int sock, const char *payload, = int *fds, size_t fds_len) cmsg =3D CMSG_FIRSTHDR(&msg); /* check to eliminate "potential null pointer dereference" errors duri= ng build */ if (!cmsg) { - virReportSystemError(EFAULT, "%s", _("Couldn't fit control msg hea= der in msg")); + errno =3D ENOSPC; return -1; } =20 @@ -536,11 +532,6 @@ virSocketSendMsgWithFDs(int sock, const char *payload,= int *fds, size_t fds_len) ret =3D sendmsg(sock, &msg, 0); } while (ret < 0 && errno =3D=3D EINTR); =20 - if (ret < 0) { - virReportSystemError(errno, "%s", _("sendmsg failed")); - return -1; - } - return ret; } =20 @@ -565,8 +556,7 @@ virSocketSendMsgWithFDs(int sock G_GNUC_UNUSED, int *fds G_GNUC_UNUSED, size_t fds_len G_GNUC_UNUSED) { - virReportSystemError(ENOSYS, "%s", - _("FD passing is not supported on this platform")= ); + errno =3D ENOSYS; return -1; } #endif /* WIN32 */ --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 11:54:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1706884170267321.84689757539945; Fri, 2 Feb 2024 06:29:30 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 34D5F1DC3; Fri, 2 Feb 2024 09:29:29 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 744C21D55; Fri, 2 Feb 2024 09:21:32 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 49DFC1C46; Fri, 2 Feb 2024 09:20:44 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 38C6E1C49 for ; Fri, 2 Feb 2024 09:20:40 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-hSUtNRsSNTCkAF9NRR2ljQ-1; Fri, 02 Feb 2024 09:20:38 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46EC287B2A4 for ; Fri, 2 Feb 2024 14:20:38 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2ED7200A08E for ; Fri, 2 Feb 2024 14:20:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: hSUtNRsSNTCkAF9NRR2ljQ-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 3/5] virSocketSendMsgWithFDs: Introduce @payload_len argument Date: Fri, 2 Feb 2024 15:20:32 +0100 Message-ID: <77e60de5b2490063f4aecc3e6764dcdac7e0a26b.1706883582.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: ZLUYCAEY7HRF7S23VUKCRF3JBN7VPUT2 X-Message-ID-Hash: ZLUYCAEY7HRF7S23VUKCRF3JBN7VPUT2 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706884170895100001 Instead of using strlen() to calculate length of payload we're sending, let caller specify the size: they may want to send just a portion of a buffer (even though the only current user doesn't). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_process.c | 5 ++++- src/util/virsocket.c | 10 ++++++++-- src/util/virsocket.h | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 3265ae90de..3bde9d9dcf 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -558,6 +558,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, g_autofree char *response =3D NULL; size_t j; size_t tapfd_len; + size_t payload_len; int saved_errno; int http_res; int rc; @@ -595,9 +596,11 @@ chProcessAddNetworkDevices(virCHDriver *driver, virBufferAsprintf(&buf, "%s", virBufferCurrentContent(&http_header= s)); virBufferAsprintf(&buf, "Content-Length: %ld\r\n\r\n", strlen(payl= oad)); virBufferAsprintf(&buf, "%s", payload); + payload_len =3D virBufferUse(&buf); payload =3D virBufferContentAndReset(&buf); =20 - rc =3D virSocketSendMsgWithFDs(mon_sockfd, payload, tapfds, tapfd_= len); + rc =3D virSocketSendMsgWithFDs(mon_sockfd, payload, payload_len, + tapfds, tapfd_len); saved_errno =3D errno; =20 /* Close sent tap fds in Libvirt, as they have been dup()ed in CH = */ diff --git a/src/util/virsocket.c b/src/util/virsocket.c index ff06eb15f7..a7272a3ec9 100644 --- a/src/util/virsocket.c +++ b/src/util/virsocket.c @@ -488,6 +488,7 @@ virSocketRecvFD(int sock, int fdflags) * virSocketSendMsgWithFDs: * @sock: socket to send payload and fds to * @payload: payload to send + * @payload_len: length of @payload * @fds: array of fds to send * @fds_len: len of fds array =20 @@ -496,7 +497,11 @@ virSocketRecvFD(int sock, int fdflags) * On error, set errno and return -1. */ int -virSocketSendMsgWithFDs(int sock, const char *payload, int *fds, size_t fd= s_len) +virSocketSendMsgWithFDs(int sock, + const char *payload, + size_t payload_len, + int *fds, + size_t fds_len) { g_autofree char *control =3D NULL; const size_t control_size =3D CMSG_SPACE(sizeof(int) * fds_len); @@ -508,7 +513,7 @@ virSocketSendMsgWithFDs(int sock, const char *payload, = int *fds, size_t fds_len) control =3D g_new0(char, control_size); =20 iov[0].iov_base =3D (void *) payload; - iov[0].iov_len =3D strlen(payload); + iov[0].iov_len =3D payload_len; =20 msg.msg_iov =3D iov; msg.msg_iovlen =3D 1; @@ -553,6 +558,7 @@ virSocketRecvFD(int sock G_GNUC_UNUSED, int fdflags G_G= NUC_UNUSED) int virSocketSendMsgWithFDs(int sock G_GNUC_UNUSED, const char *payload G_GNUC_UNUSED, + size_t payload_len G_GNUC_UNUSED, int *fds G_GNUC_UNUSED, size_t fds_len G_GNUC_UNUSED) { diff --git a/src/util/virsocket.h b/src/util/virsocket.h index 31a31c2378..0e7f9616f2 100644 --- a/src/util/virsocket.h +++ b/src/util/virsocket.h @@ -22,8 +22,8 @@ =20 int virSocketSendFD(int sock, int fd); int virSocketRecvFD(int sock, int fdflags); -int virSocketSendMsgWithFDs(int sock, const char *payload, int *fds, - size_t fd_len); +int virSocketSendMsgWithFDs(int sock, const char *payload, size_t payload_= len, + int *fds, size_t fds_len); =20 #ifdef WIN32 =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 11:54:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1706883905964210.98190031610068; Fri, 2 Feb 2024 06:25:05 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E00EB1D67; Fri, 2 Feb 2024 09:25:04 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 68AAC1C8B; Fri, 2 Feb 2024 09:21:01 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 20CAF1C41; Fri, 2 Feb 2024 09:20:44 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EE9291C58 for ; Fri, 2 Feb 2024 09:20:40 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-7pP4QlMfM_CpZbcyXKALHg-1; Fri, 02 Feb 2024 09:20:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D3DF829AC00E for ; Fri, 2 Feb 2024 14:20:38 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C7D7200A08E for ; Fri, 2 Feb 2024 14:20:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 7pP4QlMfM_CpZbcyXKALHg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/5] virsocket: Simplify virSocketSendFD() Date: Fri, 2 Feb 2024 15:20:33 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: VJNXGA4NN4AGEMB2WCUC2BNOJKLOPRRF X-Message-ID-Hash: VJNXGA4NN4AGEMB2WCUC2BNOJKLOPRRF X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706883907617100001 After previous cleanups, virSocketSendFD() is but a thin wrapper over virSocketSendMsgWithFDs(). Replace the body of the former with a call to the latter. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virsocket.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/util/virsocket.c b/src/util/virsocket.c index a7272a3ec9..c4e214e76a 100644 --- a/src/util/virsocket.c +++ b/src/util/virsocket.c @@ -388,32 +388,10 @@ int virSocketSendFD(int sock, int fd) { char byte =3D 0; - struct iovec iov; - struct msghdr msg =3D { 0 }; - struct cmsghdr *cmsg; - char buf[CMSG_SPACE(sizeof(fd))]; + int fds[] =3D { fd }; =20 - /* send at least one char */ - iov.iov_base =3D &byte; - iov.iov_len =3D 1; - msg.msg_iov =3D &iov; - msg.msg_iovlen =3D 1; - msg.msg_name =3D NULL; - msg.msg_namelen =3D 0; - - msg.msg_control =3D buf; - msg.msg_controllen =3D sizeof(buf); - cmsg =3D CMSG_FIRSTHDR(&msg); - cmsg->cmsg_level =3D SOL_SOCKET; - cmsg->cmsg_type =3D SCM_RIGHTS; - cmsg->cmsg_len =3D CMSG_LEN(sizeof(fd)); - /* Initialize the payload: */ - memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); - msg.msg_controllen =3D cmsg->cmsg_len; - - if (sendmsg(sock, &msg, 0) !=3D iov.iov_len) - return -1; - return 0; + return virSocketSendMsgWithFDs(sock, &byte, sizeof(byte), + fds, G_N_ELEMENTS(fds)); } =20 =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Thu May 9 11:54:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 170688399306970.65611613560668; Fri, 2 Feb 2024 06:26:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0AA1B1D35; Fri, 2 Feb 2024 09:26:32 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 54B5D1CDE; Fri, 2 Feb 2024 09:21:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 39B8F1C43; Fri, 2 Feb 2024 09:20:44 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 410091C67 for ; Fri, 2 Feb 2024 09:20:41 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-HyFYSgzLOWmYWFZEJDjwcg-1; Fri, 02 Feb 2024 09:20:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D38287B2A4 for ; Fri, 2 Feb 2024 14:20:39 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 153F7200B2D7 for ; Fri, 2 Feb 2024 14:20:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: HyFYSgzLOWmYWFZEJDjwcg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 5/5] qemu_monitor: Simplify qemuMonitorIOWriteWithFD() Date: Fri, 2 Feb 2024 15:20:34 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 3JH32LL5JTXKNXYL5SE3KWG3GVSAETGZ X-Message-ID-Hash: 3JH32LL5JTXKNXYL5SE3KWG3GVSAETGZ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706883994040100001 After previous cleanups, qemuMonitorIOWriteWithFD() is but a thin wrapper over virSocketSendMsgWithFDs(). Replace the body of the former with a call to the latter. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a1773d86d4..9471fe711e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -308,32 +308,9 @@ qemuMonitorIOWriteWithFD(qemuMonitor *mon, size_t len, int fd) { - struct msghdr msg =3D { 0 }; - struct iovec iov[1]; - int ret; - char control[CMSG_SPACE(sizeof(int))] =3D { 0 }; - struct cmsghdr *cmsg; + int fds[] =3D { fd }; =20 - iov[0].iov_base =3D (void *)data; - iov[0].iov_len =3D len; - - msg.msg_iov =3D iov; - msg.msg_iovlen =3D 1; - - msg.msg_control =3D control; - msg.msg_controllen =3D sizeof(control); - - cmsg =3D CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len =3D CMSG_LEN(sizeof(int)); - cmsg->cmsg_level =3D SOL_SOCKET; - cmsg->cmsg_type =3D SCM_RIGHTS; - memcpy(CMSG_DATA(cmsg), &fd, sizeof(int)); - - do { - ret =3D sendmsg(mon->fd, &msg, 0); - } while (ret < 0 && errno =3D=3D EINTR); - - return ret; + return virSocketSendMsgWithFDs(mon->fd, data, len, fds, G_N_ELEMENTS(f= ds)); } =20 =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org