From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] covert DUT hostname into ipaddress for qemu tcp forward
Date: Fri, 19 Jun 2015 16:36:25 +0800 [thread overview]
Message-ID: <1434702985-20049-1-git-send-email-yong.liu@intel.com> (raw)
From: Marvin Liu <yong.liu@intel.com>
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 434c32d..50f229b 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -36,6 +36,7 @@ import os
from virt_base import VirtBase
from exception import StartVMFailedException
+from settings import get_host_ip
# This name is derictly defined in the qemu guest serivce
# So you can not change it except it is changed by the service
@@ -408,7 +409,8 @@ class QEMUKvm(VirtBase):
# get the host addr
host_addr = field(opt_hostfwd, 1)
if not host_addr:
- host_addr = str(self.host_dut.get_ip_address())
+ addr = str(self.host_dut.get_ip_address())
+ hostaddr = get_host_ip(addr)
# get the host port in the option
host_port = field(opt_hostfwd, 2).split('-')[0]
diff --git a/framework/settings.py b/framework/settings.py
index d3cdf80..79f2a5e 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -31,6 +31,8 @@
"""
Folders for framework running enviornment.
"""
+import socket
+
FOLDERS = {
'Framework': 'framework',
'Testscripts': 'tests',
@@ -200,3 +202,16 @@ def get_netdev(crb, pci):
return vf
return None
+
+def get_host_ip(address):
+ ip_reg = r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}'
+ m = re.match(ip_reg, address)
+ if m:
+ return address
+ else:
+ try:
+ result=socket.gethostbyaddr(address)
+ return result[2][0]
+ except:
+ print "couldn't look up %s" % address
+ return ''
--
1.9.3
reply other threads:[~2015-06-19 8:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434702985-20049-1-git-send-email-yong.liu@intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).