diff --git a/roles/lmn_vm/files/vm-run b/roles/lmn_vm/files/vm-run index eef1010..293ed4f 100755 --- a/roles/lmn_vm/files/vm-run +++ b/roles/lmn_vm/files/vm-run @@ -16,6 +16,7 @@ options: --cpu num number of CPUs --os OS operating system (win10|linux|..) --data-disk size additional data-disk + --bridge virbrX additional network interface on bridge virbrX --options options additional options for virt-install command EOF } @@ -109,7 +110,7 @@ LIBVIRTOPTS="" source /etc/lmn/vm.conf -TEMP=$(getopt -o no:ps --long new,options:,persistent:,system,memory:,data-disk:,cpu:,os:,help -n $0 -- "$@") +TEMP=$(getopt -o no:ps --long new,options:,persistent:,system,memory:,data-disk:,cpu:,bridge:,os:,help -n $0 -- "$@") if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi eval set -- "$TEMP" @@ -145,6 +146,12 @@ while true; do LIBVIRTOPTS="${LIBVIRTOPTS} --vcpu $2" shift 2 ;; + --bridge ) + if ip link | grep $2; then + LIBVIRTOPTS="${LIBVIRTOPTS} --network=bridge=$2,model.type=virtio" + fi + shift 2 + ;; --os ) LIBVIRTOSINFO=$2 shift 2 @@ -191,11 +198,6 @@ if ! virsh --connect="${QEMU}" list | grep "${VM_NAME}-clone"; then # finally, create the new vm - if ip link | grep virbr1; then - LIBVIRTOPTS="${LIBVIRTOPTS} --network=bridge=virbr1,model.type=virtio" - fi - - # TODO # # find macvtap interface MAC address: # MAC="$(ip link | grep -A1 "vm-macvtap" | @@ -209,9 +211,10 @@ if ! virsh --connect="${QEMU}" list | grep "${VM_NAME}-clone"; then --clock hpet_present=yes \ --features hyperv.synic.state=on,xpath1.set=./hyperv/vpindex/@state=on \ --memorybacking source.type=memfd,access.mode=shared \ - --disk "${VM_DIR}/${VM_NAME}-clone.qcow2" \ + --disk "${VM_DIR}/${VM_NAME}-clone.qcow2",driver.discard=unmap,target.bus=scsi,cache=writeback \ --network=bridge=virbr0,model.type=virtio \ --filesystem driver.type=virtiofs,accessmode=passthrough,target.dir=virtiofs,xpath1.set=./source/@socket="/run/user/${UID}/virtiofs-${VM_NAME}.sock" \ + --controller type=scsi,model=virtio-scsi \ --check path_in_use=off \ --connect="${QEMU}" \ --noautoconsole \