[libvirt] [RFC PATCH 03/11] conf: nodedev: Split virNodeDeviceDefFormat into more functions

Peter Krempa pkrempa at redhat.com
Wed Mar 29 13:51:54 UTC 2017


On Wed, Mar 29, 2017 at 14:51:13 +0200, Erik Skultety wrote:
> Make the code look cleaner by moving the capability specific bits into
> separate functions.
> 
> Signed-off-by: Erik Skultety <eskultet at redhat.com>
> ---
>  src/conf/node_device_conf.c | 578 ++++++++++++++++++++++++--------------------
>  1 file changed, 322 insertions(+), 256 deletions(-)
> 
> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
> index 7d0baa9d1a..72fb9a5611 100644
> --- a/src/conf/node_device_conf.c
> +++ b/src/conf/node_device_conf.c
> @@ -155,6 +155,320 @@ virPCIEDeviceInfoFormat(virBufferPtr buf,
>  }
>  
>  
> +static void
> +virNodeDeviceCapSystemDefFormat(virBufferPtr buf,
> +                                const virNodeDevCapData *data)
> +{
> +    char uuidstr[VIR_UUID_STRING_BUFLEN];
> +
> +    if (data->system.product_name)
> +        virBufferEscapeString(buf, "<product>%s</product>\n",
> +                              data->system.product_name);
> +    virBufferAddLit(buf, "<hardware>\n");
> +    virBufferAdjustIndent(buf, 2);
> +    if (data->system.hardware.vendor_name)
> +        virBufferEscapeString(buf, "<vendor>%s</vendor>\n",
> +                              data->system.hardware.vendor_name);
> +    if (data->system.hardware.version)
> +        virBufferEscapeString(buf, "<version>%s</version>\n",
> +                              data->system.hardware.version);

virBufferEscapeString automatically skips formatting of the whole string
if the argument is NULL. So the condition is not necessary.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170329/b742634c/attachment-0001.sig>


More information about the libvir-list mailing list