Skip to content

Commit

Permalink
F #1226: Support for KVM iothreads (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Czerný authored Feb 11, 2021
1 parent 3d5196c commit 05e6d44
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/cli/onevm
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
5 changes: 4 additions & 1 deletion src/mad/sh/scripts_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/vm/VirtualMachine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@ void VirtualMachine::get_public_clouds(const string& pname, set<string> &clouds)
static std::map<std::string,std::vector<std::string>> 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"} },
Expand Down
39 changes: 38 additions & 1 deletion src/vmm/LibVirtDriverKVM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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 = "";

Expand Down Expand Up @@ -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>" << iothreads << "</iothreads>" << endl;
}

// ------------------------------------------------------------------------
// DEVICES SECTION
// ------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 ----
Expand Down Expand Up @@ -1725,11 +1751,22 @@ int LibVirtDriver::deployment_description_kvm(
<< "\t\t<controller type='scsi' index='0' model='virtio-scsi'>"
<< endl;

file << "\t\t\t<driver";

if ( virtio_scsi_queues > 0 )
{
file << "\t\t\t<driver queues='" << virtio_scsi_queues << "'/>" << 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</controller>" << endl
<< "\t</devices>" << endl;
}
Expand Down
7 changes: 4 additions & 3 deletions src/vmm_mad/exec/vmm_exec_kvm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions src/vmm_mad/remotes/kvm/attach_disk
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ XML+="<driver name='qemu' type='$(xml_esc "${DRIVER}")'"
[ -n "${CACHE}" ] && XML+=" cache='$(xml_esc "${CACHE}")'"
[ -n "${DISK_IO}" ] && XML+=" io='$(xml_esc "${DISK_IO}")'"
[ -n "${DISCARD}" ] && XML+=" discard='$(xml_esc "${DISCARD}")'"
[ -n "${IOTHREAD}" ] && XML+=" iothread='$(xml_esc "${IOTHREAD}")'"
XML+="/>"

XML+="<source ${TYPE_SOURCE}='$(xml_esc "${SOURCE}")' ${SOURCE_ARGS}>"
Expand Down

0 comments on commit 05e6d44

Please sign in to comment.