From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlJCm-0003JH-VQ for qemu-devel@nongnu.org; Tue, 26 Nov 2013 09:01:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlJCd-0007Pu-UG for qemu-devel@nongnu.org; Tue, 26 Nov 2013 09:01:32 -0500 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:50260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlJCd-0007Ol-9X for qemu-devel@nongnu.org; Tue, 26 Nov 2013 09:01:23 -0500 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Nov 2013 19:31:20 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 731133940064 for ; Tue, 26 Nov 2013 19:31:17 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rAQE10e143778192 for ; Tue, 26 Nov 2013 19:31:01 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rAQE133o032595 for ; Tue, 26 Nov 2013 19:31:04 +0530 Message-ID: <5294A99B.3000000@linux.vnet.ibm.com> Date: Tue, 26 Nov 2013 22:00:59 +0800 From: Lei Li MIME-Version: 1.0 References: <1385025100-3191-1-git-send-email-lilei@linux.vnet.ibm.com> <1385025100-3191-9-git-send-email-lilei@linux.vnet.ibm.com> <5294867E.1060203@redhat.com> In-Reply-To: <5294867E.1060203@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 08/17] add unix_msgfd_lookup() to callback get_buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: aarcange@redhat.com, quintela@redhat.com, qemu-devel@nongnu.org, mrhines@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, aliguori@amazon.com, lagarcia@br.ibm.com, rcj@linux.vnet.ibm.com On 11/26/2013 07:31 PM, Paolo Bonzini wrote: > Il 21/11/2013 10:11, Lei Li ha scritto: >> + /* >> + * recvmsg is called here to catch the control message for >> + * the exchange of PIPE file descriptor until it is received. >> + */ >> + len = recvmsg(s->sockfd, &msg, 0); >> + if (len != -1) { >> + if (unix_msgfd_lookup(s, &msg) > 0) { >> + pipefd_passed = 1; >> + /* >> + * Do not count one byte taken by the PIPE file >> + * descriptor. >> + */ >> + len--; > I think adding a byte in the middle of the stream is not reliable. > > Rather, you should transmit the socket always at the same place, for > example in the first call of qemu_local_save_ram, after it has written > the 64-bit field. I guess 'transmit the socket' you mean transmit the fd? Sorry that I am quite understand your suggestion here.. Do you mean that send_pipefd in the first call of qemu_local_save_ram after it has written the 64-bit field? In this way, get rid of qemu_local_send_pipefd? Currently, the fd control message is sent at the end of the stream in ram_save_setup stage, followed by the ram page. The control message of fd is always at the same place. > > The matching code in qemu_local_ram_load will be like this: > > static int qemu_local_ram_load(QEMUFile *f, void *opaque, > uint64_t flags) > { > QEMUFileLocal *s = opaque; > ram_addr_t addr; > struct iovec iov; > ssize_t ret = -EINVAL; > > if (!s->pipefd_received) { > /* > * send_pipefd was called at this point, and it wrote one byte > * to the stream. > */ > qemu_get_byte(s); > s->pipefd_received = true; > } > > if (pipefd_passed) { > ... > } > return -EINVAL; > } > > Also, please move pipefd_passed within QEMUFileLocal. > > Thanks, > > Paolo > -- Lei