The musl-libc library provides implementations of strlcpy and strlcat,
so introduce a feature check for it and only use the kvmtool
implementation if there is no library support for it.
This avoids clashes with the public definition.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
In util/iovec.c we reference EXPORT_SYMBOL, which is only useful
within the kernel. To get rid of the dummy include file, simply
remove those lines.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The original Linux copy of rbtree.c used EXPORT_SYMBOL macros which
we don't need. Remove them and get rid of the now unneeded export.h.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
This is not really Linux specific, just a neat implementation
used by kvmtool, too.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The Makefile used to reference ../.. on some occasions to point
to the Linux source tree. Since this is no longer there, remove
those bogus paths.
Since we cannot (and don't want to) determine the Linux kernel
version on this way, we hardcode v3.18.0 for now, which is the version
the in-kernel-tree version used at the point of forking.
This should be later revisited and adjusted to whatever versioning
scheme we will use.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
This should fix following warnings
builtin-stat.c:93:3: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 2 has type '__u64' [-Wformat]
builtin-run.c:188:4: warning: format '%Lu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' [-Wformat]
builtin-run.c:554:3: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 2 has type 'u64' [-Wformat]
builtin-run.c:554:3: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'u64' [-Wformat]
builtin-run.c:645:3: warning: format '%Lu' expects argument of type 'long long unsigned int', but argument 4 has type 'u64' [-Wformat]
disk/core.c:330:4: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type '__dev_t' [-Wformat]
disk/core.c:330:4: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 5 has type '__dev_t' [-Wformat]
disk/core.c:330:4: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 6 has type '__ino64_t' [-Wformat]
mmio.c:134:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'u64' [-Wformat]
util/util.c:101:7: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'u64' [-Wformat]
util/util.c:113:7: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'u64' [-Wformat]
hw/pci-shmem.c:339:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 2 has type 'u64' [-Wformat]
hw/pci-shmem.c:340:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 2 has type 'u64' [-Wformat]
as observed when compiling on mips64.
Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
They're hidden inside net/core/iovec.c. It'd be nice to just link to that
but they're not too generic and come with tons of net/ specific code we
don't want. So we just copy over the relevant parts.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Commit b67bfe0d42ca ("hlist: drop the node parameter from iterators")
incorrectly changed the way that hlist iterators are used.
This patch fixes util/init.c so it passes parameters to the new
iterators in the right manner.
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Since nothing depends on the max_high field values anymore, we can just
remove the field and the code that was used to maintain it.
Signed-off-by: Michel Lespinasse <walken@google.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
As the rbtree intervals are not overlapping, rb_int_search_single can
trivially be implemented without making use of the max_high field.
Signed-off-by: Michel Lespinasse <walken@google.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
The rbtree interval API is designed for handling non-overlapping intervals;
modify rb_int_insert() to guarantee this property is maintained by
returning -EEXIST when attempting to insert a new interval that overlaps
an existing interval.
Also fix an issue where the computation of 'result' could trigger an
integer overflow which would break the rbtree ordering.
Signed-off-by: Michel Lespinasse <walken@google.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
I've noticed message on kvm exit:
Warning: serial8250__exit failed.
kvm tool is not able to remove ioport range which was added previously.
The issue is caused by bug in rbtree-interval. Search algorithm in
rb_int_search_single() expects correct value of max_high. But the tree
can contain leaf nodes, which never were updated by propagate_callback().
For this kind of nodes high_max will be 0 and we will not be able to
find and remove them.
Let's initialize max_high on RB_INT_INIT() time.
Fixing this bug makes other bug visible: propagate_callback() can be
called for empty tree: node == NULL. The callback is not ready for empty
tree. Let's fix that as well.
Tested-by: William Dauchy <william@gandi.net>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
We already have something to wrap pthread with mutex_[init,lock,unlock]
calls. This patch creates a new struct mutex abstraction and moves
everything to work with it.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
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>
There were a number of changes that caused problems:
- UAPI conversion
- the old version of the rbtree-augmented API got removed, I
updated the implementation to the new API
- lib/rbtree.c wants a 'true' definition
Lightly tested: it boots a v3.7-rc1 defconfig+kvmconfig kernel.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
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>
This adds a method to call init/exit functions similar to the kernel's init functions.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This would fix a bug where the exit function of the threadpool would hang
if no jobs were processed yet and a request to exit was received.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Add an exit function for the threadpool which will stop all running threads in the
pool. Also clean up the init code a bit.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
On some powerpc platforms we need to make sure we only advertise page
sizes to the guest which are <= the size of the pages backing guest RAM.
So have mmap_hugetblfs() save the hugetblfs page size for us, and also
teach mmap_anon_or_hugetblfs() to set the page size for anonymous mmap.
Acked-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Use str[n|l] functions to make sure destination is
not overflowed.
Seems socket path generation should be moved into
a separate helper, but it's for another patch.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Keep trying if io_submit returns EAGAIN. No need to fail the request.
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Documentation: Change the binary name from *kvm* to *lkvm*,
since commit ad3efb18 already called the binary *lkvm* and
with a alias name *vm*.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
The kernel already has pr_err helper lets do the same.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
commit 378ee7e6dd301347c6bf2c740cb1fb40174bcb8b broke the -Werror build
on 32bit targets due to some variable typing in struct statfs:
On 14/12/11 11:03, David Evensky wrote:
> On an x86 32bit system (and using the 32bit CodeSourcery toolchain on
> a x86_64 system) I get:
>
> evensky@machine:~/.../linux-kvm/tools/kvm$ make
> CC util/util.o
> util/util.c: In function 'mmap_hugetlbfs':
> util/util.c:93:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
> util/util.c:99:7: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Werror=format]
> cc1: all warnings being treated as errors
>
> make: *** [util/util.o] Error 1
Fixes the build.
Reported-by: David Evensky <evensky@dancer.ca.sandia.gov>
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Add a --hugetlbfs commandline option to give a path to hugetlbfs-map guest
memory (down in kvm__arch_init()). For x86, guest memory is a normal
ANON mmap() if this option is not provided, otherwise a hugetlbfs mmap.
This maps directly from a hugetlbfs temp file rather than using something
like MADV_HUGEPAGES so that, if the user asks for hugepages, we definitely
are using hugepages. (This is particularly useful for architectures that
don't yet support KVM without hugepages, so we definitely need to use
them for the whole of guest RAM.)
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
read-write.c contains no kvm related code, it is just a lib.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
threadpool.c contains no kvm related code, it is just a lib.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch removes the alphabetical sorting from util/generate-cmdlist.h so
that 'kvm run' command, for example, is displayed first:
$ ./kvm
usage: kvm [--version] [--help] COMMAND [ARGS]
The most commonly used kvm commands are:
run Start the virtual machine
pause Pause/resume the virtual machine
version Print the version of the kernel tree kvm tools
list Print a list of running instances on the host.
debug Print debug information from a running instance
balloon Inflate or deflate the virtio balloon
See 'kvm help COMMAND' for more information on a specific command.
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Add a 'kvm version' command which prints the version of the kernel
used to build kvm tools.
Part of the code is based on and was loaned from perf.
Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Some kernel parameters are convenient if passed in
hex form so our options parser should handle even
such form of input.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Augmentation is started on the pre-rotation node found in the search,
augment the rotated node instead.
Max high is the max of max highs below it, not the max of highs below it.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Interval rb-tree allows to directly store interval ranges
and quickly lookup an overlap with a single point or a range.
The helper is based on the kernel rb-tree implementation
(located in <linux/rbtree.h>) which alows for the augmention
of the classical rb-tree to be used as an interval tree.
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
We can use this script to create/delete a private bridge,
and launch a dhcp server on the bridge by dnsmasq,
setup forware rule of iptable, then guest can access public network.
# ./set_private_br.sh vbr0 192.168.33
add new private bridge: vbr0
# brctl show
bridge name bridge id STP enabled interfaces
vbr0 8000.000000000000 yes
# ifconfig vbr0
vbr0 Link encap:Ethernet HWaddr 82:0f:f5:8f:92:47
inet addr:192.168.33.1 Bcast:192.168.33.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:1979 (1.9 KB)
# ps aux |grep dnsmasq
nobody .. dnsmasq --strict-order --bind-interfaces --listen-address 192.168.33.1 \
--dhcp-range 192.168.33.1,192.168.33.254
Signed-off-by: Amos Kong <kongjianjun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
- The Documentation/ directory will have a text file for each commmand. The
text file should contain the information about the command in manpage format.
- command-list.txt: is a list of common commands used with the kvm tool.
- util/generate-cmdlist.sh: is a shell script that uses command-list.txt and
text files in Documentation/ directory to generate the common-cmds.h file in
the include directory. The header file is furthur used to display a usage
messgae. Almost the entire script is copied from the tools/perf.
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>