[libvirt] [PATCH 04/23] conf: Refactor virDomainMemballoonDefFormat
Ján Tomko
jtomko at redhat.com
Wed Mar 6 09:29:16 UTC 2019
On Wed, Mar 06, 2019 at 09:20:29AM +0100, Peter Krempa wrote:
>Use virXMLFormatElement to format the internals along with simplifying
>cleanup code paths.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/conf/domain_conf.c | 47 ++++++++++--------------------------------
> 1 file changed, 11 insertions(+), 36 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index cbefa7749b..fd3f19d6ce 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -25858,40 +25859,14 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
> virBufferAsprintf(&childrenBuf, "<stats period='%i'/>\n", def->period);
>
> if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0)
>- goto cleanup;
>-
>- if (def->virtio) {
>- virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
>-
>- virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
>-
>- if (virBufferCheckError(&driverBuf) < 0)
>- goto cleanup;
>-
>- if (virBufferUse(&driverBuf)) {
>- virBufferAddLit(&childrenBuf, "<driver");
>- virBufferAddBuffer(&childrenBuf, &driverBuf);
>- virBufferAddLit(&childrenBuf, "/>\n");
>- }
>- }
Eww, who added this? ;)
>-
>- if (virBufferCheckError(&childrenBuf) < 0)
>- goto cleanup;
>-
>- if (!virBufferUse(&childrenBuf)) {
>- virBufferAddLit(buf, "/>\n");
>- } else {
>- virBufferAddLit(buf, ">\n");
>- virBufferAddBuffer(buf, &childrenBuf);
>- virBufferAddLit(buf, "</memballoon>\n");
>- }
>+ return -1;
>
>- ret = 0;
>+ virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
>
>- cleanup:
>- virBufferFreeAndReset(&childrenBuf);
>+ if (virXMLFormatElement(&childrenBuf, "driver", &driverAttrBuf, NULL) < 0)
>+ return -1;
>
>- return ret;
>+ return virXMLFormatElement(buf, "memballoon", &attrBuf, &childrenBuf);
> }
>
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190306/53baad25/attachment-0001.sig>
More information about the libvir-list
mailing list