From nobody Tue May 14 04:24:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1648467981; cv=none; d=zohomail.com; s=zohoarc; b=fccBJLKzb3ELhpsSn6bmsrdV1TQwsaP12+KL49endUJ4WxPLKEuTgjeqMg/qQ4v/WMfNcifDxXHiaSpZqnanukOs20788I/2x1scNLKttZos79ZiIwoyrsSiIQts9z5oOstZD2EU4M0C06ifjLxaCbpMLqTjcOBd0uSu4dJbtsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648467981; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fV49N09otPV9uX55E/lqTXD6F9Imm4cPeY73c7vIYR0=; b=XaOvBXu7rieHe2x83CiymXWJ9XPnM80om0hT94a07cnCfzSvXcYlaVjcLofzNwJRW3UwJWgfDTZJx8X+O7/b08GJ7tZN7BjS8SGqXnJ4tvh00TcZ6/AJfx+yxotWMAlDxKKyKsimofD9DNVlN6Z1XC4tj+0qPV9bbPLlDL1F3xA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1648467981977730.8637479567495; Mon, 28 Mar 2022 04:46:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-otKElgtXPA61uOKRlP0kCg-1; Mon, 28 Mar 2022 07:46:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36233185A794; Mon, 28 Mar 2022 11:46:15 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A38CF2166B3F; Mon, 28 Mar 2022 11:46:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 147871947BBF; Mon, 28 Mar 2022 11:46:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AE33F1947BBF for ; Mon, 28 Mar 2022 11:46:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9D76C401E12; Mon, 28 Mar 2022 11:46:12 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 461C5401E06 for ; Mon, 28 Mar 2022 11:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648467980; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fV49N09otPV9uX55E/lqTXD6F9Imm4cPeY73c7vIYR0=; b=Dq52YJm9SVF5IKnG4izKx4Llye+EzUCpOFPISHAStVUUyC9X6HgxcgfgMrAKo5kXciaHCN YBIYGyDeM7X47AGSAnd0tPQolRmLFZOp1aBllJaaHvHfduiaj+iqWAUOfCgNV5moR7C9te UzNPxVBM2L1w/ETKZqvGffQLUHeqi4M= X-MC-Unique: otKElgtXPA61uOKRlP0kCg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virfile: Report error when changing pipe size fails Date: Mon, 28 Mar 2022 13:46:08 +0200 Message-Id: <81c66d46b66511b31c90b3fcb865f6444367c2d6.1648467968.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648467983772100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When changing the size of pipe that virFileWrapperFdNew() creates we start at 1MiB and if that fails because it's above the system wide limit we get EPERM and continue with half of the size. However, we might get another error in which case we should report proper system error and return failure from virFileWrapperFdNew(). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 Tested-by: Claudio Fontana --- src/util/virfile.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 12b359d550..130b0fbace 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -217,7 +217,7 @@ struct _virFileWrapperFd { * * OS note: only for linux, on other OS this is a no-op. */ -static void +static int virFileWrapperSetPipeSize(int fd) { int sz; @@ -230,21 +230,24 @@ virFileWrapperSetPipeSize(int fd) continue; /* retry with half the size */ } if (rv < 0) { - break; + virReportSystemError(errno, "%s", + _("unable to set pipe size")); + return -1; } VIR_DEBUG("fd %d pipe size adjusted to %d", fd, sz); - return; + return 0; } =20 VIR_WARN("unable to set pipe size, data transfer might be slow: %s", g_strerror(errno)); + return 0; } =20 # else /* !__linux__ */ -static void +static int virFileWrapperSetPipeSize(int fd G_GNUC_UNUSED) { - return; + return 0; } # endif /* !__linux__ */ =20 @@ -323,6 +326,9 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) if (virPipe(pipefd) < 0) goto error; =20 + if (virFileWrapperSetPipeSize(pipefd[output]) < 0) + goto error; + if (!(iohelper_path =3D virFileFindResource("libvirt_iohelper", abs_top_builddir "/src", LIBEXECDIR))) @@ -330,8 +336,6 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) =20 ret->cmd =3D virCommandNewArgList(iohelper_path, name, NULL); =20 - virFileWrapperSetPipeSize(pipefd[output]); - if (output) { virCommandSetInputFD(ret->cmd, pipefd[0]); virCommandSetOutputFD(ret->cmd, fd); --=20 2.34.1