From nobody Wed Feb 11 03:44:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650617946541653.369657867958; Fri, 22 Apr 2022 01:59:06 -0700 (PDT) Received: from localhost ([::1]:56956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhp85-0006wQ-F7 for importer@patchew.org; Fri, 22 Apr 2022 04:59:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhonp-0006si-2I for qemu-devel@nongnu.org; Fri, 22 Apr 2022 04:38:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhonn-0006Ja-6G for qemu-devel@nongnu.org; Fri, 22 Apr 2022 04:38:08 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-q9AhmKCxMcKB_-30vHiIyg-1; Fri, 22 Apr 2022 04:38:05 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA21B1C05ABA; Fri, 22 Apr 2022 08:38:04 +0000 (UTC) Received: from localhost (unknown [10.39.208.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BC7C434822; Fri, 22 Apr 2022 08:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650616686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=spde1PPk4+g3bTy5FK58CtKYvaQh36HB5AuIUYOW3vc=; b=EDHeF6hDmoSDQagJ2ULw9h2fZffPb7aoFD3CwoMvaBa3PZ1oqhG9liuqff61uGGb2e80em wkoiWJ44dLmCYvC8AXVnefcMWSmuf2+w3bKokA41h74t4lbdVKA0tFMeraK260k257ib6e AAjL3pePegy2q+7nk22E2jlWfOl1E5s= X-MC-Unique: q9AhmKCxMcKB_-30vHiIyg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH 06/10] Replace qemu_pipe() with g_unix_open_pipe() Date: Fri, 22 Apr 2022 12:36:35 +0400 Message-Id: <20220422083639.3156978-7-marcandre.lureau@redhat.com> In-Reply-To: <20220422083639.3156978-1-marcandre.lureau@redhat.com> References: <20220422083639.3156978-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=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: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Vladimir Sementsov-Ogievskiy , Eric Blake , "open list:Network Block Dev..." , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1650617947165100001 From: Marc-Andr=C3=A9 Lureau GLib g_unix_open_pipe() is essentially like qemu_pipe(), available since 2.30. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/osdep.h | 4 ---- qemu-nbd.c | 5 +++-- util/event_notifier-posix.c | 2 +- util/oslib-posix.c | 22 ---------------------- 4 files changed, 4 insertions(+), 29 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 220b44f710e5..241d249d7e5b 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -547,10 +547,6 @@ static inline void qemu_timersub(const struct timeval = *val1, ssize_t qemu_write_full(int fd, const void *buf, size_t count) G_GNUC_WARN_UNUSED_RESULT; =20 -#ifndef _WIN32 -int qemu_pipe(int pipefd[2]); -#endif - void qemu_set_cloexec(int fd); =20 void fips_set_state(bool requested); diff --git a/qemu-nbd.c b/qemu-nbd.c index 397ffa64d768..a184c6b9992f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -902,13 +902,14 @@ int main(int argc, char **argv) =20 if ((device && !verbose) || fork_process) { #ifndef WIN32 + g_autoptr(GError) err =3D NULL; int stderr_fd[2]; pid_t pid; int ret; =20 - if (qemu_pipe(stderr_fd) < 0) { + if (!g_unix_open_pipe(stderr_fd, FD_CLOEXEC, &err)) { error_report("Error setting up communication pipe: %s", - strerror(errno)); + err->message); exit(EXIT_FAILURE); } =20 diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c index 8dc30c51414d..df21c2583e1f 100644 --- a/util/event_notifier-posix.c +++ b/util/event_notifier-posix.c @@ -49,7 +49,7 @@ int event_notifier_init(EventNotifier *e, int active) if (errno !=3D ENOSYS) { return -errno; } - if (qemu_pipe(fds) < 0) { + if (!g_unix_open_pipe(fds, FD_CLOEXEC, NULL)) { return -errno; } ret =3D fcntl_setfl(fds[0], O_NONBLOCK); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 03d97741562c..543c9944b083 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -274,28 +274,6 @@ void qemu_set_cloexec(int fd) assert(f !=3D -1); } =20 -/* - * Creates a pipe with FD_CLOEXEC set on both file descriptors - */ -int qemu_pipe(int pipefd[2]) -{ - int ret; - -#ifdef CONFIG_PIPE2 - ret =3D pipe2(pipefd, O_CLOEXEC); - if (ret !=3D -1 || errno !=3D ENOSYS) { - return ret; - } -#endif - ret =3D pipe(pipefd); - if (ret =3D=3D 0) { - qemu_set_cloexec(pipefd[0]); - qemu_set_cloexec(pipefd[1]); - } - - return ret; -} - char * qemu_get_local_state_dir(void) { --=20 2.36.0