From 05e6d4472af45cdfbc6f8597c203a36ecee5c46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Czern=C3=BD?= Date: Thu, 11 Feb 2021 15:33:09 +0100 Subject: [PATCH] F #1226: Support for KVM iothreads (#783) --- src/cli/onevm | 4 +-- src/mad/sh/scripts_common.sh | 5 +++- src/vm/VirtualMachine.cc | 2 +- src/vmm/LibVirtDriverKVM.cc | 39 ++++++++++++++++++++++++++++- src/vmm_mad/exec/vmm_exec_kvm.conf | 7 +++--- src/vmm_mad/remotes/kvm/attach_disk | 1 + 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index 9462effcaf..2a5e5671ac 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -1231,8 +1231,8 @@ CommandParser::CmdParser.new(ARGV) do This command accepts a template file or opens an editor, the full list of configuration attributes are: - OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT"] - FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT"] + OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "UUID"] + FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT", "IOTHREADS"] INPUT = ["TYPE", "BUS"] GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ] RAW = ["DATA", "DATA_VMX", "TYPE"] diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 86d82c3053..c44aed6a8c 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -836,6 +836,7 @@ function get_source_xml { # * WRITE_IOPS_SEC_MAX # * WRITE_IOPS_SEC_MAX_LENGTH # * SIZE_IOPS_SEC +# * IOTHREAD # * TYPE_SOURCE: libvirt xml source name. $TYPE_SOURCE=$SOURCE => file=/my/path # * SOURCE: disk source, can be path, ceph pool/image, device... # * TYPE_XML @@ -900,7 +901,8 @@ function get_disk_information { $DISK_XPATH/WRITE_IOPS_SEC \ $DISK_XPATH/WRITE_IOPS_SEC_MAX \ $DISK_XPATH/WRITE_IOPS_SEC_MAX_LENGTH \ - $DISK_XPATH/SIZE_IOPS_SEC ) + $DISK_XPATH/SIZE_IOPS_SEC \ + $DISK_XPATH/IOTHREAD ) VMID="${XPATH_ELEMENTS[j++]}" DRIVER="${XPATH_ELEMENTS[j++]:-$DEFAULT_TYPE}" @@ -944,6 +946,7 @@ function get_disk_information { WRITE_IOPS_SEC_MAX="${XPATH_ELEMENTS[j++]}" WRITE_IOPS_SEC_MAX_LENGTH="${XPATH_ELEMENTS[j++]}" SIZE_IOPS_SEC="${XPATH_ELEMENTS[j++]}" + IOTHREAD="${XPATH_ELEMENTS[j++]}" TYPE=$(echo "$TYPE"|tr A-Z a-z) READONLY=$(echo "$READONLY"|tr A-Z a-z) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 53331438ca..55c75acdca 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2769,7 +2769,7 @@ void VirtualMachine::get_public_clouds(const string& pname, set &clouds) static std::map> UPDATECONF_ATTRS = { {"OS", {"ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "KERNEL_CMD", "ROOT", "SD_DISK_BUS", "UUID"} }, {"FEATURES", {"PAE", "ACPI", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT", - "VIRTIO_SCSI_QUEUES"} }, + "VIRTIO_SCSI_QUEUES", "IOTHREADS"} }, {"INPUT", {"TYPE", "BUS"} }, {"GRAPHICS", {"TYPE", "LISTEN", "PASSWD", "KEYMAP", "COMMAND"} }, {"RAW", {"TYPE", "DATA", "DATA_VMX"} }, diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index f3e93c1534..fa687905a6 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -478,6 +478,7 @@ int LibVirtDriver::deployment_description_kvm( string write_iops_sec_max_length = ""; string write_iops_sec_max = ""; string size_iops_sec; + string iothreadid; string default_total_bytes_sec = ""; string default_total_bytes_sec_max_length = ""; @@ -561,6 +562,8 @@ int LibVirtDriver::deployment_description_kvm( bool guest_agent = false; int virtio_scsi_queues = 0; int scsi_targets_num = 0; + int iothreads = 0; + int iothread_actual = 1; string hyperv_options = ""; @@ -806,6 +809,13 @@ int LibVirtDriver::deployment_description_kvm( file << mbacking; } + get_attribute(vm, host, cluster, "FEATURES", "IOTHREADS", iothreads); + + if ( iothreads > 0 ) + { + file << "\t" << iothreads << "" << endl; + } + // ------------------------------------------------------------------------ // DEVICES SECTION // ------------------------------------------------------------------------ @@ -924,6 +934,7 @@ int LibVirtDriver::deployment_description_kvm( write_iops_sec_max_length = disk[i]->vector_value("WRITE_IOPS_SEC_MAX_LENGTH"); size_iops_sec = disk[i]->vector_value("SIZE_IOPS_SEC"); + iothreadid = disk[i]->vector_value("IOTHREAD"); set_sec_default(read_bytes_sec, default_read_bytes_sec); set_sec_default(read_bytes_sec_max, default_read_bytes_sec_max); @@ -1212,6 +1223,21 @@ int LibVirtDriver::deployment_description_kvm( file << " discard=" << one_util::escape_xml_attr(default_driver_discard); } + if ( iothreads > 0 && disk_bus == "virtio" ) + { + int iothreadid_i = to_i(iothreadid); + if (iothreadid_i > 0 && iothreadid_i <= iothreads) + { + file << " iothread=" << one_util::escape_xml_attr(iothreadid_i); + } + else + { + file << " iothread=" << one_util::escape_xml_attr(iothread_actual); + + iothread_actual = (iothread_actual % iothreads) + 1; + } + } + file << "/>" << endl; // ---- I/O Options ---- @@ -1725,11 +1751,22 @@ int LibVirtDriver::deployment_description_kvm( << "\t\t" << endl; + file << "\t\t\t 0 ) { - file << "\t\t\t" << endl; + file << " queues=" << one_util::escape_xml_attr(virtio_scsi_queues); } + if ( iothreads > 0 ) + { + file << " iothread=" << one_util::escape_xml_attr(iothread_actual); + + iothread_actual = (iothread_actual % iothreads) + 1; + } + + file << "/>" << endl; + file << "\t\t" << endl << "\t" << endl; } diff --git a/src/vmm_mad/exec/vmm_exec_kvm.conf b/src/vmm_mad/exec/vmm_exec_kvm.conf index 0ebdcea9cf..d491aeb80d 100644 --- a/src/vmm_mad/exec/vmm_exec_kvm.conf +++ b/src/vmm_mad/exec/vmm_exec_kvm.conf @@ -21,9 +21,9 @@ # - os [kernel,initrd,boot,root,kernel_cmd,arch,machine,sd_disk_bus] # - vcpu # - memory_slots: number of memory slots for hotplug memory -# - features [acpi, pae, apic, hyperv, localtime, guest_agent, virtio_scsi_queues] +# - features [acpi, pae, apic, hyperv, localtime, guest_agent, virtio_scsi_queues, iothreads] # - cpu_model [model] -# - disk [driver, cache, io, discard, total_bytes_sec, total_iops_sec, read_bytes_sec, write_bytes_sec, read_iops_sec, write_iops_sec] +# - disk [driver, cache, io, discard, total_bytes_sec, total_iops_sec, read_bytes_sec, write_bytes_sec, read_iops_sec, write_iops_sec, size_iops_sec] # - nic [filter, model] # - raw # - hyperv_options: options used for FEATURES = [ HYPERV = yes ] @@ -45,7 +45,8 @@ FEATURES = [ APIC = "no", HYPERV = "no", GUEST_AGENT = "yes", - VIRTIO_SCSI_QUEUES = "1" + VIRTIO_SCSI_QUEUES = "1", + IOTHREADS = "0" ] #CPU_MODEL = [ MODEL = "host-passthrough"] diff --git a/src/vmm_mad/remotes/kvm/attach_disk b/src/vmm_mad/remotes/kvm/attach_disk index b92e263bfe..e6bbe5a6bd 100755 --- a/src/vmm_mad/remotes/kvm/attach_disk +++ b/src/vmm_mad/remotes/kvm/attach_disk @@ -87,6 +87,7 @@ XML+=""