Revision d058fe03 qemu-config.c

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

  

Also available in: Unified diff