[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/5] qemu-bridge-helper: replace send_fd with qemu_s
From: |
Lei Li |
Subject: |
[Qemu-devel] [PATCH 2/5] qemu-bridge-helper: replace send_fd with qemu_send_with_fd |
Date: |
Thu, 23 Jan 2014 16:27:40 +0800 |
Signed-off-by: Lei Li <address@hidden>
---
Makefile | 2 +-
qemu-bridge-helper.c | 31 +++----------------------------
2 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/Makefile b/Makefile
index bdff4e4..6850f35 100644
--- a/Makefile
+++ b/Makefile
@@ -195,7 +195,7 @@ qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a
libqemustub.a
qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
-qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
+qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o libqemuutil.a
fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o
fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c
index 6a0974e..8303b6b 100644
--- a/qemu-bridge-helper.c
+++ b/qemu-bridge-helper.c
@@ -40,6 +40,7 @@
#endif
#include "qemu/queue.h"
+#include "qemu/fd-exchange.h"
#include "net/tap-linux.h"
@@ -174,33 +175,6 @@ static void prep_ifreq(struct ifreq *ifr, const char
*ifname)
snprintf(ifr->ifr_name, IFNAMSIZ, "%s", ifname);
}
-static int send_fd(int c, int fd)
-{
- char msgbuf[CMSG_SPACE(sizeof(fd))];
- struct msghdr msg = {
- .msg_control = msgbuf,
- .msg_controllen = sizeof(msgbuf),
- };
- struct cmsghdr *cmsg;
- struct iovec iov;
- char req[1] = { 0x00 };
-
- cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
- msg.msg_controllen = cmsg->cmsg_len;
-
- iov.iov_base = req;
- iov.iov_len = sizeof(req);
-
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
- memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
-
- return sendmsg(c, &msg, 0);
-}
-
#ifdef CONFIG_LIBCAP
static int drop_privileges(void)
{
@@ -239,6 +213,7 @@ int main(int argc, char **argv)
ACLList acl_list;
int access_allowed, access_denied;
int ret = EXIT_SUCCESS;
+ char req[1] = { 0x00 };
#ifdef CONFIG_LIBCAP
/* if we're run from an suid binary, immediately drop privileges preserving
@@ -424,7 +399,7 @@ int main(int argc, char **argv)
}
/* write fd to the domain socket */
- if (send_fd(unixfd, fd) == -1) {
+ if (qemu_send_with_fd(unixfd, fd, &req, sizeof(req)) == -1) {
fprintf(stderr, "failed to write fd to unix socket: %s\n",
strerror(errno));
ret = EXIT_FAILURE;
--
1.7.7.6
- [Qemu-devel] [PATCH 0/5 v2] Provide common methods for exchange FD, Lei Li, 2014/01/23
- [Qemu-devel] [PATCH 2/5] qemu-bridge-helper: replace send_fd with qemu_send_with_fd,
Lei Li <=
- [Qemu-devel] [PATCH 1/5] qemu-fd-exchange: provide common methods for exchange fd, Lei Li, 2014/01/23
- [Qemu-devel] [PATCH 4/5] virtfs-proxy-helper: replace send_fd with qemu_send_with_fd, Lei Li, 2014/01/23
- [Qemu-devel] [PATCH 5/5] virtio-9p-proxy: replace v9fs_receivefd with qemu_recv_with_fd, Lei Li, 2014/01/23
- [Qemu-devel] [PATCH 3/5] net/tap: replace recv_fd with qemu_recv_with_fd, Lei Li, 2014/01/23
- Re: [Qemu-devel] [PATCH 0/5 v2] Provide common methods for exchange FD, Antonios Motakis, 2014/01/23