<fix>[compute]: fix the failure to start the vm after setting the default cdRom
after updating the deviceId of the original default CD-ROM in setting
the default CD-ROM, clear the pci address of the CD-ROM
Resolves:
@@ -57,6 +57,7 @@ import org.zstack.header.vm.VmInstanceSpec.CdRomSpec;
import org.zstack.header.vm.VmInstanceSpec.HostName;
import org.zstack.header.vm.VmInstanceSpec.IsoSpec;
import org.zstack.header.vm.cdrom.*;
+import org.zstack.header.vm.devices.VmInstanceDeviceManager;
import org.zstack.header.vo.ResourceVO;
import org.zstack.header.volume.*;
import org.zstack.identity.Account;
@@ -132,6 +133,8 @@ public class VmInstanceBase extends AbstractVmInstance {
private ResourceConfigFacade rcf;
@Autowired
private TagManager tagMgr;
+ @Autowired
+ private VmInstanceDeviceManager vidm;
protected VmInstanceVO self;
protected VmInstanceVO originalCopy;
@@ -8053,6 +8056,8 @@ public class VmInstanceBase extends AbstractVmInstance {
.eq(VmCdRomVO_.uuid, beforeDefaultCdRomVO.getUuid())
.set(VmCdRomVO_.deviceId, deviceId)
.update();
+ logger.debug(String.format("delete the device address of the cdRom %s of the vm %s", beforeDefaultCdRomVO.getUuid(), beforeDefaultCdRomVO.getVmInstanceUuid()));
+ vidm.deleteVmDeviceAddress(beforeDefaultCdRomVO.getUuid(), beforeDefaultCdRomVO.getVmInstanceUuid());
}
}
}.execute();
