summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/base/remote_gdb.cc5
-rw-r--r--src/base/socket.cc18
-rw-r--r--src/base/socket.hh8
-rw-r--r--src/cpu/nativetrace.cc6
-rw-r--r--src/dev/ethertap.cc3
-rw-r--r--src/dev/terminal.cc5
-rw-r--r--src/python/m5/simulate.py2
-rw-r--r--src/python/swig/core.i3
-rw-r--r--tests/run.py10
9 files changed, 56 insertions, 4 deletions
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 51293e118..06e04e19e 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -195,6 +195,11 @@ GDBListener::name()
void
GDBListener::listen()
{
+ if (ListenSocket::allDisabled()) {
+ warn_once("Sockets disabled, not accepting gdb connections");
+ return;
+ }
+
while (!listener.listen(port, true)) {
DPRINTF(GDBMisc, "Can't bind port %d\n", port);
port++;
diff --git a/src/base/socket.cc b/src/base/socket.cc
index adcc48735..bcc5236b0 100644
--- a/src/base/socket.cc
+++ b/src/base/socket.cc
@@ -43,6 +43,23 @@
using namespace std;
+bool ListenSocket::listeningDisabled = false;
+bool ListenSocket::anyListening = false;
+
+void
+ListenSocket::disableAll()
+{
+ if (anyListening)
+ panic("Too late to disable all listeners, already have a listener");
+ listeningDisabled = true;
+}
+
+bool
+ListenSocket::allDisabled()
+{
+ return listeningDisabled;
+}
+
////////////////////////////////////////////////////////////////////////
//
//
@@ -92,6 +109,7 @@ ListenSocket::listen(int port, bool reuse)
listening = true;
+ anyListening = true;
return true;
}
diff --git a/src/base/socket.hh b/src/base/socket.hh
index 8e55eae72..942318e45 100644
--- a/src/base/socket.hh
+++ b/src/base/socket.hh
@@ -34,6 +34,14 @@
class ListenSocket
{
protected:
+ static bool listeningDisabled;
+ static bool anyListening;
+
+ public:
+ static void disableAll();
+ static bool allDisabled();
+
+ protected:
bool listening;
int fd;
diff --git a/src/cpu/nativetrace.cc b/src/cpu/nativetrace.cc
index 7152602fe..c23a9e4ad 100644
--- a/src/cpu/nativetrace.cc
+++ b/src/cpu/nativetrace.cc
@@ -50,8 +50,12 @@ using namespace TheISA;
namespace Trace {
-NativeTrace::NativeTrace(const Params *p) : InstTracer(p)
+NativeTrace::NativeTrace(const Params *p)
+ : InstTracer(p)
{
+ if (ListenSocket::allDisabled())
+ fatal("All listeners are disabled!");
+
int port = 8000;
while(!native_listener.listen(port, true))
{
diff --git a/src/dev/ethertap.cc b/src/dev/ethertap.cc
index 81b84d179..c7b292c8a 100644
--- a/src/dev/ethertap.cc
+++ b/src/dev/ethertap.cc
@@ -130,6 +130,9 @@ EtherTap::EtherTap(const Params *p)
: EtherObject(p), event(NULL), socket(-1), buflen(p->bufsz), dump(p->dump),
interface(NULL), txEvent(this)
{
+ if (ListenSocket::allDisabled())
+ fatal("All listeners are disabled! EtherTap can't work!");
+
buffer = new char[buflen];
listener = new TapListener(this, p->port);
listener->listen();
diff --git a/src/dev/terminal.cc b/src/dev/terminal.cc
index 47f280ad3..58371a2bd 100644
--- a/src/dev/terminal.cc
+++ b/src/dev/terminal.cc
@@ -125,6 +125,11 @@ Terminal::~Terminal()
void
Terminal::listen(int port)
{
+ if (ListenSocket::allDisabled()) {
+ warn_once("Sockets disabled, not accepting terminal connections");
+ return;
+ }
+
while (!listener.listen(port, true)) {
DPRINTF(Terminal,
": can't bind address terminal port %d inuse PID %d\n",
diff --git a/src/python/m5/simulate.py b/src/python/m5/simulate.py
index 3d91da368..e4dbd5784 100644
--- a/src/python/m5/simulate.py
+++ b/src/python/m5/simulate.py
@@ -182,3 +182,5 @@ def switchCpus(cpuList):
for old_cpu, new_cpu in cpuList:
new_cpu.takeOverFrom(old_cpu)
+
+from internal.core import disableAllListeners
diff --git a/src/python/swig/core.i b/src/python/swig/core.i
index 53d992ac6..3d360c017 100644
--- a/src/python/swig/core.i
+++ b/src/python/swig/core.i
@@ -34,6 +34,7 @@
%{
#include "python/swig/pyobject.hh"
+#include "base/socket.hh"
#include "sim/core.hh"
#include "sim/host.hh"
#include "sim/startup.hh"
@@ -42,6 +43,7 @@ extern const char *compileDate;
std::vector<std::string> compileFlags();
extern const char *hgRev;
extern const char *hgDate;
+inline void disableAllListeners() { ListenSocket::disableAll(); }
%}
%include "stdint.i"
@@ -53,6 +55,7 @@ void setOutputDir(const std::string &dir);
void setOutputFile(const std::string &file);
void SimStartup();
void doExitCleanup();
+void disableAllListeners();
%immutable compileDate;
char *compileDate;
diff --git a/tests/run.py b/tests/run.py
index 9b77ff9d2..aadc16b93 100644
--- a/tests/run.py
+++ b/tests/run.py
@@ -26,7 +26,12 @@
#
# Authors: Steve Reinhardt
-import os, sys
+import os
+import sys
+import m5
+
+# Since we're in batch mode, dont allow tcp socket connections
+m5.disableAllListeners()
# single "path" arg encodes everything we need to know about test
(category, name, isa, opsys, config) = sys.argv[1].split('/')
@@ -57,8 +62,7 @@ execfile(os.path.join(tests_root, 'configs', config + '.py'))
# set default maxtick... script can override
# -1 means run forever
-from m5 import MaxTick
-maxtick = MaxTick
+maxtick = m5.MaxTick
# tweak configuration for specific test