Comment 2 for bug 1930398

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

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:

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/ubuntu-20.04.2.0-desktop-amd64.iso' index='1'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Yours was slightly different:
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/5155538a-0a91-3468-9c82-a927ec96c539/206-2-7475aee1-70a6-3fe7-bc3e-95f964428d79.iso' index='1'/>
      <backingStore/>
      <target dev='hdc' bus='ide' tray='open'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

So I adapted mine to match.

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/ubuntu-20.04.2.0-desktop-amd64.iso' index='1'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

Detaching it worked fine and gave me:

    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source index='5'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

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'
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/ubuntu-20.04.2.0-desktop-amd64.iso' index='8'/>
      <backingStore/>
      <target dev='hdc' bus='ide' tray='open'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
$ virsh attach-disk iso-detach "" hdc --type cdrom --mode readonly
Disk attached successfully
$ virsh dumpxml iso-detach | grep -A8 'cdrom'
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source index='9'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

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 ?