libvirt/kvm problem with disk attach/detach/reattach on running virt Release: Ubuntu 11.10 (Oneiric) libvirt-bin: 0.9.2-4ubuntu15.1 qemu-kvm: 0.14.1+noroms-0ubuntu6 Summary: With a running KVM virt, performing an 'attach-disk', then a 'detach-disk', then another 'attach-disk' in an attempt to reattach the volume at the same point on the virt, fails, with the qemu reporting back to libvirt a 'Duplicate ID' error. Expected behavior: The 2nd invocation of 'attach-disk' should have succeeded Actual behavior: Duplicate ID error reported I believe this is most likely a qemu-kvm issue, as the DOM kvm spits back at libvirt after the 'detach-disk' does not show the just-detached disk. There is some kind of registry/lookup for devices in qemu-kvm and for whatever reason, the entry for the disk does not get removed when it is detached from the virt. Specifically, the error gets reported at the 2nd attach-disk attempt from: qemu-option.c:qemu_opts_create:697 684 QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists) 685 { 686 QemuOpts *opts = NULL; 687 688 if (id) { 689 if (!id_wellformed(id)) { 690 qerror_report(QERR_INVALID_PARAMETER_VALUE, "id", "an identifier"); 691 error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n"); 692 return NULL; 693 } 694 opts = qemu_opts_find(list, id); 695 if (opts != NULL) { 696 if (fail_if_exists) { 697 qerror_report(QERR_DUPLICATE_ID, id, list->name); <<<< ====== HERE =========== 698 return NULL; 699 } else { 700 return opts; 701 } 702 } 703 } 704 opts = qemu_mallocz(sizeof(*opts)); 705 if (id) { 706 opts->id = qemu_strdup(id); 707 } 708 opts->list = list; 709 loc_save(&opts->loc); 710 QTAILQ_INIT(&opts->head); 711 QTAILQ_INSERT_TAIL(&list->head, opts, next); 712 return opts; 713 } ======================================== Output of my attach/detach/attach ======================================== virsh # attach-disk base1 /var/lib/libvirt/images/extrastorage.img vdb Disk attached successfully virsh # dumpxml base1 base1 9ebebe7f-7dfa-4735-a80c-c19ebe4e1459 1048576 1048576 2 hvm Opteron_G3 AMD destroy restart restart /usr/bin/kvm