[pve-devel] [PATCH] implement the command get_link_status to qemu-kve paket. so you can call per QMP. this funktion is not implemented in monitor. this command return the state of the given nic to check it. 1 for up 0 for down -1 for error
Wolfgang Link
wolfgang at linksystems.org
Thu Dec 11 10:13:12 CET 2014
Signed-off-by: Wolfgang Link <wolfgang at linksystems.org>
---
debian/patches/add-qmp-get-link-status.patch | 98 ++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 99 insertions(+)
create mode 100644 debian/patches/add-qmp-get-link-status.patch
diff --git a/debian/patches/add-qmp-get-link-status.patch b/debian/patches/add-qmp-get-link-status.patch
new file mode 100644
index 0000000..105d415
--- /dev/null
+++ b/debian/patches/add-qmp-get-link-status.patch
@@ -0,0 +1,98 @@
+Index: new/qapi-schema.json
+===================================================================
+--- new.orig/qapi-schema.json 2014-12-10 09:15:50.890262765 +0100
++++ new/qapi-schema.json 2014-12-11 09:20:31.072561486 +0100
+@@ -1366,6 +1366,22 @@
+ ##
+ { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
+
++
++##
++# @get_link_status
++#
++# Get the current link state of the nics or nic.
++#
++# @name: name of the nic you get the state of
++#
++# Return: If link is up 1
++# If link is down 0
++# If an error occure an empty string.
++#
++# Notes: this is an Proxmox VE extension and not offical part of Qemu.
++##
++{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
++
+ ##
+ # @balloon:
+ #
+Index: new/net/net.c
+===================================================================
+--- new.orig/net/net.c 2014-12-10 10:24:39.790496356 +0100
++++ new/net/net.c 2014-12-11 09:37:55.971321170 +0100
+@@ -1141,6 +1141,32 @@
+ }
+ }
+
++int64_t qmp_get_link_status(const char *name, Error **errp)
++{
++ NetClientState *ncs[MAX_QUEUE_NUM];
++ NetClientState *nc;
++ int queues;
++ bool ret;
++
++ queues = qemu_find_net_clients_except(name, ncs,
++ NET_CLIENT_OPTIONS_KIND_MAX,
++ MAX_QUEUE_NUM);
++
++ if (queues == 0) {
++ error_set(errp, QERR_DEVICE_NOT_FOUND, name);
++ return (int64_t) -1;
++ }
++
++ nc = ncs[0];
++ ret = ncs[0]->link_down;
++
++ if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
++ ret = ncs[0]->peer->link_down;
++ }
++
++ return (int64_t) ret ? 0 : 1;
++}
++
+ void qmp_set_link(const char *name, bool up, Error **errp)
+ {
+ NetClientState *ncs[MAX_QUEUE_NUM];
+Index: new/qmp-commands.hx
+===================================================================
+--- new.orig/qmp-commands.hx 2014-12-10 09:15:50.891262737 +0100
++++ new/qmp-commands.hx 2014-12-11 08:36:26.583532314 +0100
+@@ -1473,6 +1473,29 @@
+ EQMP
+
+ {
++ .name = "get_link_status",
++ .args_type = "name:s",
++ .mhandler.cmd_new = qmp_marshal_input_get_link_status,
++ },
++
++SQMP
++get_link_status
++--------
++
++Get the link status of a network adapter.
++
++Arguments:
++
++- "name": network device name (json-string)
++
++Example:
++
++-> { "execute": "set_link", "arguments": { "name": "e1000.0" } }
++<- { "return": {1} }
++
++EQMP
++
++ {
+ .name = "getfd",
+ .args_type = "fdname:s",
+ .params = "getfd name",
diff --git a/debian/patches/series b/debian/patches/series
index 56741e6..e5bc4f5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -28,3 +28,4 @@ disable-efi-enable-pxe-roms.patch
backup-vma-allow-empty-backups.patch
glusterfs-daemonize.patch
gluster-backupserver.patch
+add-qmp-get-link-status.patch
--
1.7.10.4
More information about the pve-devel
mailing list