<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi!<div><br></div><div>We're struggling to get device detaching to work reliably using Xen. We can reliably use the same code to manage devices using Libvirt+KVM without any problems. We've tested this on Xen with both CD-ROM and USB devices without success. See below for detailed descriptions.</div><div><br></div><div>Thankful for any help!</div><div><br></div><div>Regards,</div><div>Daniel Espling</div><div><br></div><div>---</div><div><br></div><div>For CD-ROM, we can mount them using attach-device but cannot remove them using the correspoding call to detach-device:</div><div><br></div><div><div>cdrom7.xml contains:</div><div><div><disk type='file' device='cdrom'></div><div><span class="Apple-tab-span" style="white-space: pre; ">   </span><driver name='file' type='raw'/></div><div><span class="Apple-tab-span" style="white-space: pre; ">    </span><source file='/opt/diskimages/test7.iso'/></div><div><span class="Apple-tab-span" style="white-space: pre; ">  </span><target dev='hdc' bus='ide'/></div><div><span class="Apple-tab-span" style="white-space: pre; ">       </span><readonly/></div><div></disk></div></div></div><div><br></div><div><div>eject.xml contains:</div><div><div><disk type='block' device='cdrom'></div><div><span class="Apple-tab-span" style="white-space: pre; ">     </span><driver name='file'/></div><div><span class="Apple-tab-span" style="white-space: pre; ">       </span><target dev='hdc' bus='ide'/></div><div><span class="Apple-tab-span" style="white-space: pre; ">       </span><readonly/></div><div></disk></div></div></div><div><br></div><div>cdrom8.xml is identical to cdrom7.xml apart from the .iso file used.</div><div><br></div><div><div># virsh attach-device deb cdrom7.xml                                           </div><div>Device attached successfully</div><div><br></div><div># virsh detach-device deb cdrom7.xml                                           </div><div>error: no such device in deb</div></div><div><br></div><div># virsh attach-device deb eject.xml</div><div><div>error: Failed to attach device from eject.xml</div><div>error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected')</div></div><div><br></div><div><div># virsh update-device deb cdrom8.xml --persistent</div><div>error: Failed to update device from cdrom8.xml</div><div>error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 5632 not connected')</div></div><div><br></div><div>dumpxml shows the cdrom device attached exactly as it's defined in the xml.</div><div><br></div><div>Using virsh we're able to use "virsh detach-disk deb hdc" to unmount the CD-ROM, but we need to be able to do this using the python API. We cannot find a corresponding call to detach-disk and we therefore have to rely on detach-device instead, right? Are there any flags we can use for detachDeviceFlags() to replicate the functionality of detach-disk?</div><div><br></div><div>----</div><div><br></div><div>Similarly for USB devices, we can mount them OK but not remove them using the corresponding call to detach-device. Calling detach-disk works, but again we need to find the corresponding call for this function using the python API. One thing we've found with mounting USB devices is that they seem to be mounted on the SCSI bus instead of the USB one as specified:</div><div><br></div><div>Example:</div><div><br></div><div>usb7.xml contains:</div><div><disk type='file' device='disk'></div><div><span class="Apple-tab-span" style="white-space:pre">        </span><driver name='file' type='raw'/></div><div><span class="Apple-tab-span" style="white-space:pre">       </span><source file='/opt/diskimages/test7.iso'/></div><div><span class="Apple-tab-span" style="white-space:pre">     </span><target dev='sda' bus='<b>usb</b>'/></div><div><span class="Apple-tab-span" style="white-space:pre">       </span><readonly/></div><div></disk></div><div><br></div><div>dumpxml shows:</div><div><div><disk type='file' device='disk'></div><div>      <driver name='file'/></div><div>      <source file='/opt/diskimages/test7.iso'/></div><div>      <target dev='sda' bus='<b>scsi</b>'/></div><div>      <readonly/></div><div></disk></div></div><div><br></div><div># virsh attach-device deb usb7.xml<br>Device attached successfully<br><br></div><div>Test attaching again (expected to fail):</div><div># virsh attach-device deb usb7.xml                                             <br>error: Failed to attach device from usb7.xml<br>error: Requested operation is not valid: target 'sda' already exists<br><br>`-testgrid7.leeds.ac.uk /opt/recontext # virsh detach-device deb usb7.xml<br>error: no such device in deb</div><div><br></div><div>----</div><div><br></div><div><div>Relevant info:</div><div><br></div><div><div>Compiled against library: libvir 0.9.9</div><div>Using library: libvir 0.9.9</div><div>Using API: Xen 0.9.9</div><div>Running hypervisor: Xen 4.0.0</div></div></div><div><br></div><div>Running CentOS 5.5 (final)</div><div>Linux 2.6.32.24 #3 SMP Fri Oct 29 16:22:02 BST 2010 x86_64 x86_64 x86_64 GNU/Linux</div></body></html>