From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlGrV-0005tG-7o for qemu-devel@nongnu.org; Tue, 26 Nov 2013 06:31:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlGrM-0001Uk-OL for qemu-devel@nongnu.org; Tue, 26 Nov 2013 06:31:25 -0500 Received: from mail-qe0-x22e.google.com ([2607:f8b0:400d:c02::22e]:55808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlGrM-0001Ub-Jv for qemu-devel@nongnu.org; Tue, 26 Nov 2013 06:31:16 -0500 Received: by mail-qe0-f46.google.com with SMTP id a11so5303592qen.5 for ; Tue, 26 Nov 2013 03:31:16 -0800 (PST) Sender: Paolo Bonzini Message-ID: <5294867E.1060203@redhat.com> Date: Tue, 26 Nov 2013 12:31:10 +0100 From: Paolo Bonzini 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> In-Reply-To: <1385025100-3191-9-git-send-email-lilei@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 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: Lei Li Cc: aarcange@redhat.com, quintela@redhat.com, mdroth@linux.vnet.ibm.com, mrhines@linux.vnet.ibm.com, qemu-devel@nongnu.org, aliguori@amazon.com, lagarcia@br.ibm.com, rcj@linux.vnet.ibm.com 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. 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