mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
improve vfio cleanup; fix potential segfault in graph/directed.hpp
Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
parent
bd1a7d7538
commit
83ecfe16d2
4 changed files with 12 additions and 7 deletions
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
std::shared_ptr<VertexType> getVertex(VertexIdentifier vertexId) const
|
||||
{
|
||||
if (vertexId >= lastVertexId)
|
||||
if (vertexId >= vertices.size())
|
||||
throw std::invalid_argument("vertex doesn't exist");
|
||||
|
||||
// cannot use [] operator, because creates non-existing elements
|
||||
|
@ -154,6 +154,7 @@ public:
|
|||
|
||||
auto startVertex = getVertex(edge->from);
|
||||
startVertex->edges.remove(edge->id);
|
||||
|
||||
}
|
||||
|
||||
if ((edge->from == vertexId) or removeEdge) {
|
||||
|
@ -167,6 +168,7 @@ public:
|
|||
|
||||
logger->debug("Remove vertex {}", vertexId);
|
||||
vertices.erase(vertexId);
|
||||
lastVertexId--;
|
||||
}
|
||||
|
||||
const std::list<EdgeIdentifier>&
|
||||
|
|
|
@ -93,11 +93,10 @@ Container::Container() :
|
|||
|
||||
Container::~Container()
|
||||
{
|
||||
log->debug("Clean up container with fd {}", fd);
|
||||
|
||||
/* Release memory and close fds */
|
||||
groups.clear();
|
||||
|
||||
log->debug("Cleaning up container with fd {}", fd);
|
||||
/* Close container */
|
||||
int ret = close(fd);
|
||||
if (ret < 0)
|
||||
|
|
|
@ -125,11 +125,14 @@ Device::Device(const std::string &name, int groupFileDescriptor, const kernel::p
|
|||
|
||||
Device::~Device()
|
||||
{
|
||||
log->debug("Clean up device {} with fd {}", this->name, this->fd);
|
||||
log->debug("Cleaning up device {} with fd {}", this->name, this->fd);
|
||||
|
||||
for (auto ®ion : regions) {
|
||||
regionUnmap(region.index);
|
||||
}
|
||||
if (isVfioPciDevice()) {
|
||||
pciHotReset();
|
||||
}
|
||||
reset();
|
||||
|
||||
int ret = close(fd);
|
||||
|
@ -412,6 +415,7 @@ bool Device::pciHotReset()
|
|||
if (!isVfioPciDevice())
|
||||
return false;
|
||||
|
||||
log->debug("Performing hot reset.");
|
||||
const size_t reset_info_len = sizeof(struct vfio_pci_hot_reset_info) +
|
||||
sizeof(struct vfio_pci_dependent_device) * 64;
|
||||
|
||||
|
@ -461,7 +465,7 @@ bool Device::pciHotReset()
|
|||
delete[] reset_buf;
|
||||
|
||||
if (!success) {
|
||||
log->warn("PCI hot reset failed, maybe not IOMMU available?");
|
||||
log->warn("PCI hot reset failed, maybe no IOMMU available?");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,11 +118,11 @@ void Group::dump()
|
|||
|
||||
Group::~Group()
|
||||
{
|
||||
log->debug("Clean up group {} with fd {}", this->index, this->fd);
|
||||
|
||||
/* Release memory and close fds */
|
||||
devices.clear();
|
||||
|
||||
log->debug("Cleaning up group {} with fd {}", index, fd);
|
||||
|
||||
if (fd < 0)
|
||||
log->debug("Destructing group that has not been attached");
|
||||
else {
|
||||
|
|
Loading…
Add table
Reference in a new issue