dev: Add basic checkpoint support to VirtIO9PProxy device
This patch adds very basic checkpoint support for the VirtIO9PProxy device. Previously, attempts to checkpoint gem5 with a present 9P device caused gem5 to fatal as none of the state is tracked. We still do not track any state, but we replace the fatal with a warning which is triggered if the device has been used by the guest system. In the event that it has not been used, we assume that no state is lost during checkpointing. The warning is triggered on both a serialize and an unserialize to ensure maximum visibility for the user.
This commit is contained in:
parent
9719b261a1
commit
9d23e6d323
2 changed files with 32 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014 ARM Limited
|
||||
* Copyright (c) 2014-2015 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
|
@ -204,7 +204,7 @@ VirtIO9PBase::dumpMsg(const P9MsgHeader &header, const uint8_t *data, size_t siz
|
|||
|
||||
|
||||
VirtIO9PProxy::VirtIO9PProxy(Params *params)
|
||||
: VirtIO9PBase(params)
|
||||
: VirtIO9PBase(params), deviceUsed(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -214,15 +214,29 @@ VirtIO9PProxy::~VirtIO9PProxy()
|
|||
|
||||
|
||||
void
|
||||
VirtIO9PProxy::VirtIO9PProxy::serialize(CheckpointOut &cp) const
|
||||
VirtIO9PProxy::serialize(CheckpointOut &cp) const
|
||||
{
|
||||
fatal("Can't checkpoint a system with a VirtIO 9p proxy!\n");
|
||||
if (deviceUsed) {
|
||||
warn("Serializing VirtIO9Base device after device has been used. It is "
|
||||
"likely that state will be lost, and that the device will cease "
|
||||
"to work!");
|
||||
}
|
||||
SERIALIZE_SCALAR(deviceUsed);
|
||||
|
||||
VirtIO9PBase::serialize(cp);
|
||||
}
|
||||
|
||||
void
|
||||
VirtIO9PProxy::unserialize(CheckpointIn &cp)
|
||||
{
|
||||
fatal("Can't checkpoint a system with a VirtIO 9p proxy!\n");
|
||||
UNSERIALIZE_SCALAR(deviceUsed);
|
||||
|
||||
if (deviceUsed) {
|
||||
warn("Unserializing VirtIO9Base device after device has been used. It is "
|
||||
"likely that state has been lost, and that the device will cease "
|
||||
"to work!");
|
||||
}
|
||||
VirtIO9PBase::unserialize(cp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,6 +244,7 @@ void
|
|||
VirtIO9PProxy::recvTMsg(const P9MsgHeader &header,
|
||||
const uint8_t *data, size_t size)
|
||||
{
|
||||
deviceUsed = true;
|
||||
assert(header.len == sizeof(header) + size);
|
||||
// While technically not needed, we send the packet as one
|
||||
// contiguous segment to make some packet dissectors happy.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014 ARM Limited
|
||||
* Copyright (c) 2014-2015 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
|
@ -269,6 +269,17 @@ class VirtIO9PProxy : public VirtIO9PBase
|
|||
* @param len Number of bytes to write.
|
||||
*/
|
||||
void writeAll(const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* Bool to track if the device has been used or not.
|
||||
*
|
||||
* We need to keep track of if the device has been used as we are
|
||||
* unable to checkpoint the device in the event that the device
|
||||
* has been mounted in the guest system. This is due to the fact
|
||||
* that we do not, and cannot, track the complete state across
|
||||
* host and guest.
|
||||
*/
|
||||
bool deviceUsed;
|
||||
};
|
||||
|
||||
struct VirtIO9PDiodParams;
|
||||
|
|
Loading…
Reference in a new issue