This is an automated email from the ASF dual-hosted git repository.
gabriel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new c565db2 kvm: Set amount of queues for Virtio SCSI driver to vCPU of
Instance (#3101)
c565db2 is described below
commit c565db2cf2ab5fdbd2fba65409928dfa7c5f2d25
Author: Wido den Hollander <[email protected]>
AuthorDate: Tue Jan 8 10:39:21 2019 +0100
kvm: Set amount of queues for Virtio SCSI driver to vCPU of Instance (#3101)
The additional queues can enhance the performance of the VirtIO SCSI disk
and it is recommended to set this to the amount of vCPUs a Instance is
assigned.
The optional queues attribute specifies the number of queues for the
controller. For best performance, it's recommended to specify a value
matching
the number of vCPUs. Since 1.0.5 (QEMU and KVM only)
Source: https://libvirt.org/formatdomain.html#elementsVirtio
Signed-off-by: Wido den Hollander <[email protected]>
---
.../cloud/hypervisor/kvm/resource/LibvirtComputingResource.java | 2 +-
.../java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java | 9 +++++++--
.../java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java | 3 ++-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index ac92f37..ced37c9 100644
---
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -2214,7 +2214,7 @@ public class LibvirtComputingResource extends
ServerResourceBase implements Serv
// If we're using virtio scsi, then we need to add a virtual scsi
controller
if (busT == DiskDef.DiskBus.SCSI) {
- final SCSIDef sd = new SCSIDef((short)0, 0, 0, 9, 0);
+ final SCSIDef sd = new SCSIDef((short)0, 0, 0, 9, 0, vcpus);
devices.addDevice(sd);
}
diff --git
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index e0089dc..1f1c3a0 100644
---
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -1501,13 +1501,15 @@ public class LibvirtVMDef {
private int bus = 0;
private int slot = 9;
private int function = 0;
+ private int queues = 0;
- public SCSIDef(short index, int domain, int bus, int slot, int
function) {
+ public SCSIDef(short index, int domain, int bus, int slot, int
function, int queues) {
this.index = index;
this.domain = domain;
this.bus = bus;
this.slot = slot;
this.function = function;
+ this.queues = queues;
}
public SCSIDef() {
@@ -1518,9 +1520,12 @@ public class LibvirtVMDef {
public String toString() {
StringBuilder scsiBuilder = new StringBuilder();
- scsiBuilder.append(String.format("<controller type='scsi'
index='%d' model='virtio-scsi'>\n", this.index ));
+ scsiBuilder.append(String.format("<controller type='scsi'
index='%d' model='virtio-scsi'>\n", this.index));
scsiBuilder.append(String.format("<address type='pci'
domain='0x%04X' bus='0x%02X' slot='0x%02X' function='0x%01X'/>\n",
this.domain, this.bus, this.slot, this.function ) );
+ if (this.queues > 0) {
+ scsiBuilder.append(String.format("<driver queues='%d'/>\n",
this.queues));
+ }
scsiBuilder.append("</controller>\n");
return scsiBuilder.toString();
}
diff --git
a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
index 32effb4..e127ed3 100644
---
a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
+++
b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java
@@ -196,10 +196,11 @@ public class LibvirtVMDefTest extends TestCase {
}
public void testSCSIDef() {
- SCSIDef def = new SCSIDef();
+ SCSIDef def = new SCSIDef((short)0, 0, 0, 9, 0, 4);
String str = def.toString();
String expected = "<controller type='scsi' index='0'
model='virtio-scsi'>\n" +
"<address type='pci' domain='0x0000' bus='0x00' slot='0x09'
function='0x0'/>\n" +
+ "<driver queues='4'/>\n" +
"</controller>\n";
assertEquals(str, expected);
}