diff --git a/newvm.sh b/newvm.sh index 17e4894..da41865 100755 --- a/newvm.sh +++ b/newvm.sh @@ -1,6 +1,8 @@ #!/bin/sh # vim: set sw=4 ts=4 sts=4 et : +METADATA_XMLNS='http://du5t1n.me/xmlns/libvirt/metadata/' + memory=2048 vcpus=2 disk_size=16 @@ -73,6 +75,13 @@ while [ $# -gt 0 ]; do --domain=*) dnsdomain=${1#=*} ;; + --group) + shift + groups_xml="${groups_xml}" + ;; + --group=*) + groups_xml="${groups_xml}" + ;; --no-console|--noconsole) console=false ;; @@ -139,6 +148,7 @@ extra_args="${extra_args} inst.notmux quiet systemd.show_status=1 console=ttyS0" set -- \ --name ${name} \ + --metadata title=${hostname} \ --memory ${memory} \ --cpu host \ --location ${location} \ @@ -159,4 +169,11 @@ else set -- "$@" --noautoconsole --wait -1 fi -exec virt-install "$@" +( +virsh event --event lifecycle --loop | awk '/Started/{exit}' +virsh metadata ${name} --live --config ${METADATA_XMLNS} dch \ + "${groups_xml}" +) & + +virt-install "$@" +wait