Commit 34be0190 authored by Ahmad Siavashi's avatar Ahmad Siavashi

GpuHost revised

parent 79ffca08
......@@ -81,7 +81,7 @@ public class GpuHost extends Host {
return true;
}
// if the VM has a vGPU and the host has no local video card -> return false.
else if(getVideoCardAllocationPolicy() == null) {
else if (getVideoCardAllocationPolicy() == null) {
return false;
}
// if the VM has a vGPU and the host has video card(s) -> check compatibility.
......@@ -122,15 +122,27 @@ public class GpuHost extends Host {
// Device (GPU) allocation
Vgpu vgpu = ((GpuVm) vm).getVgpu();
if (vgpu != null) {
boolean isGpuAllocated = getVideoCardAllocationPolicy().allocate(vgpu, vgpu.getPCIeBw());
if (!isGpuAllocated) {
Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(),
" to Host #", getId(), " failed due to vgpu allocation failure.");
// if the VM has no vGPU -> success.
if (vgpu == null) {
getVmList().add(vm);
vm.setHost(this);
return true;
}
// if the VM has a vGPU but the host has no local video card -> fail.
else if (getVideoCardAllocationPolicy() == null) {
rollbackHostResourceAllocation(vm);
return false;
}
}
// if the VM has a vGPU and the host has local video card(s) -> check
boolean isVgpuAllocated = getVideoCardAllocationPolicy().allocate(vgpu, vgpu.getPCIeBw());
// if vGPU allocation failed -> fail.
if (!isVgpuAllocated) {
Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(), " to Host #",
getId(), " failed due to vgpu allocation failure.");
rollbackHostResourceAllocation(vm);
return false;
} // else -> success
getVmList().add(vm);
vm.setHost(this);
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment