qdict: Extract qdict_extract_subqdict.
PATCH 1/1 qdict: Extract qdict_extract_subqdict.
Signed-off-by Benoit Canet <[email protected]>
--- block.c | 23 ++--------------------- include/qapi/qmp/qdict.h | 2 ++ qobject/qdict.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 21 deletions(-)
block.c +2 -21
@@ -963,25 +963,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options)return 0 ; } -static void extract_subqdict (QDict *src,QDict **dst,const char *start) -{ -const QDictEntry *entry, *next; -const char *p; - - *dst =qdict_new (); - entry =qdict_first (src); - -while (entry !=NULL ) { - next =qdict_next (src, entry); -if (strstart (entry->key, start, &p)) { -qobject_incref (entry->value); -qdict_put_obj (*dst, p, entry->value); -qdict_del (src, entry->key); - } - entry = next; - } -} -/* * Opens a disk image (raw, qcow2, vmdk, ...) *
@@ -1079,7 +1060,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, flags |=BDRV_O_ALLOW_RDWR ; } -extract_subqdict (options, &file_options,"file." ); +qdict_extract_subqdict (options, &file_options,"file." ); ret =bdrv_file_open (&file, filename, file_options,bdrv_open_flags (bs, flags |BDRV_O_UNMAP ));
@@ -1117,7 +1098,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,if ((flags &BDRV_O_NO_BACKING ) ==0 ) {QDict *backing_options; -extract_subqdict (options, &backing_options,"backing." ); +qdict_extract_subqdict (options, &backing_options,"backing." ); ret =bdrv_open_backing_file (bs, backing_options);if (ret <0 ) { goto close_and_fail;
include/qapi/qmp/qdict.h +2 -0
@@ -67,4 +67,6 @@ const char *qdict_get_try_str(const QDict *qdict, const char *key);QDict *qdict_clone_shallow (const QDict *src);void qdict_flatten (QDict *qdict); +void qdict_extract_subqdict (QDict *src,QDict **dst,const char *start); +#endif /* QDICT_H */
qobject/qdict.c +21 -0
@@ -527,3 +527,24 @@ void qdict_flatten(QDict *qdict) {qdict_do_flatten (qdict, qdict,NULL ); } + +/* extract all the src QDict entries starting by start into dst */ +void qdict_extract_subqdict (QDict *src,QDict **dst,const char *start) + +{ +const QDictEntry *entry, *next; +const char *p; + + *dst =qdict_new (); + entry =qdict_first (src); + +while (entry !=NULL ) { + next =qdict_next (src, entry); +if (strstart (entry->key, start, &p)) { +qobject_incref (entry->value); +qdict_put_obj (*dst, p, entry->value); +qdict_del (src, entry->key); + } + entry = next; + } +}
Signature · 1 line
1.8.1.2
Kevin Wolf
AppliedAm 25.09.2013 um 13:30 hat Benoît Canet geschrieben:
Quoted 1 line
Signed-off-by Benoit Canet <[email protected]>
Thanks, applied to the block branch.
(And I like how the subject line sounds :-))
Kevin