#
d30d9487 |
| 06-Jun-2023 |
Jean-Philippe Brucker <jean-philippe@linaro.org> |
Factor epoll thread
Both ioeventfd and ipc use an epoll thread roughly the same way. In order to add a new epoll user, factor the common bits into epoll.c
Slight implementation changes which should
Factor epoll thread
Both ioeventfd and ipc use an epoll thread roughly the same way. In order to add a new epoll user, factor the common bits into epoll.c
Slight implementation changes which shouldn't affect behavior:
* At the moment ioeventfd mixes file descriptor (for the stop event) and pointers in the epoll_event.data union, which could in theory cause aliasing. Use a pointer for the stop event instead. kvm-ipc uses only file descriptors. It could be changed but since epoll.c compares the stop event pointer first, the risk of aliasing with an fd is much lower there.
* kvm-ipc uses EPOLLET, edge-triggered events, but having the stop event level-triggered shouldn't make a difference.
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Link: https://lore.kernel.org/r/20230606130426.978945-16-jean-philippe@linaro.org Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
ef5b941f |
| 07-Jun-2019 |
Andre Przywara <andre.przywara@arm.com> |
run: Check for ghost socket file upon VM creation
Kvmtool creates a (debug) UNIX socket file for each VM, using its (possibly auto-generated) name as the filename. There is a check using access(), w
run: Check for ghost socket file upon VM creation
Kvmtool creates a (debug) UNIX socket file for each VM, using its (possibly auto-generated) name as the filename. There is a check using access(), which bails out with an error message if a socket with that name already exists.
Aside from this check being unnecessary, as the bind() call later would complain as well, this is also racy. But more annoyingly the bail out is not needed most of the time: an existing socket inode is most likely just an orphaned leftover from a previous kvmtool run, which just failed to remove that file, because of a crash, for instance.
Upon finding such a collision, let's first try to connect to that socket, to detect if there is still a kvmtool instance listening on the other end. If that fails, this socket will never come back to life, so we can safely clean it up and reuse the name for the new guest. However if the connect() succeeds, there is an actual live kvmtool instance using this name, so not proceeding is the only option. This should never happen with the (PID based) automatically generated names, though.
This avoids an annoying (and not helpful) error message and helps automated kvmtool runs to proceed in more cases.
Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
show more ...
|
#
67f9f7b7 |
| 07-Jun-2019 |
Andre Przywara <andre.przywara@arm.com> |
list: Clean up ghost socket files
When kvmtool (or the host kernel) crashes or gets killed, we cannot automatically remove the socket file we created for that VM. A later call of "lkvm list" iterate
list: Clean up ghost socket files
When kvmtool (or the host kernel) crashes or gets killed, we cannot automatically remove the socket file we created for that VM. A later call of "lkvm list" iterates over all those files and complains about those "ghost socket files", as there is no one listening on the other side. Also sometimes the automatic guest name generation happens to generate the same name again, so an unrelated "lkvm run" later complains and stops, which is bad for automation.
As the only code doing a listen() on this socket is kvmtool upon VM *creation*, such an orphaned socket file will never come back to life, so we can as well unlink() those sockets in the code. This spares the user from doing it herself. We keep the message in the code to notify the user of this.
Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
show more ...
|
#
d62653e1 |
| 17-Apr-2016 |
Michal Rostecki <michal.rostecki@gmail.com> |
kvmtool: Change readdir_r to readdir
readdir_r is deprecated[1] and usage of readdir is recommended.
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=7584a3f96de88d5eefe5d6c634515278cbfbf052
kvmtool: Change readdir_r to readdir
readdir_r is deprecated[1] and usage of readdir is recommended.
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=7584a3f96de88d5eefe5d6c634515278cbfbf052
Signed-off-by: Michal Rostecki <michal.rostecki@gmail.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
show more ...
|
#
2aa76b26 |
| 05-Nov-2015 |
Will Deacon <will.deacon@arm.com> |
kvmtool: fix VM exit race attempting to pthread_kill an exited thread
lkvm currently suffers from a Segmentation Fault when exiting, which can also lead to the console not being cleaned up correctly
kvmtool: fix VM exit race attempting to pthread_kill an exited thread
lkvm currently suffers from a Segmentation Fault when exiting, which can also lead to the console not being cleaned up correctly after a VM exits.
The issue is that (the misnamed) kvm_cpu__reboot function sends a SIGKVMEXIT to each vcpu thread, which causes those vcpu threads to exit once their main loops (kvm_cpu__start) detect that cpu->is_running is now false. The lack of synchronisation in this exit path means that a concurrent pause event (due to the br_write_lock in ioport__unregister) ends up sending SIGKVMPAUSE to an exited thread, resulting in a SEGV.
This patch fixes the issue by moving kvm_cpu__reboot into kvm.c (renaming it in the process) where it can hold the pause_lock mutex across the reboot operation. This in turn makes it safe for the pause code to check the is_running field of each CPU before attempting to send a SIGKVMPAUSE signal.
Signed-off-by: Will Deacon <will.deacon@arm.com>
show more ...
|
#
d77bd4f4 |
| 17-Jul-2015 |
Andre Przywara <andre.przywara@arm.com> |
Fix call to connect()
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 fixe
Fix call to connect()
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>
show more ...
|
#
a2583dbf |
| 17-Jul-2015 |
Andre Przywara <andre.przywara@arm.com> |
kvm-ipc: use proper type for file descriptor
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
kvm-ipc: use proper type for file descriptor
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>
show more ...
|
#
22fb13f6 |
| 06-Jun-2013 |
Milan Kocian <milon@wq.cz> |
kvm tools: Fix dirent handling on dirent non-friendly filesystems
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
kvm tools: Fix dirent handling on dirent non-friendly filesystems
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>
show more ...
|
#
211370d6 |
| 06-Feb-2013 |
Michael Ellerman <michael@ellerman.id.au> |
kvm tools: More error handling in the ipc code
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 rea
kvm tools: More error handling in the ipc code
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>
show more ...
|
#
a4d8c55e |
| 24-Oct-2012 |
Sasha Levin <sasha.levin@oracle.com> |
kvm tools: Specify names for VM internal threads
Give threads a meaningful name. This makes debugging much easier, and everything else much prettier.
Suggested-by: Ingo Molnar <mingo@kernel.org> Si
kvm tools: Specify names for VM internal threads
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>
show more ...
|
#
4346fd8f |
| 17-Sep-2012 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: remove global kvm object
This was ugly, and now we get rid of it.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
#
49a8afd1 |
| 17-Sep-2012 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: use init/exit where possible
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: Pekk
kvm tools: use init/exit where possible
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>
show more ...
|
#
e1063726 |
| 05-Sep-2012 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: kvm-ipc cleanup
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@gmai
kvm tools: kvm-ipc cleanup
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>
show more ...
|
#
066c5809 |
| 09-May-2012 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: use bitwise 'and' in kvm-ipc
Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
#
e21e8ff3 |
| 10-Feb-2012 |
Yang Bai <hamo.by@gmail.com> |
kvm tools: if kvm_ipc__start failed, return negative
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
kvm tools: if kvm_ipc__start failed, return negative
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>
show more ...
|
#
ca088268 |
| 09-Jan-2012 |
Asias He <asias.hejun@gmail.com> |
kvm tools: Simply write_in_full() check semantics
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;
kvm tools: Simply write_in_full() check semantics
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>
show more ...
|
#
fd5b45a1 |
| 09-Jan-2012 |
Asias He <asias.hejun@gmail.com> |
kvm tools: Fix kvm-ipc.c build breakage
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 ex
kvm tools: Fix kvm-ipc.c build breakage
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>
show more ...
|
#
8e463c62 |
| 22-Dec-2011 |
Asias He <asias.hejun@gmail.com> |
kvm tools: Handle multiple IPC cmd at a time
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 Enb
kvm tools: Handle multiple IPC cmd at a time
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>
show more ...
|
#
50dc18ae |
| 20-Dec-2011 |
Lai Jiangshan <laijs@cn.fujitsu.com> |
kvm tools: add kvm_ipc__send() and kvm_ipc__send_msg()
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__se
kvm tools: add kvm_ipc__send() and kvm_ipc__send_msg()
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>
show more ...
|
#
a9aae6c5 |
| 20-Dec-2011 |
Lai Jiangshan <laijs@cn.fujitsu.com> |
kvm tools: add kvm_ipc__receive()
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:
kvm tools: add kvm_ipc__receive()
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>
show more ...
|
#
44a56bfd |
| 20-Dec-2011 |
Lai Jiangshan <laijs@cn.fujitsu.com> |
kvm tools: cleanup kvm_ipc__handle()
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@
kvm tools: cleanup kvm_ipc__handle()
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>
show more ...
|
#
21b3c2c0 |
| 06-Dec-2011 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: Zero out event before calling epoll_ctl()
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 <l
kvm tools: Zero out event before calling epoll_ctl()
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>
show more ...
|
#
47f72b90 |
| 28-Oct-2011 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: Handle only relevant events in epoll
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 'k
kvm tools: Handle only relevant events in epoll
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>
show more ...
|
#
c733c80b |
| 25-Oct-2011 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: Add method to stop ipc thread
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 <jyan
kvm tools: Add method to stop ipc thread
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>
show more ...
|
#
4b1addae |
| 16-Oct-2011 |
Sasha Levin <levinsasha928@gmail.com> |
kvm tools: Switch to using UNIX sockets instead of signals
This patch changes the IPC method to use UNIX sockets instead of signals.
This allows for more flexibility in moving data between processe
kvm tools: Switch to using UNIX sockets instead of signals
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>
show more ...
|