Revision d058fe03

b/qemu-config.c
71 71
    },
72 72
};
73 73

  
74
static QemuOptsList *lists[] = {
75
    &qemu_drive_opts,
76
    NULL,
77
};
78

  
79
int qemu_set_option(const char *str)
80
{
81
    char group[64], id[64], arg[64];
82
    QemuOpts *opts;
83
    int i, rc, offset;
84

  
85
    rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
86
    if (rc < 3 || str[offset] != '=') {
87
        fprintf(stderr, "can't parse: \"%s\"\n", str);
88
        return -1;
89
    }
90

  
91
    for (i = 0; lists[i] != NULL; i++) {
92
        if (strcmp(lists[i]->name, group) == 0)
93
            break;
94
    }
95
    if (lists[i] == NULL) {
96
        fprintf(stderr, "there is no option group \"%s\"\n", group);
97
        return -1;
98
    }
99

  
100
    opts = qemu_opts_find(lists[i], id);
101
    if (!opts) {
102
        fprintf(stderr, "there is no %s \"%s\" defined\n",
103
                lists[i]->name, id);
104
        return -1;
105
    }
106

  
107
    if (-1 == qemu_opt_set(opts, arg, str+offset+1)) {
108
        fprintf(stderr, "failed to set \"%s\" for %s \"%s\"\n",
109
                arg, lists[i]->name, id);
110
        return -1;
111
    }
112
    return 0;
113
}
114

  
b/qemu-config.h
1 1
extern QemuOptsList qemu_drive_opts;
2

  
3
int qemu_set_option(const char *str);
b/qemu-options.hx
95 95
    "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
96 96
    "       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
97 97
    "       [,cache=writethrough|writeback|none][,format=f][,serial=s]\n"
98
    "       [,addr=A]\n"
98
    "       [,addr=A][,id=name]\n"
99 99
    "                use 'file' as a drive image\n")
100
DEF("set", HAS_ARG, QEMU_OPTION_set,
101
    "-set group.id.arg=value\n"
102
    "                set <arg> parameter for item <id> of type <group>\n"
103
    "                i.e. -set drive.$id.file=/path/to/image\n")
100 104
STEXI
101 105
@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
102 106

  
b/vl.c
4966 4966
            case QEMU_OPTION_drive:
4967 4967
                drive_add(NULL, "%s", optarg);
4968 4968
	        break;
4969
            case QEMU_OPTION_set:
4970
                if (qemu_set_option(optarg) != 0)
4971
                    exit(1);
4972
	        break;
4969 4973
            case QEMU_OPTION_mtdblock:
4970 4974
                drive_add(optarg, MTD_ALIAS);
4971 4975
                break;

Also available in: Unified diff