From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W40If-0002WR-NT for qemu-devel@nongnu.org; Thu, 16 Jan 2014 22:41:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W40IT-0004Is-Bz for qemu-devel@nongnu.org; Thu, 16 Jan 2014 22:40:53 -0500 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:49160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W40IO-0004H3-O7 for qemu-devel@nongnu.org; Thu, 16 Jan 2014 22:40:41 -0500 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2014 13:40:27 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id DC3A82BB002D for ; Fri, 17 Jan 2014 14:40:25 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s0H3LScv327966 for ; Fri, 17 Jan 2014 14:21:29 +1100 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s0H3eOdt029072 for ; Fri, 17 Jan 2014 14:40:24 +1100 Message-ID: <52D8A626.1080608@linux.vnet.ibm.com> Date: Fri, 17 Jan 2014 11:40:22 +0800 From: Lei Li MIME-Version: 1.0 References: <1389172376-30636-1-git-send-email-lilei@linux.vnet.ibm.com> <1389172376-30636-5-git-send-email-lilei@linux.vnet.ibm.com> <20140116101522.GB29231@redhat.com> In-Reply-To: <20140116101522.GB29231@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/6] virtfs-proxy-helper: replace send_fd with qemu_send_with_fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: pbonzini@redhat.com, mohan@in.ibm.com, qemu-devel@nongnu.org On 01/16/2014 06:15 PM, Daniel P. Berrange wrote: > On Wed, Jan 08, 2014 at 05:12:54PM +0800, Lei Li wrote: >> Signed-off-by: Lei Li >> --- >> fsdev/virtfs-proxy-helper.c | 51 ++++++------------------------------------ >> hw/9pfs/virtio-9p-proxy.h | 5 ---- >> 2 files changed, 8 insertions(+), 48 deletions(-) >> >> diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c >> index 713a7b2..44c6e61 100644 >> --- a/fsdev/virtfs-proxy-helper.c >> +++ b/fsdev/virtfs-proxy-helper.c >> -static int send_fd(int sockfd, int fd) >> -{ > ... >> - /* No ancillary data on error */ >> - if (fd < 0) { >> - /* fd is really negative errno if the request failed */ >> - data = fd; >> - } else { >> - data = V9FS_FD_VALID; > The way data is initialized here... > >> @@ -784,11 +743,17 @@ static void usage(char *prog) >> static int process_reply(int sock, int type, >> struct iovec *out_iovec, int retval) >> { >> + int data = V9FS_FD_VALID; > > Doesn't match what you do here. Well, it looks like it does not match the original order, because the 'data' has to be passed to the common methods by the parameter *buf first, as there would be different data value set for the check by those callers. But the logical is the same: if the passed_fd is negative, 'data' will be set to the negative fd; otherwise it'll be the check value. > >> + >> switch (type) { >> case T_OPEN: >> case T_CREATE: >> - if (send_fd(sock, retval) < 0) { >> + if (qemu_send_with_fd(sock, retval, &data, sizeof(data)) < 0) { >> return -1; >> + } else { >> + if (retval >= 0) { >> + close(retval); >> + } >> } >> break; >> case T_MKNOD: > Regards, > Daniel -- Lei