1 Index: new/qapi-schema.json
2 ===================================================================
3 --- new.orig/qapi-schema.json 2014-12-10 09:15:50.890262765 +0100
4 +++ new/qapi-schema.json 2014-12-11 09:20:31.072561486 +0100
7 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
13 +# Get the current link state of the nics or nic.
15 +# @name: name of the nic you get the state of
17 +# Return: If link is up 1
19 +# If an error occure an empty string.
21 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
23 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
29 ===================================================================
30 --- new.orig/net/net.c 2014-12-10 10:24:39.790496356 +0100
31 +++ new/net/net.c 2014-12-11 09:37:55.971321170 +0100
32 @@ -1141,6 +1141,32 @@
36 +int64_t qmp_get_link_status(const char *name, Error **errp)
38 + NetClientState *ncs[MAX_QUEUE_NUM];
43 + queues = qemu_find_net_clients_except(name, ncs,
44 + NET_CLIENT_OPTIONS_KIND_MAX,
48 + error_set(errp, QERR_DEVICE_NOT_FOUND, name);
49 + return (int64_t) -1;
53 + ret = ncs[0]->link_down;
55 + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
56 + ret = ncs[0]->peer->link_down;
59 + return (int64_t) ret ? 0 : 1;
62 void qmp_set_link(const char *name, bool up, Error **errp)
64 NetClientState *ncs[MAX_QUEUE_NUM];
65 Index: new/qmp-commands.hx
66 ===================================================================
67 --- new.orig/qmp-commands.hx 2014-12-10 09:15:50.891262737 +0100
68 +++ new/qmp-commands.hx 2014-12-11 08:36:26.583532314 +0100
69 @@ -1473,6 +1473,29 @@
73 + .name = "get_link_status",
74 + .args_type = "name:s",
75 + .mhandler.cmd_new = qmp_marshal_input_get_link_status,
82 +Get the link status of a network adapter.
86 +- "name": network device name (json-string)
90 +-> { "execute": "set_link", "arguments": { "name": "e1000.0" } }
97 .args_type = "fdname:s",
98 .params = "getfd name",