block-qdict.c (e5af0da1dcbfb1a4694150f9954554fb6df88819) block-qdict.c (af91062ee1408f7f5bb58389d355d29a5040c648)
1/*
2 * Special QDict functions used by the block layer
3 *
4 * Copyright (c) 2013-2018 Red Hat, Inc.
5 *
6 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
7 * See the COPYING.LIB file in the top-level directory.
8 */
9
10#include "qemu/osdep.h"
11#include "block/qdict.h"
12#include "qapi/qmp/qbool.h"
13#include "qapi/qmp/qlist.h"
14#include "qapi/qmp/qnum.h"
15#include "qapi/qmp/qstring.h"
1/*
2 * Special QDict functions used by the block layer
3 *
4 * Copyright (c) 2013-2018 Red Hat, Inc.
5 *
6 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
7 * See the COPYING.LIB file in the top-level directory.
8 */
9
10#include "qemu/osdep.h"
11#include "block/qdict.h"
12#include "qapi/qmp/qbool.h"
13#include "qapi/qmp/qlist.h"
14#include "qapi/qmp/qnum.h"
15#include "qapi/qmp/qstring.h"
16#include "qapi/qobject-input-visitor.h"
16#include "qemu/cutils.h"
17#include "qapi/error.h"
18
19/**
20 * qdict_copy_default(): If no entry mapped by 'key' exists in 'dst' yet, the
21 * value of 'key' in 'src' is copied there (and the refcount increased
22 * accordingly).
23 */

--- 500 unchanged lines hidden (view full) ---

524 * Like qdict_crumple(), but additionally transforms scalar values so
525 * the result can be passed to qobject_input_visitor_new_keyval().
526 *
527 * The block subsystem uses this function to prepare its flat QDict
528 * with possibly confused scalar types for a visit. It should not be
529 * used for anything else, and it should go away once the block
530 * subsystem has been cleaned up.
531 */
17#include "qemu/cutils.h"
18#include "qapi/error.h"
19
20/**
21 * qdict_copy_default(): If no entry mapped by 'key' exists in 'dst' yet, the
22 * value of 'key' in 'src' is copied there (and the refcount increased
23 * accordingly).
24 */

--- 500 unchanged lines hidden (view full) ---

525 * Like qdict_crumple(), but additionally transforms scalar values so
526 * the result can be passed to qobject_input_visitor_new_keyval().
527 *
528 * The block subsystem uses this function to prepare its flat QDict
529 * with possibly confused scalar types for a visit. It should not be
530 * used for anything else, and it should go away once the block
531 * subsystem has been cleaned up.
532 */
532QObject *qdict_crumple_for_keyval_qiv(QDict *src, Error **errp)
533static QObject *qdict_crumple_for_keyval_qiv(QDict *src, Error **errp)
533{
534 QDict *tmp = NULL;
535 char *buf;
536 const char *s;
537 const QDictEntry *ent;
538 QObject *dst;
539
540 for (ent = qdict_first(src); ent; ent = qdict_next(src, ent)) {

--- 149 unchanged lines hidden (view full) ---

690 qdict_put_obj(qdict, renames->to, qobject_ref(qobj));
691 qdict_del(qdict, renames->from);
692 }
693
694 renames++;
695 }
696 return true;
697}
534{
535 QDict *tmp = NULL;
536 char *buf;
537 const char *s;
538 const QDictEntry *ent;
539 QObject *dst;
540
541 for (ent = qdict_first(src); ent; ent = qdict_next(src, ent)) {

--- 149 unchanged lines hidden (view full) ---

691 qdict_put_obj(qdict, renames->to, qobject_ref(qobj));
692 qdict_del(qdict, renames->from);
693 }
694
695 renames++;
696 }
697 return true;
698}
699
700/*
701 * Create a QObject input visitor for flat @qdict with possibly
702 * confused scalar types.
703 *
704 * The block subsystem uses this function to visit its flat QDict with
705 * possibly confused scalar types. It should not be used for anything
706 * else, and it should go away once the block subsystem has been
707 * cleaned up.
708 */
709Visitor *qobject_input_visitor_new_flat_confused(QDict *qdict,
710 Error **errp)
711{
712 QObject *crumpled;
713 Visitor *v;
714
715 crumpled = qdict_crumple_for_keyval_qiv(qdict, errp);
716 if (!crumpled) {
717 return NULL;
718 }
719
720 v = qobject_input_visitor_new_keyval(crumpled);
721 qobject_unref(crumpled);
722 return v;
723}