On 2009-11-10, at 12:48 AM, Gerry Reno wrote:
> Adam Mooz wrote:
>> On 2009-11-09, at 11:46 PM, Gerry Reno wrote:
>>
>>> Adam Mooz wrote:
>>>> Hello List,
>>>>
>>>> I'm attempting to pass a DVD drive of a headless server into a
>>>> virtual machine. So far I've managed to mount *something* into
>>>> the VM, but it's being registered as a blank DVD within the VM.
>>>> When I mount /dev/dvd into the bare-metal machine it registers
>>>> normally as the DVD. How do I pass physical drives into a VM and
>>>> back out using libvirt? Command used:
>>>> #virsh attach-disk Montreal /dev/dvd hdc --mode readonly --driver
>>>> phy --type cdrom
>>>> Connecting to uri: qemu:///system
>>>> Disk attached successfully
>>>>
>>>> VM XML file:
>>>>
>>>> <domain type='kvm'>
>>>> <name>Montreal</name>
>>>> <uuid>0f79ba7f-27bf-16a0-5887-6cfa2b5569f1</uuid>
>>>> <memory>2097152</memory>
>>>> <currentMemory>2097152</currentMemory>
>>>> <vcpu>1</vcpu>
>>>> <os>
>>>> <type arch='x86_64'
machine='pc-0.11'>hvm</type>
>>>> <boot dev='hd'/>
>>>> </os>
>>>> <features>
>>>> <acpi/>
>>>> <apic/>
>>>> <pae/>
>>>> </features>
>>>> <clock offset='utc'/>
>>>> <on_poweroff>destroy</on_poweroff>
>>>> <on_reboot>restart</on_reboot>
>>>> <on_crash>restart</on_crash>
>>>> <devices>
>>>> <emulator>/usr/bin/kvm</emulator>
>>>> <disk type='file' device='cdrom'>
>>>> <target dev='hdc' bus='ide'/>
>>>> <readonly/>
>>>> </disk>
>>>> <disk type='file' device='disk'>
>>>> <source file='(Mangled Purposely)'/>
>>>> <target dev='vda' bus='virtio'/>
>>>> </disk>
>>>> <interface type='bridge'>
>>>> <mac address='(mangled purposly)/> <source
bridge='br0'/>
>>>> <model type='virtio'/>
>>>> </interface>
>>>> <serial type='pty'>
>>>> <target port='0'/>
>>>> </serial>
>>>> <console type='pty'>
>>>> <target port='0'/>
>>>> </console>
>>>> <input type='mouse' bus='ps2'/>
>>>> <graphics type='vnc' port='-1'
autoport='yes' keymap='en-us'/>
>>>> <video>
>>>> <model type='cirrus' vram='9216'
heads='1'/>
>>>> </video>
>>>> </devices>
>>>> </domain>
>>>>
>>>
>>> I haven't done this for a while but I believe you have to issue a
>>> 'detach' command afterwards.
>>>
>>> -Gerry
>>>
>>> --
>>> Libvir-list mailing list
>>> Libvir-list(a)redhat.com <mailto:Libvir-list@redhat.com>
>>> <mailto:Libvir-list@redhat.com>
>>>
https://www.redhat.com/mailman/listinfo/libvir-list
>>
>> # virsh detach-disk Montreal hdc
>> Connecting to uri: qemu:///system
>> error: this function is not supported by the hypervisor: only SCSI
>> or virtio disk device can be detached dynamically
>>
>> ? Also, I'm not sure if you understood my question. When I pass in
>> the DVD device into the VM it registers as a blank DVD. if I pass
>> in a non-existant folder it blows up, so I know it's reading
>> something from the real DVD drive. Mounting the real DVD drive in
>> the bare-metal machine shows the files on the drive, but I cannot
>> get them to appear in the VM. How do I get the same files to show
>> up in the VM (i.e. mount the DVD drive into the VM)?
>>
>>
> I didn't see /dev/dvd in your xml. If you attach it and then dump
> the xml what does it look like? And then have you tried booting the
> VM with an xml file with this device and can you read the files on
> the device this way?
>
> The other thing is that maybe your version of libvirt is too old. I
> think 0.7.1 is current.
>
> -Gerry
>
>
> --
> Libvir-list mailing list
> Libvir-list(a)redhat.com <mailto:Libvir-list@redhat.com>
>
https://www.redhat.com/mailman/listinfo/libvir-list
Booting with the drive specified within the XML also gives a blank DVD
in the VM, no luck there. It turns out I'm running libvirt 7.0, was
there a large change between 7.0 and 7.1 in the way they handle
mounting block devices?
Here is some more output:
After mounting at runtime, not at boot to the VM.
virsh # dumpxml Montreal
<domain type='kvm' id='3'>
<name>Montreal</name>
<uuid>0f79ba7f-27bf-16a0-5887-6cfa2b5569f1</uuid>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc-0.11'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='block' device='cdrom'>
<source dev='/dev/dvd'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<source file='/mnt/vmdrive/Montreal-ubuntu-media/montreal.vmdk'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='bridge'>
<mac address='54:52:00:63:bf:8d'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target port='0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='yes'
keymap='en-us'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
</devices>
<seclabel type='dynamic' model='apparmor'>
<label>libvirt-0f79ba7f-27bf-16a0-5887-6cfa2b5569f1</label>
<imagelabel>libvirt-0f79ba7f-27bf-16a0-5887-6cfa2b5569f1</imagelabel>
</seclabel>
</domain>
virsh # version
Compiled against library: libvir 0.7.0
Using library: libvir 0.7.0
Using API: QEMU 0.7.0
Running hypervisor: QEMU 0.11.0
The only other problem that I can think of is that there is some type of
permissions problem going on.
-Gerry