qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexey Kirillov <lekiravi@yandex-team.ru>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PULL V2 16/20] qapi: net: Add query-netdev command
Date: Thu, 25 Mar 2021 10:36:29 +0800	[thread overview]
Message-ID: <8a4189e5-7bfc-4205-b421-d18f0882fe22@redhat.com> (raw)
In-Reply-To: <cfd051e2-0bee-2d7d-16cd-0c70c8924ccf@redhat.com>


在 2021/3/17 上午11:34, Jason Wang 写道:
>
> 在 2021/3/17 上午5:37, Peter Maydell 写道:
>> On Mon, 15 Mar 2021 at 09:15, Jason Wang <jasowang@redhat.com> wrote:
>>> From: Alexey Kirillov <lekiravi@yandex-team.ru>
>>>
>>> The query-netdev command is used to get the configuration of the 
>>> current
>>> network device backends (netdevs).
>>> This is the QMP analog of the HMP command "info network" but only for
>>> netdevs (i.e. excluding NIC and hubports).
>>>
>>> The query-netdev command returns an array of objects of the NetdevInfo
>>> type, which are an extension of Netdev type. It means that response can
>>> be used for netdev-add after small modification. This can be useful for
>>> recreate the same netdev configuration.
>>>
>>> Information about the network device is filled in when it is created or
>>> modified and is available through the NetClientState->stored_config.
>>>
>>> Signed-off-by: Alexey Kirillov <lekiravi@yandex-team.ru>
>>> Acked-by: Markus Armbruster <armbru@redhat.com>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>> ---
>> Hi; Coverity complains about a memory leak in this code
>> (CID 1450842):
>>
>>> @@ -581,15 +693,25 @@ static int net_slirp_init(NetClientState 
>>> *peer, const char *model,
>>>       s->poll_notifier.notify = net_slirp_poll_notify;
>>>       main_loop_poll_add_notifier(&s->poll_notifier);
>>>
>>> +    stored_hostfwd = &stored->hostfwd;
>>> +    stored_guestfwd = &stored->guestfwd;
>>> +
>>>       for (config = slirp_configs; config; config = config->next) {
>>> +        String *element = g_new0(String, 1);
>> Here we allocate memory...
>>
>>> +
>>> +        element->str = g_strdup(config->str);
>>>           if (config->flags & SLIRP_CFG_HOSTFWD) {
>>>               if (slirp_hostfwd(s, config->str, errp) < 0) {
>>>                   goto error;
>> ...but if we take this error-exit path we have neither freed nor
>> kept a pointer to that memory.
>
>
> Yes.
>
>
>>
>>>               }
>>> +            stored->has_hostfwd = true;
>>> +            QAPI_LIST_APPEND(stored_hostfwd, element);
>>>           } else {
>>>               if (slirp_guestfwd(s, config->str, errp) < 0) {
>>>                   goto error;
>> Similarly here.
>>
>>>               }
>>> +            stored->has_guestfwd = true;
>>> +            QAPI_LIST_APPEND(stored_guestfwd, element);
>>>           }
>>>       }
>>>   #ifndef _WIN32
>> More generally, what state is the net backend init function
>> supposed to leave 'stored' in if it fails? Is it the backend's
>> responsibility to free everything that it might have allocated
>> and left a pointer to? eg if we did
>>     stored->hostname = g_strdup(vhostname);
>> do we need to go back and free(stored->hostname) ? Or is the caller
>> guaranteeing to clean up 'stored' somehow ? Or is the backend
>> supposed to not touch 'stored' until it's sure it's going to
>> succeed ? (presumably not, as the current code does not do this...)
>
>
> Clean and free in the function that do the allocation seems better 
> (self-conatined).
>
>
>>
>> This commit has no comments describing or documenting the
>> API requirements the new functionality imposes on a net backend:
>> could we have a followup patch which adds some documentation,
>> please, so that authors of future backends know what they have to
>> implement ?
>
>
> Alexey, plase send patches to fix the above issues and document the API.
>
> Thanks


Alexey, any update on this. If it takes time I tend to revert this and 
let's re-try for 6.1?

Thanks


>
>
>>
>> thanks
>> -- PMM
>>
>
>



  reply	other threads:[~2021-03-25  2:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15  9:14 [PULL V2 00/20] Net patches Jason Wang
2021-03-15  9:14 ` [PULL V2 01/20] virtio-net: calculating proper msix vectors on init Jason Wang
2021-03-15  9:14 ` [PULL V2 02/20] net: Fix build error when DEBUG_NET is on Jason Wang
2021-03-15  9:14 ` [PULL V2 03/20] net: validate that ids are well formed Jason Wang
2021-03-15  9:14 ` [PULL V2 04/20] e1000: fail early for evil descriptor Jason Wang
2021-03-15  9:14 ` [PULL V2 05/20] net: introduce qemu_receive_packet() Jason Wang
2021-03-15  9:14 ` [PULL V2 06/20] e1000: switch to use qemu_receive_packet() for loopback Jason Wang
2021-03-15  9:14 ` [PULL V2 07/20] dp8393x: switch to use qemu_receive_packet() for loopback packet Jason Wang
2021-03-15  9:14 ` [PULL V2 08/20] msf2-mac: switch to use qemu_receive_packet() for loopback Jason Wang
2021-03-15  9:14 ` [PULL V2 09/20] sungem: " Jason Wang
2021-03-15  9:14 ` [PULL V2 10/20] tx_pkt: switch to use qemu_receive_packet_iov() " Jason Wang
2021-03-15  9:14 ` [PULL V2 11/20] rtl8139: switch to use qemu_receive_packet() " Jason Wang
2021-03-15  9:14 ` [PULL V2 12/20] pcnet: " Jason Wang
2021-03-15  9:14 ` [PULL V2 13/20] cadence_gem: " Jason Wang
2021-03-15  9:14 ` [PULL V2 14/20] lan9118: " Jason Wang
2021-03-15  9:14 ` [PULL V2 15/20] pvrdma: wean code off pvrdma_ring.h kernel header Jason Wang
2021-03-15  9:14 ` [PULL V2 16/20] qapi: net: Add query-netdev command Jason Wang
2021-03-16 21:27   ` Peter Maydell
2021-03-17  4:16     ` Jason Wang
2021-03-16 21:37   ` Peter Maydell
2021-03-17  3:34     ` Jason Wang
2021-03-25  2:36       ` Jason Wang [this message]
2021-03-15  9:14 ` [PULL V2 17/20] tests: Add tests for " Jason Wang
2021-03-15  9:14 ` [PULL V2 18/20] net: Move NetClientState.info_str to dynamic allocations Jason Wang
2021-03-15  9:14 ` [PULL V2 19/20] hmp: Use QAPI NetdevInfo in hmp_info_network Jason Wang
2021-03-15  9:14 ` [PULL V2 20/20] net: Do not fill legacy info_str for backends Jason Wang
2021-03-16 12:30 ` [PULL V2 00/20] Net patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a4189e5-7bfc-4205-b421-d18f0882fe22@redhat.com \
    --to=jasowang@redhat.com \
    --cc=lekiravi@yandex-team.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).