Eli Mesika has uploaded a new change for review. Change subject: core: remove unmanaged devices when ...(#846696) ......................................................................
core: remove unmanaged devices when ...(#846696) core: remove unmanaged devices when run-once VM is stopped When a VM that has an attached CD or Floppy is running with run-once a duplicate unmanaged copy of the CD/Floppy is created. When running this VM again, both copies of the Cd/Floppy(the original managed one and the unmanaged one created by the run-once) will be sent to VDSM causing an exception in libvirt since only one CD/Floppy is currently supported. This patch handles removal of managed devices in StopVmCommandBse in the same manner as stateless VM is handled. Change-Id: I1a34e93d0c9ef401afdb8eded95782cbf859dda6 Signed-off-by: Eli Mesika <emes...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java 1 file changed, 19 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/7947/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java index 6b728a0..6392b3a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVmCommandBase.java @@ -15,6 +15,7 @@ import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDynamic; import org.ovirt.engine.core.common.utils.VmDeviceCommonUtils; +import org.ovirt.engine.core.common.utils.VmDeviceType; import org.ovirt.engine.core.common.vdscommands.DestroyVmVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.UpdateVmDynamicDataVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; @@ -91,7 +92,7 @@ } private void removeStatelessVmUnmanagedDevices() { - if (getSucceeded() && getVm().getis_stateless()) { + if (getSucceeded() && (getVm().getis_stateless() || isRunOnce())) { // remove all unmanaged devices of a stateless VM List<VmDevice> vmDevices = DbFacade.getInstance() @@ -106,6 +107,23 @@ } } + /* + * This method checks if we are stopping a VM that was started by run-once + * In such case we will may have 2 devices, one managed and one unmanaged for CD or Floppy + * This is not supported currently by libvirt that allows only one CD/Floppy + * This code should be removed if libvirt will support in future multiple CD/Floppy + */ + private boolean isRunOnce() { + List<VmDevice> cdList = + DbFacade.getInstance() + .getVmDeviceDAO().getVmDeviceByVmIdTypeAndDevice(getVm().getId(), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName()); + List<VmDevice> floppyList = + DbFacade.getInstance() + .getVmDeviceDAO().getVmDeviceByVmIdTypeAndDevice(getVm().getId(), VmDeviceType.DISK.getName(), VmDeviceType.FLOPPY.getName()); + + return (cdList.size() > 1 || floppyList.size() > 1); + } + /** * Start stopping operation for suspended VM, by deleting its storage image groups (Created by hibernation process * which indicated its saved memory), and set the VM status to image locked. -- To view, visit http://gerrit.ovirt.org/7947 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1a34e93d0c9ef401afdb8eded95782cbf859dda6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches