This patch introduces a new QMP command "query-netdevs" to get information
about currently attached network devices.
Potentially, this patch makes the "info_str" field of "struct NetClientState"
and HMP command "info network" obsolete as new command gives out more
information in a structured way.

Usage example:

{ "execute": "x-query-netdevs" }
{ "return": [
    {
      "peer": "netdev0",
      "netdev": "netdev0",
      "model": "virtio-net-pci",
      "macaddr": "52:54:00:12:34:56",
      "queues_count": 1,
      "type": "nic",
      "id": "net0"
    },
    {
      "peer": "net0",
      "ipv6": true,
      "ipv4": true,
      "host": "10.0.2.2",
      "queues_count": 1,
      "ipv6-dns": "fec0::3",
      "ipv6-prefix": "fec0::",
      "net": "10.0.2.0/255.255.255.0",
      "ipv6-host": "fec0::2",
      "type": "user",
      "dns": "10.0.2.3",
      "hostfwd": [
        {
          "str": "tcp::20004-:22"
        }
      ],
      "ipv6-prefixlen": 64,
      "id": "netdev0",
      "restrict": false
    }
  ]
}

Alexey Kirillov (2):
  qapi: net: Add query-netdevs command
  tests: Add tests for query-netdevs command

 include/net/net.h          |   1 +
 net/hub.c                  |   8 +++
 net/l2tpv3.c               |  19 ++++++
 net/net.c                  |  80 +++++++++++++++++++++++
 net/netmap.c               |  13 ++++
 net/slirp.c                | 126 +++++++++++++++++++++++++++++++++++++
 net/socket.c               |  71 +++++++++++++++++++++
 net/tap-win32.c            |   9 +++
 net/tap.c                  | 103 ++++++++++++++++++++++++++++--
 net/vde.c                  |  26 ++++++++
 net/vhost-user.c           |  18 +++++-
 qapi/net.json              |  85 +++++++++++++++++++++++++
 tests/Makefile.include     |   2 +
 tests/test-query-netdevs.c | 114 +++++++++++++++++++++++++++++++++
 14 files changed, 667 insertions(+), 8 deletions(-)
 create mode 100644 tests/test-query-netdevs.c

-- 
2.17.1


Reply via email to