Revision 9f506893 fsdev/qemu-fsdev.c

b/fsdev/qemu-fsdev.c
29 29
{
30 30
    struct FsTypeListEntry *fsle;
31 31
    int i;
32
    const char *fsdev_id = qemu_opts_id(opts);
33
    const char *fstype = qemu_opt_get(opts, "fstype");
34
    const char *path = qemu_opt_get(opts, "path");
35
    const char *sec_model = qemu_opt_get(opts, "security_model");
32 36

  
33
    if (qemu_opts_id(opts) == NULL) {
37
    if (!fsdev_id) {
34 38
        fprintf(stderr, "fsdev: No id specified\n");
35 39
        return -1;
36 40
    }
37 41

  
38
    for (i = 0; i < ARRAY_SIZE(FsTypes); i++) {
39
        if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0) {
40
            break;
42
    if (fstype) {
43
        for (i = 0; i < ARRAY_SIZE(FsTypes); i++) {
44
            if (strcmp(FsTypes[i].name, fstype) == 0) {
45
                break;
46
            }
41 47
        }
42
    }
43 48

  
44
    if (i == ARRAY_SIZE(FsTypes)) {
45
        fprintf(stderr, "fsdev: fstype %s not found\n",
46
                    qemu_opt_get(opts, "fstype"));
49
        if (i == ARRAY_SIZE(FsTypes)) {
50
            fprintf(stderr, "fsdev: fstype %s not found\n", fstype);
51
            return -1;
52
        }
53
    } else {
54
        fprintf(stderr, "fsdev: No fstype specified\n");
47 55
        return -1;
48 56
    }
49 57

  
50
    if (qemu_opt_get(opts, "security_model") == NULL) {
58
    if (!sec_model) {
51 59
        fprintf(stderr, "fsdev: No security_model specified.\n");
52 60
        return -1;
53 61
    }
54 62

  
63
    if (!path) {
64
        fprintf(stderr, "fsdev: No path specified.\n");
65
        return -1;
66
    }
67

  
55 68
    fsle = qemu_malloc(sizeof(*fsle));
56 69

  
57
    fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts));
58
    fsle->fse.path = qemu_strdup(qemu_opt_get(opts, "path"));
59
    fsle->fse.security_model = qemu_strdup(qemu_opt_get(opts,
60
                "security_model"));
70
    fsle->fse.fsdev_id = qemu_strdup(fsdev_id);
71
    fsle->fse.path = qemu_strdup(path);
72
    fsle->fse.security_model = qemu_strdup(sec_model);
61 73
    fsle->fse.ops = FsTypes[i].ops;
62 74

  
63 75
    QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next);
......
67 79

  
68 80
FsTypeEntry *get_fsdev_fsentry(char *id)
69 81
{
70
    struct FsTypeListEntry *fsle;
82
    if (id) {
83
        struct FsTypeListEntry *fsle;
71 84

  
72
    QTAILQ_FOREACH(fsle, &fstype_entries, next) {
73
        if (strcmp(fsle->fse.fsdev_id, id) == 0) {
74
            return &fsle->fse;
85
        QTAILQ_FOREACH(fsle, &fstype_entries, next) {
86
            if (strcmp(fsle->fse.fsdev_id, id) == 0) {
87
                return &fsle->fse;
88
            }
75 89
        }
76 90
    }
77 91
    return NULL;

Also available in: Unified diff