
On 2012年08月03日 06:29, Eric Blake wrote:
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.
Thanks, I pushed it as-is, and will clean up the similar VIR_REALLOC_N use together as a separate patch (Most of the *$DeviceRemove funcs use it). Regards, Osier