Skip to content
  • Eric Blake's avatar
    ad739706
    qom: Wrap prop visit in visit_start_struct · ad739706
    Eric Blake authored
    
    
    The qmp-input visitor was allowing callers to play rather fast
    and loose: when visiting a QDict, you could grab members of the
    root dictionary without first pushing into the dict; the final
    such culprit was the QOM code for converting to and from object
    properties.  But we are about to tighten the input visitor, at
    which point user_creatable_add_type() as called with a QMP input
    visitor via qmp_object_add() MUST follow the same paradigms as
    everyone else, of pushing into the struct before grabbing its
    keys.
    
    The use of 'err ? NULL : &err' is temporary; a later patch will
    clean that up when it splits visit_end_struct().
    
    Furthermore, note that both callers always pass qdict, so we can
    convert the conditional into an assert and reduce indentation.
    
    The change has no impact to the testsuite now, but is required to
    avoid a failure in tests/test-netfilter once qmp-input is made
    stricter to detect inconsistent 'name' arguments on the root visit.
    
    Since user_creatable_add_type() is also called with OptsVisitor
    through user_creatable_add_opts(), we must also check that there
    is no negative impact there; both pre- and post-patch, we see:
    
    $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio -object secret,id=sec0,data=letmein,format=raw,foo=bar
    qemu-system-x86_64: -object secret,id=sec0,data=letmein,format=raw,foo=bar: Property '.foo' not found
    
    That is, the only new checking that the new visit_end_struct() can
    perform is for excess input, but we already catch excess input
    earlier in object_property_set().
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <1461879932-9020-10-git-send-email-eblake@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    ad739706
    qom: Wrap prop visit in visit_start_struct
    Eric Blake authored
    
    
    The qmp-input visitor was allowing callers to play rather fast
    and loose: when visiting a QDict, you could grab members of the
    root dictionary without first pushing into the dict; the final
    such culprit was the QOM code for converting to and from object
    properties.  But we are about to tighten the input visitor, at
    which point user_creatable_add_type() as called with a QMP input
    visitor via qmp_object_add() MUST follow the same paradigms as
    everyone else, of pushing into the struct before grabbing its
    keys.
    
    The use of 'err ? NULL : &err' is temporary; a later patch will
    clean that up when it splits visit_end_struct().
    
    Furthermore, note that both callers always pass qdict, so we can
    convert the conditional into an assert and reduce indentation.
    
    The change has no impact to the testsuite now, but is required to
    avoid a failure in tests/test-netfilter once qmp-input is made
    stricter to detect inconsistent 'name' arguments on the root visit.
    
    Since user_creatable_add_type() is also called with OptsVisitor
    through user_creatable_add_opts(), we must also check that there
    is no negative impact there; both pre- and post-patch, we see:
    
    $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio -object secret,id=sec0,data=letmein,format=raw,foo=bar
    qemu-system-x86_64: -object secret,id=sec0,data=letmein,format=raw,foo=bar: Property '.foo' not found
    
    That is, the only new checking that the new visit_end_struct() can
    perform is for excess input, but we already catch excess input
    earlier in object_property_set().
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <1461879932-9020-10-git-send-email-eblake@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Loading