I try to open and read a file in Python 2.7.3 which is running in a virtual machine:
Host: Ubuntu 14.04 LTS
Guest: Debian Wheezy 7.5
VM-Software: VirtualBox V4.3.30
In the Python console inside the VM, I enter the following:
>>> f = open("Testing/results.txt", "w+")
>>> f.read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 71] Protocol error
The file exists and is located in a shared folder. If I try to do the same on a file which is located on the file system of the VM, it works fine. Also opening the file with mode "r+" or "a+", it works but it doesn't get truncated. Truncating the file manually after opening in read mode is working and currently, I use that as a workaround. But maybe anybody here knows, why this error occurs?
The most probable cause of this error is a bug in the VirtualBox Linux Guest Additions, more specifically, one of its device drivers vboxguest
(which communicates with the host) and vboxsf
(which provides shared folder services on the guest on top of vboxguest
).
Background: When using the Linux read(2)
system call on VirtualBox shared files, specific conditions make the VirtualBox driver(s) fail with error 71 (EPROTO) – Protocol error
(see tickets below). The error originates in the Linux kernel space and propagates via the C library to applications (see errno(3)). In this case, the application happens to be the Python interpreter.
There is nothing wrong with the Python code or file permissions. The code just performs a legitimate sequence of operations which triggers the error.
Relevant VirtualBox tickets:
According to ticket #8463, this bug (or a related one) was fixed in VirtualBox Linux Guest Additions 5.1.14 / 5.0.32 on January 17, 2017.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With