From: Lei Li <lilei@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mohan@in.ibm.com, Lei Li <lilei@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 6/6] migration-local: replace send_pipefd with qemu_send_with_fd
Date: Wed, 8 Jan 2014 17:12:56 +0800 [thread overview]
Message-ID: <1389172376-30636-7-git-send-email-lilei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1389172376-30636-1-git-send-email-lilei@linux.vnet.ibm.com>
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
---
migration-local.c | 52 +++-------------------------------------------------
1 files changed, 3 insertions(+), 49 deletions(-)
diff --git a/migration-local.c b/migration-local.c
index ce4c070..c01ba06 100644
--- a/migration-local.c
+++ b/migration-local.c
@@ -26,6 +26,7 @@
#include "sysemu/sysemu.h"
#include "block/block.h"
#include "qemu/sockets.h"
+#include "qemu/fd-exchange.h"
#include "migration/block.h"
#include "qemu/thread.h"
#include "qmp-commands.h"
@@ -169,8 +170,6 @@ static int qemu_local_close(void *opaque)
return 0;
}
-static int send_pipefd(int sockfd, int pipefd);
-
static size_t qemu_local_save_ram(QEMUFile *f, void *opaque,
MemoryRegion *mr, ram_addr_t offset,
size_t size, int *bytes_sent)
@@ -179,13 +178,14 @@ static size_t qemu_local_save_ram(QEMUFile *f, void *opaque,
ram_addr_t current_addr = mr->ram_addr + offset;
void *ram_addr;
ssize_t ret;
+ char req[1] = { 0x01 };
if (s->unix_page_flipping) {
qemu_put_be64(s->file, current_addr | RAM_SAVE_FLAG_HOOK);
qemu_fflush(s->file);
if (!s->pipefd_passed) {
- ret = send_pipefd(s->sockfd, s->pipefd[0]);
+ ret = qemu_send_with_fd(s->sockfd, s->pipefd[0], &req, sizeof(req));
if (ret < 0) {
fprintf(stderr, "failed to pass PIPE\n");
return ret;
@@ -342,49 +342,3 @@ fail:
g_free(s);
return NULL;
}
-
-
-/*
- * Pass a pipe file descriptor to another process.
- *
- * Return negative value If pipefd < 0. Return 0 on
- * success.
- *
- */
-static int send_pipefd(int sockfd, int pipefd)
-{
- struct msghdr msg;
- struct iovec iov[1];
- ssize_t ret;
- char req[1] = { 0x01 };
-
- union {
- struct cmsghdr cm;
- char control[CMSG_SPACE(sizeof(int))];
- } control_un;
- struct cmsghdr *cmptr;
-
- msg.msg_control = control_un.control;
- msg.msg_controllen = sizeof(control_un.control);
-
- cmptr = CMSG_FIRSTHDR(&msg);
- cmptr->cmsg_len = CMSG_LEN(sizeof(int));
- cmptr->cmsg_level = SOL_SOCKET;
- cmptr->cmsg_type = SCM_RIGHTS;
- *((int *) CMSG_DATA(cmptr)) = pipefd;
-
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
-
- iov[0].iov_base = req;
- iov[0].iov_len = sizeof(req);
- msg.msg_iov = iov;
- msg.msg_iovlen = 1;
-
- ret = sendmsg(sockfd, &msg, 0);
- if (ret <= 0) {
- DPRINTF("sendmsg error: %s\n", strerror(errno));
- }
-
- return ret;
-}
--
1.7.7.6
next prev parent reply other threads:[~2014-01-08 9:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-08 9:12 [Qemu-devel] [PATCH resend 0/6 RFC] Provide common methods for exchange FD Lei Li
2014-01-08 9:12 ` [Qemu-devel] [PATCH 1/6] qemu-fd-exchange: provide common methods for exchange fd Lei Li
2014-01-16 15:16 ` Eric Blake
2014-01-17 3:40 ` Lei Li
2014-01-16 15:26 ` Eric Blake
2014-01-17 3:41 ` Lei Li
2014-01-17 10:02 ` Daniel P. Berrange
2014-01-20 1:50 ` Lei Li
2014-01-08 9:12 ` [Qemu-devel] [PATCH 2/6] qemu-bridge-helper: replace send_fd with qemu_send_with_fd Lei Li
2014-01-08 9:12 ` [Qemu-devel] [PATCH 3/6] net/tap: replace recv_fd with qemu_recv_with_fd Lei Li
2014-01-08 9:12 ` [Qemu-devel] [PATCH 4/6] virtfs-proxy-helper: replace send_fd with qemu_send_with_fd Lei Li
2014-01-16 10:15 ` Daniel P. Berrange
2014-01-17 3:40 ` Lei Li
2014-01-08 9:12 ` [Qemu-devel] [PATCH 5/6] virtio-9p-proxy: replace v9fs_receivefd with qemu_recv_with_fd Lei Li
2014-01-16 10:16 ` Daniel P. Berrange
2014-01-17 3:40 ` Lei Li
2014-01-08 9:12 ` Lei Li [this message]
2014-01-16 9:26 ` [Qemu-devel] [PATCH resend 0/6 RFC] Provide common methods for exchange FD Lei Li
2014-01-16 10:17 ` Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389172376-30636-7-git-send-email-lilei@linux.vnet.ibm.com \
--to=lilei@linux.vnet.ibm.com \
--cc=mohan@in.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).