Revision e14ea479 vl.c
b/vl.c | ||
---|---|---|
2447 | 2447 |
} |
2448 | 2448 |
break; |
2449 | 2449 |
case QEMU_OPTION_virtfs: { |
2450 |
char *arg_fsdev = NULL; |
|
2451 |
char *arg_9p = NULL; |
|
2452 |
int len = 0; |
|
2450 |
QemuOpts *fsdev; |
|
2451 |
QemuOpts *device; |
|
2453 | 2452 |
|
2454 | 2453 |
olist = qemu_find_opts("virtfs"); |
2455 | 2454 |
if (!olist) { |
... | ... | |
2468 | 2467 |
qemu_opt_get(opts, "security_model") == NULL) { |
2469 | 2468 |
fprintf(stderr, "Usage: -virtfs fstype,path=/share_path/," |
2470 | 2469 |
"security_model=[mapped|passthrough|none]," |
2471 |
"mnt_tag=tag.\n"); |
|
2470 |
"mount_tag=tag.\n");
|
|
2472 | 2471 |
exit(1); |
2473 | 2472 |
} |
2474 | 2473 |
|
2475 |
len = strlen(",id=,path=,security_model="); |
|
2476 |
len += strlen(qemu_opt_get(opts, "fstype")); |
|
2477 |
len += strlen(qemu_opt_get(opts, "mount_tag")); |
|
2478 |
len += strlen(qemu_opt_get(opts, "path")); |
|
2479 |
len += strlen(qemu_opt_get(opts, "security_model")); |
|
2480 |
arg_fsdev = qemu_malloc((len + 1) * sizeof(*arg_fsdev)); |
|
2481 |
|
|
2482 |
snprintf(arg_fsdev, (len + 1) * sizeof(*arg_fsdev), |
|
2483 |
"%s,id=%s,path=%s,security_model=%s", |
|
2484 |
qemu_opt_get(opts, "fstype"), |
|
2485 |
qemu_opt_get(opts, "mount_tag"), |
|
2486 |
qemu_opt_get(opts, "path"), |
|
2487 |
qemu_opt_get(opts, "security_model")); |
|
2488 |
|
|
2489 |
len = strlen("virtio-9p,fsdev=,mount_tag="); |
|
2490 |
len += 2*strlen(qemu_opt_get(opts, "mount_tag")); |
|
2491 |
arg_9p = qemu_malloc((len + 1) * sizeof(*arg_9p)); |
|
2492 |
|
|
2493 |
snprintf(arg_9p, (len + 1) * sizeof(*arg_9p), |
|
2494 |
"virtio-9p,fsdev=%s,mount_tag=%s", |
|
2495 |
qemu_opt_get(opts, "mount_tag"), |
|
2496 |
qemu_opt_get(opts, "mount_tag")); |
|
2497 |
|
|
2498 |
if (!qemu_opts_parse(qemu_find_opts("fsdev"), arg_fsdev, 1)) { |
|
2499 |
fprintf(stderr, "parse error [fsdev]: %s\n", optarg); |
|
2474 |
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), |
|
2475 |
qemu_opt_get(opts, "mount_tag"), 1); |
|
2476 |
if (!fsdev) { |
|
2477 |
fprintf(stderr, "duplicate fsdev id: %s\n", |
|
2478 |
qemu_opt_get(opts, "mount_tag")); |
|
2500 | 2479 |
exit(1); |
2501 | 2480 |
} |
2502 |
|
|
2503 |
if (!qemu_opts_parse(qemu_find_opts("device"), arg_9p, 1)) { |
|
2504 |
fprintf(stderr, "parse error [device]: %s\n", optarg); |
|
2505 |
exit(1); |
|
2506 |
} |
|
2507 |
|
|
2508 |
qemu_free(arg_fsdev); |
|
2509 |
qemu_free(arg_9p); |
|
2481 |
qemu_opt_set(fsdev, "fstype", qemu_opt_get(opts, "fstype")); |
|
2482 |
qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path")); |
|
2483 |
qemu_opt_set(fsdev, "security_model", |
|
2484 |
qemu_opt_get(opts, "security_model")); |
|
2485 |
|
|
2486 |
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0); |
|
2487 |
qemu_opt_set(device, "driver", "virtio-9p-pci"); |
|
2488 |
qemu_opt_set(device, "fsdev", |
|
2489 |
qemu_opt_get(opts, "mount_tag")); |
|
2490 |
qemu_opt_set(device, "mount_tag", |
|
2491 |
qemu_opt_get(opts, "mount_tag")); |
|
2510 | 2492 |
break; |
2511 | 2493 |
} |
2512 | 2494 |
case QEMU_OPTION_serial: |
Also available in: Unified diff