Leonardo Bianconi has uploaded a new change for review.

Change subject: core: Change NIC type from sPAPR VLAN to any other
......................................................................

core: Change NIC type from sPAPR VLAN to any other

Backporting change.
After created the VM, added a network interface and have changed its
type, the VM cannot be started.

Change-Id: Ia77afccc75bd500db6f3b88872847a06ebe43513
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1060729
Signed-off-by: Leonardo Bianconi <leonardo.bianc...@eldorado.org.br>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
1 file changed, 15 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/24078/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
index f1d0c77..78289c6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
@@ -89,6 +89,10 @@
                 macAddedToPool = addMacToPool(getMacAddress());
             }
 
+            if (mustChangeAddress(oldIface.getType(), 
getInterface().getType())) {
+                getVmDeviceDao().clearDeviceAddress(getInterface().getId());
+            }
+
             
getInterface().setSpeed(VmInterfaceType.forValue(getInterface().getType()).getSpeed());
 
             TransactionSupport.executeInNewTransaction(new 
TransactionMethod<Void>() {
@@ -277,6 +281,17 @@
         return permissionList;
     }
 
+    /**
+     * Check if address must be changed after change NIC type
+     * @param oldType - Old nic type
+     * @param newType - New nic type
+     * @return
+     */
+    private boolean mustChangeAddress (int oldType, int newType) {
+        int spaprVlanType = VmInterfaceType.spaprVlan.getValue();
+        return oldType == spaprVlanType ^ newType == spaprVlanType;
+    }
+
     private boolean isVnicProfileChanged(VmNic oldNic, VmNic newNic) {
         return !ObjectUtils.equals(oldNic.getVnicProfileId(), 
newNic.getVnicProfileId());
     }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia77afccc75bd500db6f3b88872847a06ebe43513
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Leonardo Bianconi <leonardo.bianc...@eldorado.org.br>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to