GutoVeronezi commented on a change in pull request #6031:
URL: https://github.com/apache/cloudstack/pull/6031#discussion_r812368219
##########
File path:
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
##########
@@ -4621,4 +4623,37 @@ public static long countDomainRunningVcpus(Domain dm)
throws LibvirtException {
VcpuInfo vcpus[] = dm.getVcpusInfo();
return Arrays.stream(vcpus).filter(vcpu ->
vcpu.state.equals(VcpuInfo.VcpuState.VIR_VCPU_RUNNING)).count();
}
+
+ /**
+ * Retrieves the cpu_shares (priority) of the running VM <br/>
+ * @param dm domain of the VM.
+ * @return the value of cpu_shares of the running VM.
+ * @throws org.libvirt.LibvirtException
+ **/
+ public static Integer getCpuShares(Domain dm) throws LibvirtException {
+ int cpu_shares = 0;
+ for (SchedParameter c : dm.getSchedulerParameters()) {
+ if (c.field.equals("cpu_shares")) {
+ cpu_shares = Integer.parseInt(c.getValueAsString());
+ return cpu_shares;
+ }
+ }
+ s_logger.warn(String.format("Could not get cpu_shares of domain: [%s].
Returning default value of 0. ", dm.getName()));
+ return cpu_shares;
+ }
+
+ /**
+ * Set the cpu_shares (priority) of the running VM <br/>
Review comment:
```suggestion
* Sets the cpu_shares (priority) of the running VM <br/>
```
##########
File path:
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtScaleVmCommandWrapper.java
##########
@@ -68,6 +71,23 @@ public Answer execute(ScaleVmCommand command,
LibvirtComputingResource libvirtCo
}
}
+ /**
+ * Set the cpu_shares (priority) of the running VM. This is necessary
because the priority is only calculated when deploying the VM.
Review comment:
```suggestion
* Sets the cpu_shares (priority) of the running VM. This is necessary
because the priority is only calculated when deploying the VM.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]