This method is used to get the network peers by querying the monitor.

Signed-off-by: Jason Wang <jasow...@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 969558b..c44117c 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -1207,6 +1207,20 @@ class VM:
                 raise VMPortNotRedirectedError(port)
 
 
+    def get_peer(self, netid):
+        """
+        Return the peer of netdev or network deivce.
+
+        @param netid: id of netdev or device
+        @return: id of the peer device otherwise None
+        """
+        network_info = self.monitor.info("network")
+        try:
+            return re.findall("%s:.*peer=(.*)" % netid, network_info)[0]
+        except IndexError:
+            return None
+
+
     def get_ifname(self, nic_index=0):
         """
         Return the ifname of a tap device associated with a NIC.

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to