Juan Hernandez has uploaded a new change for review.

Change subject: core: Find CD path only if VM is up
......................................................................

core: Find CD path only if VM is up

Currently when we try to change the CDROM of a VM we try to compute the
actual path of the disk before checking if the VM is up and before
checking if the storage domain is accessible. This eventually generates
a NPE. This patch changes the relevant commmand so that it will try to
find the path of the CDROM only after the state of the VM and the
accesibility of the storage domain have been checked.

Change-Id: I96af7437a002308c14d7b29493bce48b87d946c2
Bug-Url: https://bugzilla.redhat.com/1067407
Signed-off-by: Juan Hernandez <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java
1 file changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/24823/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java
index d1327e7..dcc49c6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java
@@ -1,7 +1,5 @@
 package org.ovirt.engine.core.bll;
 
-import java.io.File;
-
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.validator.LocalizedVmStatus;
 import org.ovirt.engine.core.common.AuditLogType;
@@ -16,10 +14,6 @@
 
     public ChangeDiskCommand(T parameters) {
         super(parameters);
-    }
-
-    public String getDiskName() {
-        return new File(cdImagePath).getName();
     }
 
     @Override
@@ -38,9 +32,12 @@
 
         if (retValue && !canRunActionOnNonManagedVm()) {
             retValue = false;
-        } else {
-            cdImagePath = 
ImagesHandler.cdPathWindowsToLinux(getParameters().getCdImagePath(), 
getVm().getStoragePoolId(), getVm().getRunOnVds());
         }
+
+        // We need the image path here, but only to check if it is empty, as 
an empty image path means that we should
+        // eject the disk, the actual path of the disk can't be calculated 
here, as the VM may be down or the storage
+        // domain not accessible:
+        cdImagePath = getParameters().getCdImagePath();
 
         if (retValue && !getVm().isRunningOrPaused()) {
             setSucceeded(false);
@@ -66,6 +63,10 @@
 
     @Override
     protected void perform() {
+        // Now that the state of the VM and the accesibility of the storage 
domain have been verified we can calculate
+        // the actual path of the disk:
+        cdImagePath = ImagesHandler.cdPathWindowsToLinux(cdImagePath, 
getVm().getStoragePoolId(), getVm().getRunOnVds());
+
         setActionReturnValue(Backend
                 .getInstance()
                 .getResourceManager()


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

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

Reply via email to