From 6fa28b1fb7e44d33f83681ec834bb4f79d0db936 Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Mon, 15 Aug 2016 14:05:59 +0200 Subject: [PATCH] Introduce support for kvm acceleration This change introduces kvm acceleration support. The default settings still use qemu as the domain type and kvm needs to be explicitly set in order to enable it. Change-Id: I59af1b7a844b927cac45722f7ea7ea4abeef7c8f Signed-off-by: Fatih Degirmenci --- playbooks/roles/bifrost-create-vm-nodes/README.md | 4 ++++ .../roles/bifrost-create-vm-nodes/defaults/main.yml | 1 + .../files/create_vm_nodes-for-role.sh | 10 ++++++++-- playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml | 1 + .../kvm-acceleration-support-8be50d32bc34c4b3.yaml | 7 +++++++ scripts/test-bifrost.sh | 2 ++ 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/kvm-acceleration-support-8be50d32bc34c4b3.yaml diff --git a/playbooks/roles/bifrost-create-vm-nodes/README.md b/playbooks/roles/bifrost-create-vm-nodes/README.md index 27260711f..1abbb9503 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/README.md +++ b/playbooks/roles/bifrost-create-vm-nodes/README.md @@ -24,6 +24,10 @@ test_vm_memory_size: Tunable setting to allow a user to define a specific between test runs, you may need to undefine the test virtual machine(s) that were previously created. +test_vm_domain_type: Tunable setting to allow a user to chosee the domain + type of the created VMs. The default is "qemu" and can + be set to kvm to enable kvm acceleration. + test_vm_num_nodes: Tunable setting to allow a user to define the number of test VMs that will be created. They will all be created with same settings. diff --git a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml index c20a283c6..42bf5330e 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml @@ -3,3 +3,4 @@ baremetal_csv_file: "/tmp/baremetal.csv" test_vm_memory_size: "3072" test_vm_num_nodes: "1" +test_vm_domain_type: "qemu" diff --git a/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh b/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh index 6be9af1c8..c6e052299 100755 --- a/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh +++ b/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh @@ -17,6 +17,9 @@ # # Create 3 nodes with base name of 'junk' # sudo NODEBASE=junk NODECOUNT=3 create_nodes.sh # +# # Create 2 nodes that use KVM acceleration +# sudo VM_DOMAIN_TYPE=kvm NODECOUNT=2 create_nodes.sh +# # THANKS # Thanks to the author(s) of the ironic-supporting code within devstack, # from which all of this is derived. @@ -34,6 +37,7 @@ LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"} export VIRSH_DEFAULT_CONNECT_URI="$LIBVIRT_CONNECT_URI" # VM specs +VM_DOMAIN_TYPE=${VM_DOMAIN_TYPE:-qemu} VM_EMULATOR=${VM_EMULATOR:-/usr/bin/qemu-system-x86_64} VM_CPU=${VM_CPU:-1} VM_RAM=${VM_RAM:-3072} @@ -67,6 +71,7 @@ VM_LOGDIR=/var/log/libvirt/baremetal_logs # $6: Network bridge for the VMs # $7: Path to VM emulator # $8: Logging directory for the VMs +# $9: Domain type of the VM ############################################################################# function create_node { NAME=$1 @@ -85,6 +90,7 @@ function create_node { BRIDGE=$6 EMULATOR=$7 LOGDIR=$8 + DOMAIN_TYPE=$9 LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"e1000"} LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"} @@ -135,7 +141,7 @@ function create_node { chattr +C "$volume_path" || true fi vm_xml=" - + ${NAME} ${MEM} ${CPU} @@ -238,7 +244,7 @@ fi for (( i=1; i<=${NODECOUNT}; i++ )) do name=${NODEBASE}${i} - mac=$(create_node $name $VM_CPU $VM_RAM $VM_DISK amd64 $VM_NET_BRIDGE $VM_EMULATOR $VM_LOGDIR) + mac=$(create_node $name $VM_CPU $VM_RAM $VM_DISK amd64 $VM_NET_BRIDGE $VM_EMULATOR $VM_LOGDIR $VM_DOMAIN_TYPE) printf "$mac,root,undefined,192.168.122.1,$VM_CPU,$VM_RAM,$VM_DISK,flavor,type,a8cb6624-0d9f-c882-affc-046ebb96ec0${i},$name,192.168.122.$((i+1))\n" >>$TEMPFILE done diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml index 41c1ee435..ba68f1197 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml @@ -56,6 +56,7 @@ environment: NODEOUTPUT: "{{baremetal_csv_file}}" VM_RAM: "{{ test_vm_memory_size }}" + VM_DOMAIN_TYPE: "{{ test_vm_domain_type }}" NODECOUNT: "{{ test_vm_num_nodes }}" register: task_create_vm_nodes ignore_errors: yes diff --git a/releasenotes/notes/kvm-acceleration-support-8be50d32bc34c4b3.yaml b/releasenotes/notes/kvm-acceleration-support-8be50d32bc34c4b3.yaml new file mode 100644 index 000000000..63daa6dee --- /dev/null +++ b/releasenotes/notes/kvm-acceleration-support-8be50d32bc34c4b3.yaml @@ -0,0 +1,7 @@ +--- +features: + - Add support for kvm acceleration for the VMs created + by bifrost-create-vm-nodes. The default domain type + for the created VMs is qemu which uses tcg acceleration. + In order to use kvm acceleration, users need to set + VM_DOMAIN_TYPE to kvm. diff --git a/scripts/test-bifrost.sh b/scripts/test-bifrost.sh index 71360a21a..728badd40 100755 --- a/scripts/test-bifrost.sh +++ b/scripts/test-bifrost.sh @@ -23,6 +23,7 @@ BUILD_IMAGE="false" # use cirros. VM_MEMORY_SIZE="3072" +VM_DOMAIN_TYPE=qemu TEST_VM_NUM_NODES=1 USE_CIRROS=true TESTING_USER=cirros @@ -106,6 +107,7 @@ ${ANSIBLE} -vvvv \ test-bifrost-create-vm.yaml \ -e test_vm_num_nodes=${TEST_VM_NUM_NODES} \ -e test_vm_memory_size=${VM_MEMORY_SIZE} \ + -e test_vm_domain_type=${VM_DOMAIN_TYPE} \ -e enable_venv=${ENABLE_VENV} if [ ${USE_DHCP} = "true" ]; then