From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlGlg-0002pj-21 for qemu-devel@nongnu.org; Tue, 26 Nov 2013 06:25:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlGlX-0007w3-LL for qemu-devel@nongnu.org; Tue, 26 Nov 2013 06:25:23 -0500 Received: from mail-qe0-x233.google.com ([2607:f8b0:400d:c02::233]:49354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlGlX-0007vz-Gp for qemu-devel@nongnu.org; Tue, 26 Nov 2013 06:25:15 -0500 Received: by mail-qe0-f51.google.com with SMTP id 1so3306107qee.10 for ; Tue, 26 Nov 2013 03:25:15 -0800 (PST) Sender: Paolo Bonzini Message-ID: <52948515.7050207@redhat.com> Date: Tue, 26 Nov 2013 12:25:09 +0100 From: Paolo Bonzini 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> In-Reply-To: <1385025100-3191-13-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 12/17] migration-local: override hook_ram_load 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: > +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. Paolo