1 Index: new/scripts/qapi.py
2 ===================================================================
3 --- new.orig/scripts/qapi.py 2015-07-13 10:00:00.000000000 +0100
4 +++ new/scripts/qapi.py 2015-07-13 15:50:00.000000000 +0100
7 # Whitelist of commands allowed to return a non-dictionary
12 'human-monitor-command',
13 'query-migrate-cache-size',
14 Index: new/qapi-schema.json
15 ===================================================================
16 --- new.orig/qapi-schema.json 2014-12-10 09:15:50.890262765 +0100
17 +++ new/qapi-schema.json 2014-12-11 09:20:31.072561486 +0100
18 @@ -1366,6 +1366,21 @@
20 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
25 +# Get the current link state of the nics or nic.
27 +# @name: name of the nic you get the state of
29 +# Return: If link is up 1
31 +# If an error occure an empty string.
33 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
35 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
41 ===================================================================
42 --- new.orig/net/net.c 2014-12-10 10:24:39.790496356 +0100
43 +++ new/net/net.c 2014-12-11 09:37:55.971321170 +0100
44 @@ -1141,6 +1141,33 @@
48 +int64_t qmp_get_link_status(const char *name, Error **errp)
50 + NetClientState *ncs[MAX_QUEUE_NUM];
55 + queues = qemu_find_net_clients_except(name, ncs,
56 + NET_CLIENT_OPTIONS_KIND_MAX,
60 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
61 + "Device '%s' not found", name);
62 + return (int64_t) -1;
66 + ret = ncs[0]->link_down;
68 + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
69 + ret = ncs[0]->peer->link_down;
72 + return (int64_t) ret ? 0 : 1;
75 void qmp_set_link(const char *name, bool up, Error **errp)
77 NetClientState *ncs[MAX_QUEUE_NUM];
78 Index: new/qmp-commands.hx
79 ===================================================================
80 --- new.orig/qmp-commands.hx 2014-12-10 09:15:50.891262737 +0100
81 +++ new/qmp-commands.hx 2014-12-11 08:36:26.583532314 +0100
82 @@ -1473,6 +1473,29 @@
86 + .name = "get_link_status",
87 + .args_type = "name:s",
88 + .mhandler.cmd_new = qmp_marshal_input_get_link_status,
95 +Get the link status of a network adapter.
99 +- "name": network device name (json-string)
103 +-> { "execute": "get_link_status", "arguments": { "name": "e1000.0" } }
104 +<- { "return": {1} }
110 .args_type = "fdname:s",
111 .params = "getfd name",