[libvirt] eject ISO from cdrom

Daniel P. Berrange berrange at redhat.com
Mon Mar 15 15:47:31 UTC 2010


On Tue, Mar 09, 2010 at 02:06:02PM -0800, Shi Jin wrote:
> 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 "".

Yeah this sounds like a virsh bug to me.  One alternative is to just pass the
XML snippet you show directly to 'virsh attach-device'  which is what the
'attach-disk' command ends up calling itself

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list