On 2021/3/1 11:07 下午, Eric Blake wrote:
On 3/1/21 8:56 AM, Paolo Bonzini wrote:
When a network or network device is created from the command line or HMP,
QemuOpts ensures that the id passes the id_wellformed check. However,
QMP skips this:
$ qemu-system-x86_64 -qmp stdio -S -nic user,id=123/456
qemu-system-x86_64: -nic user,id=123/456: Parameter id expects an identifier
Identifiers consist of letters, digits, -, ., _, starting with a letter.
$ qemu-system-x86_64 -qmp stdio -S
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}}
{"return": {}}
After:
$ qemu-system-x86_64 -qmp stdio -S
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}}
{"error": {"class": "GenericError", "desc": "Parameter "id" expects an
identifier"}}
Validity checks should be performed always at the bottom of the call chain,
because QMP skips all the steps above. Do this for the network subsystem.
Cc: Jason Wang <jasow...@redhat.com>
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
net/net.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
Reviewed-by: Eric Blake <ebl...@redhat.com>
Queued.
Thanks