Bug #3763

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

Added by Carlos Martín over 5 years ago. Updated over 5 years ago.

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

0%

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

Description

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

Versions:

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'>
  <name>one-4</name>
  <uuid>a979df5b-25b7-4acc-a1d5-d42dc75e0ec6</uuid>
  <memory unit='KiB'>131072</memory>
  <currentMemory unit='KiB'>131072</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <cputune>
    <shares>103</shares>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-utopic'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/one//datastores/0/4/disk.0'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/one//datastores/0/4/disk.1'/>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/one//datastores/0/4/disk.2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5904' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='apparmor' relabel='yes'>
    <label>libvirt-a979df5b-25b7-4acc-a1d5-d42dc75e0ec6</label>
    <imagelabel>libvirt-a979df5b-25b7-4acc-a1d5-d42dc75e0ec6</imagelabel>
  </seclabel>
</domain>

History

#1 Updated by Ruben S. Montero over 5 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