Hi,

I am having 2 issues with disks and KVM.

ISSUE 1:

I am unable to detach a disk from a running KVM.

(root@h2)-(/tmp)# virsh dumpxml vps_99
<domain type='kvm' id='224'>
  <name>vps_99</name>
  <uuid>5e24e17c-f0e4-1030-ac57-0050560018a2</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>restart</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd1'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd2'/>
      <target dev='vdb' bus='virtio'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd3'/>
      <target dev='vde' bus='virtio'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd4'/>
      <target dev='vdg' bus='virtio'/>
    </disk>
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd5'/>
      <target dev='vdi' bus='virtio'/>
    </disk>
    <interface type='bridge'>
      <mac address='00:50:56:00:1b:24'/>
      <source bridge='br0'/>
      <target dev='vnet3'/>
      <model type='virtio'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5999' autoport='no' keymap='en-us'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-5e24e17c-f0e4-1030-ac57-0050560018a2</label>
    <imagelabel>libvirt-5e24e17c-f0e4-1030-ac57-0050560018a2</imagelabel>
  </seclabel>
</domain>

(root@h2)-(/tmp)# cat disk.xml
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/nbd5'/>
      <target dev='vdi' bus='virtio'/>
    </disk>

(root@h2)-(/tmp)# virsh detach-device vps_99 disk.xml
error: Failed to detach device from disk.xml
error: operation failed: disk vdi cannot be detached - no PCI address for device

(root@h2)-(/tmp)# virsh detach-disk vps_99 vdi
error: operation failed: disk vdi cannot be detached - no PCI address for device

I have tried specifing a <address> for each disk, ie:
address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>

However, I still get the same "no PCI" error.

I am able to add and remove NEW disks to the virtual server after it has been started, but I can't detach the disks that were defined when the KVM was created (even though it looks exactly the same in the XML-file).

ISSUE 2:

When I add a disk to a KVM running linux (ubuntu in this case), it totally ignores my "target dev". I.e if I specify this:

<target dev='vdi' bus='virtio'/>

The disk is still being detected as "vdc". Removing the disk and adding it again, gives it "vdd" etc. So it seems it is pretty much just increamenting the letter and totally ignore my config. I read in the documentation that the target defined is just a "hint" for the system and is not always honered, but sorry, I simply cannot accept that :)

There must be a way to specify the device the disk should be connected to. Amazon Web Services seems to be able to do this just fine. It will be a pain to write automated scripts when new disks are just attached to random devices.

Regards,
Daniele