]> Git Repo - qemu.git/commit
qom: Avoid unvisited 'id'/'qom-type' in user_creatable_add_opts
authorEric Blake <[email protected]>
Wed, 22 Mar 2017 14:45:24 +0000 (09:45 -0500)
committerMarkus Armbruster <[email protected]>
Wed, 22 Mar 2017 18:24:34 +0000 (19:24 +0100)
commit9a6d1acb3e752e1e0b693cc0491fa12875b76be0
treec8c5bc7444abd923df179b6348c2fdd511ef768d
parent76861f6befc50c30cb71e84b372dc91dd26656a4
qom: Avoid unvisited 'id'/'qom-type' in user_creatable_add_opts

A regression in commit 15c2f669e caused us to silently ignore
excess input to the QemuOpts visitor.  Later, commit ea4641
accidentally abused that situation, by removing "qom-type" and
"id" from the corresponding QDict but leaving them defined in
the QemuOpts, when using the pair of containers to create a
user-defined object. Note that since we are already traversing
two separate items (a QDict and a QemuOpts), we are already
able to flag bogus arguments, as in:

$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio -object memory-backend-ram,id=mem1,size=4k,bogus=huh
qemu-system-x86_64: -object memory-backend-ram,id=mem1,size=4k,bogus=huh: Property '.bogus' not found

So the only real concern is that when we re-enable strict checking
in the QemuOpts visitor, we do not want to start flagging the two
leftover keys as unvisited.  Rearrange the code to clean out the
QemuOpts listing in advance, rather than removing items from the
QDict.  Since "qom-type" is usually an automatic implicit default,
we don't have to restore it (this does mean that once instantiated,
QemuOpts is not necessarily an accurate representation of the
original command line - but this is not the first place to do that);
however "id" has to be put back (requiring us to cast away a const).

[As a side note, hmp_object_add() turns a QDict into a QemuOpts,
then calls user_creatable_add_opts() which converts QemuOpts into
a new QDict. There are probably a lot of wasteful conversions like
this, but cleaning them up is a much bigger task than the immediate
regression fix.]

CC: [email protected]
Signed-off-by: Eric Blake <[email protected]>
Message-Id: <20170322144525[email protected]>
Tested-by: Laurent Vivier <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
qom/object_interfaces.c
This page took 0.023396 seconds and 4 git commands to generate.