Skip to content

Commit

Permalink
core: Use virtio-vga driver for VGA
Browse files Browse the repository at this point in the history
If VM is configured with VGA display type, use virtio-vga driver for it.
This behaviour may be configured through osinfo database.

Change-Id: I2476286e90cd84b51e35bd3170affeaee1924951
Bug-Url: https://bugzilla.redhat.com/2038694
Signed-off-by: Shmuel Melamud <smelamud@redhat.com>
  • Loading branch information
smelamud committed Jul 5, 2022
1 parent c9b4ead commit fbc8549
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
Expand Up @@ -126,6 +126,12 @@ public interface OsRepository {
*/
int getVgamemMultiplier(int osId);

/**
* Checks if virtio-vga driver should be used for vga display type
* @param osId operation system id
*/
boolean isVirtioVgaUsed(int osId, Version version);

/**
* Checks if that OS network devices support hotplug.
* @return an boolean
Expand Down
Expand Up @@ -461,6 +461,10 @@ public int getVgamemMultiplier(int osId) {
return getInt(getValueByVersion(idToUnameLookup.get(osId), "devices.display.vgamemMultiplier", null), 1);
}

public boolean isVirtioVgaUsed(int osId, Version version) {
return getBoolean(getValueByVersion(idToUnameLookup.get(osId), "devices.display.virtioVga", version), false);
}

@Override
public boolean hasNicHotplugSupport(int osId, Version version) {
return getBoolean(getValueByVersion(idToUnameLookup.get(osId), "devices.network.hotplugSupport", version), false);
Expand Down
Expand Up @@ -61,6 +61,7 @@ void devices() : {} {
("display.protocols" displayValue())
| ("display.vramMultiplier" intValue())
| ("display.vgamemMultiplier" intValue())
| ("display.virtioVga" booleanValue())
| ("watchdog.models" watchdogValue())
| ("network" networkValue())
| ("network.hotplugSupport" booleanValue())
Expand Down
Expand Up @@ -3014,7 +3014,7 @@ void writeVideo(VmDevice device) {
if (mdevDisplayOn) {
writer.writeAttributeString("type", "none");
} else {
writer.writeAttributeString("type", device.getDevice());
writer.writeAttributeString("type", getVideoType(device.getDevice()));
Object vram = device.getSpecParams().get(VdsProperties.VIDEO_VRAM);
writer.writeAttributeString("vram", vram != null ? vram.toString() : "32768");
Object heads = device.getSpecParams().get(VdsProperties.VIDEO_HEADS);
Expand All @@ -3033,6 +3033,13 @@ void writeVideo(VmDevice device) {
writer.writeEndElement();
}

private String getVideoType(String deviceType) {
if (!deviceType.equals("vga")) {
return deviceType;
}
return vmInfoBuildUtils.isVirtioVgaUsed(vm.getVmOsId(), vm.getCompatibilityVersion()) ? "virtio" : "vga";
}

private void writeDefaultVideo() {
writer.writeStartElement("video");
writer.writeStartElement("model");
Expand Down
Expand Up @@ -903,6 +903,10 @@ public VmDevice createVideoDeviceByDisplayType(DisplayType displayType, Guid vmI
return vmDevice;
}

public boolean isVirtioVgaUsed(int osId, Version version) {
return osRepository.isVirtioVgaUsed(osId, version);
}

public void addVmGraphicsOptions(Map<GraphicsType, GraphicsInfo> infos, Map<String, Object> params, VM vm) {
if (infos.containsKey(GraphicsType.SPICE)) {
params.put(VdsProperties.spiceFileTransferEnable,
Expand Down
1 change: 1 addition & 0 deletions packaging/conf/osinfo-defaults.properties
Expand Up @@ -65,6 +65,7 @@ os.other.devices.display.protocols.value.4.3 = spice/qxl,vnc/vga,vnc/qxl
os.other.devices.display.protocols.value.4.2 = spice/qxl,vnc/vga,vnc/qxl,vnc/cirrus
os.other.devices.display.protocols.value.4.1 = spice/qxl,vnc/vga,vnc/qxl,vnc/cirrus
os.other.devices.display.protocols.value.4.0 = spice/qxl,vnc/vga,vnc/qxl,vnc/cirrus
os.other.devices.display.virtioVga.value = true
os.other.devices.watchdog.models.value = i6300esb
os.other.devices.usb.controller.value = piix3-uhci,q35/qemu-xhci
os.other.vmInitType.value = cloudinit
Expand Down

0 comments on commit fbc8549

Please sign in to comment.