- if (params) {
- while (params[0]) {
- if (2 != sscanf(params, "%31[^=]=%255[^,]%n", tag, value, &n)) {
- fprintf(stderr, "parse error at \"%s\"\n", params);
- break;
- }
- params += n;
- if (params[0] == ',')
- params++;
- if (strcmp(tag, "bus") == 0)
- continue;
- if (strcmp(tag, "id") == 0) {
- qdev->id = qemu_strdup(value);
- continue;
- }
- if (-1 == qdev_prop_parse(qdev, tag, value)) {
- fprintf(stderr, "can't set property \"%s\" to \"%s\" for \"%s\"\n",
- tag, value, driver);
- }
- }
+ /* create device, set properties */
+ qdev = qdev_create(bus, driver);
+ id = qemu_opts_id(opts);
+ if (id) {
+ qdev->id = id;
+ }
+ if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
+ qdev_free(qdev);
+ return NULL;