According to the manpage and the prototype the second argument to
connect(2) is a "const struct sockaddr*", so cast our protocol
specific type back to the super type.
This fixes compilation on musl-libc.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
A socket (as any other file descriptor) is of type "int" to catch the
negative error cases. Fix the declaration to allow errors to be
detected.
Found and needed by clang.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Some filesystems don't return valid d_type field in dirent
structure (e.g XFS). So we must handle this case properly.
Signed-off-by: Milan Kocian <milon@wq.cz>
Cc: Sasha Levin <levinsasha928@gmail.com>
[ penberg@kernel.org: cleanups ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Add perror() calls to a couple of exit paths, to ease debugging.
There are also two places where we print "Failed starting IPC thread",
but one is really an epoll failure, so make that obvious.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Give threads a meaningful name. This makes debugging much easier, and
everything else much prettier.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
[ penberg@kernel.org: specify vcpu names ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Switch to using init/exit calls instead of the repeating call blocks in builtin-run.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Move all the kvm-ipc specific code into the relevant file, and modify
the ipc callback to pass a ptr to struct kvm as well.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
If kvm_ipc__start failed, it returns a negative and by checking
this return value, we can ensure that it succeeds.
Signed-off-by: Yang Bai <hamo.by@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
write_in_full() would not return until count byes has been written or
error has occurred.
So
if (write_in_full(fd, buf, count) < 0)
goto err;
is enough.
And
if (write_in_full(fd, buf, count) != count)
goto err;
is not necessary.
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
CC kvm-ipc.o
kvm-ipc.c: In function ???kvm_ipc__send_msg???:
kvm-ipc.c:53:34: error: comparison between signed and unsigned integer
expressions [-Werror=sign-compare]
cc1: all warnings being treated as errors
Reported-by: Jean-Philippe Menil <jean-philippe.menil@univ-nantes.fr>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This is useful when client submiting multiple IPC cmd in one socket
connection.
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Current code write the sock manually. There is nothing constrains the format of
the written data is expect. Use kvm_ipc__send() and kvm_ipc__send_msg() for
such constraint.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Rename struct kvm_ipc_msg to struct kvm_ipc_head.
Change current kvm_ipc__new_data() to kvm_ipc__receive().
Don't allocate memory for the msg head.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Make it be a static function.
Expland to kvm_ipc_msg to its arguments.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Zero out struct epoll_event before calling epoll_ctl(). This isn't really
required, but is done to avoid warnings.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Handle only new incoming data for listener and stop fds, treat all other
events as error events which close the socket.
This fixes the bug where a 'kvm list' could have hanged because a close
event in the listener fd have been treated as a new connection.
Cc: Osier Yang <jyang@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Stop the ipc thread when shutting down the hypervisor.
This solves a bug where the .sock files weren't removed upon shutdown.
Reported-by: Osier Yang <jyang@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch changes the IPC method to use UNIX sockets instead of
signals.
This allows for more flexibility in moving data between processes, for example
it would allow avoid printing output in the terminal of the guest.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>