[libvirt] [PATCH v6 2/6] conf: Add one interface to add default input devices

Ján Tomko jtomko at redhat.com
Thu Feb 13 12:37:07 UTC 2014


On 02/13/2014 09:48 AM, Li Zhang wrote:
> From: Li Zhang <zhlcindy at linux.vnet.ibm.com>
> 
> This patch is to add one new interface to add input devices.
> 
> Signed-off-by: Li Zhang <zhlcindy at linux.vnet.ibm.com>
> ---
>  src/conf/domain_conf.c   | 29 +++++++++++++++++++++++++++++
>  src/conf/domain_conf.h   |  4 ++++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 34 insertions(+)

ACK.

> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 9d344bc..786f9d1 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -11043,6 +11043,35 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
>      return 0;
>  }
>  
> +int
> +virDomainDefMaybeAddInput(virDomainDefPtr def,
> +                               int type,
> +                               int bus)
> +{
> +    size_t i;
> +    virDomainInputDefPtr input;
> +
> +    for (i = 0; i < def->ninputs; i++) {
> +        if (def->inputs[i]->type == type &&
> +            def->inputs[i]->bus == bus)
> +            return 0;
> +    }
> +
> +    if (VIR_ALLOC(input) < 0)
> +        return -1;
> +
> +    input->type = type;
> +    input->bus = bus;
> +
> +    if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) {
> +        VIR_FREE(input);
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +
> +

Nitpick: I'd move this extra line above the function, to have them separated
evenly by 2 lines.

>  
>  /* Parse a memory element located at XPATH within CTXT, and store the
>   * result into MEM.  If REQUIRED, then the value must exist;

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140213/44f1b611/attachment-0001.sig>


More information about the libvir-list mailing list