Arik Hadas has uploaded a new change for review.

Change subject: core: fix run once starts with wrong display type
......................................................................

core: fix run once starts with wrong display type

This patch fix the following bug: trying to run once a VM which has vnc
console set in its default settings, with spice console results in starting
qemu process with '-vga cirrus' instead of '-vga qxl'.

There was a special treatment for the case of run once with vnc console
a vm that has spice console in its default settings, but no treatment
for the scenario described above.

The fix is to add qxl video device in that case.

Change-Id: I635307847edf764b174230203ee355987b948ce4
Signed-off-by: Arik Hadas <aha...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
1 file changed, 40 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/10537/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
index 5bd0cb4..f86459d 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
@@ -13,7 +13,6 @@
 import org.ovirt.engine.core.common.businessentities.Disk;
 import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
-import org.ovirt.engine.core.common.businessentities.DisplayType;
 import org.ovirt.engine.core.common.businessentities.Entities;
 import org.ovirt.engine.core.common.businessentities.LunDisk;
 import org.ovirt.engine.core.common.businessentities.PropagateErrors;
@@ -58,39 +57,51 @@
     @Override
     protected void buildVmVideoCards() {
         createInfo.add(VdsProperties.display, vm.getDisplayType().toString());
-        // check if display type was changed in given parameters
+        // the requested display type might be different than the default 
display of
+        // the VM in Run Once scenario, in that case we need to add proper 
video device
         if (vm.getDisplayType() != vm.getDefaultDisplayType()) {
-            if (vm.getDisplayType() == DisplayType.vnc) { // check spice to 
vnc change
-                XmlRpcStruct struct = new XmlRpcStruct();
-                // create a monitor as an unmanaged device
-                struct.add(VdsProperties.Type, VmDeviceType.VIDEO.getName());
-                struct.add(VdsProperties.Device, 
VmDeviceType.CIRRUS.getName());
-                struct.add(VdsProperties.SpecParams, 
getNewMonitorSpecParams());
-                struct.add(VdsProperties.DeviceId, 
String.valueOf(Guid.NewGuid()));
-                devices.add(struct);
-            }
+            addVideoCardAccordingToTheRequestedDisplayType();
         }
         else {
-            // get vm device for Video Cards from DB
-            List<VmDevice> vmDevices =
-                    DbFacade.getInstance()
-                            .getVmDeviceDao()
-                            .getVmDeviceByVmIdAndType(vm.getId(), 
VmDeviceType.VIDEO.getName());
-            for (VmDevice vmDevice : vmDevices) {
-                // skip unmanaged devices (handled separately)
-                if (!vmDevice.getIsManaged()) {
-                    continue;
-                }
+            addVideoCardsDefinedForTheVmFromDB();
+        }
+    }
 
-                XmlRpcStruct struct = new XmlRpcStruct();
-                struct.add(VdsProperties.Type, vmDevice.getType());
-                struct.add(VdsProperties.Device, vmDevice.getDevice());
-                addAddress(vmDevice, struct);
-                struct.add(VdsProperties.SpecParams, vmDevice.getSpecParams());
-                struct.add(VdsProperties.DeviceId, 
String.valueOf(vmDevice.getId().getDeviceId()));
-                addToManagedDevices(vmDevice);
-                devices.add(struct);
+    /**
+     * Add video device according to the requested display type
+     */
+    private void addVideoCardAccordingToTheRequestedDisplayType() {
+        XmlRpcStruct struct = new XmlRpcStruct();
+        // create a monitor as an unmanaged device
+        struct.add(VdsProperties.Type, VmDeviceType.VIDEO.getName());
+        struct.add(VdsProperties.Device, 
vm.getDisplayType().getVmDeviceType().getName());
+        struct.add(VdsProperties.SpecParams, getNewMonitorSpecParams());
+        struct.add(VdsProperties.DeviceId, String.valueOf(Guid.NewGuid()));
+        devices.add(struct);
+    }
+
+    /**
+     * Add the video cards defined for the VM in the DB
+     */
+    private void addVideoCardsDefinedForTheVmFromDB() {
+        List<VmDevice> vmDevices =
+                DbFacade.getInstance()
+                        .getVmDeviceDao()
+                        .getVmDeviceByVmIdAndType(vm.getId(), 
VmDeviceType.VIDEO.getName());
+        for (VmDevice vmDevice : vmDevices) {
+            // skip unmanaged devices (handled separately)
+            if (!vmDevice.getIsManaged()) {
+                continue;
             }
+
+            XmlRpcStruct struct = new XmlRpcStruct();
+            struct.add(VdsProperties.Type, vmDevice.getType());
+            struct.add(VdsProperties.Device, vmDevice.getDevice());
+            addAddress(vmDevice, struct);
+            struct.add(VdsProperties.SpecParams, vmDevice.getSpecParams());
+            struct.add(VdsProperties.DeviceId, 
String.valueOf(vmDevice.getId().getDeviceId()));
+            addToManagedDevices(vmDevice);
+            devices.add(struct);
         }
     }
 


--
To view, visit http://gerrit.ovirt.org/10537
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I635307847edf764b174230203ee355987b948ce4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <aha...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to