From nobody Sun Feb 8 17:48:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065100; cv=none; d=zoho.com; s=zohoarc; b=UXsitl19RSho2/mSMyoi1v06CVvPedFJDljXQz9vAKGDw6BbTIvclKZQ+xYDFp/Oy6Hjn+C90may+rEywX33R/tlPpi5XoB6X9Q1i15jVvXNRnZx0Mh0nwXDMhBZU16ttvjSVB5NGyM97u1w435iLT/laEQEpZtXN3apUqneMx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065100; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yYRKGc6bLG0uQu9p03DT/PVyaItwwJQ/bxTlyy4NavQ=; b=iMQuN+vU+3eHfM6jeC0XP7rDcoPSQgbB1Fn4njPlfsPKHv411nED25eVIFXnt/qiGi1YN5fAT998dO1K3fKP8ClMVyInWfCTpa/y091l1KomJzxaekp3OOUIdBrcvycGYPidUPm9kvdXobzd+kqweI+C2JP2zhW9KiAqSvN2BSw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065100507575.1466153640852; Thu, 25 Jul 2019 07:31:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CD8A300C72E; Thu, 25 Jul 2019 14:31:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 669FA7A012; Thu, 25 Jul 2019 14:31:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 21170E177; Thu, 25 Jul 2019 14:31:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUtwR012820 for ; Thu, 25 Jul 2019 10:30:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9A1960C68; Thu, 25 Jul 2019 14:30:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E93860C6B for ; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0B7630C34D5 for ; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETha8135485 for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tye288krq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:50 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:48 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUl1I53018914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:47 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2C80BE058; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98402BE051; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:27 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-8235-0000-0000-00000EBE02EA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027886; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:49 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-8236-0000-0000-0000468AF22E Message-Id: <20190725143033.1176271-14-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=983 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:52 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 13/19] utils: Extend virCommandProcessIO to include the send buffers X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 25 Jul 2019 14:31:39 +0000 (UTC) Extend virCommandProcessIO to include the send buffers in the poll loop. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vircommand.c | 62 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index d63990b53a..a66e0ba4a2 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1802,6 +1802,61 @@ virCommandSetSendBuffer(virCommandPtr cmd, } =20 =20 +static int +virCommandSendBuffersFillPollfd(virCommandPtr cmd, + struct pollfd *fds, + int startidx) +{ + size_t i, j; + + for (i =3D 0, j =3D 0; i < virCommandGetNumSendBuffers(cmd); i++) { + if (cmd->sendBuffers[i].fd >=3D 0) { + fds[startidx + j].fd =3D cmd->sendBuffers[i].fd; + fds[startidx + j].events =3D POLLOUT; + fds[startidx + j].revents =3D 0; + j++; + } + } + + return j; +} + + +static int +virCommandSendBuffersHandlePoll(virCommandPtr cmd, + struct pollfd *fds) +{ + size_t i; + ssize_t done; + + for (i =3D 0; i < virCommandGetNumSendBuffers(cmd); i++) { + if (fds->fd =3D=3D cmd->sendBuffers[i].fd) + break; + } + if (i =3D=3D virCommandGetNumSendBuffers(cmd)) + return 0; + + done =3D write(fds->fd, + cmd->sendBuffers[i].buffer + cmd->sendBuffers[i].offset, + cmd->sendBuffers[i].buflen - cmd->sendBuffers[i].offset); + if (done < 0) { + if (errno =3D=3D EPIPE) { + VIR_DEBUG("child closed PIPE early, ignoring EPIPE " + "on fd %d", cmd->sendBuffers[i].fd); + VIR_FORCE_CLOSE(cmd->sendBuffers[i].fd); + } else if (errno !=3D EINTR && errno !=3D EAGAIN) { + virReportSystemError(errno, "%s", + _("unable to write to child input")); + return -1; + } + } else { + cmd->sendBuffers[i].offset +=3D done; + if (cmd->sendBuffers[i].offset =3D=3D cmd->sendBuffers[i].buflen) + VIR_FORCE_CLOSE(cmd->sendBuffers[i].fd); + } + return 0; +} + /** * virCommandSetInputBuffer: * @cmd: the command to modify @@ -2156,7 +2211,7 @@ virCommandProcessIO(virCommandPtr cmd) goto cleanup; ret =3D -1; =20 - if (VIR_ALLOC_N(fds, 3) < 0) + if (VIR_ALLOC_N(fds, 3 + virCommandGetNumSendBuffers(cmd)) < 0) goto cleanup; =20 for (;;) { @@ -2182,6 +2237,8 @@ virCommandProcessIO(virCommandPtr cmd) nfds++; } =20 + nfds +=3D virCommandSendBuffersFillPollfd(cmd, fds, nfds); + if (nfds =3D=3D 0) break; =20 @@ -2254,6 +2311,9 @@ virCommandProcessIO(virCommandPtr cmd) if (inoff =3D=3D inlen) VIR_FORCE_CLOSE(cmd->inpipe); } + } else if (fds[i].revents & (POLLOUT | POLLHUP | POLLERR)) { + if (virCommandSendBuffersHandlePoll(cmd, &fds[i]) < 0) + goto cleanup; } } } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list