[libvirt] [PATCHv3 5/7] xen_common: Split per-Vfi logic from xenParseVif()
Ján Tomko
jtomko at redhat.com
Mon Jun 11 13:32:07 UTC 2018
On Mon, May 28, 2018 at 12:28:24AM +0200, Fabiano Fidêncio wrote:
>xenParseVfi() does a lot of stuff and, in order to make things cleaner,
>let's split it in two new functions:
>- xenParseVfi(): it's a new function that keeps the old name. It's
>responsible for the whole per-Vfi logic from the old xenParseVfi();
>- xenParseVfiList(): it's basically the old xenParsePCI(), but now it
>just iterates over the list of Vfis, calling xenParsePCI() per each Vfi.
>
s/Vfi/Vif/g
>This patch is basically preparing the ground for the future when
>typesafe virConf acessors will be used.
>
>Signed-off-by: Fabiano Fidêncio <fabiano at fidencio.org>
>---
> src/xenconfig/xen_common.c | 363 ++++++++++++++++++++++++---------------------
> 1 file changed, 192 insertions(+), 171 deletions(-)
>
>diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
>index fc7b0683b8..45fecbced8 100644
>--- a/src/xenconfig/xen_common.c
>+++ b/src/xenconfig/xen_common.c
>@@ -846,202 +846,223 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
> }
>
>
>-static int
>-xenParseVif(virConfPtr conf, virDomainDefPtr def, const char *vif_typename)
>+static virDomainNetDefPtr
>+xenParseVif(char *entry, const char *vif_typename)
> {
>- char *script = NULL;
> virDomainNetDefPtr net = NULL;
>- virConfValuePtr list = virConfGetValue(conf, "vif");
>+ char *script = NULL;
>+ char model[10];
>+ char type[10];
>+ char ip[128];
>+ char mac[18];
>+ char bridge[50];
>+ char vifname[50];
>+ char rate[50];
>+ char *key;
>+ int rc = 0;
The usage of rc adds a lot of non-whitespace changes.
Instead, you can declare another NetDefPtr:
virDomainNetDefPtr ret = NULL;
>+
>+ bridge[0] = '\0';
>+ mac[0] = '\0';
>+ ip[0] = '\0';
>+ model[0] = '\0';
>+ type[0] = '\0';
[...]
>- goto cleanup;
>- if (VIR_ALLOC(bandwidth->out) < 0) {
>- VIR_FREE(bandwidth);
>- goto cleanup;
>- }
do:
VIR_STEAL_PTR(ret, net);
>+ cleanup:
>+ if (rc < 0)
>+ virDomainNetDefFree(net);
And make this free unconditional.
Jano
>+ VIR_FREE(script);
>+ return net;
>+}
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180611/e0290871/attachment-0001.sig>
More information about the libvir-list
mailing list