-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GuestMemory::read_from and GuestMemory::write_to have "exact" semantics #171
Comments
An example where this can be problematic: When reading from a non-blocking socket you can't know the length of the data available on the socket, so one may use a maximum length of N bytes for the If there are only M bytes available (where M<N), the I believe we should better define the semantics of these functions. For example, the |
That would be doable, though it would incur some code duplication. One difference between |
Indeed. Another difference that may break client applications is that we would only call The workaround we're using in Firecracker is to use the |
The GuestMemory implementation of the
read_from
function of theBytes
trait is equivalent toread_exact_from
.In analogy, the
write_to
implementation is equivalent towrite_all_to
.This is because both functions rely on a call to
try_access
, which will run until an irrecoverable error occurs (notErrorKind::Interrupted
) orcount
bytes are transferred.This semantic is correct for
read_exact_from
andwrite_all_to
, assuming they have similar meaning to theread_exact
andwrite_all
functions of thestd::io::Read
andstd::io::Write
traits.For the "non-exact" counterparts, only one read/write should occur.
The text was updated successfully, but these errors were encountered: