mirror of https://github.com/apache/cloudstack.git
[KVM] Add MV Settings for virtual GPU hardware type and memory (#5513)
* KVM: Add MV Settings for virtual GPU hardware type and memory * fix method createVideoDef argument in test package * add available options for KVM virtual GPU hardware VM setting * fix videoRam default value * fix _videoRam is 0, it will use default provided by libvirt
This commit is contained in:
parent
669ab73efe
commit
72a1c0e7f1
|
|
@ -40,6 +40,10 @@ public interface VmDetailConstants {
|
|||
String KVM_VNC_PORT = "kvm.vnc.port";
|
||||
String KVM_VNC_ADDRESS = "kvm.vnc.address";
|
||||
|
||||
// KVM specific, custom virtual GPU hardware
|
||||
String VIDEO_HARDWARE = "video.hardware";
|
||||
String VIDEO_RAM = "video.ram";
|
||||
|
||||
// Mac OSX guest specific (internal)
|
||||
String SMC_PRESENT = "smc.present";
|
||||
String FIRMWARE = "firmware";
|
||||
|
|
|
|||
|
|
@ -2427,7 +2427,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
devices.addDevice(createChannelDef(vmTO));
|
||||
devices.addDevice(createWatchDogDef());
|
||||
devices.addDevice(createVideoDef());
|
||||
devices.addDevice(createVideoDef(vmTO));
|
||||
devices.addDevice(createConsoleDef());
|
||||
devices.addDevice(createGraphicDef(vmTO));
|
||||
devices.addDevice(createTabletInputDef());
|
||||
|
|
@ -2488,8 +2488,20 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
return new ConsoleDef(PTY, null, null, (short)0);
|
||||
}
|
||||
|
||||
protected VideoDef createVideoDef() {
|
||||
return new VideoDef(_videoHw, _videoRam);
|
||||
protected VideoDef createVideoDef(VirtualMachineTO vmTO) {
|
||||
Map<String, String> details = vmTO.getDetails();
|
||||
String videoHw = _videoHw;
|
||||
int videoRam = _videoRam;
|
||||
if (details != null) {
|
||||
if (details.containsKey(VmDetailConstants.VIDEO_HARDWARE)) {
|
||||
videoHw = details.get(VmDetailConstants.VIDEO_HARDWARE);
|
||||
}
|
||||
if (details.containsKey(VmDetailConstants.VIDEO_RAM)) {
|
||||
String value = details.get(VmDetailConstants.VIDEO_RAM);
|
||||
videoRam = NumbersUtil.parseInt(value, videoRam);
|
||||
}
|
||||
}
|
||||
return new VideoDef(videoHw, videoRam);
|
||||
}
|
||||
|
||||
protected RngDef createRngDef() {
|
||||
|
|
|
|||
|
|
@ -1624,9 +1624,13 @@ public class LibvirtVMDef {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder videoBuilder = new StringBuilder();
|
||||
if (_videoModel != null && !_videoModel.isEmpty() && _videoRam != 0){
|
||||
if (_videoModel != null && !_videoModel.isEmpty()){
|
||||
videoBuilder.append("<video>\n");
|
||||
videoBuilder.append("<model type='" + _videoModel + "' vram='" + _videoRam + "'/>\n");
|
||||
if (_videoRam != 0) {
|
||||
videoBuilder.append("<model type='" + _videoModel + "' vram='" + _videoRam + "'/>\n");
|
||||
} else {
|
||||
videoBuilder.append("<model type='" + _videoModel + "'/>\n");
|
||||
}
|
||||
videoBuilder.append("</video>\n");
|
||||
return videoBuilder.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ public class LibvirtComputingResourceTest {
|
|||
libvirtComputingResourceSpy._videoRam = 200;
|
||||
libvirtComputingResourceSpy._videoHw = "vGPU";
|
||||
|
||||
VideoDef videoDef = libvirtComputingResourceSpy.createVideoDef();
|
||||
VideoDef videoDef = libvirtComputingResourceSpy.createVideoDef(to);
|
||||
Document domainDoc = parse(videoDef.toString());
|
||||
assertXpath(domainDoc, "/video/model/@type", "vGPU");
|
||||
assertXpath(domainDoc, "/video/model/@vram", "200");
|
||||
|
|
|
|||
|
|
@ -3879,6 +3879,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
|
||||
if (HypervisorType.KVM.equals(hypervisorType)) {
|
||||
options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "virtio"));
|
||||
options.put(VmDetailConstants.VIDEO_HARDWARE, Arrays.asList("cirrus", "vga", "qxl", "virtio"));
|
||||
options.put(VmDetailConstants.VIDEO_RAM, Collections.emptyList());
|
||||
}
|
||||
|
||||
if (HypervisorType.VMware.equals(hypervisorType)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue