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

GpuHost revised

parent 79ffca08
...@@ -81,7 +81,7 @@ public class GpuHost extends Host { ...@@ -81,7 +81,7 @@ public class GpuHost extends Host {
return true; return true;
} }
// if the VM has a vGPU and the host has no local video card -> return false. // 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; return false;
} }
// if the VM has a vGPU and the host has video card(s) -> check compatibility. // if the VM has a vGPU and the host has video card(s) -> check compatibility.
...@@ -122,15 +122,27 @@ public class GpuHost extends Host { ...@@ -122,15 +122,27 @@ public class GpuHost extends Host {
// Device (GPU) allocation // Device (GPU) allocation
Vgpu vgpu = ((GpuVm) vm).getVgpu(); Vgpu vgpu = ((GpuVm) vm).getVgpu();
if (vgpu != null) {
boolean isGpuAllocated = getVideoCardAllocationPolicy().allocate(vgpu, vgpu.getPCIeBw()); // if the VM has no vGPU -> success.
if (!isGpuAllocated) { if (vgpu == null) {
Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(), getVmList().add(vm);
" to Host #", getId(), " failed due to vgpu allocation failure."); vm.setHost(this);
rollbackHostResourceAllocation(vm); return true;
return false;
}
} }
// 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); getVmList().add(vm);
vm.setHost(this); vm.setHost(this);
return true; 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