Hi gu, I was trying to reproduce your case and spawned a guest to attach&detach an ISO. When started the guest had this XMLrepresentation of the cd drive:
Yours was slightly different:
So I adapted mine to match.
Detaching it worked fine and gave me:
Also re-attaching was fine. I did attach/detach the ISO via virt-manager UI as well as via commandline like: $ virsh attach-disk iso-detach "" hdc --type cdrom --mode readonly $ virsh attach-disk iso-detach "/var/lib/libvirt/images/ubuntu-20.04.2.0-desktop-amd64.iso" hdc --type cdrom --mode readonly None of these failed. From the hipervisor I wasn't able to get the "tray='open'" even when defining it that way at runtime it was not present. I could get it into that state when ejecting the CD from the guests POV via: $ eject -m But even then it detached fine: $ virsh dumpxml iso-detach | grep -A8 'cdrom'
$ virsh attach-disk iso-detach "" hdc --type cdrom --mode readonly Disk attached successfully $ virsh dumpxml iso-detach | grep -A8 'cdrom'
So it is unclear to me how you hit this issue, as I tried guest reboots as well as forcing the tray to be open. All just worked. Have you done any particular setup step to make this happen? If you'd have clear steps to reproduce from a guest created from scratch into the error that might be helpful. P.S. While doing so I realized that you use a machine type of pc-i440fx-5.0. You reported to use qemu-kvm 1:4.2-3ubuntu6.15 which does not have that type at all. root@f:~# qemu-system-x86_64 -M ? | grep 5.0 pc-i440fx-wily Ubuntu 15.04 PC (i440FX + PIIX, 1996) So something must be wrong in addition to your cdrom issues. I'd recommend to use the type "ubuntu" which in your case would translate to "pc-i440fx-focal" Your setup should not work at all as a 5.0 type is not part of that qemu that you are running - so this also seems like an unsupported setup anyway ?