File tree Expand file tree Collapse file tree
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource Expand file tree Collapse file tree Original file line number Diff line number Diff line change 155155import com .cloud .agent .api .to .VolumeTO ;
156156import com .cloud .hypervisor .kvm .resource .KVMHABase .NfsStoragePool ;
157157import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .ConsoleDef ;
158+ import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .CpuTuneDef ;
158159import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .DevicesDef ;
159160import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .DiskDef ;
160161import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .DiskDef .diskProtocol ;
@@ -2475,6 +2476,10 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) {
24752476 grd .setVcpuNum (vmTO .getCpus ());
24762477 vm .addComp (grd );
24772478
2479+ CpuTuneDef ctd = new CpuTuneDef ();
2480+ ctd .setShares (vmTO .getCpus () * vmTO .getSpeed ());
2481+ vm .addComp (ctd );
2482+
24782483 FeaturesDef features = new FeaturesDef ();
24792484 features .addFeatures ("pae" );
24802485 features .addFeatures ("apic" );
@@ -2550,9 +2555,6 @@ protected synchronized StartAnswer execute(StartCommand cmd) {
25502555
25512556 s_logger .debug ("starting " + vmName + ": " + vm .toString ());
25522557 startDomain (conn , vmName , vm .toString ());
2553- Script .runSimpleBashScript ("virsh schedinfo " + vmName
2554- + " --set cpu_shares=" + vmSpec .getCpus ()
2555- * vmSpec .getSpeed ());
25562558
25572559 NicTO [] nics = vmSpec .getNics ();
25582560 for (NicTO nic : nics ) {
Original file line number Diff line number Diff line change @@ -752,6 +752,29 @@ public String toString() {
752752 }
753753 }
754754
755+ public static class CpuTuneDef {
756+ private int _shares = 0 ;
757+
758+ public void setShares (int shares ) {
759+ _shares = shares ;
760+ }
761+
762+ public int getShares () {
763+ return _shares ;
764+ }
765+
766+ @ Override
767+ public String toString () {
768+ StringBuilder cpuTuneBuilder = new StringBuilder ();
769+ cpuTuneBuilder .append ("<cputune>\n " );
770+ if (_shares > 0 ) {
771+ cpuTuneBuilder .append ("<shares>" + _shares + "</shares>\n " );
772+ }
773+ cpuTuneBuilder .append ("</cputune>\n " );
774+ return cpuTuneBuilder .toString ();
775+ }
776+ }
777+
755778 public static class SerialDef {
756779 private final String _type ;
757780 private final String _source ;
You can’t perform that action at this time.
0 commit comments