vm is a command line utility that provides a high-level interface to create
and manage virtual machines through libvirt.
It supports creation and deletion of domains and snapshots, connecting to serial and SSH terminals, downloading and converting templates from vagrantup.com and builder.libguestfs.org, and importing locally downloading images.
go get -u github.com/subpop/vm/cmd/vmvm includes a Makefile to aid distributions in packaging. The default target
will build vm along with shell completion data and a man page. The Makefile
includes an install target to install the binary and data into distribution-appropriate
locations. To override the installation directory (commonly referred to as the
DESTDIR), set the DESTDIR variable when running the install target:
[link@localhost vm]$ make
go build ./cmd/vm
go run ./cmd/vm --generate-fish-completion > vm.fish
go run ./cmd/vm --generate-bash-completion > vm.bash
go run ./cmd/vm --generate-man-page > vm.1
gzip -k vm.1
[link@localhost vm]$ make DESTDIR=_inst install
install -D -m755 -t _inst//usr/local/bin vm
install -D -m644 -t _inst//usr/local/share/man/man1 vm.1.gz
install -D -m644 -t _inst//usr/local/share/fish/completions vm.fish
install -d _inst//usr/local/share/bash-completion/completions
install -m644 -T vm.bash _inst//usr/local/share/bash-completion/completions/vm
[link@localhost vm]$Download a base image:
vm image get https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2Download and convert a Vagrant ".box":
vm image get https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-31-1.9.x86_64.vagrant-libvirt.boxCreate a domain backed by that image:
vm create Fedora-Cloud-Base-31-1.9.x86_64 --name my-f31Create a domain without defining it:
vm create Fedora-Cloud-Base-31-1.9.x86_64 --transientList active domains:
vm listStart a created domain:
vm up my-f31Connect to an existing domain over SSH:
vm connect -m ssh -u vagrant my-f31 -i ~/.ssh/cloud_user_rsaConnect to an existing domain over VirtIO PTY:
vm connect -m console my-f31Take a snapshot:
vm snapshot create my-f31 --name fresh_installRevert to snapshot:
vm snapshot revert my-f31 --snapshot fresh_install