]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
bump version to 8.0.2-1
[pve-qemu.git] / debian / patches / pve / 0007-PVE-Up-qmp-add-get_link_status.patch
CommitLineData
23102ed6 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
95259824 2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
83faa3fe
TL
3Date: Mon, 6 Apr 2020 12:16:37 +0200
4Subject: [PATCH] PVE: [Up] qmp: add get_link_status
95259824 5
b855dce7 6Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
271ac0a8
FE
7[FE: add get_link_status to command name exceptions]
8Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
95259824 9---
83faa3fe
TL
10 net/net.c | 27 +++++++++++++++++++++++++++
11 qapi/net.json | 15 +++++++++++++++
271ac0a8
FE
12 qapi/pragma.json | 2 ++
13 3 files changed, 44 insertions(+)
95259824
WB
14
15diff --git a/net/net.c b/net/net.c
bf251437 16index 6492ad530e..33e901cba8 100644
95259824
WB
17--- a/net/net.c
18+++ b/net/net.c
bf251437
FE
19@@ -1397,6 +1397,33 @@ RxFilterInfoList *qmp_query_rx_filter(const char *name, Error **errp)
20 return filter_list;
95259824
WB
21 }
22
23+int64_t qmp_get_link_status(const char *name, Error **errp)
24+{
25+ NetClientState *ncs[MAX_QUEUE_NUM];
26+ NetClientState *nc;
27+ int queues;
28+ bool ret;
29+
30+ queues = qemu_find_net_clients_except(name, ncs,
31+ NET_CLIENT_DRIVER__MAX,
32+ MAX_QUEUE_NUM);
33+
34+ if (queues == 0) {
35+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
36+ "Device '%s' not found", name);
37+ return (int64_t) -1;
38+ }
39+
40+ nc = ncs[0];
41+ ret = ncs[0]->link_down;
42+
43+ if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
44+ ret = ncs[0]->peer->link_down;
45+ }
46+
47+ return (int64_t) ret ? 0 : 1;
48+}
49+
b855dce7 50 void colo_notify_filters_event(int event, Error **errp)
95259824 51 {
b855dce7 52 NetClientState *nc;
6838f038 53diff --git a/qapi/net.json b/qapi/net.json
bf251437 54index d6eb30008b..4fe71b149d 100644
6838f038
WB
55--- a/qapi/net.json
56+++ b/qapi/net.json
d03e1b3c 57@@ -36,6 +36,21 @@
b855dce7 58 ##
95259824
WB
59 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
60
b855dce7 61+##
a544966d 62+# @get_link_status:
95259824
WB
63+#
64+# Get the current link state of the nics or nic.
65+#
66+# @name: name of the nic you get the state of
67+#
68+# Return: If link is up 1
69+# If link is down 0
70+# If an error occure an empty string.
71+#
72+# Notes: this is an Proxmox VE extension and not offical part of Qemu.
73+##
83faa3fe 74+{ 'command': 'get_link_status', 'data': {'name': 'str'} , 'returns': 'int' }
95259824 75+
b855dce7 76 ##
6838f038 77 # @netdev_add:
95259824 78 #
83faa3fe 79diff --git a/qapi/pragma.json b/qapi/pragma.json
271ac0a8 80index 7f810b0e97..29233db825 100644
83faa3fe
TL
81--- a/qapi/pragma.json
82+++ b/qapi/pragma.json
271ac0a8
FE
83@@ -15,6 +15,7 @@
84 'device_add',
85 'device_del',
86 'expire_password',
87+ 'get_link_status',
88 'migrate_cancel',
89 'netdev_add',
90 'netdev_del',
91@@ -26,6 +27,7 @@
8dca018b 92 'system_wakeup' ],
5b15e2ec 93 # Commands allowed to return a non-dictionary
8dca018b
SR
94 'command-returns-exceptions': [
95+ 'get_link_status',
83faa3fe
TL
96 'human-monitor-command',
97 'qom-get',
8dca018b 98 'query-tpm-models',