Roy Golan has uploaded a new change for review.

Change subject: core: fix adding the right video device type (#849635)
......................................................................

core: fix adding the right video device type (#849635)

https://bugzilla.redhat.com/show_bug.cgi?id=849635

Change-Id: I3d28d171b53eb5d44a97f0956384b1012ab5cd1f
Signed-off-by: Roy Golan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
4 files changed, 28 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/14/7414/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
index b246778..762afd0 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java
@@ -15,6 +15,7 @@
 import org.ovirt.engine.core.common.businessentities.BaseDisk;
 import org.ovirt.engine.core.common.businessentities.Disk;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
+import org.ovirt.engine.core.common.businessentities.DisplayType;
 import org.ovirt.engine.core.common.businessentities.UsbPolicy;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VmBase;
@@ -348,7 +349,7 @@
                 Guid newId = Guid.NewGuid();
                 VmDeviceUtils.addManagedDevice(new VmDeviceId(newId, 
newStatic.getId()),
                         VmDeviceType.VIDEO,
-                        VmDeviceType.QXL,
+                        
getDeviceDisplayType(newStatic.getdefault_display_type()),
                         getMemExpr(newStatic.getnum_of_monitors()),
                         true,
                         false);
@@ -363,6 +364,17 @@
         }
     }
 
+    private static VmDeviceType getDeviceDisplayType(DisplayType displyType) {
+        VmDeviceType type = null;
+        switch (displyType) {
+        case qxl:
+            type = VmDeviceType.QXL;
+        case vnc:
+            type = VmDeviceType.CIRRUS;
+        }
+        return type;
+    }
+
     /**
      * Updates new/existing VM USB slots in vm device
      * Currently assuming the number of slots is between 0 and 
SLOTS_PER_CONTROLLER, i.e., no more than one controller
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
index f090193..8e571e1 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
@@ -166,6 +166,10 @@
     @Type(type = "guid")
     private NGuid dedicated_vm_for_vds;
 
+    @Column(name = "default_display_type")
+    @Enumerated
+    protected DisplayType defaultDisplayType = DisplayType.qxl;
+
     public VmBase(Guid id,
             Guid vds_group_id,
             VmOsType mOs,
@@ -751,4 +755,12 @@
     public void setdedicated_vm_for_vds(NGuid value) {
         dedicated_vm_for_vds = value;
     }
+
+    public DisplayType getdefault_display_type() {
+        return defaultDisplayType;
+    }
+
+    public void setdefault_display_type(DisplayType value) {
+        defaultDisplayType = value;
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
index c3a92ad..fb459c3 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
@@ -41,9 +41,6 @@
     @Column(name = "is_initialized")
     private boolean is_initialized;
 
-    @Column(name = "default_display_type")
-    private DisplayType default_display_type = DisplayType.qxl;
-
     @OvfExportOnlyField(exportOption = ExportOption.EXPORT_NON_IGNORED_VALUES)
     @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE)
     @Column(name = "userdefined_properties")
@@ -77,7 +74,7 @@
         setis_auto_suspend(false);
         setnice_level(0);
         setdefault_boot_sequence(BootSequence.C);
-        default_display_type = DisplayType.qxl;
+        defaultDisplayType = DisplayType.qxl;
         setvm_type(VmType.Desktop);
         sethypervisor_type(HypervisorType.KVM);
         setoperation_mode(OperationMode.FullVirtualized);
@@ -231,14 +228,6 @@
         is_initialized = value;
     }
 
-    public DisplayType getdefault_display_type() {
-        return default_display_type;
-    }
-
-    public void setdefault_display_type(DisplayType value) {
-        default_display_type = value;
-    }
-
     public int getMinAllocatedMem() {
         if (minAllocatedMemField > 0) {
             return minAllocatedMemField;
@@ -273,7 +262,7 @@
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + ((default_display_type == null) ? 0 : 
default_display_type.hashCode());
+        result = prime * result + ((defaultDisplayType == null) ? 0 : 
defaultDisplayType.hashCode());
         result = prime * result + (is_initialized ? 1231 : 1237);
         result = prime * result + m_nDiskSize;
         result = prime * result + ((name == null) ? 0 : name.hashCode());
@@ -295,7 +284,7 @@
             return false;
         }
         VmStatic other = (VmStatic) obj;
-        if (default_display_type != other.default_display_type) {
+        if (defaultDisplayType != other.defaultDisplayType) {
             return false;
         }
         if (is_initialized != other.is_initialized) {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
index 8d40a85..ca0ddd8 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
@@ -72,10 +72,6 @@
     @Transient
     private String storagePoolName;
 
-    @Column(name = "default_display_type", nullable = false)
-    @Enumerated
-    private DisplayType defaultDisplayType = DisplayType.vnc;
-
     @Transient
     private Map<Guid, DiskImage> diskMap = new HashMap<Guid, DiskImage>();
 
@@ -199,14 +195,6 @@
 
     public void setstorage_pool_name(String value) {
         storagePoolName = value;
-    }
-
-    public DisplayType getdefault_display_type() {
-        return defaultDisplayType;
-    }
-
-    public void setdefault_display_type(DisplayType value) {
-        defaultDisplayType = value;
     }
 
     public double getSizeGB() {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d28d171b53eb5d44a97f0956384b1012ab5cd1f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to