[libvirt] [PATCH v2] qemu: Allow to attach/detach controller device persistently
Eric Blake
eblake at redhat.com
Thu Aug 2 22:29:36 UTC 2012
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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120802/7bb5a984/attachment-0001.sig>
More information about the libvir-list
mailing list