[libvirt] eject ISO from cdrom

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I am using libvirt+qemu/kvm.
For a guest VM that is running, I could change its cdrom media by running the following virsh command:
virsh attach-disk <vm-id> <path-to-iso-file> hdc --driver file --type cdrom --mode readonly
This will change the media in the cdrom for the guest VM.

Once I am done, I can use virt-manager to disconnect the iso file to the cdrom. The resulting xml file looks like (only showing the relevant part)
    <disk type='file' device='cdrom'>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>


However, I am having trouble to do the same task (eject cd media) using virsh command. I am successful in running the "virsh attach-device 1 emptyCD.xml" command where the emptyCD.xml is an xml without the source file path, just like the one above. However, I want to do it by a single command without the need to create xml files. It should be something like
> virsh attach-disk 1 "" hdc --driver file --type cdrom --mode readonly
However, virsh does not like the empty string "".

I also looked at the virt-manager source code, in this case, the python script is
 912         if curpath:
 913             # Disconnect cdrom
 914             self.change_cdrom_media(dev_id_info, None, _type=None)
Basically a None parameter is pass to the API. All I need to find out is how to do the same thing in the "virsh attach-disk" command.

Do you have any suggestions/comments?
Thanks a lot.

Shi

--
Shi Jin, PhD


      

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]