From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPa95-0006ES-OD for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:40:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPa90-0007Q4-9H for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:39:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPa90-0007Pq-2I for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:39:50 -0400 From: Kevin Wolf Date: Fri, 27 Sep 2013 17:39:12 +0200 Message-Id: <1380296370-14523-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1380296370-14523-1-git-send-email-kwolf@redhat.com> References: <1380296370-14523-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 12/30] qdict: Extract qdict_extract_subqdict List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Beno=C3=AEt Canet Signed-off-by: Benoit Canet Signed-off-by: Kevin Wolf --- block.c | 23 ++--------------------- include/qapi/qmp/qdict.h | 2 ++ qobject/qdict.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/block.c b/block.c index 4a98250..4833b37 100644 --- a/block.c +++ b/block.c @@ -1007,25 +1007,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, Q= Dict *options, Error **errp) return 0; } =20 -static void extract_subqdict(QDict *src, QDict **dst, const char *start) -{ - const QDictEntry *entry, *next; - const char *p; - - *dst =3D qdict_new(); - entry =3D qdict_first(src); - - while (entry !=3D NULL) { - next =3D 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 =3D next; - } -} - /* * Opens a disk image (raw, qcow2, vmdk, ...) * @@ -1131,7 +1112,7 @@ int bdrv_open(BlockDriverState *bs, const char *fil= ename, QDict *options, flags |=3D BDRV_O_ALLOW_RDWR; } =20 - extract_subqdict(options, &file_options, "file."); + qdict_extract_subqdict(options, &file_options, "file."); =20 ret =3D bdrv_file_open(&file, filename, file_options, bdrv_open_flags(bs, flags | BDRV_O_UNMAP), &loc= al_err); @@ -1169,7 +1150,7 @@ int bdrv_open(BlockDriverState *bs, const char *fil= ename, QDict *options, if ((flags & BDRV_O_NO_BACKING) =3D=3D 0) { QDict *backing_options; =20 - extract_subqdict(options, &backing_options, "backing."); + qdict_extract_subqdict(options, &backing_options, "backing."); ret =3D bdrv_open_backing_file(bs, backing_options, &local_err); if (ret < 0) { goto close_and_fail; diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index d6855d1..5cefd80 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -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); =20 +void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start); + #endif /* QDICT_H */ diff --git a/qobject/qdict.c b/qobject/qdict.c index 472f106..0f3e0a6 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -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 =3D qdict_new(); + entry =3D qdict_first(src); + + while (entry !=3D NULL) { + next =3D 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 =3D next; + } +} --=20 1.8.1.4