> On Feb. 15, 2013, 9:51 a.m., Wei Zhou wrote: > > I just see this issue. I had some test about DetachISO at the beginn of > > this year. I did not add a jira ticket because I think it is not the bug of > > CloudStack. > > > > I was using Ubuntu 12.04, and the qemu version is 1.0+noroms-0ubuntu14.3. > > Here is the result of my test. > > > > (1) If the Guest OS is CentOS 5.5, it works well! > > ISO can be Attached successfully. > > ISO can be detached successfully if it is not mounted in Guest OS. > > ISO cannot be detached if it is mounted in Guest OS (even if DetachISO many > > times). (mount /dev/cdrom /mnt) > > ISO can be detached successfully after “umount” the ISO in Guest OS > > (umount /mnt) > > ISO will be detached successfully when I add -- force flag, even if it is > > mounted in Guest OS. (it may be a problem) > > > > (2) If the Guest OS is Ubuntu 12.04 > > I create two XML files to attach and eject ISO. > > > > attach.xml > > <disk type='file' device='cdrom'> > > <source file='/root/KNOPPIX_V7.0.4bootonly-2012-08-20-EN.iso'/> > > <target dev='hdc' bus='ide'/> > > </disk> > > > > eject.xml > > <disk type='file' device='cdrom'> > > <target dev='hdc' bus='ide'/> > > <readonly/> > > </disk> > > > > a) the result of attachISO looks like random. But it does not matter, as > > attachISO always works well after the ISO is ejected successfully. > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > Device updated successfully > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > error: Failed to update device from attach.xml > > error: internal error unable to execute QEMU command 'change': Device > > 'drive-ide0-1-0' is locked > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > error: Failed to update device from attach.xml > > error: internal error unable to execute QEMU command 'change': Device > > 'drive-ide0-1-0' is locked > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > error: Failed to update device from attach.xml > > error: internal error unable to execute QEMU command 'change': Device > > 'drive-ide0-1-0' is locked > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > Device updated successfully > > > > b) the ISO can be detached after being ejected some times( sometimes 1, > > sometimes 2, sometimes N…), no matter whether ISO is mounted or not in > > Guest OS. > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > Device updated successfully > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM eject.xml > > error: Failed to update device from eject.xml > > error: internal error unable to execute QEMU command 'eject': Device > > 'drive-ide0-1-0' is locked > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM eject.xml > > error: Failed to update device from eject.xml > > error: internal error unable to execute QEMU command 'eject': Device > > 'drive-ide0-1-0' is locked > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM eject.xml > > Device updated successfully > > > > c) if I add --force flag when DetachISO, it works. > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > Device updated successfully > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM eject.xml --force > > Device updated successfully > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM attach.xml > > Device updated successfully > > > > root@cs-kvm002:~# virsh update-device i-2-17-VM eject.xml --force > > Device updated successfully > > > > > >
I think the ideal result should be (1) We can detach ISO when the virtual machine is stopped. (2) We can detach ISO when the ISO is attached to but not used(such as mounted/read) in the running virtual machine. (3) We cannot detach ISO when the ISO is attach and also used in the running virtual machine. For a solution, I have upgraded “libvirt” on host from 0.9.8(default) to 1.0.1(the latest version). However, this problem still exists. I also had tested the --force flag, although I do think it is not a good way (!). I have changed com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.attachOrDetachDevice(Connect, boolean, String, String). dm.attachDevice(xml); -> dm.attachDeviceFlags(xml, 4); dm.detachDevice(xml); -> dm.detachDeviceFlags(xml, 4); from http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDeviceModifyFlags VIR_DOMAIN_DEVICE_MODIFY_FORCE = 4 Forcibly modify device (ex. force eject a cdrom) from the /var/log/cloud/management/management-server.log, I can see that the libvirt do not support this flag. 2013-01-09 16:30:43,988 DEBUG [agent.transport.Request] (AgentManager-Handler-13:null) Seq 6-1083047954: Processing: { Ans: , MgmtId: 345051234346, via: 6, Ver: v1, Flags: 110, [{"Answer":{"result":false,"details":"org.libvirt.LibvirtException: invalid argument: qemuDomainModifyDeviceFlags: unsupported flags (0x4)","wait":0}}] } - Wei ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/7660/#review16639 ----------------------------------------------------------- On Feb. 15, 2013, 5:02 a.m., deepti dohare wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/7660/ > ----------------------------------------------------------- > > (Updated Feb. 15, 2013, 5:02 a.m.) > > > Review request for cloudstack. > > > Description > ------- > > Currently no warning or confirmation is given or required to delete an iso > which is attached to a virtual machine. > > Fixing this issue using “force” delete option. > If an admin or a user deletes an ISO which is attached to a vm: > 1. Without force option; gives a warning that ISO is attached to vm “Failed > to delete iso. It is currently attached to virtual machine. Please detach it > before deleting”. > 2. With force option: first detach the ISO from all vms and then deletes the > ISO. > > > This addresses bug CLOUDSTACK-357. > > > Diffs > ----- > > api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java > c821775 > server/src/com/cloud/template/TemplateManagerImpl.java f9cf277 > server/src/com/cloud/vm/dao/UserVmDao.java 9fbcde3 > server/src/com/cloud/vm/dao/UserVmDaoImpl.java f2fc10b > ui/scripts/templates.js 040ce4a > > Diff: https://reviews.apache.org/r/7660/diff/ > > > Testing > ------- > > Verified locally. Tested for some cases: > > 1. Deleting iso(not attached to any vm) > 2. Deleting iso(attached to multiple vms in same domain) > 3. Deleting iso(attached to multiple vms in different domains) > > For admin/user > > > Thanks, > > deepti dohare > >