#
c7b7a542 |
| 07-Sep-2023 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Document mode=none for -n/--network
It can be useful to disable all network devices, for example, to remove the compat warning for the default network device when the guest does not ini
builtin-run: Document mode=none for -n/--network
It can be useful to disable all network devices, for example, to remove the compat warning for the default network device when the guest does not initialize it. This can be done by passing mode=none to the --network command line option, but without in-depth knowledge of the code, there is no way for the user to know this. Update the help message for -n/--network to explain what mode=none does.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20230907171655.6996-3-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
63643b11 |
| 17-Jul-2023 |
Fuad Tabba <tabba@google.com> |
Apply scaling down the calculated guest ram size to the number of pages
Calculate the guest ram size based a ratio proportional to the number of pages available, rather than the amount of memory ava
Apply scaling down the calculated guest ram size to the number of pages
Calculate the guest ram size based a ratio proportional to the number of pages available, rather than the amount of memory available in bytes, in the host. This is to ensure that the result is always page-aligned.
If the result of get_ram_size() isn't aligned to the host page size, it triggers an error in __kvm_set_memory_region(), called via the KVM_SET_USER_MEMORY_REGION ioctl, which requires the size to be page-aligned.
Fixes: 18bd8c3bd2a7 ("kvm tools: Don't use all of host RAM for guests by default") Signed-off-by: Fuad Tabba <tabba@google.com> Link: https://lore.kernel.org/r/20230717121232.3559948-4-tabba@google.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
834e5ed6 |
| 17-Jul-2023 |
Fuad Tabba <tabba@google.com> |
Factor out getting the number of physical memory host pages
Factor out getting the number of physical pages available for the host into a separate function. This will be used in a subsequent patch.
Factor out getting the number of physical memory host pages
Factor out getting the number of physical pages available for the host into a separate function. This will be used in a subsequent patch.
No functional change intended.
Signed-off-by: Fuad Tabba <tabba@google.com> Link: https://lore.kernel.org/r/20230717121232.3559948-3-tabba@google.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
b6bae725 |
| 17-Jul-2023 |
Fuad Tabba <tabba@google.com> |
Factor out getting the host page size
Factor out getting the page size of the host into a separate function. This will be used in a subsequent patch.
No functional change intended.
Signed-off-by:
Factor out getting the host page size
Factor out getting the page size of the host into a separate function. This will be used in a subsequent patch.
No functional change intended.
Signed-off-by: Fuad Tabba <tabba@google.com> Link: https://lore.kernel.org/r/20230717121232.3559948-2-tabba@google.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
bd4ba571 |
| 07-Jul-2023 |
Alexandru Elisei <alexandru.elisei@arm.com> |
Add --loglevel argument for the run command
Add --loglevel command line argument, with the possible values of 'error', 'warning', 'info' or 'debug' to control what messages kvmtool displays. The arg
Add --loglevel argument for the run command
Add --loglevel command line argument, with the possible values of 'error', 'warning', 'info' or 'debug' to control what messages kvmtool displays. The argument functions similarly to the Linux kernel parameter, when lower verbosity levels hide all message with a higher verbosity (for example, 'warning' hides info and debug messages, allows warning and error messsages).
The default level is 'info', to match the current behaviour. --debug has been kept as a legacy option, which might be removed in the future.
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230707151119.81208-5-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
72e13944 |
| 07-Jul-2023 |
Alexandru Elisei <alexandru.elisei@arm.com> |
Replace printf/fprintf with pr_* macros
To prepare for allowing finer control over the messages that kvmtool displays, replace printf() and fprintf() with the pr_* macros.
Minor changes were made t
Replace printf/fprintf with pr_* macros
To prepare for allowing finer control over the messages that kvmtool displays, replace printf() and fprintf() with the pr_* macros.
Minor changes were made to fix coding style issues that were pet peeves for the author. And use pr_err() in kvm_cpu__init() instead of pr_warning() for fatal errors.
Also, fix the message when printing the exit code for KVM_EXIT_UNKNOWN by removing the '0x' part, because it's printing a decimal number, not a hexadecimal one (the format specifier is %llu, not %llx).
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230707151119.81208-3-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
c1eecc61 |
| 25-May-2023 |
Andre Przywara <andre.przywara@arm.com> |
option parsing: fix type of empty .argh parameter
The "force-pci" and "virtio-legacy" option definitions were using '\0' to initialise an unused ".argh" member, even though this is a string. This tr
option parsing: fix type of empty .argh parameter
The "force-pci" and "virtio-legacy" option definitions were using '\0' to initialise an unused ".argh" member, even though this is a string. This triggers warnings with some compilers like clang. Also, for some odd reason, the .argh member was not named explicitly in the option helper macros initialisation, which made this problem harder to locate.
Sanitise the option macros by always using designated initialisers for each member, and use the correct empty string for the "force-pci" and "virtio-legacy" options.
This fixes warnings (promoted to errors) when compiling with clang.
Signed-off-by: Andre Przywara <andre.przywara@arm.com> Link: https://lore.kernel.org/r/20230525144827.679651-2-andre.przywara@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
9b46ebc5 |
| 20-Mar-2023 |
Rajnesh Kanwal <rkanwal@rivosinc.com> |
Add virtio-transport option and deprecate force-pci and virtio-legacy.
This is a follow-up patch for [0] which proposed the --force-pci option for riscv. As per the discussion it was concluded to ad
Add virtio-transport option and deprecate force-pci and virtio-legacy.
This is a follow-up patch for [0] which proposed the --force-pci option for riscv. As per the discussion it was concluded to add virtio-tranport option taking in four options (pci, pci-legacy, mmio, mmio-legacy).
With this change force-pci and virtio-legacy are both deprecated and arm's default transport changes from MMIO to PCI as agreed in [0]. This is also true for riscv.
Nothing changes for other architectures.
[0]: https://lore.kernel.org/all/20230118172007.408667-1-rkanwal@rivosinc.com/
Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com> Link: https://lore.kernel.org/r/20230320143344.404307-1-rkanwal@rivosinc.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
b0d56e3c |
| 01-Jul-2022 |
Jean-Philippe Brucker <jean-philippe.brucker@arm.com> |
virtio: Add support for modern virtio-pci
Add support for modern virtio-pci implementation (based on the 1.0 virtio spec). We add a new transport, alongside MMIO and PCI-legacy. This is now the defa
virtio: Add support for modern virtio-pci
Add support for modern virtio-pci implementation (based on the 1.0 virtio spec). We add a new transport, alongside MMIO and PCI-legacy. This is now the default when selecting PCI, but users can still select the legacy transport for all virtio devices by passing "--virtio-legacy" on the command-line.
The main change in modern PCI is the way we address virtqueues, using 64-bit values instead of PFNs. To keep the queue configuration atomic the device also gets a "queue enable" register. Configuration is also made extensible by more feature bits and PCI capabilities. Scalability is improved as well, as devices can have notification registers for each virtqueue on separate pages. However this implementation keeps a single notification register.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Link: https://lore.kernel.org/r/20220701142434.75170-9-jean-philippe.brucker@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
8b91a182 |
| 16-Jun-2022 |
Alexandru Elisei <alexandru.elisei@arm.com> |
arm64: Allow the user to specify the RAM base address
Allow the user to specify the RAM base address by using -m/--mem size@addr command line argument. The base address must be above 2GB, as to not
arm64: Allow the user to specify the RAM base address
Allow the user to specify the RAM base address by using -m/--mem size@addr command line argument. The base address must be above 2GB, as to not overlap with the MMIO I/O region.
Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-and-Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20220616134828.129006-13-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
a9c24ec7 |
| 16-Jun-2022 |
Suzuki K Poulose <suzuki.poulose@arm.com> |
builtin_run: Allow standard size specifiers for memory
Allow the user to use the standard B (bytes), K (kilobytes), M (megabytes), G (gigabytes), T (terabytes) and P (petabytes) suffixes for memory
builtin_run: Allow standard size specifiers for memory
Allow the user to use the standard B (bytes), K (kilobytes), M (megabytes), G (gigabytes), T (terabytes) and P (petabytes) suffixes for memory size. When none are specified, the default is megabytes.
Also raise an error if the guest specifies 0 as the memory size, instead of treating it as uninitialized, as kvmtool has done so far.
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Reviewed-and-Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20220616134828.129006-9-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
abe3f28a |
| 16-Jun-2022 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Add arch hook to validate VM configuration
Architectures are free to set their own command line options. Add an architecture specific hook to validate these options.
For now, the hook
builtin-run: Add arch hook to validate VM configuration
Architectures are free to set their own command line options. Add an architecture specific hook to validate these options.
For now, the hook does nothing, but it will be used in later patches.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Reviewed-and-Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20220616134828.129006-5-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
28b96259 |
| 16-Jun-2022 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Rework RAM size validation
host_ram_size() uses sysconf() to calculate the available ram, and sysconf() can fail. When that happens, host_ram_size() returns 0. kvmtool warns the user wh
builtin-run: Rework RAM size validation
host_ram_size() uses sysconf() to calculate the available ram, and sysconf() can fail. When that happens, host_ram_size() returns 0. kvmtool warns the user when the configured VM ram size exceeds the size of the host's memory, but doesn't take into account that host_ram_size() can return 0. If the function returns zero, skip the warning.
Since this can only happen when the user sets the memory size (via the -m/--mem command line argument), skip the check entirely if the user hasn't set it. Move the check to kvm_run_validate_cfg(), as it checks for valid user configuration.
Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-and-Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20220616134828.129006-4-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
9d655190 |
| 16-Jun-2022 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Always use RAM size in bytes
The user can specify the virtual machine memory size in MB, which is saved in cfg->ram_size. kvmtool validates it against the host memory size, converted fr
builtin-run: Always use RAM size in bytes
The user can specify the virtual machine memory size in MB, which is saved in cfg->ram_size. kvmtool validates it against the host memory size, converted from bytes to MB. ram_size is then converted to bytes, and this is how it is used throughout the rest of kvmtool.
To avoid any confusion about the unit of measurement, especially once the user is allowed to specify the unit of measurement, always use ram_size in bytes.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Reviewed-and-Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20220616134828.129006-3-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
024c331b |
| 16-Jun-2022 |
Alexandru Elisei <alexandru.elisei@arm.com> |
Use MB for megabytes consistently
The help text for the -m/--mem argument states that the guest memory size is in MiB (mebibyte). MiB is the same thing as MB (megabyte), and indeed this is how MB is
Use MB for megabytes consistently
The help text for the -m/--mem argument states that the guest memory size is in MiB (mebibyte). MiB is the same thing as MB (megabyte), and indeed this is how MB is used throughout kvmtool.
Replace MiB with MB, so people don't get the wrong idea and start believing that for kvmtool a MB is 10^6 bytes instead of 2^20.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-and-Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20220616134828.129006-2-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
ffa86546 |
| 24-Mar-2022 |
Sebastian Ene <sebastianene@google.com> |
Make --no-pvtime command argument arm specific
The stolen time option is available only for aarch64 and is enabled by default. Move the option that disables stolen time functionality in the arch spe
Make --no-pvtime command argument arm specific
The stolen time option is available only for aarch64 and is enabled by default. Move the option that disables stolen time functionality in the arch specific path.
Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://lore.kernel.org/r/20220324154304.2572891-1-sebastianene@google.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
1b76b6e1 |
| 13-Mar-2022 |
Sebastian Ene <sebastianene@google.com> |
Add --no-pvtime command line argument
The command line argument disables the stolen time functionality when is specified.
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Seb
Add --no-pvtime command line argument
The command line argument disables the stolen time functionality when is specified.
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Sebastian Ene <sebastianene@google.com> Link: https://lore.kernel.org/r/20220313161949.3565171-4-sebastianene@google.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
5613ae26 |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
Add --nodefaults command line argument
kvmtool attempts to make it as easier as possible on the user to run a VM by doing a few different things: it tries to create a rootfs filesystem in a director
Add --nodefaults command line argument
kvmtool attempts to make it as easier as possible on the user to run a VM by doing a few different things: it tries to create a rootfs filesystem in a directory if not disk or initrd is set by the user, and it adds various parameters to the kernel command line based on the VM configuration options.
While this is generally very useful, today there isn't any way for the user to prohibit this behaviour, even though there are situations where this might not be desirable, like, for example: loading something which is not a kernel (kvm-unit-tests comes to mind, which expects test parameters on the kernel command line); the kernel has a built-in initramfs and there is no need to generate the root filesystem, or it not possible; and what is probably the most important use case, when the user is actively trying to break things for testing purposes.
Add a --nodefaults command line argument which disables everything that cannot be disabled via another command line switch. The purpose of this knob is not to disable the default options for arguments that can be set via the kvmtool command line, but rather to inhibit behaviour that cannot be disabled otherwise.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-8-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
a5253f7c |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Move kernel command line generation to a separate function
The real kernel command line is gradually generated in kvm_cmd_run_init() and it is interspersed with the initialization code.
builtin-run: Move kernel command line generation to a separate function
The real kernel command line is gradually generated in kvm_cmd_run_init() and it is interspersed with the initialization code. This means that both the code that generates the command line and the rest of the code is unnecessarily difficult to follow and to modify. Move the code that generates the command line to one function, to make it easier to understand, and to declutter kvm_cmd_run_init().
No functional change intended.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-7-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
39ab3a0b |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
Use kvm->nr_disks instead of kvm->cfg.image_count
A user can specify multiple disk images using the --disk/-d argument. The callback for the argument ends up in disk/core.c::calling disk_img_name_pa
Use kvm->nr_disks instead of kvm->cfg.image_count
A user can specify multiple disk images using the --disk/-d argument. The callback for the argument ends up in disk/core.c::calling disk_img_name_parser(), which increments kvm->cfg.image_count for each disk image.
Immediately after parsing the arguments in kvm_cmd_run_init(), kvm->nr_disks is set to kvm->cfg.image_count, effectively making kvm->nr_disks an alias for kvm->cfg.image_count, as image_count is never changed afterward.
Later on, the core disk code uses kvm->cfg.image_count when opening all the disk images, but kvm->nr_disks when closing them, which is inconsistent, but technically correct since they represent the same thing and have the same value.
Let's remove all this confusing usage and use only kvm->nr_disks to represent the number of disk images specified by the user.
While this technically means that kvmtool now supports up to INT_MAX disk images, in practice this is limited by MAX_DISK_IMAGES, which is equal to four. Which means there are no functional changes.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-6-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
cce96164 |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Abstract argument validation into a separate function
kvm_cmd_run_init() is a complex function which parses the command line arguments, configures various aspects of a VM (the size of t
builtin-run: Abstract argument validation into a separate function
kvm_cmd_run_init() is a complex function which parses the command line arguments, configures various aspects of a VM (the size of the RAM, the number of CPUs, the network, the active console, the kernel command line, creates a custom rootfs, etc), and after the recent patches, also does a few checks against mutually exclusive kvmtool arguments.
Make the function just that little bit easier to read by moving the argument validation into a separate function.
No functional change intended.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-5-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
638630c9 |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Do not attempt to find vmlinux if --firmware
kvm->vmlinux is used by symbol.c on x86 to translate a PC address to a kernel symbol when kvmtool exits unexpectedly. When the --firmware ar
builtin-run: Do not attempt to find vmlinux if --firmware
kvm->vmlinux is used by symbol.c on x86 to translate a PC address to a kernel symbol when kvmtool exits unexpectedly. When the --firmware argument is used, a kernel image is not used for the VM, and the vmlinux file has no relevance in this case.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-4-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
6cbec43e |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Warn when ignoring initrd because --firmware was specified
The firmware image is copied into the guest memory with the arch specific function kvm__load_firmware() in kvm__init(). That f
builtin-run: Warn when ignoring initrd because --firmware was specified
The firmware image is copied into the guest memory with the arch specific function kvm__load_firmware() in kvm__init(). That function ignores the initrd file, if the user specified one. Let the user know that the file is ignored by KVM and the --initrd argument does nothing with --firmware.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-3-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
6810e75c |
| 23-Sep-2021 |
Alexandru Elisei <alexandru.elisei@arm.com> |
builtin-run: Treat specifying both --kernel and --firmware as an error
If the user specifies both the --kernel and the --firmware arguments, --firmware takes precedence and --kernel is silently igno
builtin-run: Treat specifying both --kernel and --firmware as an error
If the user specifies both the --kernel and the --firmware arguments, --firmware takes precedence and --kernel is silently ignored. Since kvmtool has no way of knowing what the user really intended, and guessing that --firmware is the right argument might prove to be quite unexpected for the user, be vocal about the incompatibility and refuse to create the VM.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-2-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|
#
117d6495 |
| 15-Sep-2020 |
Tianjia Zhang <tianjia.zhang@linux.alibaba.com> |
virtio: add support for vsock
The "run" command accepts a new option (--vsock <cid>) which specify the guest CID. For instance:
$ lkvm run --kernel ./bzImage --disk test --vsock 3
One can easily
virtio: add support for vsock
The "run" command accepts a new option (--vsock <cid>) which specify the guest CID. For instance:
$ lkvm run --kernel ./bzImage --disk test --vsock 3
One can easily test by: https://github.com/stefanha/nc-vsock.
In the guest:
# modprobe vsock # nc-vsock -l 1234
In the host:
# modprobe vhost_vsock # nc-vsock 3 1234
This patch comes from the early submission of G. Campana. On this basis, I fixed the compilation errors and runtime crashes. Thanks for the work done by G. Campana. https://patchwork.kernel.org/patch/9542313/
Signed-off-by: G. Campana <gcampana+kvm@quarkslab.com> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Link: https://lore.kernel.org/r/20200915094402.107988-1-tianjia.zhang@linux.alibaba.com Signed-off-by: Will Deacon <will@kernel.org>
show more ...
|