Skip to content

Commit 95b8c31

Browse files
committed
minor fixups
1 parent 152a883 commit 95b8c31

3 files changed

Lines changed: 373 additions & 261 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,8 +2027,21 @@ protected List<VgpuTypesInfo> parseGpuDevicesFromResult(String result) {
20272027
String numaNode = getJsonStringValueOrNull(jsonObject, "numa_node");
20282028
String pciRoot = getJsonStringValueOrNull(jsonObject, "pci_root");
20292029

2030+
Long maxInstances = getJsonLongValueOrNull(jsonObject, "max_instances");
2031+
Long videoRam = getJsonLongValueOrNull(jsonObject, "video_ram");
2032+
Long maxHeads = getJsonLongValueOrNull(jsonObject, "max_heads");
2033+
Long maxResolutionX = getJsonLongValueOrNull(jsonObject, "max_resolution_x");
2034+
Long maxResolutionY = getJsonLongValueOrNull(jsonObject, "max_resolution_y");
2035+
20302036
VgpuTypesInfo vgpuType = new VgpuTypesInfo(GpuDevice.DeviceType.PCI, vendorName + " " + deviceName,
20312037
"passthrough", busAddress, vendorId, vendorName, deviceId, deviceName, numaNode, pciRoot);
2038+
2039+
vgpuType.setMaxVgpuPerGpu(maxInstances);
2040+
vgpuType.setVideoRam(videoRam);
2041+
vgpuType.setMaxHeads(maxHeads);
2042+
vgpuType.setMaxResolutionX(maxResolutionX);
2043+
vgpuType.setMaxResolutionY(maxResolutionY);
2044+
20322045
if (fullPassthroughEnabled) {
20332046
vgpuType.setPassthroughEnabled(true);
20342047
} else {
@@ -2078,11 +2091,22 @@ protected VgpuTypesInfo getGpuDeviceFromVgpuInstance(JsonElement vgpuInstance, S
20782091

20792092
protected VgpuTypesInfo getGpuDeviceFromVfInstance(JsonElement vfInstance, String busAddress, String vendorId,
20802093
String vendorName, String deviceId, String deviceName, String numaNode, String pciRoot) {
2081-
String vfPciAddress = vfInstance.getAsJsonObject().get("vf_pci_address").getAsString();
2082-
String vfProfile = vfInstance.getAsJsonObject().get("vf_profile").getAsString();
2094+
JsonObject vfInstanceJsonObject = vfInstance.getAsJsonObject();
2095+
String vfPciAddress = vfInstanceJsonObject.get("vf_pci_address").getAsString();
2096+
String vfProfile = vfInstanceJsonObject.get("vf_profile").getAsString();
2097+
Long maxInstances = getJsonLongValueOrNull(vfInstanceJsonObject, "max_instances");
2098+
Long videoRam = getJsonLongValueOrNull(vfInstanceJsonObject, "video_ram");
2099+
Long maxHeads = getJsonLongValueOrNull(vfInstanceJsonObject, "max_heads");
2100+
Long maxResolutionX = getJsonLongValueOrNull(vfInstanceJsonObject, "max_resolution_x");
2101+
Long maxResolutionY = getJsonLongValueOrNull(vfInstanceJsonObject, "max_resolution_y");
20832102
VgpuTypesInfo device = new VgpuTypesInfo(GpuDevice.DeviceType.PCI, vendorName + " " + deviceName, vfProfile, vfPciAddress, vendorId, vendorName, deviceId, deviceName, numaNode, pciRoot);
20842103
device.setParentBusAddress(busAddress);
2085-
device.setVmName(getJsonStringValueOrNull(vfInstance.getAsJsonObject(), "used_by_vm"));
2104+
device.setMaxVgpuPerGpu(maxInstances);
2105+
device.setVideoRam(videoRam);
2106+
device.setMaxHeads(maxHeads);
2107+
device.setMaxResolutionX(maxResolutionX);
2108+
device.setMaxResolutionY(maxResolutionY);
2109+
device.setVmName(getJsonStringValueOrNull(vfInstanceJsonObject, "used_by_vm"));
20862110
return device;
20872111
}
20882112

0 commit comments

Comments
 (0)