Hello Anouk Van Laer, Andreas Sandberg,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/c/public/gem5/+/15895
to review the following change.
Change subject: dev, virtio: Remove socketPath as parameter
......................................................................
dev, virtio: Remove socketPath as parameter
diod requires a socket path but does not use it. Previously, a
socket path would be passed during configuration (to make sure a
socket path with that name did not already exist). However,
functionally, it should not have been a parameter of the
VirtIO9PDiod object. This commit fixes that: the unused socket
path will now be handled completely by the object itself, the
unused socket path will placed in the output directory and will
be removed when terminating diod. If there is an unused socket
path in the output directory at the start of a run, it will
simply be removed.
Change-Id: Ic4c81edbbcfcaf8d15cbaf77c2b275e26db64b43
Reviewed-by: Andreas Sandberg <[email protected]>
Reviewed-by: Sascha Bischoff <[email protected]>
---
M src/dev/virtio/VirtIO9P.py
M src/dev/virtio/fs9p.cc
M src/dev/virtio/fs9p.hh
M src/python/m5/main.py
4 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/dev/virtio/VirtIO9P.py b/src/dev/virtio/VirtIO9P.py
index 623403d..e5d847d 100644
--- a/src/dev/virtio/VirtIO9P.py
+++ b/src/dev/virtio/VirtIO9P.py
@@ -1,6 +1,6 @@
# -*- mode:python -*-
-# Copyright (c) 2014,2017 ARM Limited
+# Copyright (c) 2014,2017-2018 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -61,7 +61,6 @@
diod = Param.String("/usr/sbin/diod", "Path to diod")
root = Param.String("/tmp", "Path to export through diod")
- socketPath = Param.String("Unused socket to diod")
class VirtIO9PSocket(VirtIO9PProxy):
type = 'VirtIO9PSocket'
diff --git a/src/dev/virtio/fs9p.cc b/src/dev/virtio/fs9p.cc
index 7857fea..491a25c 100644
--- a/src/dev/virtio/fs9p.cc
+++ b/src/dev/virtio/fs9p.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2017 ARM Limited
+ * Copyright (c) 2014-2018 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -43,6 +43,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -363,7 +364,12 @@
memset(&socket_address, 0, sizeof(struct sockaddr_un));
socket_address.sun_family = AF_UNIX;
- const std::string socket_path = simout.resolve(p->socketPath);
+ if (isSocket(simout.resolve("unused_socket"))) {
+ // Remove socket from previous simulation, if socket exists, diod
will
+ // fail (even though it does not use it)
+ simout.remove("unused_socket");
+ }
+ const std::string socket_path = simout.resolve("unused_socket");
fatal_if(!OutputDirectory::isAbsolute(socket_path), "Please make the" \
" output directory an absolute path, else diod will fail!\n");
@@ -415,6 +421,14 @@
#undef DIOD_WFD
}
+bool
+VirtIO9PDiod::isSocket(const std::string &socket_name)
+{
+ struct stat st_buf;
+ int st = stat(socket_name.c_str(), &st_buf);
+ return (st == 0) && S_ISSOCK(st_buf.st_mode);
+}
+
ssize_t
VirtIO9PDiod::read(uint8_t *data, size_t len)
{
@@ -472,7 +486,8 @@
perror("Killing diod process");
warn("Failed to kill diod using SIGKILL");
} else {
- // Managed to kill diod
+ // Managed to kill diod so remove socket
+ simout.remove("unused_socket");
return;
}
diff --git a/src/dev/virtio/fs9p.hh b/src/dev/virtio/fs9p.hh
index 4652560..86eb0ba 100644
--- a/src/dev/virtio/fs9p.hh
+++ b/src/dev/virtio/fs9p.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2017 ARM Limited
+ * Copyright (c) 2014-2018 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -332,6 +332,7 @@
/** PID of diod process */
int diod_pid;
+ bool isSocket(const std::string &socket_name);
};
struct VirtIO9PSocketParams;
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index 9d46d43..3040244 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016 ARM Limited
+# Copyright (c) 2016, 2018 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -336,6 +336,9 @@
options.usage(2)
# tell C++ about output directory
+ # Some things (e.g. diod) need absolute paths, so convert if relative
+ if not os.path.isabs(options.outdir):
+ options.outdir = os.path.abspath(options.outdir)
core.setOutputDir(options.outdir)
# update the system path with elements from the -p option
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15895
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ic4c81edbbcfcaf8d15cbaf77c2b275e26db64b43
Gerrit-Change-Number: 15895
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Anouk Van Laer <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev