]>
Commit | Line | Data |
---|---|---|
1bd87f7c WL |
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 | |
047e4448 | 5 | @@ -1366,6 +1366,31 @@ |
1bd87f7c WL |
6 | ## |
7 | { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} } | |
8 | ||
047e4448 WB |
9 | +## |
10 | +# @LinkStatus: | |
11 | +# | |
12 | +# Nic LinkStatus information. | |
13 | +# | |
14 | +# @status: the status of the nic | |
15 | +# | |
16 | +## | |
17 | +{ 'struct': 'LinkStatus', 'data': {'status': 'int'} } | |
1bd87f7c WL |
18 | + |
19 | +## | |
20 | +# @get_link_status | |
21 | +# | |
22 | +# Get the current link state of the nics or nic. | |
23 | +# | |
24 | +# @name: name of the nic you get the state of | |
25 | +# | |
26 | +# Return: If link is up 1 | |
27 | +# If link is down 0 | |
28 | +# If an error occure an empty string. | |
29 | +# | |
30 | +# Notes: this is an Proxmox VE extension and not offical part of Qemu. | |
31 | +## | |
047e4448 | 32 | +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'LinkStatus'} |
1bd87f7c WL |
33 | + |
34 | ## | |
35 | # @balloon: | |
36 | # | |
37 | Index: new/net/net.c | |
38 | =================================================================== | |
39 | --- new.orig/net/net.c 2014-12-10 10:24:39.790496356 +0100 | |
40 | +++ new/net/net.c 2014-12-11 09:37:55.971321170 +0100 | |
41 | @@ -1141,6 +1141,32 @@ | |
42 | } | |
43 | } | |
44 | ||
45 | +int64_t qmp_get_link_status(const char *name, Error **errp) | |
46 | +{ | |
47 | + NetClientState *ncs[MAX_QUEUE_NUM]; | |
48 | + NetClientState *nc; | |
49 | + int queues; | |
50 | + bool ret; | |
51 | + | |
52 | + queues = qemu_find_net_clients_except(name, ncs, | |
53 | + NET_CLIENT_OPTIONS_KIND_MAX, | |
54 | + MAX_QUEUE_NUM); | |
55 | + | |
56 | + if (queues == 0) { | |
57 | + error_set(errp, QERR_DEVICE_NOT_FOUND, name); | |
58 | + return (int64_t) -1; | |
59 | + } | |
60 | + | |
61 | + nc = ncs[0]; | |
62 | + ret = ncs[0]->link_down; | |
63 | + | |
64 | + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { | |
65 | + ret = ncs[0]->peer->link_down; | |
66 | + } | |
67 | + | |
68 | + return (int64_t) ret ? 0 : 1; | |
69 | +} | |
70 | + | |
71 | void qmp_set_link(const char *name, bool up, Error **errp) | |
72 | { | |
73 | NetClientState *ncs[MAX_QUEUE_NUM]; | |
74 | Index: new/qmp-commands.hx | |
75 | =================================================================== | |
76 | --- new.orig/qmp-commands.hx 2014-12-10 09:15:50.891262737 +0100 | |
77 | +++ new/qmp-commands.hx 2014-12-11 08:36:26.583532314 +0100 | |
78 | @@ -1473,6 +1473,29 @@ | |
79 | EQMP | |
80 | ||
81 | { | |
82 | + .name = "get_link_status", | |
83 | + .args_type = "name:s", | |
84 | + .mhandler.cmd_new = qmp_marshal_input_get_link_status, | |
85 | + }, | |
86 | + | |
87 | +SQMP | |
88 | +get_link_status | |
89 | +-------- | |
90 | + | |
91 | +Get the link status of a network adapter. | |
92 | + | |
93 | +Arguments: | |
94 | + | |
95 | +- "name": network device name (json-string) | |
96 | + | |
97 | +Example: | |
98 | + | |
99 | +-> { "execute": "set_link", "arguments": { "name": "e1000.0" } } | |
100 | +<- { "return": {1} } | |
101 | + | |
102 | +EQMP | |
103 | + | |
104 | + { | |
105 | .name = "getfd", | |
106 | .args_type = "fdname:s", | |
107 | .params = "getfd name", |