qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax


From: Martin Cerveny
Subject: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
Date: Wed, 13 May 2015 14:14:53 +0200

Add network syntax parsing (ip address, port) to qom-* scripts.

Signed-off-by: Martin Cerveny <address@hidden>
---
 scripts/qmp/qom-fuse |   13 ++++++++++++-
 scripts/qmp/qom-get  |   12 +++++++++++-
 scripts/qmp/qom-list |   12 +++++++++++-
 scripts/qmp/qom-set  |   12 +++++++++++-
 scripts/qmp/qom-tree |   12 +++++++++++-
 5 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index 5c6754a..d49f36d 100755
--- a/scripts/qmp/qom-fuse
+++ b/scripts/qmp/qom-fuse
@@ -134,5 +134,16 @@ class QOMFS(Fuse):
 if __name__ == '__main__':
     import sys, os
 
-    fs = QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET']))
+    socket_path = os.environ['QMP_SOCKET']
+    connection = socket_path.split(':')
+    if len(connection) == 2:
+        try:
+            port = int(connection[1])
+        except ValueError:
+            raise QMPBadPort
+        connection = ( connection[0], port )
+    else:
+        connection = socket_path
+
+    fs = QOMFS(QEMUMonitorProtocol(connection))
     fs.main(sys.argv)
diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
index 0172c69..f12eb52 100755
--- a/scripts/qmp/qom-get
+++ b/scripts/qmp/qom-get
@@ -56,7 +56,17 @@ if len(args) > 0:
 else:
     usage_error("not enough arguments")
 
-srv = QEMUMonitorProtocol(socket_path)
+connection = socket_path.split(':')
+if len(connection) == 2:
+    try:
+         port = int(connection[1])
+    except ValueError:
+         raise QMPBadPort
+    connection = ( connection[0], port )
+else:
+    connection = socket_path
+
+srv = QEMUMonitorProtocol(connection)
 srv.connect()
 
 rsp = srv.command('qom-get', path=path, property=prop)
diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
index 1e7cc6c..fadcce4 100755
--- a/scripts/qmp/qom-list
+++ b/scripts/qmp/qom-list
@@ -48,7 +48,17 @@ if not socket_path:
     else:
         usage_error("no QMP socket path or address given");
 
-srv = QEMUMonitorProtocol(socket_path)
+connection = socket_path.split(':')
+if len(connection) == 2:
+    try:
+         port = int(connection[1])
+    except ValueError:
+         raise QMPBadPort
+    connection = ( connection[0], port )
+else:
+    connection = socket_path
+
+srv = QEMUMonitorProtocol(connection)
 srv.connect()
 
 if len(args) == 0:
diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
index 54ecfec..b05fae3 100755
--- a/scripts/qmp/qom-set
+++ b/scripts/qmp/qom-set
@@ -58,7 +58,17 @@ if len(args) > 1:
 else:
     usage_error("not enough arguments")
 
-srv = QEMUMonitorProtocol(socket_path)
+connection = socket_path.split(':')
+if len(connection) == 2:
+    try:
+         port = int(connection[1])
+    except ValueError:
+         raise QMPBadPort
+    connection = ( connection[0], port )
+else:
+    connection = socket_path
+
+srv = QEMUMonitorProtocol(connection)
 srv.connect()
 
 print srv.command('qom-set', path=path, property=prop, value=sys.argv[2])
diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
index aea11d4..07f8a9d 100755
--- a/scripts/qmp/qom-tree
+++ b/scripts/qmp/qom-tree
@@ -50,7 +50,17 @@ if not socket_path:
     else:
         usage_error("no QMP socket path or address given");
 
-srv = QEMUMonitorProtocol(socket_path)
+connection = socket_path.split(':')
+if len(connection) == 2:
+    try:
+         port = int(connection[1])
+    except ValueError:
+         raise QMPBadPort
+    connection = ( connection[0], port )
+else:
+    connection = socket_path
+
+srv = QEMUMonitorProtocol(connection)
 srv.connect()
 
 def list_node(path):
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]