]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0008-PVE-Up-qmp-add-get_link_status.patch
bump version to 4.2.0-2
[pve-qemu.git] / debian / patches / pve / 0008-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>
6402d961
TL
3Date: Tue, 10 Mar 2020 12:55:05 +0100
4Subject: [PATCH 08/32] PVE: [Up] qmp: add get_link_status
95259824 5
b855dce7 6Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
95259824 7---
53e83913
WB
8 net/net.c | 27 +++++++++++++++++++++++++++
9 qapi/net.json | 15 +++++++++++++++
10 qapi/qapi-schema.json | 1 +
11 3 files changed, 43 insertions(+)
95259824
WB
12
13diff --git a/net/net.c b/net/net.c
6402d961 14index 84aa6d8d00..f548202ec6 100644
95259824
WB
15--- a/net/net.c
16+++ b/net/net.c
6402d961 17@@ -1349,6 +1349,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
95259824
WB
18 }
19 }
20
21+int64_t qmp_get_link_status(const char *name, Error **errp)
22+{
23+ NetClientState *ncs[MAX_QUEUE_NUM];
24+ NetClientState *nc;
25+ int queues;
26+ bool ret;
27+
28+ queues = qemu_find_net_clients_except(name, ncs,
29+ NET_CLIENT_DRIVER__MAX,
30+ MAX_QUEUE_NUM);
31+
32+ if (queues == 0) {
33+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
34+ "Device '%s' not found", name);
35+ return (int64_t) -1;
36+ }
37+
38+ nc = ncs[0];
39+ ret = ncs[0]->link_down;
40+
41+ if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
42+ ret = ncs[0]->peer->link_down;
43+ }
44+
45+ return (int64_t) ret ? 0 : 1;
46+}
47+
b855dce7 48 void colo_notify_filters_event(int event, Error **errp)
95259824 49 {
b855dce7 50 NetClientState *nc;
6838f038 51diff --git a/qapi/net.json b/qapi/net.json
6402d961 52index 335295be50..7f3ea194c8 100644
6838f038
WB
53--- a/qapi/net.json
54+++ b/qapi/net.json
b855dce7
TL
55@@ -34,6 +34,21 @@
56 ##
95259824
WB
57 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
58
b855dce7 59+##
a544966d 60+# @get_link_status:
95259824
WB
61+#
62+# Get the current link state of the nics or nic.
63+#
64+# @name: name of the nic you get the state of
65+#
66+# Return: If link is up 1
67+# If link is down 0
68+# If an error occure an empty string.
69+#
70+# Notes: this is an Proxmox VE extension and not offical part of Qemu.
71+##
72+{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
73+
b855dce7 74 ##
6838f038 75 # @netdev_add:
95259824 76 #
53e83913 77diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
6402d961 78index 9751b11f8f..a449f158e1 100644
53e83913
WB
79--- a/qapi/qapi-schema.json
80+++ b/qapi/qapi-schema.json
81@@ -61,6 +61,7 @@
82 'query-migrate-cache-size',
83 'query-tpm-models',
84 'query-tpm-types',
85+ 'get_link_status',
86 'ringbuf-read' ],
87 'name-case-whitelist': [
b855dce7 88 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status