]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0012-qmp-add-get_link_status.patch
bump version to 2.11.1-1
[pve-qemu.git] / debian / patches / pve / 0012-qmp-add-get_link_status.patch
CommitLineData
23102ed6 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
95259824
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Wed, 9 Dec 2015 16:34:41 +0100
23102ed6 4Subject: [PATCH] qmp: add get_link_status
95259824
WB
5
6---
6838f038
WB
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi/net.json | 15 +++++++++++++++
9 2 files changed, 42 insertions(+)
95259824
WB
10
11diff --git a/net/net.c b/net/net.c
6838f038 12index 39ef546708..3681aa2173 100644
95259824
WB
13--- a/net/net.c
14+++ b/net/net.c
6838f038 15@@ -1399,6 +1399,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
95259824
WB
16 }
17 }
18
19+int64_t qmp_get_link_status(const char *name, Error **errp)
20+{
21+ NetClientState *ncs[MAX_QUEUE_NUM];
22+ NetClientState *nc;
23+ int queues;
24+ bool ret;
25+
26+ queues = qemu_find_net_clients_except(name, ncs,
27+ NET_CLIENT_DRIVER__MAX,
28+ MAX_QUEUE_NUM);
29+
30+ if (queues == 0) {
31+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
32+ "Device '%s' not found", name);
33+ return (int64_t) -1;
34+ }
35+
36+ nc = ncs[0];
37+ ret = ncs[0]->link_down;
38+
39+ if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
40+ ret = ncs[0]->peer->link_down;
41+ }
42+
43+ return (int64_t) ret ? 0 : 1;
44+}
45+
46 void qmp_set_link(const char *name, bool up, Error **errp)
47 {
48 NetClientState *ncs[MAX_QUEUE_NUM];
6838f038
WB
49diff --git a/qapi/net.json b/qapi/net.json
50index 4beff5d582..73334c8f3c 100644
51--- a/qapi/net.json
52+++ b/qapi/net.json
53@@ -35,6 +35,21 @@
95259824
WB
54 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
55
56 ##
a544966d 57+# @get_link_status:
95259824
WB
58+#
59+# Get the current link state of the nics or nic.
60+#
61+# @name: name of the nic you get the state of
62+#
63+# Return: If link is up 1
64+# If link is down 0
65+# If an error occure an empty string.
66+#
67+# Notes: this is an Proxmox VE extension and not offical part of Qemu.
68+##
69+{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
70+
71+##
6838f038 72 # @netdev_add:
95259824 73 #
6838f038 74 # Add a network backend.
95259824 75--
45169293 762.11.0
95259824 77