]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0009-PVE-Up-qmp-add-get_link_status.patch
e210da25d4373ed6b8a83da5c772eb02d44aeca7
[pve-qemu.git] / debian / patches / pve / 0009-PVE-Up-qmp-add-get_link_status.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 16:34:41 +0100
4 Subject: [PATCH] PVE: [Up] qmp: add get_link_status
5
6 ---
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi/net.json | 15 +++++++++++++++
9 qapi/qapi-schema.json | 1 +
10 3 files changed, 43 insertions(+)
11
12 diff --git a/net/net.c b/net/net.c
13 index 2a3133990c..cd9178d6c9 100644
14 --- a/net/net.c
15 +++ b/net/net.c
16 @@ -1331,6 +1331,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
17 }
18 }
19
20 +int64_t qmp_get_link_status(const char *name, Error **errp)
21 +{
22 + NetClientState *ncs[MAX_QUEUE_NUM];
23 + NetClientState *nc;
24 + int queues;
25 + bool ret;
26 +
27 + queues = qemu_find_net_clients_except(name, ncs,
28 + NET_CLIENT_DRIVER__MAX,
29 + MAX_QUEUE_NUM);
30 +
31 + if (queues == 0) {
32 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
33 + "Device '%s' not found", name);
34 + return (int64_t) -1;
35 + }
36 +
37 + nc = ncs[0];
38 + ret = ncs[0]->link_down;
39 +
40 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
41 + ret = ncs[0]->peer->link_down;
42 + }
43 +
44 + return (int64_t) ret ? 0 : 1;
45 +}
46 +
47 void qmp_set_link(const char *name, bool up, Error **errp)
48 {
49 NetClientState *ncs[MAX_QUEUE_NUM];
50 diff --git a/qapi/net.json b/qapi/net.json
51 index c86f351161..9a69a3b0f7 100644
52 --- a/qapi/net.json
53 +++ b/qapi/net.json
54 @@ -35,6 +35,21 @@
55 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
56
57 ##
58 +# @get_link_status:
59 +#
60 +# Get the current link state of the nics or nic.
61 +#
62 +# @name: name of the nic you get the state of
63 +#
64 +# Return: If link is up 1
65 +# If link is down 0
66 +# If an error occure an empty string.
67 +#
68 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
69 +##
70 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
71 +
72 +##
73 # @netdev_add:
74 #
75 # Add a network backend.
76 diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
77 index 65b6dc2f6f..4bc906bc7c 100644
78 --- a/qapi/qapi-schema.json
79 +++ b/qapi/qapi-schema.json
80 @@ -61,6 +61,7 @@
81 'query-migrate-cache-size',
82 'query-tpm-models',
83 'query-tpm-types',
84 + 'get_link_status',
85 'ringbuf-read' ],
86 'name-case-whitelist': [
87 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status
88 --
89 2.11.0
90