* [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev
@ 2010-06-30 14:52 Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 1/7] QMP: Introduce the documentation for query-netdev and info netdev Miguel Di Ciurcio Filho
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:52 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, armbru, lcapitulino
This series implement the previously discussed QMP command query-netdev.
Regards,
changelog from v1
-----------------
- Fixed wrong usage of qemu_free() with vc->info_dict, now using QDECREF()
- Fixed QString leak in netdev_iter()
changelog from last protocol spec
---------------------------------
When "type" is "tap", the attribute "sndbuf" have been removed. "sndbuf" is
not available on all platforms and most of the tap_set_sndbuf() implementations
are stubs.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 1/7] QMP: Introduce the documentation for query-netdev and info netdev
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
@ 2010-06-30 14:52 ` Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 2/7] QObject API: introduce qdict_to_qstring() function Miguel Di Ciurcio Filho
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:52 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
These commands show the information about active backend network devices.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
qemu-monitor.hx | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 9f62b94..330d7a6 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1674,6 +1674,106 @@ show the various VLANs and the associated devices
ETEXI
STEXI
+@item info netdev
+show information about the current backend network devices
+ETEXI
+SQMP
+query-netdev
+------------
+
+Each device is represented by a json-object. The returned value is a json-array
+of all devices.
+
+Each json-object contains the following:
+
+- "id": the device's ID, must be unique (json-string)
+- "type": device type (json-string)
+ - Possible values: "tap", "user", "vde"
+- "peer": ID of the frontend guest device, if not available means that this
+ netdev is not connected to a guest device yet (json-string, optional)
+- "info": json-object containing the configuration information about the device.
+ - When "type" is "tap", the following values might be available:
+ - "fd": available if connected to an already opened TAP interface
+ (json-int, optional)
+ - "script": path to an script used to configure the interface,
+ available only if an script is used. (json-string, optional, only
+ present if "fd" is not present)
+ - "downscript": path to an script used to deconfigure the interface,
+ available only if an script is used. (json-string, optional, only
+ present if "fd" is not present)
+ - "ifname": name of the attached host interface (json-string, only
+ present if "fd" is not present)
+ - "vhost": vhost acceleration status, true if enabled, false
+ otherwise (json-boolean)
+ - "vnet_hdr": true if the IFF_VNET_HDR flag must be set and is in
+ use, false otherwise (json-boolean)
+ - "vhostfd": fd used to connect the device to an already opened
+ vhost net device (json-int, optional)
+ - When "type" is "vde", the following values might be available:
+ - "sock": path to the VDE listening socket (json-string)
+ - "port": port number connected to virtual switch (json-int)
+ - "mode": permission mode, in octal (json-int)
+ - "group": group name (json-string, optional)
+ - When "type" is "user", the following values might be available:
+ - "hostname": client hostname reported by the builtin DHCP server,
+ (json-string, optional)
+ - "restrict": true if guest is isolated from the host,
+ false otherwise (json-boolean)
+ - "net": network address (json-string)
+ - "netmask": netmask (json-string)
+ - "host": guest-visible address of the host (json-string)
+ - "tftp": root directory of the built-in TFTP server (json-string,
+ optional)
+ - "bootfile": BOOTP filename (json-string, optional)
+ - "dhcpstart": the first of the 16 IPs the built-in DHCP server can
+ assign (json-string)
+ - "dns": guest-visible address of the virtual nameserver
+ (json-string)
+ - "smb": root directory of the built-in SMB server (json-string,
+ optional)
+ - "smbserver": IP address of the built-in SMB server (json-string,
+ optional)
+ - "hostfwd": guest port number to forward incoming TCP or UDP
+ connections (json-int, optional)
+ - "guestfwd": IP address and port to forward guest TCP connections
+ (json-int, optional)
+
+Example:
+
+-> { "execute": "query-netdev" }
+<- {
+ "return": [
+ {
+ "id": "tap.0",
+ "type": "tap",
+ "peer": "virtio-net-pci.0",
+ "info": {
+ "script": "/etc/qemu-ifup",
+ "downscript": "/etc/qemu-ifdown",
+ "ifname": "tap0",
+ "vnet_hdr": false,
+ "vhost": true
+ },
+ },
+ {
+ "id": "user.0",
+ "type": "user",
+ "peer": "e1000.0",
+ "info": {
+ "restrict": false,
+ "net": "10.0.2.0",
+ "netmask": "255.255.255.0",
+ "host": 10.0.2.2",
+ "dhcpstart": "10.2.0.15",
+ "dns": "10.0.2.3"
+ },
+ },
+ ]
+ }
+
+EQMP
+
+STEXI
@item info chardev
show the character devices
ETEXI
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 2/7] QObject API: introduce qdict_to_qstring() function
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 1/7] QMP: Introduce the documentation for query-netdev and info netdev Miguel Di Ciurcio Filho
@ 2010-06-30 14:52 ` Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 3/7] net: Introduce VLANClientState->info_dict Miguel Di Ciurcio Filho
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:52 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
This is a helper function that converts a QDict to a QString, using
the format:
key1=value1 SEP key2=value2 SEP key3=value3
Handy for debugging and formating the Monitor output.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
qdict.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
qdict.h | 2 ++
2 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/qdict.c b/qdict.c
index 175bc17..dc95199 100644
--- a/qdict.c
+++ b/qdict.c
@@ -267,6 +267,66 @@ const char *qdict_get_str(const QDict *qdict, const char *key)
return qstring_get_str(qobject_to_qstring(obj));
}
+struct qstring_pack {
+ QString *str;
+ size_t total_keys;
+ size_t current_key;
+ const char *separator;
+};
+
+static void qdict_to_qstring_iter(const char *key, QObject *obj, void *opaque)
+{
+ struct qstring_pack *pack = opaque;
+ qstring_append(pack->str, key);
+ qstring_append(pack->str, "=");
+ switch (qobject_type(obj)) {
+ case QTYPE_QSTRING:
+ qstring_append(pack->str, qstring_get_str(qobject_to_qstring(obj)));
+ break;
+ case QTYPE_QINT:
+ qstring_append_int(pack->str, qint_get_int(qobject_to_qint(obj)));
+ break;
+ case QTYPE_QBOOL:
+ qstring_append(pack->str, qbool_get_int(qobject_to_qbool(obj)) ? "true" :
+ "false" );
+ break;
+ default:
+ qstring_append(pack->str, "NULL");
+ }
+
+ pack->current_key++;
+
+ if (pack->current_key < pack->total_keys) {
+ qstring_append(pack->str, pack->separator);
+ }
+}
+
+/**
+ * qdict_to_qstring(): Format a string with the keys and values of a QDict.
+ *
+ * Nested lists and dicts are not supported, yet.
+ *
+ * Return a pointer to a QString, with the following format:
+ * key1=value1 SEP key2=value2 SEP key3=value3
+ */
+QString *qdict_to_qstring(const QDict *qdict, const char *separator)
+{
+ struct qstring_pack *pack;
+ QString *str;
+ str = qstring_new();
+
+ pack = qemu_malloc(sizeof(*pack));
+ pack->str = str;
+ pack->current_key = 0;
+ pack->total_keys = qdict_size(qdict);
+ pack->separator = separator;
+
+ qdict_iter(qdict, qdict_to_qstring_iter, pack);
+
+ qemu_free(pack);
+
+ return str;
+}
/**
* qdict_get_try_int(): Try to get integer mapped by 'key'
*
diff --git a/qdict.h b/qdict.h
index 5e5902c..0c64089 100644
--- a/qdict.h
+++ b/qdict.h
@@ -15,6 +15,7 @@
#include "qobject.h"
#include "qlist.h"
+#include "qstring.h"
#include "qemu-queue.h"
#include <stdint.h>
@@ -55,6 +56,7 @@ int qdict_get_bool(const QDict *qdict, const char *key);
QList *qdict_get_qlist(const QDict *qdict, const char *key);
QDict *qdict_get_qdict(const QDict *qdict, const char *key);
const char *qdict_get_str(const QDict *qdict, const char *key);
+QString *qdict_to_qstring(const QDict *qdict, const char *separator);
int64_t qdict_get_try_int(const QDict *qdict, const char *key,
int64_t err_value);
const char *qdict_get_try_str(const QDict *qdict, const char *key);
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 3/7] net: Introduce VLANClientState->info_dict
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 1/7] QMP: Introduce the documentation for query-netdev and info netdev Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 2/7] QObject API: introduce qdict_to_qstring() function Miguel Di Ciurcio Filho
@ 2010-06-30 14:53 ` Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 4/7] net: tap/tap-win32: introduce info_dict Miguel Di Ciurcio Filho
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:53 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
There is no standard format when formatting VLANClientState.info_str,
so it is difficult to extract information and transmit it over QMP.
This patch adds info_dict, a QDict to better handle this information.
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
net.c | 1 +
net.h | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/net.c b/net.c
index 0703698..2936fe6 100644
--- a/net.c
+++ b/net.c
@@ -301,6 +301,7 @@ void qemu_del_vlan_client(VLANClientState *vc)
qemu_free(vc->name);
qemu_free(vc->model);
+ QDECREF(vc->info_dict);
qemu_free(vc);
}
diff --git a/net.h b/net.h
index 518cf9c..cfe837f 100644
--- a/net.h
+++ b/net.h
@@ -65,6 +65,7 @@ struct VLANClientState {
char *model;
char *name;
char info_str[256];
+ QDict *info_dict;
unsigned receive_disabled : 1;
};
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 4/7] net: tap/tap-win32: introduce info_dict
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
` (2 preceding siblings ...)
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 3/7] net: Introduce VLANClientState->info_dict Miguel Di Ciurcio Filho
@ 2010-06-30 14:53 ` Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 5/7] net: vde: " Miguel Di Ciurcio Filho
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:53 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
net/tap-win32.c | 7 +++++++
net/tap.c | 22 +++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 74348da..5e58702 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -32,6 +32,8 @@
#include "net.h"
#include "sysemu.h"
#include "qemu-error.h"
+#include "qdict.h"
+#include "qstring.h"
#include <stdio.h>
#include <windows.h>
#include <winioctl.h>
@@ -693,6 +695,11 @@ static int tap_win32_init(VLANState *vlan, const char *model,
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"tap: ifname=%s", ifname);
+ nc->info_dict = qdict_new()
+ qdict_put(nc->info_dict, "ifname", qstring_from_str(ifname));
+ qdict_put(nc->info_dict, "vhost", qbool_from_int(0));
+ qdict_put(nc->info_dict, "vnet_hdr", qbool_from_int(0));
+
s->handle = handle;
qemu_add_wait_object(s->handle->tap_semaphore, tap_win32_send, s);
diff --git a/net/tap.c b/net/tap.c
index 0147dab..f294091 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -39,6 +39,8 @@
#include "qemu-char.h"
#include "qemu-common.h"
#include "qemu-error.h"
+#include "qint.h"
+#include "qbool.h"
#include "net/tap-linux.h"
@@ -448,6 +450,11 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
if (qemu_opt_get(opts, "fd")) {
snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
+
+ assert(s->nc.info_dict == NULL);
+ s->nc.info_dict = qdict_new();
+ qdict_put(s->nc.info_dict, "fd", qint_from_int(fd));
+
} else {
const char *ifname, *script, *downscript;
@@ -459,12 +466,23 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
"ifname=%s,script=%s,downscript=%s",
ifname, script, downscript);
- if (strcmp(downscript, "no") != 0) {
+ assert(s->nc.info_dict == NULL);
+ s->nc.info_dict = qdict_new();
+ qdict_put(s->nc.info_dict, "ifname", qstring_from_str(ifname));
+
+ if (strcmp(downscript, "no") != 0 && downscript[0] != '\0') {
snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);
snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname);
+ qdict_put(s->nc.info_dict, "downscript", qstring_from_str(downscript));
+ }
+
+ if (strcmp(script, "no") != 0 && script[0] != '\0') {
+ qdict_put(s->nc.info_dict, "script", qstring_from_str(script));
}
}
+ qdict_put(s->nc.info_dict, "vnet_hdr", qbool_from_int(s->has_vnet_hdr));
+
if (qemu_opt_get_bool(opts, "vhost", !!qemu_opt_get(opts, "vhostfd"))) {
int vhostfd, r;
if (qemu_opt_get(opts, "vhostfd")) {
@@ -473,6 +491,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
return -1;
}
vhostfd = r;
+ qdict_put(s->nc.info_dict, "vhostfd", qint_from_int(vhostfd));
} else {
vhostfd = -1;
}
@@ -486,6 +505,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan
return -1;
}
+ qdict_put(s->nc.info_dict, "vhost", qbool_from_int(s->vhost_net ? 1 : 0));
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 5/7] net: vde: introduce info_dict
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
` (3 preceding siblings ...)
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 4/7] net: tap/tap-win32: introduce info_dict Miguel Di Ciurcio Filho
@ 2010-06-30 14:53 ` Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 6/7] net: slirp: " Miguel Di Ciurcio Filho
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:53 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
net/vde.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/net/vde.c b/net/vde.c
index 0b46fa6..a8a5b03 100644
--- a/net/vde.c
+++ b/net/vde.c
@@ -31,6 +31,9 @@
#include "qemu-char.h"
#include "qemu-common.h"
#include "qemu-option.h"
+#include "qdict.h"
+#include "qstring.h"
+#include "qint.h"
#include "sysemu.h"
typedef struct VDEState {
@@ -102,6 +105,17 @@ static int net_vde_init(VLANState *vlan, const char *model,
snprintf(nc->info_str, sizeof(nc->info_str), "sock=%s,fd=%d",
sock, vde_datafd(vde));
+ assert(nc->info_dict == NULL);
+ nc->info_dict = qdict_new();
+ qdict_put(nc->info_dict, "sock", qstring_from_str(sock));
+ qdict_put(nc->info_dict, "fd", qint_from_int(vde_datafd(vde)));
+ qdict_put(nc->info_dict, "port", qint_from_int(port));
+ qdict_put(nc->info_dict, "mode", qint_from_int(mode));
+
+ if (group) {
+ qdict_put(nc->info_dict, "group", qstring_from_str(group));
+ }
+
s = DO_UPCAST(VDEState, nc, nc);
s->vde = vde;
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 6/7] net: slirp: introduce info_dict
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
` (4 preceding siblings ...)
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 5/7] net: vde: " Miguel Di Ciurcio Filho
@ 2010-06-30 14:53 ` Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 7/7] monitor/net: introduce 'info netdev' with QMP support Miguel Di Ciurcio Filho
2010-07-05 14:05 ` [Qemu-devel] Re: [PATCH v2 0/7] QMP: Introduce query-netdev Luiz Capitulino
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:53 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
net/slirp.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index b41c60a..9549711 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -32,6 +32,9 @@
#include "monitor.h"
#include "sysemu.h"
#include "qemu_socket.h"
+#include "qdict.h"
+#include "qbool.h"
+#include "qstring.h"
#include "slirp/libslirp.h"
static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
@@ -243,6 +246,26 @@ static int net_slirp_init(VLANState *vlan, const char *model,
snprintf(nc->info_str, sizeof(nc->info_str),
"net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
+ nc->info_dict = qdict_new();
+ qdict_put(nc->info_dict, "net", qstring_from_str(inet_ntoa(net)));
+ qdict_put(nc->info_dict, "host", qstring_from_str(inet_ntoa(host)));
+ qdict_put(nc->info_dict, "dns", qstring_from_str(inet_ntoa(dns)));
+ qdict_put(nc->info_dict, "dhcpstart", qstring_from_str(inet_ntoa(dhcp)));
+ qdict_put(nc->info_dict, "netmask", qstring_from_str(inet_ntoa(mask)));
+ qdict_put(nc->info_dict, "restrict", qbool_from_int(restricted));
+
+ if (vhostname) {
+ qdict_put(nc->info_dict, "hostname", qstring_from_str(vhostname));
+ }
+
+ if (tftp_export) {
+ qdict_put(nc->info_dict, "tftp", qstring_from_str(tftp_export));
+ }
+
+ if (bootfile) {
+ qdict_put(nc->info_dict, "bootfile", qstring_from_str(bootfile));
+ }
+
s = DO_UPCAST(SlirpState, nc, nc);
s->slirp = slirp_init(restricted, net, mask, host, vhostname,
@@ -252,12 +275,20 @@ static int net_slirp_init(VLANState *vlan, const char *model,
for (config = slirp_configs; config; config = config->next) {
if (config->flags & SLIRP_CFG_HOSTFWD) {
if (slirp_hostfwd(s, config->str,
- config->flags & SLIRP_CFG_LEGACY) < 0)
+ config->flags & SLIRP_CFG_LEGACY) < 0) {
goto error;
+ } else {
+ qdict_put(nc->info_dict, "hostfwd",
+ qstring_from_str(config->str));
+ }
} else {
if (slirp_guestfwd(s, config->str,
- config->flags & SLIRP_CFG_LEGACY) < 0)
+ config->flags & SLIRP_CFG_LEGACY) < 0) {
goto error;
+ } else {
+ qdict_put(nc->info_dict, "guestfwd",
+ qstring_from_str(config->str));
+ }
}
}
#ifndef _WIN32
@@ -265,8 +296,13 @@ static int net_slirp_init(VLANState *vlan, const char *model,
smb_export = legacy_smb_export;
}
if (smb_export) {
- if (slirp_smb(s, smb_export, smbsrv) < 0)
+ if (slirp_smb(s, smb_export, smbsrv) < 0) {
goto error;
+ } else {
+ qdict_put(nc->info_dict, "smb", qstring_from_str(smb_export));
+ qdict_put(nc->info_dict, "smbserver",
+ qstring_from_str(inet_ntoa(smbsrv)));
+ }
}
#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 7/7] monitor/net: introduce 'info netdev' with QMP support
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
` (5 preceding siblings ...)
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 6/7] net: slirp: " Miguel Di Ciurcio Filho
@ 2010-06-30 14:53 ` Miguel Di Ciurcio Filho
2010-07-05 14:05 ` [Qemu-devel] Re: [PATCH v2 0/7] QMP: Introduce query-netdev Luiz Capitulino
7 siblings, 0 replies; 9+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-06-30 14:53 UTC (permalink / raw)
To: qemu-devel; +Cc: avi, Miguel Di Ciurcio Filho, armbru, lcapitulino
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
monitor.c | 8 +++++++
net.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
net.h | 2 +
3 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c
index 170b269..b44768c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2314,6 +2314,14 @@ static const mon_cmd_t info_cmds[] = {
.mhandler.info = do_info_network,
},
{
+ .name = "netdev",
+ .args_type = "",
+ .params = "",
+ .help = "show information about network backend devices",
+ .user_print = do_info_netdev_print,
+ .mhandler.info_new = do_info_netdev,
+ },
+ {
.name = "chardev",
.args_type = "",
.params = "",
diff --git a/net.c b/net.c
index 2936fe6..bbb8998 100644
--- a/net.c
+++ b/net.c
@@ -36,6 +36,8 @@
#include "qemu-common.h"
#include "qemu_socket.h"
#include "hw/qdev.h"
+#include "qdict.h"
+#include "qjson.h"
static QTAILQ_HEAD(, VLANState) vlans;
static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
@@ -1249,6 +1251,75 @@ void do_info_network(Monitor *mon)
}
}
+static void netdev_iter(QObject *obj, void *opaque)
+{
+
+ Monitor *mon = opaque;
+ QDict *net_device = qobject_to_qdict(obj);
+ QString *qstring;
+
+ monitor_printf(mon, "%s: ", qdict_get_str(net_device, "id"));
+
+ monitor_printf(mon, "type=%s,", qdict_get_str(net_device, "type"));
+
+ if (qdict_haskey(net_device, "peer")) {
+ monitor_printf(mon, "peer=%s,", qdict_get_str(net_device, "peer"));
+ }
+
+ qstring = qdict_to_qstring(qdict_get_qdict(net_device, "info"), ",");
+ monitor_printf(mon, qstring_get_str(qstring));
+ QDECREF(qstring);
+
+ monitor_printf(mon, "\n");
+
+}
+
+void do_info_netdev_print(Monitor *mon, const QObject *ret_data)
+{
+
+ QList *net_devices;
+
+ net_devices = qobject_to_qlist(ret_data);
+
+ qlist_iter(net_devices, netdev_iter, mon);
+
+}
+
+void do_info_netdev(Monitor *mon, QObject **ret_data)
+{
+ VLANClientState *vc;
+ QDict *net_device;
+ QList *device_list;
+ device_list = qlist_new();
+ QObject *obj;
+
+ QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
+
+ if (vc->info->type == NET_CLIENT_TYPE_NONE ||
+ vc->info->type == NET_CLIENT_TYPE_NIC ||
+ vc->info->type == NET_CLIENT_TYPE_SOCKET ||
+ vc->info->type == NET_CLIENT_TYPE_DUMP) {
+ continue;
+ }
+
+ obj = qobject_from_jsonf("{'id': %s, 'type': %s}",
+ vc->name, vc->model);
+
+ net_device = qobject_to_qdict(obj);
+
+ QINCREF(vc->info_dict);
+ qdict_put(net_device, "info", vc->info_dict);
+
+ if (vc->peer) {
+ qdict_put(net_device, "peer", qstring_from_str(vc->peer->name));
+ }
+
+ qlist_append(device_list, net_device);
+ }
+
+ *ret_data = QOBJECT(device_list);
+}
+
int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
VLANState *vlan;
diff --git a/net.h b/net.h
index cfe837f..69a3c9f 100644
--- a/net.h
+++ b/net.h
@@ -118,6 +118,8 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
const char *default_model);
void do_info_network(Monitor *mon);
+void do_info_netdev_print(Monitor *mon, const QObject *ret_data);
+void do_info_netdev(Monitor *mon, QObject **ret_data);
int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data);
/* NIC info */
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] Re: [PATCH v2 0/7] QMP: Introduce query-netdev
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
` (6 preceding siblings ...)
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 7/7] monitor/net: introduce 'info netdev' with QMP support Miguel Di Ciurcio Filho
@ 2010-07-05 14:05 ` Luiz Capitulino
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Capitulino @ 2010-07-05 14:05 UTC (permalink / raw)
To: Miguel Di Ciurcio Filho; +Cc: avi, qemu-devel, armbru
On Wed, 30 Jun 2010 11:52:57 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:
> This series implement the previously discussed QMP command query-netdev.
Looks good to me now, applied to the monitor queue.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-07-05 14:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-30 14:52 [Qemu-devel] [PATCH v2 0/7] QMP: Introduce query-netdev Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 1/7] QMP: Introduce the documentation for query-netdev and info netdev Miguel Di Ciurcio Filho
2010-06-30 14:52 ` [Qemu-devel] [PATCH v2 2/7] QObject API: introduce qdict_to_qstring() function Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 3/7] net: Introduce VLANClientState->info_dict Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 4/7] net: tap/tap-win32: introduce info_dict Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 5/7] net: vde: " Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 6/7] net: slirp: " Miguel Di Ciurcio Filho
2010-06-30 14:53 ` [Qemu-devel] [PATCH v2 7/7] monitor/net: introduce 'info netdev' with QMP support Miguel Di Ciurcio Filho
2010-07-05 14:05 ` [Qemu-devel] Re: [PATCH v2 0/7] QMP: Introduce query-netdev Luiz Capitulino
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).