
On 07/23/2012 02:18 AM, Osier Yang wrote:
* src/conf/domain_conf.c: - Add virDomainControllerFind to find controller device by type and index. - Add virDomainControllerRemove to remove the controller device from maintained controler list.
s/controler/controller/
* src/conf/domain_conf.h: - Declare the two new helpers.
* src/libvirt_private.syms: - Expose private symbols for the two new helpers.
* src/qemu/qemu_driver.c: - Support attach/detach controller device persistently
* src/qemu/qemu_hotplug.c: - Use the two helpers to simplify the codes.
v1 - v2: - Allow to detach the controller too. +virDomainControllerDefPtr +virDomainControllerRemove(virDomainDefPtr def, size_t i) +{ + virDomainControllerDefPtr controller = def->controllers[i]; + + if (def->ncontrollers > 1) { + memmove(def->controllers + i, + def->controllers + i + 1, + sizeof(*def->controllers) * + (def->ncontrollers - (i + 1))); + def->ncontrollers--; + if (VIR_REALLOC_N(def->controllers, def->ncontrollers) < 0) { + /* ignore, harmless */
VIR_SHRINK_N is nicer, it lets you omit the lame comment. ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org