Some incremental findings:
In 'qemu-kvm' the DeviceState for the peer device of the
BlockDeviceState that gets created when a disk attached by 'virsh
attach-disk' references the 'QemuOpts' options structure that lists the
options and the device ID string (ex: as 'virtio-disk4') that will (on a
re-attach for the same disk when the hotplug module is not loaded in the
virt) be found by 'qemu_find_opts()' under the call to 'drive_add'.
When the PCI hotplug module *is* loaded in the virt, the DriveState structure
and the associatsd QemuOpts get released from within a separate thread by a
call to 'qdev_free()' asynchronously from the main thread's invocation of
'do_device_del()'. When the PCI hotplug modules is *not* loaded in the
virt, there is never an invocation of 'qdev_free' for the device , so the
options structure hangs around to be located in the attempt to re-attach a disk
for the same disk, and we get the Duplicate ID error. In the even of the
hotplug module being loaded in the virt, the trace of the thread which invokes
'qdev_free' looks something like:
==
#1 0x00007fbb4b3403d9 in qdev_free (dev=0x7fbb4cc8d820) at
/home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/hw/qdev.c:382
#2 0x00007fbb4b4aabd7 in pciej_write (opaque=0x7fbb4c95dc90, addr=44552,
val=33554432)
at /home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/hw/acpi_piix4.c:615
#3 0x00007fbb4b309839 in ioport_write (index=2, address=44552, data=33554432)
at ioport.c:81
#4 0x00007fbb4b30a2c7 in cpu_outl (addr=44552, val=33554432) at ioport.c:278
#5 0x00007fbb4b2a7b82 in kvm_handle_io (port=44552, data=0x7fbb4b1fa000,
direction=1, size=4, count=1)
at /home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/kvm-all.c:824
#6 0x00007fbb4b2aa353 in kvm_run (env=0x7fbb4c734860) at
/home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/qemu-kvm.c:617
#7 0x00007fbb4b2abab8 in kvm_cpu_exec (env=0x7fbb4c734860) at
/home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/qemu-kvm.c:1233
#8 0x00007fbb4b2ac2dd in kvm_main_loop_cpu (env=0x7fbb4c734860) at
/home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/qemu-kvm.c:1419
#9 0x00007fbb4b2ac476 in ap_main_loop (_env=0x7fbb4c734860) at
/home/justinlw/src/qemu/qemu-kvm-0.14.1+noroms/qemu-kvm.c:1466
#10 0x00007fbb4a9bbefc in start_thread (arg=0x7fbb4397f700) at
pthread_create.c:304
#11 0x00007fbb481c589d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#12 0x0000000000000000 in ?? ()
==
In a nutshell, the code is designed such that there is a resource leak
if the virt does not play ball with PCI hotplugging in a case like this.
I have yet to do complete line of code: I will have to have a much
better understanding of the Qemu PCI handling mechanisms first, I think.
Still I believe there are potentially useful findings in further nailing
this bug (design feature?).
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/897750
Title:
libvirt/kvm problem with disk attach/detach/reattach on running virt
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/897750/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs