mirror of https://github.com/xemu-project/xemu.git
Two fixes for virtfs/9p from Paolo.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlZcWOcACgkQAvw66wEB28J96QCgoMJRcWSdhboxEXPasd9Pc4UK N3EAn2L/vkcFaC6cCt81jZell+jrhzCH =Z5Wi -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging Two fixes for virtfs/9p from Paolo. # gpg: Signature made Mon 30 Nov 2015 14:10:47 GMT using DSA key ID 0101DBC2 # gpg: Good signature from "Greg Kurz <gkurz@fr.ibm.com>" # gpg: aka "Greg Kurz <groug@free.fr>" # gpg: aka "Greg Kurz <gkurz@linux.vnet.ibm.com>" # gpg: aka "Gregory Kurz (Groug) <groug@free.fr>" # gpg: aka "Gregory Kurz (Cimai Technology) <gkurz@cimai.com>" # gpg: aka "Gregory Kurz (Meiosys Technology) <gkurz@meiosys.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 2BD4 3B44 535E C0A7 9894 DBA2 02FC 3AEB 0101 DBC2 * remotes/gkurz/tags/for-upstream: virtio-9p: use QEMU thread pool fsdev-proxy-helper: avoid TOC/TOU race Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
d90eb45902
|
@ -1128,10 +1128,19 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chdir("/") < 0) {
|
||||||
|
do_perror("chdir");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if (chroot(rpath) < 0) {
|
||||||
|
do_perror("chroot");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
get_version = false;
|
get_version = false;
|
||||||
#ifdef FS_IOC_GETVERSION
|
#ifdef FS_IOC_GETVERSION
|
||||||
/* check whether underlying FS support IOC_GETVERSION */
|
/* check whether underlying FS support IOC_GETVERSION */
|
||||||
retval = statfs(rpath, &st_fs);
|
retval = statfs("/", &st_fs);
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
switch (st_fs.f_type) {
|
switch (st_fs.f_type) {
|
||||||
case EXT2_SUPER_MAGIC:
|
case EXT2_SUPER_MAGIC:
|
||||||
|
@ -1144,16 +1153,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (chdir("/") < 0) {
|
|
||||||
do_perror("chdir");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (chroot(rpath) < 0) {
|
|
||||||
do_perror("chroot");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
umask(0);
|
umask(0);
|
||||||
|
|
||||||
if (init_capabilities() < 0) {
|
if (init_capabilities() < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,71 +12,30 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fsdev/qemu-fsdev.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu/thread.h"
|
#include "block/thread-pool.h"
|
||||||
#include "qemu/event_notifier.h"
|
|
||||||
#include "qemu/coroutine.h"
|
#include "qemu/coroutine.h"
|
||||||
|
#include "qemu/main-loop.h"
|
||||||
#include "virtio-9p-coth.h"
|
#include "virtio-9p-coth.h"
|
||||||
|
|
||||||
/* v9fs glib thread pool */
|
/* Called from QEMU I/O thread. */
|
||||||
static V9fsThPool v9fs_pool;
|
static void coroutine_enter_cb(void *opaque, int ret)
|
||||||
|
{
|
||||||
|
Coroutine *co = opaque;
|
||||||
|
qemu_coroutine_enter(co, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called from worker thread. */
|
||||||
|
static int coroutine_enter_func(void *arg)
|
||||||
|
{
|
||||||
|
Coroutine *co = arg;
|
||||||
|
qemu_coroutine_enter(co, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void co_run_in_worker_bh(void *opaque)
|
void co_run_in_worker_bh(void *opaque)
|
||||||
{
|
{
|
||||||
Coroutine *co = opaque;
|
Coroutine *co = opaque;
|
||||||
g_thread_pool_push(v9fs_pool.pool, co, NULL);
|
thread_pool_submit_aio(qemu_get_aio_context()->thread_pool,
|
||||||
}
|
coroutine_enter_func, co, coroutine_enter_cb, co);
|
||||||
|
|
||||||
static void v9fs_qemu_process_req_done(EventNotifier *e)
|
|
||||||
{
|
|
||||||
Coroutine *co;
|
|
||||||
|
|
||||||
event_notifier_test_and_clear(e);
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Coroutine *co = data;
|
|
||||||
|
|
||||||
qemu_coroutine_enter(co, NULL);
|
|
||||||
|
|
||||||
g_async_queue_push(v9fs_pool.completed, co);
|
|
||||||
|
|
||||||
event_notifier_set(&v9fs_pool.e);
|
|
||||||
}
|
|
||||||
|
|
||||||
int v9fs_init_worker_threads(void)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
V9fsThPool *p = &v9fs_pool;
|
|
||||||
sigset_t set, oldset;
|
|
||||||
|
|
||||||
sigfillset(&set);
|
|
||||||
/* Leave signal handling to the iothread. */
|
|
||||||
pthread_sigmask(SIG_SETMASK, &set, &oldset);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
event_notifier_init(&p->e, 0);
|
|
||||||
|
|
||||||
event_notifier_set_handler(&p->e, v9fs_qemu_process_req_done);
|
|
||||||
err_out:
|
|
||||||
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,6 @@
|
||||||
#include "qemu/thread.h"
|
#include "qemu/thread.h"
|
||||||
#include "qemu/coroutine.h"
|
#include "qemu/coroutine.h"
|
||||||
#include "virtio-9p.h"
|
#include "virtio-9p.h"
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
typedef struct V9fsThPool {
|
|
||||||
EventNotifier e;
|
|
||||||
|
|
||||||
GThreadPool *pool;
|
|
||||||
GAsyncQueue *completed;
|
|
||||||
} V9fsThPool;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we want to use bottom half because we want to make sure the below
|
* we want to use bottom half because we want to make sure the below
|
||||||
|
@ -45,7 +37,7 @@ typedef struct V9fsThPool {
|
||||||
qemu_bh_schedule(co_bh); \
|
qemu_bh_schedule(co_bh); \
|
||||||
/* \
|
/* \
|
||||||
* yield in qemu thread and re-enter back \
|
* yield in qemu thread and re-enter back \
|
||||||
* in glib worker thread \
|
* in worker thread \
|
||||||
*/ \
|
*/ \
|
||||||
qemu_coroutine_yield(); \
|
qemu_coroutine_yield(); \
|
||||||
qemu_bh_delete(co_bh); \
|
qemu_bh_delete(co_bh); \
|
||||||
|
|
|
@ -116,10 +116,6 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
|
||||||
" and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root);
|
" and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (v9fs_init_worker_threads() < 0) {
|
|
||||||
error_setg(errp, "worker thread initialization failed");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check details of export path, We need to use fs driver
|
* Check details of export path, We need to use fs driver
|
||||||
|
|
Loading…
Reference in New Issue