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] qmp: add get_link_status
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi/net.json | 15 +++++++++++++++
9 2 files changed, 42 insertions(+)
11 diff --git a/net/net.c b/net/net.c
12 index 39ef546708..3681aa2173 100644
15 @@ -1399,6 +1399,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
19 +int64_t qmp_get_link_status(const char *name, Error **errp)
21 + NetClientState *ncs[MAX_QUEUE_NUM];
26 + queues = qemu_find_net_clients_except(name, ncs,
27 + NET_CLIENT_DRIVER__MAX,
31 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
32 + "Device '%s' not found", name);
33 + return (int64_t) -1;
37 + ret = ncs[0]->link_down;
39 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
40 + ret = ncs[0]->peer->link_down;
43 + return (int64_t) ret ? 0 : 1;
46 void qmp_set_link(const char *name, bool up, Error **errp)
48 NetClientState *ncs[MAX_QUEUE_NUM];
49 diff --git a/qapi/net.json b/qapi/net.json
50 index 4beff5d582..73334c8f3c 100644
54 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
59 +# Get the current link state of the nics or nic.
61 +# @name: name of the nic you get the state of
63 +# Return: If link is up 1
65 +# If an error occure an empty string.
67 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
69 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
74 # Add a network backend.