diff options
author | Harsh Prateek Bora <harsh@linux.vnet.ibm.com> | 2010-10-18 15:36:36 +0530 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-10-20 12:10:58 -0500 |
commit | 9f506893a454ce24263aba49594aa953e9a52853 (patch) | |
tree | 9decd82cbe79795c2cd8a2f6e8b4c4572884c59a /fsdev | |
parent | 70fc55ebe4fe5e72802468f16ae09169cf323b04 (diff) | |
download | qemu-9f506893a454ce24263aba49594aa953e9a52853.zip qemu-9f506893a454ce24263aba49594aa953e9a52853.tar.gz qemu-9f506893a454ce24263aba49594aa953e9a52853.tar.bz2 |
[virtio-9p] Qemu 9p commandline options validity checks
Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Diffstat (limited to 'fsdev')
-rw-r--r-- | fsdev/qemu-fsdev.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 280b8f5..0b33290 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -29,35 +29,47 @@ int qemu_fsdev_add(QemuOpts *opts) { struct FsTypeListEntry *fsle; int i; + const char *fsdev_id = qemu_opts_id(opts); + const char *fstype = qemu_opt_get(opts, "fstype"); + const char *path = qemu_opt_get(opts, "path"); + const char *sec_model = qemu_opt_get(opts, "security_model"); - if (qemu_opts_id(opts) == NULL) { + if (!fsdev_id) { fprintf(stderr, "fsdev: No id specified\n"); return -1; } - for (i = 0; i < ARRAY_SIZE(FsTypes); i++) { - if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0) { - break; + if (fstype) { + for (i = 0; i < ARRAY_SIZE(FsTypes); i++) { + if (strcmp(FsTypes[i].name, fstype) == 0) { + break; + } } - } - if (i == ARRAY_SIZE(FsTypes)) { - fprintf(stderr, "fsdev: fstype %s not found\n", - qemu_opt_get(opts, "fstype")); + if (i == ARRAY_SIZE(FsTypes)) { + fprintf(stderr, "fsdev: fstype %s not found\n", fstype); + return -1; + } + } else { + fprintf(stderr, "fsdev: No fstype specified\n"); return -1; } - if (qemu_opt_get(opts, "security_model") == NULL) { + if (!sec_model) { fprintf(stderr, "fsdev: No security_model specified.\n"); return -1; } + if (!path) { + fprintf(stderr, "fsdev: No path specified.\n"); + return -1; + } + fsle = qemu_malloc(sizeof(*fsle)); - fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts)); - fsle->fse.path = qemu_strdup(qemu_opt_get(opts, "path")); - fsle->fse.security_model = qemu_strdup(qemu_opt_get(opts, - "security_model")); + fsle->fse.fsdev_id = qemu_strdup(fsdev_id); + fsle->fse.path = qemu_strdup(path); + fsle->fse.security_model = qemu_strdup(sec_model); fsle->fse.ops = FsTypes[i].ops; QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next); @@ -67,11 +79,13 @@ int qemu_fsdev_add(QemuOpts *opts) FsTypeEntry *get_fsdev_fsentry(char *id) { - struct FsTypeListEntry *fsle; + if (id) { + struct FsTypeListEntry *fsle; - QTAILQ_FOREACH(fsle, &fstype_entries, next) { - if (strcmp(fsle->fse.fsdev_id, id) == 0) { - return &fsle->fse; + QTAILQ_FOREACH(fsle, &fstype_entries, next) { + if (strcmp(fsle->fse.fsdev_id, id) == 0) { + return &fsle->fse; + } } } return NULL; |