Bug #3763

KVM: Detach leaves the device defined, a new attach fails

Added by Carlos Martín about 6 years ago. Updated almost 6 years ago.

Status:ClosedStart date:04/20/2015
Priority:NormalDue date:
Assignee:-% Done:


Category:Drivers - VM
Target version:Release 4.14
Resolution:fixed Pull request:
Affected Versions:OpenNebula 4.12


Steps to reproduce:
- Start a VM with 2 disks, vda & vdb
- Detach vdb, virsh still reports the device
- When a new image is attached, ONE gives it the vdb target, which is used according to libvirt


Ubuntu 14.10
libvirt version: 1.2.8, package: 1.2.8-0ubuntu11.4

VM log:

Mon Apr 20 16:09:10 2015 [Z0][VMM][E]: attach_disk: Command "virsh --connect qemu:///system attach-device one-4 /var/lib/one//datastores/0/4/disk.3.attach" failed: error: Failed to attach device from /var/lib/one//datastores/0/4/disk.3.attach
Mon Apr 20 16:09:10 2015 [Z0][VMM][I]: error: operation failed: target vdb already exists
Mon Apr 20 16:09:10 2015 [Z0][VMM][E]: Could not attach /var/lib/one//datastores/0/4/disk.3 (vdb) to one-4
Mon Apr 20 16:09:10 2015 [Z0][VMM][I]: ExitCode: 1
Mon Apr 20 16:09:11 2015 [Z0][VMM][I]: Successfully execute transfer manager driver operation: tm_detach.
Mon Apr 20 16:09:11 2015 [Z0][VMM][I]: Failed to execute virtualization driver operation: attach_disk.
Mon Apr 20 16:09:11 2015 [Z0][VMM][E]: Error attaching new VM Disk: Could not attach /var/lib/one//datastores/0/4/disk.3 (vdb) to one-4

Virsh dumpxml. After the disk detach, before any new attach is attempted:

<domain type='kvm' id='6'>
  <memory unit='KiB'>131072</memory>
  <currentMemory unit='KiB'>131072</currentMemory>
  <vcpu placement='static'>1</vcpu>
    <type arch='x86_64' machine='pc-i440fx-utopic'>hvm</type>
    <boot dev='hd'/>
  <clock offset='utc'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/one//datastores/0/4/disk.0'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/one//datastores/0/4/disk.1'/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/one//datastores/0/4/disk.2'/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5904' autoport='no' listen=''>
      <listen type='address' address=''/>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
  <seclabel type='dynamic' model='apparmor' relabel='yes'>


#1 Updated by Ruben S. Montero almost 6 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

Now the driver checks if the device is actually detached or not

Also available in: Atom PDF