Martin Peřina has uploaded a new change for review.

Change subject: core: Fixes device type for spicevmc and smartcard devices
......................................................................

core: Fixes device type for spicevmc and smartcard devices

Adds general device type REDIR.
Reverts device type for spicevmc device from CHANNEL back to REDIR.
Fixes SMARTCARD device type and name to send when creating new VM.

Change-Id: I10776d96f9e43676efd5660ec888022d1786957a
Bug-Url: https://bugzilla.redhat.com/984586
Signed-off-by: Martin Perina <[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/VmDeviceGeneralType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/customprop/DevicePropertiesUtilsTest.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
6 files changed, 27 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/08/17708/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 c2dc05f..9a31344 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
@@ -8,6 +8,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.VmHandler;
 import org.ovirt.engine.core.bll.network.VmInterfaceManager;
@@ -830,7 +831,7 @@
     private static void addUsbSlots(VmBase vm, int numOfSlots) {
         for (int index = 1; index <= numOfSlots; index++) {
             VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.newGuid(), 
vm.getId()),
-                    VmDeviceGeneralType.CHANNEL,
+                    VmDeviceGeneralType.REDIR,
                     VmDeviceType.SPICEVMC,
                     getUsbSlotSpecParams(),
                     true,
@@ -884,7 +885,7 @@
     }
 
     private static List<VmDevice> getUsbRedirectDevices(VmBase vm) {
-        List<VmDevice> list = 
dao.getVmDeviceByVmIdTypeAndDevice(vm.getId(),VmDeviceGeneralType.CHANNEL, 
VmDeviceType.SPICEVMC.getName());
+        List<VmDevice> list = 
dao.getVmDeviceByVmIdTypeAndDevice(vm.getId(),VmDeviceGeneralType.REDIR, 
VmDeviceType.SPICEVMC.getName());
 
         return list;
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java
index 0afa012..694f27e 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java
@@ -42,6 +42,11 @@
     CHANNEL,
 
     /**
+     * USB device redirection
+     */
+    REDIR,
+
+    /**
      * A console device
      */
     CONSOLE,
@@ -142,6 +147,10 @@
 
             case REDIR:
             case SPICEVMC:
+                type = REDIR;
+                break;
+
+            case CHANNEL:
                 type = CHANNEL;
                 break;
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
index 206f7bd..461a2eb 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java
@@ -281,7 +281,7 @@
     public static boolean isSpecialDevice(String device, VmDeviceGeneralType 
type) {
         return (VmDeviceGeneralType.SOUND == type || 
VmDeviceType.USB.getName().equals(device)
                 || (VmDeviceType.SMARTCARD.getName().equals(device) && 
VmDeviceGeneralType.SMARTCARD == type)
-                || (VmDeviceType.SPICEVMC.getName().equals(device) && 
VmDeviceGeneralType.CHANNEL == type)
+                || (VmDeviceType.SPICEVMC.getName().equals(device) && 
VmDeviceGeneralType.REDIR == type)
                 || (VmDeviceType.MEMBALLOON.getName().equals(device) && 
VmDeviceGeneralType.BALLOON == type))
                 || (VmDeviceType.WATCHDOG.getName().equals(device) && 
VmDeviceGeneralType.WATCHDOG == type);
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java
index 3700d56..db2d69e 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java
@@ -18,6 +18,7 @@
     ICH6("ich6"),
     AC97("ac97"),
     MEMBALLOON("memballoon"),
+    CHANNEL("channel"),
     SMARTCARD("smartcard"),
     BALLOON("balloon"),
     CONSOLE("console"),
diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/customprop/DevicePropertiesUtilsTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/customprop/DevicePropertiesUtilsTest.java
index a1a365c..0323c52 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/customprop/DevicePropertiesUtilsTest.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/customprop/DevicePropertiesUtilsTest.java
@@ -188,8 +188,9 @@
                 + "{type=video;prop={turned_on=^(true|false)$}};"
                 + "{type=sound;prop={volume=[0-9]{1,2}}};"
                 + "{type=controller;prop={hotplug=^(true|false)$}};"
-                + "{type=balloon;prop={max_size=[0-9]{1,15})}};"
-                + "{type=channel;prop={auth_type=^(plain|md5|kerberos)$)}};"
+                + "{type=balloon;prop={max_size=[0-9]{1,15}}};"
+                + "{type=channel;prop={auth_type=^(plain|md5|kerberos)$}};"
+                + "{type=redir;prop={max_len=[0-9]{1,15}}};"
                 + "{type=console;prop={type=^(text|vnc)$}};"
                 + "{type=smartcard;prop={version=([1-9]{1}).([0-9]{1})}}";
         DevicePropertiesUtils utils = DevicePropertiesUtils.getInstance();
@@ -300,6 +301,7 @@
                 + "{type=controller;prop={hotplug=^(true|false)$}};"
                 + "{type=balloon;prop={max_size=[0-9]{1,15}}};"
                 + "{type=channel;prop={auth_type=^(plain|md5|kerberos)$}};"
+                + "{type=redir;prop={max_len=[0-9]{1,15}}};"
                 + "{type=console;prop={type=^(text|vnc)$;prop=\\{\\}}};"
                 + 
"{type=smartcard;prop={spec_chars=[\\@\\#\\$\\%\\^\\&\\*\\(\\)\\{\\}\\:\\<\\>\\,\\.\\?\\[\\]]?}}";
 
@@ -310,7 +312,7 @@
         assertTrue(utils.isDevicePropertiesDefinitionValid(customDevPropSpec));
 
         // test parsed properties
-        assertEquals(9, 
utils.getDeviceTypesWithProperties(Version.v3_3).size());
+        assertEquals(10, 
utils.getDeviceTypesWithProperties(Version.v3_3).size());
 
         // test disk properties
         devProp = utils.getDeviceProperties(Version.v3_3, 
VmDeviceGeneralType.DISK);
@@ -348,6 +350,11 @@
         validatePropertyMap(devProp, 1);
         validatePropertyPattern(devProp, "auth_type", 
"^(plain|md5|kerberos)$");
 
+        // test redir properties
+        devProp = utils.getDeviceProperties(Version.v3_3, 
VmDeviceGeneralType.REDIR);
+        validatePropertyMap(devProp, 1);
+        validatePropertyPattern(devProp, "max_len", "[0-9]{1,15}");
+
         // test console properties
         devProp = utils.getDeviceProperties(Version.v3_3, 
VmDeviceGeneralType.CONSOLE);
         validatePropertyMap(devProp, 2);
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 13e38ae..15a7c4c 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
@@ -302,7 +302,7 @@
 
         if (containsVirtioScsiDisk) {
             Map<String, Object> struct = new HashMap<String, Object>();
-            struct.put(VdsProperties.Type, VmDeviceType.CONTROLLER.getName());
+            struct.put(VdsProperties.Type, 
VmDeviceGeneralType.CONTROLLER.getValue());
             struct.put(VdsProperties.Device, VdsProperties.Scsi);
             struct.put(VdsProperties.Model, VdsProperties.VirtioScsi);
             devices.add(struct);
@@ -643,7 +643,7 @@
                 DbFacade.getInstance()
                         .getVmDeviceDao()
                         .getVmDeviceByVmIdTypeAndDevice(vm.getId(),
-                                VmDeviceGeneralType.CHANNEL,
+                                VmDeviceGeneralType.REDIR,
                                 VmDeviceType.SPICEVMC.getName());
         for (VmDevice vmDevice : vmDevices) {
             Map struct = new HashMap();
@@ -675,7 +675,7 @@
         for (VmDevice vmDevice : vmDevices) {
             Map struct = new HashMap();
             struct.put(VdsProperties.Type, vmDevice.getType().getValue());
-            struct.put(VdsProperties.Device, vmDevice.getType());
+            struct.put(VdsProperties.Device, vmDevice.getDevice());
             addDevice(struct, vmDevice, null);
         }
     }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I10776d96f9e43676efd5660ec888022d1786957a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to