diff --git a/README.md b/README.md index e0df9ee..9ca8deb 100755 --- a/README.md +++ b/README.md @@ -28,6 +28,26 @@ ssh deb12-1 ## KVM + +### etc-profile.d-virsh.sh + +Useful Bash aliases (actually they are functions) for managing KVM containers. + +For these aliases to be system-wide for Bash users, put them in: +`/etc/profile.d/virsh.sh` + +For a user only, they can be copied into ~/.bashrc + + +vlist List machines and their status +vstart Start +vsave Save (suspend) +vtop Stop (gracefully shutdown) +vkill Kill (force shutdown) +vconsole Open console on +vrm Completely remove (destroy) + + ### kvm-setup Bash script to assist with setting up a Linux virtual machine under KVM/QEMU from an ISO image file. diff --git a/kvm/etc-profile.d-virsh.sh b/kvm/etc-profile.d-virsh.sh new file mode 100644 index 0000000..b807649 --- /dev/null +++ b/kvm/etc-profile.d-virsh.sh @@ -0,0 +1,27 @@ +# Aliases for virsh +vlist() { + /usr/bin/virsh --connect qemu:///system list --all +} +vstart() { + /usr/bin/virsh --connect qemu:///system start $1 +} +vsave() { + /usr/bin/virsh --connect qemu:///system managedsave $1 --running +} +vstop() { + /usr/bin/virsh --connect qemu:///system shutdown $1 +} +vkill() { + /usr/bin/virsh --connect qemu:///system destroy $1 +} +vconsole() { + /usr/bin/virsh --connect qemu:///system console $1 +} +vrm() { + echo "This will completely remove $1 and its associated storage." + read -r -p "Are you sure? (y/N) " ans + echo + if [[ "$ans" =~ ^[Yy]$ ]]; then + /usr/bin/virsh --connect qemu:///system undefine --nvram --remove-all-storage $1 + fi +}