Revision 74db920c
b/Makefile.objs | ||
---|---|---|
35 | 35 |
net-nested-$(CONFIG_VDE) += vde.o |
36 | 36 |
net-obj-y += $(addprefix net/, $(net-nested-y)) |
37 | 37 |
|
38 |
fsdev-nested-$(CONFIG_LINUX) = qemu-fsdev.o |
|
39 |
fsdev-obj-$(CONFIG_LINUX) += $(addprefix fsdev/, $(fsdev-nested-y)) |
|
40 |
|
|
38 | 41 |
###################################################################### |
39 | 42 |
# libqemu_common.a: Target independent part of system emulation. The |
40 | 43 |
# long term path is to suppress *all* target specific code in case of |
... | ... | |
44 | 47 |
common-obj-y = $(block-obj-y) |
45 | 48 |
common-obj-y += $(net-obj-y) |
46 | 49 |
common-obj-y += $(qobject-obj-y) |
50 |
common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX)) |
|
47 | 51 |
common-obj-y += readline.o console.o async.o qemu-error.o |
48 |
|
|
49 | 52 |
common-obj-y += tcg-runtime.o host-utils.o |
50 | 53 |
common-obj-y += irq.o ioport.o input.o |
51 | 54 |
common-obj-$(CONFIG_PTIMER) += ptimer.o |
b/configure | ||
---|---|---|
2757 | 2757 |
if test "$source_path_used" = "yes" ; then |
2758 | 2758 |
DIRS="tests tests/cris slirp audio block net pc-bios/optionrom" |
2759 | 2759 |
DIRS="$DIRS roms/seabios roms/vgabios" |
2760 |
DIRS="$DIRS fsdev" |
|
2760 | 2761 |
FILES="Makefile tests/Makefile" |
2761 | 2762 |
FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit" |
2762 | 2763 |
FILES="$FILES tests/test-mmap.c" |
b/fsdev/qemu-fsdev.c | ||
---|---|---|
1 |
/* |
|
2 |
* Virtio 9p |
|
3 |
* |
|
4 |
* Copyright IBM, Corp. 2010 |
|
5 |
* |
|
6 |
* Authors: |
|
7 |
* Gautham R Shenoy <ego@in.ibm.com> |
|
8 |
* |
|
9 |
* This work is licensed under the terms of the GNU GPL, version 2. See |
|
10 |
* the COPYING file in the top-level directory. |
|
11 |
* |
|
12 |
*/ |
|
13 |
#include <stdio.h> |
|
14 |
#include <string.h> |
|
15 |
#include "qemu-fsdev.h" |
|
16 |
#include "qemu-queue.h" |
|
17 |
#include "osdep.h" |
|
18 |
#include "qemu-common.h" |
|
19 |
|
|
20 |
static QTAILQ_HEAD(FsTypeEntry_head, FsTypeListEntry) fstype_entries = |
|
21 |
QTAILQ_HEAD_INITIALIZER(fstype_entries); |
|
22 |
|
|
23 |
static FsTypeTable FsTypes[] = { |
|
24 |
{ .name = "local", .ops = NULL}, |
|
25 |
}; |
|
26 |
|
|
27 |
int qemu_fsdev_add(QemuOpts *opts) |
|
28 |
{ |
|
29 |
struct FsTypeListEntry *fsle; |
|
30 |
int i; |
|
31 |
|
|
32 |
if (qemu_opts_id(opts) == NULL) { |
|
33 |
fprintf(stderr, "fsdev: No id specified\n"); |
|
34 |
return -1; |
|
35 |
} |
|
36 |
|
|
37 |
for (i = 0; i < ARRAY_SIZE(FsTypes); i++) { |
|
38 |
if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0) { |
|
39 |
break; |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
if (i == ARRAY_SIZE(FsTypes)) { |
|
44 |
fprintf(stderr, "fsdev: fstype %s not found\n", |
|
45 |
qemu_opt_get(opts, "fstype")); |
|
46 |
return -1; |
|
47 |
} |
|
48 |
|
|
49 |
fsle = qemu_malloc(sizeof(*fsle)); |
|
50 |
|
|
51 |
fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts)); |
|
52 |
fsle->fse.path = qemu_strdup(qemu_opt_get(opts, "path")); |
|
53 |
fsle->fse.ops = FsTypes[i].ops; |
|
54 |
|
|
55 |
QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next); |
|
56 |
return 0; |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
FsTypeEntry *get_fsdev_fsentry(char *id) |
|
61 |
{ |
|
62 |
struct FsTypeListEntry *fsle; |
|
63 |
|
|
64 |
QTAILQ_FOREACH(fsle, &fstype_entries, next) { |
|
65 |
if (strcmp(fsle->fse.fsdev_id, id) == 0) { |
|
66 |
return &fsle->fse; |
|
67 |
} |
|
68 |
} |
|
69 |
return NULL; |
|
70 |
} |
b/fsdev/qemu-fsdev.h | ||
---|---|---|
1 |
/* |
|
2 |
* Virtio 9p |
|
3 |
* |
|
4 |
* Copyright IBM, Corp. 2010 |
|
5 |
* |
|
6 |
* Authors: |
|
7 |
* Gautham R Shenoy <ego@in.ibm.com> |
|
8 |
* |
|
9 |
* This work is licensed under the terms of the GNU GPL, version 2. See |
|
10 |
* the COPYING file in the top-level directory. |
|
11 |
* |
|
12 |
*/ |
|
13 |
#ifndef QEMU_FSDEV_H |
|
14 |
#define QEMU_FSDEV_H |
|
15 |
#include "qemu-option.h" |
|
16 |
#include "hw/file-op-9p.h" |
|
17 |
|
|
18 |
|
|
19 |
/* |
|
20 |
* A table to store the various file systems and their callback operations. |
|
21 |
* ----------------- |
|
22 |
* fstype | ops |
|
23 |
* ----------------- |
|
24 |
* local | local_ops |
|
25 |
* . | |
|
26 |
* . | |
|
27 |
* . | |
|
28 |
* . | |
|
29 |
* ----------------- |
|
30 |
* etc |
|
31 |
*/ |
|
32 |
typedef struct FsTypeTable { |
|
33 |
const char *name; |
|
34 |
FileOperations *ops; |
|
35 |
} FsTypeTable; |
|
36 |
|
|
37 |
/* |
|
38 |
* Structure to store the various fsdev's passed through command line. |
|
39 |
*/ |
|
40 |
typedef struct FsTypeEntry { |
|
41 |
char *fsdev_id; |
|
42 |
char *path; |
|
43 |
FileOperations *ops; |
|
44 |
} FsTypeEntry; |
|
45 |
|
|
46 |
typedef struct FsTypeListEntry { |
|
47 |
FsTypeEntry fse; |
|
48 |
QTAILQ_ENTRY(FsTypeListEntry) next; |
|
49 |
} FsTypeListEntry; |
|
50 |
|
|
51 |
extern int qemu_fsdev_add(QemuOpts *opts); |
|
52 |
extern FsTypeEntry *get_fsdev_fsentry(char *id); |
|
53 |
#endif |
b/hw/file-op-9p.h | ||
---|---|---|
1 |
/* |
|
2 |
* Virtio 9p |
|
3 |
* |
|
4 |
* Copyright IBM, Corp. 2010 |
|
5 |
* |
|
6 |
* Authors: |
|
7 |
* Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> |
|
8 |
* |
|
9 |
* This work is licensed under the terms of the GNU GPL, version 2. See |
|
10 |
* the COPYING file in the top-level directory. |
|
11 |
* |
|
12 |
*/ |
|
13 |
#ifndef _FILEOP_H |
|
14 |
#define _FILEOP_H |
|
15 |
#include <sys/types.h> |
|
16 |
#include <dirent.h> |
|
17 |
#include <sys/time.h> |
|
18 |
#include <utime.h> |
|
19 |
#include <sys/stat.h> |
|
20 |
#include <sys/uio.h> |
|
21 |
|
|
22 |
typedef struct FsContext |
|
23 |
{ |
|
24 |
char *fs_root; |
|
25 |
uid_t uid; |
|
26 |
} FsContext; |
|
27 |
|
|
28 |
typedef struct FileOperations |
|
29 |
{ |
|
30 |
void *opaque; |
|
31 |
} FileOperations; |
|
32 |
#endif |
b/qemu-config.c | ||
---|---|---|
151 | 151 |
}, |
152 | 152 |
}; |
153 | 153 |
|
154 |
#ifdef CONFIG_LINUX |
|
155 |
QemuOptsList qemu_fsdev_opts = { |
|
156 |
.name = "fsdev", |
|
157 |
.implied_opt_name = "fstype", |
|
158 |
.head = QTAILQ_HEAD_INITIALIZER(qemu_fsdev_opts.head), |
|
159 |
.desc = { |
|
160 |
{ |
|
161 |
.name = "fstype", |
|
162 |
.type = QEMU_OPT_STRING, |
|
163 |
}, { |
|
164 |
.name = "path", |
|
165 |
.type = QEMU_OPT_STRING, |
|
166 |
}, |
|
167 |
{ /*End of list */ } |
|
168 |
}, |
|
169 |
}; |
|
170 |
#endif |
|
171 |
|
|
154 | 172 |
QemuOptsList qemu_device_opts = { |
155 | 173 |
.name = "device", |
156 | 174 |
.implied_opt_name = "driver", |
b/qemu-config.h | ||
---|---|---|
3 | 3 |
|
4 | 4 |
extern QemuOptsList qemu_drive_opts; |
5 | 5 |
extern QemuOptsList qemu_chardev_opts; |
6 |
#ifdef CONFIG_LINUX |
|
7 |
extern QemuOptsList qemu_fsdev_opts; |
|
8 |
#endif |
|
6 | 9 |
extern QemuOptsList qemu_device_opts; |
7 | 10 |
extern QemuOptsList qemu_netdev_opts; |
8 | 11 |
extern QemuOptsList qemu_net_opts; |
b/qemu-options.hx | ||
---|---|---|
478 | 478 |
@code{-device @var{driver},@var{option}=?}. |
479 | 479 |
ETEXI |
480 | 480 |
|
481 |
#ifdef CONFIG_LINUX |
|
482 |
DEFHEADING(File system options:) |
|
483 |
|
|
484 |
DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, |
|
485 |
"-fsdev local,id=id,path=path\n", |
|
486 |
QEMU_ARCH_ALL) |
|
487 |
|
|
488 |
STEXI |
|
489 |
|
|
490 |
The general form of a File system device option is: |
|
491 |
@table @option |
|
492 |
|
|
493 |
@item -fsdev @var{fstype} ,id=@var{id} [,@var{options}] |
|
494 |
@findex -fsdev |
|
495 |
Fstype is one of: |
|
496 |
@option{local}, |
|
497 |
The specific Fstype will determine the applicable options. |
|
498 |
|
|
499 |
Options to each backend are described below. |
|
500 |
|
|
501 |
@item -fsdev local ,id=@var{id} ,path=@var{path} |
|
502 |
|
|
503 |
Create a file-system-"device" for local-filesystem. |
|
504 |
|
|
505 |
@option{local} is only available on Linux. |
|
506 |
|
|
507 |
@option{path} specifies the path to be exported. @option{path} is required. |
|
508 |
|
|
509 |
@end table |
|
510 |
ETEXI |
|
511 |
#endif |
|
512 |
|
|
513 |
DEFHEADING() |
|
514 |
|
|
481 | 515 |
DEF("name", HAS_ARG, QEMU_OPTION_name, |
482 | 516 |
"-name string1[,process=string2]\n" |
483 | 517 |
" set the name of the guest\n" |
b/vl.c | ||
---|---|---|
149 | 149 |
#include "qemu-option.h" |
150 | 150 |
#include "qemu-config.h" |
151 | 151 |
#include "qemu-objects.h" |
152 |
#ifdef CONFIG_LINUX |
|
153 |
#include "fsdev/qemu-fsdev.h" |
|
154 |
#endif |
|
152 | 155 |
|
153 | 156 |
#include "disas.h" |
154 | 157 |
|
... | ... | |
2310 | 2313 |
return 0; |
2311 | 2314 |
} |
2312 | 2315 |
|
2316 |
#ifdef CONFIG_LINUX |
|
2317 |
static int fsdev_init_func(QemuOpts *opts, void *opaque) |
|
2318 |
{ |
|
2319 |
int ret; |
|
2320 |
ret = qemu_fsdev_add(opts); |
|
2321 |
|
|
2322 |
return ret; |
|
2323 |
} |
|
2324 |
#endif |
|
2325 |
|
|
2313 | 2326 |
static int mon_init_func(QemuOpts *opts, void *opaque) |
2314 | 2327 |
{ |
2315 | 2328 |
CharDriverState *chr; |
... | ... | |
3081 | 3094 |
exit(1); |
3082 | 3095 |
} |
3083 | 3096 |
break; |
3097 |
#ifdef CONFIG_LINUX |
|
3098 |
case QEMU_OPTION_fsdev: |
|
3099 |
opts = qemu_opts_parse(&qemu_fsdev_opts, optarg, 1); |
|
3100 |
if (!opts) { |
|
3101 |
fprintf(stderr, "parse error: %s\n", optarg); |
|
3102 |
exit(1); |
|
3103 |
} |
|
3104 |
break; |
|
3105 |
#endif |
|
3084 | 3106 |
case QEMU_OPTION_serial: |
3085 | 3107 |
add_device_config(DEV_SERIAL, optarg); |
3086 | 3108 |
default_serial = 0; |
... | ... | |
3437 | 3459 |
|
3438 | 3460 |
if (qemu_opts_foreach(&qemu_chardev_opts, chardev_init_func, NULL, 1) != 0) |
3439 | 3461 |
exit(1); |
3462 |
#ifdef CONFIG_LINUX |
|
3463 |
if (qemu_opts_foreach(&qemu_fsdev_opts, fsdev_init_func, NULL, 1) != 0) { |
|
3464 |
exit(1); |
|
3465 |
} |
|
3466 |
#endif |
|
3440 | 3467 |
|
3441 | 3468 |
#ifndef _WIN32 |
3442 | 3469 |
if (daemonize) { |
Also available in: Unified diff