All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Jason Wang <jasowang@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] slirp: Add "query-usernet" QMP command
Date: Fri, 9 Mar 2018 08:22:39 -0600	[thread overview]
Message-ID: <804ef917-9538-80d0-5cb5-b4aaf0ae3b88@redhat.com> (raw)
In-Reply-To: <20180226075846.20307-2-famz@redhat.com>

On 02/26/2018 01:58 AM, Fam Zheng wrote:
> HMP "info usernet" has been available but it isn't ideal for programed

s/programed/programmed/

> use cases. This closes the gap in QMP by adding a counterpart
> "query-usernet" command. It is basically translated from
> the HMP slirp_connection_info() loop, which now calls the QMP
> implementation and prints the data, just like other HMP info_* commands.
> 
> The TCPS_* macros are now defined as a QAPI enum.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>   net/slirp.c      |  26 +++++++
>   qapi/net.json    | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   slirp/libslirp.h |   1 +
>   slirp/misc.c     | 156 +++++++++++++++++++++++++++++-------------
>   slirp/tcp.h      |  15 -----
>   5 files changed, 339 insertions(+), 60 deletions(-)
> 

> +++ b/net/slirp.c
> @@ -36,6 +36,7 @@
>   #include "monitor/monitor.h"
>   #include "qemu/error-report.h"
>   #include "qemu/sockets.h"
> +#include "slirp/slirp.h"
>   #include "slirp/libslirp.h"
>   #include "slirp/ip6.h"
>   #include "chardev/char-fe.h"
> @@ -43,6 +44,7 @@
>   #include "qemu/cutils.h"
>   #include "qapi/error.h"
>   #include "qapi/qmp/qdict.h"
> +#include "qmp-commands.h"

Needs rebasing to master, although off-hand I think it is probably as 
simple as a switch to qapi/qapi-net-commands.h

> +++ b/qapi/net.json
> @@ -706,3 +706,204 @@
>   ##
>   { 'event': 'NIC_RX_FILTER_CHANGED',
>     'data': { '*name': 'str', 'path': 'str' } }
> +
> +##
> +# @TCPS:
> +#
> +# TCP States of a SLIRP connection.
> +#
> +# - States where connections are not established: none, closed, listen, syn_sent,
> +#   syn_received
> +#
> +# - States where user has closed: fin_wait_1, closing, last_ack, fin_wait_2,
> +#   time_wait
> +#
> +# - States await ACK of FIN: fin_wait_1, closing, last_ack

s/await/awaiting/

> +#
> +# 'none' state is used only when host forwarding
> +#
> +# Since 2.12
> +#
> +##
> +{ 'enum': 'TCPS',
> +  'data':
> +   ['closed',
> +    'listen',
> +    'syn_sent',

Probably nicer to spell this 'syn-sent'; it results in the same C code, 
but is more consistent with modern QMP naming.

> +    'syn_received',
> +    'established',
> +    'close_wait',
> +    'fin_wait_1',
> +    'closing',
> +    'last_ack',
> +    'fin_wait_2',
> +    'time_wait',

Likewise for these _.

> +    'none'
> +   ] }
> +
> +##
> +# @UsernetTCPConnection:
> +#
> +# SLIRP TCP information.
> +#
> +# @state: tcp connection state
> +#
> +# @hostfwd: whether this connection has host port forwarding
> +#
> +# @fd: the file descriptor of the connection
> +#
> +# @src_addr: source address of host port forwarding

Likewise, for src-addr and friends.

> +#
> +# @src_port: source port of host port forwarding
> +#
> +# @dest_addr: destination address of host port forwarding
> +#
> +# @dest_port: destination port of host port forwarding
> +#
> +# @recv_buffered: number of bytes queued in the receive buffer
> +#
> +# @send_buffered: number of bytes queued in the send buffer
> +#
> +# Since: 2.12
> +##
> +{ 'struct': 'UsernetTCPConnection',
> +  'data': {
> +    'state': 'TCPS',
> +    'hostfwd': 'bool',
> +    'fd': 'int',
> +    'src_addr': 'str',
> +    'src_port': 'int',
> +    'dest_addr': 'str',
> +    'dest_port': 'int',
> +    'recv_buffered': 'int',
> +    'send_buffered': 'int'
> +  } }
> +
> +##
> +# @UsernetUDPConnection:
> +#
> +# SLIRP UDP information.
> +#
> +# @hostfwd: whether this connection has host port forwarding
> +#
> +# @expire_time_ms: time in microseconds after which this connection will expire

And again.

> +#
> +# @fd: the file descriptor of the connection
> +#
> +# @src_addr: source address of host port forwarding
> +#
> +# @src_port: source port of host port forwarding
> +#
> +# @dest_addr: destination address of host port forwarding
> +#
> +# @dest_port: destination port of host port forwarding
> +#
> +# @recv_buffered: number of bytes queued in the receive buffer
> +#
> +# @send_buffered: number of bytes queued in the send buffer
> +#
> +# Since: 2.12
> +##
> +{ 'struct': 'UsernetUDPConnection',
> +  'data': {
> +    'hostfwd': 'bool',
> +    'expire_time_ms': 'int',
> +    'fd': 'int',
> +    'src_addr': 'str',
> +    'src_port': 'int',
> +    'dest_addr': 'str',
> +    'dest_port': 'int',
> +    'recv_buffered': 'int',
> +    'send_buffered': 'int'
> +    } }
> +
> +##
> +# @UsernetICMPConnection:
> +#
> +# SLIRP ICMP information.
> +#
> +# @expire_time_ms: time in microseconds after which this connection will expire

Etc.

> +#
> +# @fd: the file descriptor of the connection
> +#
> +# @src_addr: source address of host port forwarding
> +#
> +# @dest_addr: destination address of host port forwarding
> +#
> +# @recv_buffered: number of bytes queued in the receive buffer
> +#
> +# @send_buffered: number of bytes queued in the send buffer
> +#
> +# Since: 2.12
> +##
> +{ 'struct': 'UsernetICMPConnection',
> +  'data': {
> +    'expire_time_ms': 'int',
> +    'fd': 'int',
> +    'src_addr': 'str',
> +    'dest_addr': 'str',
> +    'recv_buffered': 'int',
> +    'send_buffered': 'int'
> +    } }
> +
> +##
> +# @UsernetType:
> +#
> +# Available netdev drivers.
> +#
> +# Since: 2.7

Since 2.7? Why not 2.12?

> +##
> +{ 'enum': 'UsernetType',
> +  'data': [ 'tcp', 'udp', 'icmp' ] }
> +
> +##
> +# @UsernetConnection:
> +#
> +# SLIRP usernet connection information.
> +#
> +# Since: 2.12
> +##
> +{ 'union': 'UsernetConnection',
> +  'discriminator': 'type',
> +  'base': { 'type': 'UsernetType' },
> +  'data': {
> +    'tcp':     'UsernetTCPConnection',
> +    'udp':     'UsernetUDPConnection',
> +    'icmp':    'UsernetICMPConnection'
> +    } }

Looks good.

> +
> +##
> +# @UsernetInfo:
> +#
> +# SLIRP usernet information.
> +#
> +# Since: 2.12
> +##
> +{ 'struct': 'UsernetInfo',
> +  'data': {
> +    'id':              'str',
> +    'vlan':            'int',
> +    'connections':     ['UsernetConnection']
> +} }
> +
> +##
> +# @query-usernet:
> +#
> +# Return SLIRP network information.
> +#
> +# Since: 2.11

2.12

> +#
> +# Example:
> +#
> +# -> { "execute": "query-usernet", "arguments": { } }
> +# <- { "return": [
> +#         {
> +#             "promiscuous": true,
> +#             "name": "vnet0",
> +#         }

Trailing comma is not valid JSON; is the example incomplete?  And 
doesn't match the UsernetInfo struct, which would have "id", "vlan", and 
"connections" instead of "promiscuous" and "name".

> +#       ]
> +#    }
> +#
> +##
> +{ 'command': 'query-usernet',
> +  'returns': ['UsernetInfo'] }

The idea makes sense, but you'll need a v3.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-03-09 14:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26  7:58 [Qemu-devel] [PATCH v2 0/2] slirp: Add query-usernet QMP command Fam Zheng
2018-02-26  7:58 ` [Qemu-devel] [PATCH v2 1/2] slirp: Add "query-usernet" " Fam Zheng
2018-03-09 14:22   ` Eric Blake [this message]
2018-02-26  7:58 ` [Qemu-devel] [PATCH v2 2/2] tests: Use query-usernet instead of 'info usernet' Fam Zheng
2018-03-09 14:24   ` Eric Blake
2018-03-09  1:33 ` [Qemu-devel] [PATCH v2 0/2] slirp: Add query-usernet QMP command Fam Zheng

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=804ef917-9538-80d0-5cb5-b4aaf0ae3b88@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.