Revision 5726d872
b/block.c | ||
---|---|---|
1007 | 1007 |
return 0; |
1008 | 1008 |
} |
1009 | 1009 |
|
1010 |
static void extract_subqdict(QDict *src, QDict **dst, const char *start) |
|
1011 |
{ |
|
1012 |
const QDictEntry *entry, *next; |
|
1013 |
const char *p; |
|
1014 |
|
|
1015 |
*dst = qdict_new(); |
|
1016 |
entry = qdict_first(src); |
|
1017 |
|
|
1018 |
while (entry != NULL) { |
|
1019 |
next = qdict_next(src, entry); |
|
1020 |
if (strstart(entry->key, start, &p)) { |
|
1021 |
qobject_incref(entry->value); |
|
1022 |
qdict_put_obj(*dst, p, entry->value); |
|
1023 |
qdict_del(src, entry->key); |
|
1024 |
} |
|
1025 |
entry = next; |
|
1026 |
} |
|
1027 |
} |
|
1028 |
|
|
1029 | 1010 |
/* |
1030 | 1011 |
* Opens a disk image (raw, qcow2, vmdk, ...) |
1031 | 1012 |
* |
... | ... | |
1131 | 1112 |
flags |= BDRV_O_ALLOW_RDWR; |
1132 | 1113 |
} |
1133 | 1114 |
|
1134 |
extract_subqdict(options, &file_options, "file."); |
|
1115 |
qdict_extract_subqdict(options, &file_options, "file.");
|
|
1135 | 1116 |
|
1136 | 1117 |
ret = bdrv_file_open(&file, filename, file_options, |
1137 | 1118 |
bdrv_open_flags(bs, flags | BDRV_O_UNMAP), &local_err); |
... | ... | |
1169 | 1150 |
if ((flags & BDRV_O_NO_BACKING) == 0) { |
1170 | 1151 |
QDict *backing_options; |
1171 | 1152 |
|
1172 |
extract_subqdict(options, &backing_options, "backing."); |
|
1153 |
qdict_extract_subqdict(options, &backing_options, "backing.");
|
|
1173 | 1154 |
ret = bdrv_open_backing_file(bs, backing_options, &local_err); |
1174 | 1155 |
if (ret < 0) { |
1175 | 1156 |
goto close_and_fail; |
b/include/qapi/qmp/qdict.h | ||
---|---|---|
67 | 67 |
QDict *qdict_clone_shallow(const QDict *src); |
68 | 68 |
void qdict_flatten(QDict *qdict); |
69 | 69 |
|
70 |
void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start); |
|
71 |
|
|
70 | 72 |
#endif /* QDICT_H */ |
b/qobject/qdict.c | ||
---|---|---|
527 | 527 |
{ |
528 | 528 |
qdict_do_flatten(qdict, qdict, NULL); |
529 | 529 |
} |
530 |
|
|
531 |
/* extract all the src QDict entries starting by start into dst */ |
|
532 |
void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start) |
|
533 |
|
|
534 |
{ |
|
535 |
const QDictEntry *entry, *next; |
|
536 |
const char *p; |
|
537 |
|
|
538 |
*dst = qdict_new(); |
|
539 |
entry = qdict_first(src); |
|
540 |
|
|
541 |
while (entry != NULL) { |
|
542 |
next = qdict_next(src, entry); |
|
543 |
if (strstart(entry->key, start, &p)) { |
|
544 |
qobject_incref(entry->value); |
|
545 |
qdict_put_obj(*dst, p, entry->value); |
|
546 |
qdict_del(src, entry->key); |
|
547 |
} |
|
548 |
entry = next; |
|
549 |
} |
|
550 |
} |
Also available in: Unified diff