files.c: In function ‘collect_fd’:
files.c:111:2: error: format ‘%d’ expects type ‘int’, but argument 3 has type ‘u64’
files.c: In function ‘open_fd’:
files.c:348:3: error: format ‘%d’ expects type ‘int’, but argument 2 has type ‘u64’
files.c: In function ‘receive_fd’:
files.c:425:5: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘u64’
files.c:425:5: error: format ‘%d’ expects type ‘int’, but argument 5 has type ‘u64’
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This is a standard convention to print error message (i.e. strerror(errno))
at the end of line, like this:
Cannot remove file: Permission denied
So pr_perror is fixed to follow this convention (using GNU extension
%m helps a lot here). Unfortunately, due to this we have to make
pr_perror() print a new line character, too, so we had to strip it
from the all pr_perror() invocations.
That (appending a newline) also makes pr_perror() a black sheep
in the herd of pr_* helpers, but what can we do? Worst case scenario
is an extra newline after an error message, not too harmful.
An alternative approach (stripping the newline from the passed format
string and re-adding it) was discussed thoroughly, and it was decided
that such a hack looks a bit too dirty.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
The absent image file on shared resources preparation now means -- no resources
for this pid (zombies will not have these files).
This is not the most elegant solution, but I don't have anything better in mind.
Need to think over, all the more so we're most likely about to reimplement the
way image is stored some day in the future.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Kill all the macros for reading/writing image parts. New API looks like
* write_img_buf/write_img
Write an object into an image. Reports 0 for OK, -1 for error. The _buf
version accepts object size as an argument, the other one uses sizeof()
* read_img_buf/read_img
Reads an object from image. Reports 0 for OK, -1 for error or EOF.
* read_img_buf_eof/read_img
Reads an object from image. Reports 1 for OK, 0 for EOF and -1 for error.
This is not symmetrical with the previous one, but it was done deliberately
to make it possible to write code like
ret = read_img_bug_eof();
if (ret <= 0)
return ret; /* 0 means OK, all is done, -1 means error was met */.
... /* 1 means object was read, can proceed */
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
We allocate only one page for fdinfo_list_entries.
In the future we will be able to resize this memory.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Yet again -- this makes code easier to understand from my POV.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
open_fdinfo calls move_img_fd, so other functions should not care about it
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Some process can share one struct file-s, we may find them by "object IDs".
A file descriptor is opened in one process and send to other via unix socket.
The procedure of restoring files contains four stages.
* Collect data about all file's descriptors
On this stage we find process which will restore a file descriptor and
create a list of processes, who should get this descriptor.
* Create datagrams unix sockets
If a file descriptor should be received, a unix socket is created
instead of it.
* Open file descriptors
A process with the least pid opens a file and sends this file
descriptors to all one who wait it.
* Receive file descriptors.
When we were thinking up this algoritm, we wanted to minimize a number
of context switches. A number of context switches is proportional of a
number of processes.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>