kvm tools: introduce kvm_config to store instance-specific config options

Move all the configurable options from global static variables to a self-contained
structure.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: generate command line options dynamically

Since we now store options in a struct, we should generate the command line options
dynamically. This is a pre-requisite to the following patch moving the options
into struct kvm.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: split struct kvm into arch specific part

Move all the non-arch specific members into a generic struct, and the arch specific
members into a arch specific kvm_arch. This prevents code duplication across different
archs.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: move kvm_config into struct kvm

Contain the options within struct kvm itself. This way options are specific
to a given struct kvm and not just global.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: remove redundancy between kvm_config and kvm

Remove some redundant members between struct kvm_config and struct kvm
since options are now contained within struct kvm.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: move ioport_debug into struct kvm_config

This config option was 'extern'ed between different objects. Clean it up
and move it into struct kvm_config.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: move mmio_debug into struct kvm_config

This config option was 'extern'ed between different objects. Clean it up
and move it into struct kvm_config.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: move active_console into struct kvm_config

This config option was 'extern'ed between different objects. Clean it up
and move it into struct kvm_config.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: add private ptr to option parser

Support passing a private ptr to CALLBACK options. This will make it possible
assigning options into specific struct kvms by passing them directly to parsers.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: disk image related cleanup

Move io debug delay into kvm_config, the parser out of builtin-run into the disk code
and make the init/exit functions match the rest of the code in style.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: move nrcpus into struct kvm_config

This no longer has to be a global since we now have kvm_config.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: move kvm_cpus into struct kvm

There's no reason the array of guest specific vcpus is global. Move it into
struct kvm.

Also split up arch specific vcpu init from the generic code and call it from
the kvm_cpu initializer.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: improve framebuffer manager initialization

Make the init and exit functions of the framebuffer similar to the rest
of the code.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: improve term init/exit functions

Make the init and exit functions of the term code similar to the rest
of the code.

Also move in the pty parser into the term code out of builtin-run.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: threadpool exit routine

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>
kvm tools: timer cleanup

Make the timer init/exit follow the rest of the code, and move it out of
builtin-run.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: virtio-console init/exit

Make the init/exit of virtio-console self-contained, so the global init code
won't need to check if it was selected or not.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: virtio-rng init/exit

Make the init/exit of virtio-rng self-contained, so the global init code
won't need to check if it was selected or not.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: virtio-bln init/exit

Make the init/exit of virtio-balloon self-contained, so the global init code
won't need to check if it was selected or not.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: pci-shmem init-exit

Make the init/exit of pci-shmem self-contained, so the global init code
won't need to check if it was selected or not.

Also move the parser out of builtin-run into the pci-shmem code.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>