From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlHUS-00031Z-Lo for qemu-devel@nongnu.org; Tue, 26 Nov 2013 07:11:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlHUI-0006Dq-C7 for qemu-devel@nongnu.org; Tue, 26 Nov 2013 07:11:40 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:43721) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlHUH-0006De-KO for qemu-devel@nongnu.org; Tue, 26 Nov 2013 07:11:30 -0500 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Nov 2013 22:11:27 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 0CF2F3578050 for ; Tue, 26 Nov 2013 23:11:24 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rAQBrK0a2949628 for ; Tue, 26 Nov 2013 22:53:20 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rAQCBN05015216 for ; Tue, 26 Nov 2013 23:11:23 +1100 Message-ID: <52948FE8.8030206@linux.vnet.ibm.com> Date: Tue, 26 Nov 2013 20:11:20 +0800 From: Lei Li MIME-Version: 1.0 References: <1385025100-3191-1-git-send-email-lilei@linux.vnet.ibm.com> <1385025100-3191-13-git-send-email-lilei@linux.vnet.ibm.com> <52948515.7050207@redhat.com> In-Reply-To: <52948515.7050207@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 12/17] migration-local: override hook_ram_load 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:25 PM, Paolo Bonzini wrote: > Il 21/11/2013 10:11, Lei Li ha scritto: >> +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; >> + >> + /* >> + * PIPE file descriptor will be received by another callback >> + * get_buffer. >> + */ >> + if (pipefd_passed) { >> + void *host; >> + /* >> + * Extract the page address from the 8-byte record and >> + * read the page data from the pipe. >> + */ >> + addr = qemu_get_be64(s->file); >> + host = qemu_get_ram_ptr(addr); >> + >> + iov.iov_base = host; >> + iov.iov_len = TARGET_PAGE_SIZE; >> + >> + /* The flag SPLICE_F_MOVE is introduced in kernel for the page >> + * flipping feature in QEMU, which will movie pages rather than >> + * copying, previously unused. >> + * >> + * If a move is not possible the kernel will transparently falls >> + * back to copying data. >> + * >> + * For older kernels the SPLICE_F_MOVE would be ignored and a copy >> + * would occur. >> + */ >> + ret = vmsplice(s->pipefd[0], &iov, 1, SPLICE_F_MOVE); >> + if (ret == -1) { >> + if (errno != EAGAIN && errno != EINTR) { >> + fprintf(stderr, "vmsplice() load error: %s", strerror(errno)); >> + return ret; >> + } >> + DPRINTF("vmsplice load error\n"); >> + } else if (ret == 0) { >> + DPRINTF(stderr, "load_page: zero read\n"); >> + } >> + >> + DPRINTF("vmsplice (read): %zu\n", ret); >> + return ret; >> + } >> + >> + return 0; >> +} > I think you need to return -EINVAL if there is no pipe. Yes, you are right.. > > Paolo > -- Lei