- use builtin vm list to dynamically generate distros
- use builtin vm list to add custom distros in the .kivrc file
- support for --arch; add x86_64 and aarch64 default qcow2 images
- remove support for end of life distros
- support set -euo pipefail
- some shellcheck cleanups
- remove ISO generation in favour of --cloud-init flag
- add timeout when waiting for MAC address
- set default distro to rocky9
- bump default memory to 1536MB to support newer distributions
Fedora example script to install dependencies use `-y` flag, so I added
it too on Ubuntu example.
Signed-off-by: Zasda Yusuf Mikail <zasdaym@gmail.com>
Use the `qemu-img resize` command to resize ubuntu 20.04, as is done for
ubuntu 18.04 This fixes the error on boot:
Booting form Hard Disk...
error: unknown filesystem.
Entering resue mode...
grub rescue>
Also use `qemu-img resize` on ubuntu 16.04, so all versions of ubuntu
use this method.
* Update README.md
on ubuntu 18.04 got following errors when tried to spin up VM:
./kvm-install-vm: line 470: osinfo-query: command not found
ERR: Unknown OS variant 'ubuntu18.04'. Please update your osinfo-db. See https://libosinfo.org/download for more information.
* Update README.md
updated packages names for ubuntu/debian based distros + added small troubleshooting hint
* Update README.md
* Update README.md
small fix
Co-authored-by: Tomas Bezdek <tomas.bezdek@tieto.com>
Check the osinfo-db is not too old, and if so issue an error message to
explain how to upgrade the osinfo-db.
The osinfo-db provided by package managers tend to lag the upstream
libosinfo project. This makes it harder to support new os versions when
your kvm is running on something like CentOS or Ubuntu LTS. Fortunately
the libosinfo project provides downloads and a tool to import the
osinfo-db without impacting the files managed by the package manager,
which makes using kvm-import-vm create a much more pleasant experience.
* Add command wrapper for verbose mode
Add a wrapper function to automatically print command arguments when
running in verbose mode. Currently, this is only done for the `virsh
pool-create-as` and `virt-install` commands, but more commands could
be added in the future.
Having the wrapper run the command removes the redundant command
arguments and will allow us to more easily support a variable number
of virt-install arguments
This commit introduces the following shell helper functions:
join Join strings into a single string, joined
by a delimiter.
output_command Print the command arguments for verbose mode,
formatted as one argument per line, with line
continuation characters as needed.
run Command execution wrapper to print the command
when running in verbose mode and to redirect
output to the current log file.
* Support virt-install graphics auto-detection
Typically, the `virt-install` user does not need to specify the
--graphics option. When the --graphics flag is not specified,
virt-install will try and choose a useful default and launch a suitable
connection.
Support graphics auto-detection by omitting the virt-install --grahics
option when the kvm-install-vm '-g' flag is set to 'auto' or the
GRAPHICS variable in the ~/.kivrc file is set to 'auto'.
* Hypervisor custom parameters
Support custom virt-install parameters for advanced usage. This allows
for advanced customization and to support Xen and other non-KVM
hypervisors.
Users may specify hypervisor specific settings in the $HOME/.kivrc
customization file, without resorting to patching kvm-install-vm.
With this change, none of the virt-install parameters are hardcoded in
the script, values may be specified to be empty to avoid setting a given
parameter, and additional options may be provided as needed.
This commit adds the following custom virt-install options:
NETWORK_MODEL --network model value (default: virtio)
NETWORK_EXTRA extra --network options
DISK_BUS --disk bus type (default: virtio)
DISK_EXTRA extra --disk parameters
CI_ISO_DEVICE ci cdrom device type (default: cdrom)
CI_ISO_EXTRA extra ci cdrom parameters (default: "")
GRAPHICS_LISTEN --graphics listen value (default: localhost)
GRAPHICS_EXTRA extra graphics parameters
VIRT_INSTALL_EXTRA extra virt-install options
The following virt-install options are dependent on the image being
installed, and so are determined the value of -t command line option.
OS_TYPE --os-type (currently always "linux")
DISK_FORMAT --disk format (currently always "qcow2")
Currently, if an image download is interrupted or fails, a partial file
is left in the image directory and a subsequent kvm-install-vm create
command will blissfully use the partial image, which then silently fails
to create the guest.
Instead, name the files with the '.part' file extension while the file
download is in progress, then pivot to the real image name after the
download is complete. Use the wget '--continue' option to resume
partial downloads so we don't have to restart the download from the
beginning.
Add the -l and -L options to the kvm-install-vm remove command to
specify the paths to the images and guest files. Those options are
required if they were given in the previous kvm-install-vm create
command, otherwise the remove will fail to remove the items created with
the custom paths.
Fix the handling of flags in the remove subcommand. Add the missing
shift operator so the guest name is properly detected. Use the internal
destroy_vm when overritting a guest during the kvm-install-vm create
command, since we should not perform the shift in that code path.
This commit fixes the error when a flag is given to the remove command.
$ kvm-install-vm remove -v test01
Please specify a single host to remove.
Run 'kvm-install-vm help remove' for usage.
Currently the eject command hard-codes device name 'hda' to eject the CI
CDROM image. However the device name depends on the distribution of the
kvm host system.
Fortunately, the 'virsh change-media' command can alternately use the
path of the image instead of the device name, so use that instead of the
hard-coded device name 'hda' to eject the CDROM image.
The cloud-init iso file can be created as a read-only file, which causes
the `rm` program to prompt the user to confirm remove. Use the rm force
option to override this prompt and remove the file.
Example output before this commit:
$ kvm-install-vm create test01
- Copying cloud image (CentOS-7-x86_64-GenericCloud.qcow2) ... OK
- Generating ISO for cloud-init ... OK
- Creating storage pool ... OK
- Installing the domain ... OK
- Enabling autostart ... OK
- Cleaning up cloud-init files ... rm: remove write-protected regular file 'test01-cidata.iso'? (hangs here)
Having seperate directories makes it easier to work multiple images and vms.
This change keeps the current image storage location as ~/virt/images but
moves the domains under the ~/virt/vms directory.
Also adds the -L switch to customize the VM storage location.