summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2014-07-01 17:12:05 +0900
committerSooyoung Ha <yoosah.ha@samsung.com>2014-07-02 14:48:29 +0900
commit29001b79191fa5aa70ba217540de8534d652c92a (patch)
treefb097df1ec648232b6057496bacfe0b0222f03f8 /hw
parent7a0aee5d236d6aade91fb19727e1bbae2ea72886 (diff)
downloadqemu-29001b79191fa5aa70ba217540de8534d652c92a.tar.gz
qemu-29001b79191fa5aa70ba217540de8534d652c92a.tar.bz2
qemu-29001b79191fa5aa70ba217540de8534d652c92a.zip
9pfs: use event_notifier instead of qemu_pipe
Change-Id: I5b2c51ef18849fa6f29e126ef889dcff86cad645 Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com> Signed-off-by: Sooyoung Ha <yoosah.ha@samsung.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/9pfs/Makefile.objs22
-rw-r--r--hw/9pfs/virtio-9p-coth-maru.c161
-rw-r--r--hw/9pfs/virtio-9p-coth.c32
-rw-r--r--hw/9pfs/virtio-9p-coth.h4
4 files changed, 21 insertions, 198 deletions
diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs
index 7e9264c92e..6bd86c1d30 100644
--- a/hw/9pfs/Makefile.objs
+++ b/hw/9pfs/Makefile.objs
@@ -1,7 +1,14 @@
ifeq ($(CONFIG_MARU),y)
common-obj-y = virtio-9p-maru.o
common-obj-y += virtio-9p-local-maru.o
-common-obj-y += virtio-9p-coth-maru.o cofs.o codir.o cofile.o
+endif
+
+ifneq ($(CONFIG_MARU),y)
+common-obj-y = virtio-9p.o
+common-obj-y += virtio-9p-local.o
+endif
+
+common-obj-y += virtio-9p-coth.o cofs.o codir.o cofile.o
ifneq ($(CONFIG_WIN32),y)
common-obj-y += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
common-obj-y += virtio-9p-xattr.o coxattr.o
@@ -11,16 +18,3 @@ common-obj-$(CONFIG_LINUX) += virtio-9p-proxy.o
common-obj-$(CONFIG_OPEN_BY_HANDLE) += virtio-9p-handle.o
obj-y += virtio-9p-device.o
-endif
-
-ifneq ($(CONFIG_MARU),y)
-common-obj-y = virtio-9p.o
-common-obj-y += virtio-9p-local.o virtio-9p-xattr.o
-common-obj-y += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
-common-obj-y += virtio-9p-coth.o cofs.o codir.o cofile.o
-common-obj-y += coxattr.o virtio-9p-synth.o
-common-obj-$(CONFIG_OPEN_BY_HANDLE) += virtio-9p-handle.o
-common-obj-y += virtio-9p-proxy.o
-
-obj-y += virtio-9p-device.o
-endif
diff --git a/hw/9pfs/virtio-9p-coth-maru.c b/hw/9pfs/virtio-9p-coth-maru.c
deleted file mode 100644
index d86a302f0b..0000000000
--- a/hw/9pfs/virtio-9p-coth-maru.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Virtio 9p backend for Maru
- * Based on hw/9pfs/virtio-9p-coth.c:
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact:
- * Sooyoung Ha <yoosah.ha@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "fsdev/qemu-fsdev.h"
-#include "qemu/thread.h"
-#include "block/coroutine.h"
-#include "virtio-9p-coth.h"
-
-#ifdef CONFIG_WIN32
-#include <winsock2.h>
-#endif
-
-#include "../../tizen/src/debug_ch.h"
-MULTI_DEBUG_CHANNEL(tizen, qemu_9p_coth);
-
-/* v9fs glib thread pool */
-static V9fsThPool v9fs_pool;
-
-void co_run_in_worker_bh(void *opaque)
-{
- Coroutine *co = opaque;
- g_thread_pool_push(v9fs_pool.pool, co, NULL);
-}
-
-static void v9fs_qemu_process_req_done(void *arg)
-{
- char byte;
- ssize_t len;
- Coroutine *co;
-
- do {
-#ifndef CONFIG_WIN32
- len = read(v9fs_pool.rfd, &byte, sizeof(byte));
-#else
- struct sockaddr_in saddr;
- int recv_size = sizeof(saddr);
- len = recvfrom((SOCKET)v9fs_pool.rfd, &byte, sizeof(byte), 0, (struct sockaddr *)&saddr, &recv_size);
-#endif
- } while (len == -1 && errno == EINTR);
-
- while ((co = g_async_queue_try_pop(v9fs_pool.completed)) != NULL) {
- qemu_coroutine_enter(co, NULL);
- }
-}
-
-static void v9fs_thread_routine(gpointer data, gpointer user_data)
-{
- ssize_t len = 0;
- char byte = 0;
- Coroutine *co = data;
-
- qemu_coroutine_enter(co, NULL);
-
- g_async_queue_push(v9fs_pool.completed, co);
- do {
-#ifndef CONFIG_WIN32
- len = write(v9fs_pool.wfd, &byte, sizeof(byte));
-#else
- struct sockaddr_in saddr;
- saddr.sin_family = AF_INET;
- saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
- saddr.sin_port=htons(9190);
- len = sendto((SOCKET)v9fs_pool.wfd, &byte, sizeof(byte), 0, (const struct sockaddr *)&saddr, sizeof(saddr));
-#endif
- } while (len == -1 && errno == EINTR);
-}
-
-int v9fs_init_worker_threads(void)
-{
- TRACE("[%d][ Enter >> %s]\n", __LINE__, __func__);
- int ret = 0;
- V9fsThPool *p = &v9fs_pool;
-#ifndef CONFIG_WIN32
- int notifier_fds[2];
- sigset_t set, oldset;
-
- sigfillset(&set);
- /* Leave signal handling to the iothread. */
- pthread_sigmask(SIG_SETMASK, &set, &oldset);
-
- if (qemu_pipe(notifier_fds) == -1) {
- ret = -1;
- goto err_out;
- }
-#else
- WSADATA wsadata;
- struct sockaddr_in saddr;
-
- WSAStartup(MAKEWORD(2,2),&wsadata);
-
- SOCKET pSock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
- saddr.sin_family = AF_INET;
- saddr.sin_addr.s_addr = htonl(INADDR_ANY);
- saddr.sin_port=htons(9190);
-
- if(bind(pSock, (const struct sockaddr *)&saddr, sizeof(saddr)) == -1){
- ERR("[%d][%s] >> bind err: %d \n", __LINE__, __func__, WSAGetLastError());
- } else {
- TRACE("[%d][%s] >> bind ok\n", __LINE__, __func__);
- }
-#endif
- p->pool = g_thread_pool_new(v9fs_thread_routine, p, -1, FALSE, NULL);
- if (!p->pool) {
- ret = -1;
- goto err_out;
- }
- p->completed = g_async_queue_new();
- if (!p->completed) {
- /*
- * We are going to terminate.
- * So don't worry about cleanup
- */
- ret = -1;
- goto err_out;
- }
-#ifndef CONFIG_WIN32
- p->rfd = notifier_fds[0];
- p->wfd = notifier_fds[1];
-
- fcntl(p->rfd, F_SETFL, O_NONBLOCK);
- fcntl(p->wfd, F_SETFL, O_NONBLOCK);
-#else
- p->rfd = (int)pSock;
- p->wfd = (int)pSock;
-#endif
-
- qemu_set_fd_handler(p->rfd, v9fs_qemu_process_req_done, NULL, NULL);
-err_out:
-#ifndef CONFIG_WIN32
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
-#endif
- TRACE("[%d][ Leave >> %s]\n", __LINE__, __func__);
- return ret;
-}
diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c
index ae6cde8005..99056f1215 100644
--- a/hw/9pfs/virtio-9p-coth.c
+++ b/hw/9pfs/virtio-9p-coth.c
@@ -14,6 +14,7 @@
#include "fsdev/qemu-fsdev.h"
#include "qemu/thread.h"
+#include "qemu/event_notifier.h"
#include "block/coroutine.h"
#include "virtio-9p-coth.h"
@@ -26,15 +27,11 @@ void co_run_in_worker_bh(void *opaque)
g_thread_pool_push(v9fs_pool.pool, co, NULL);
}
-static void v9fs_qemu_process_req_done(void *arg)
+static void v9fs_qemu_process_req_done(EventNotifier *e)
{
- char byte;
- ssize_t len;
Coroutine *co;
- do {
- len = read(v9fs_pool.rfd, &byte, sizeof(byte));
- } while (len == -1 && errno == EINTR);
+ event_notifier_test_and_clear(e);
while ((co = g_async_queue_try_pop(v9fs_pool.completed)) != NULL) {
qemu_coroutine_enter(co, NULL);
@@ -43,33 +40,27 @@ static void v9fs_qemu_process_req_done(void *arg)
static void v9fs_thread_routine(gpointer data, gpointer user_data)
{
- ssize_t len;
- char byte = 0;
Coroutine *co = data;
qemu_coroutine_enter(co, NULL);
g_async_queue_push(v9fs_pool.completed, co);
- do {
- len = write(v9fs_pool.wfd, &byte, sizeof(byte));
- } while (len == -1 && errno == EINTR);
+
+ event_notifier_set(&v9fs_pool.e);
}
int v9fs_init_worker_threads(void)
{
int ret = 0;
- int notifier_fds[2];
V9fsThPool *p = &v9fs_pool;
+#ifndef __WIN32
sigset_t set, oldset;
sigfillset(&set);
/* Leave signal handling to the iothread. */
pthread_sigmask(SIG_SETMASK, &set, &oldset);
+#endif
- if (qemu_pipe(notifier_fds) == -1) {
- ret = -1;
- goto err_out;
- }
p->pool = g_thread_pool_new(v9fs_thread_routine, p, -1, FALSE, NULL);
if (!p->pool) {
ret = -1;
@@ -84,14 +75,13 @@ int v9fs_init_worker_threads(void)
ret = -1;
goto err_out;
}
- p->rfd = notifier_fds[0];
- p->wfd = notifier_fds[1];
- fcntl(p->rfd, F_SETFL, O_NONBLOCK);
- fcntl(p->wfd, F_SETFL, O_NONBLOCK);
+ event_notifier_init(&p->e, 0);
- qemu_set_fd_handler(p->rfd, v9fs_qemu_process_req_done, NULL, NULL);
+ event_notifier_set_handler(&p->e, v9fs_qemu_process_req_done);
err_out:
+#ifndef __WIN32
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+#endif
return ret;
}
diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h
index 86d5ed4169..4f51b250d1 100644
--- a/hw/9pfs/virtio-9p-coth.h
+++ b/hw/9pfs/virtio-9p-coth.h
@@ -21,8 +21,8 @@
#include <glib.h>
typedef struct V9fsThPool {
- int rfd;
- int wfd;
+ EventNotifier e;
+
GThreadPool *pool;
GAsyncQueue *completed;
} V9fsThPool;