From nobody Wed May 14 02:25:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526917253996603.1879404203221; Mon, 21 May 2018 08:40:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3428F394D10; Mon, 21 May 2018 15:40:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3DD530012B7; Mon, 21 May 2018 15:40:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A4F661801250; Mon, 21 May 2018 15:40:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LFbYok024090 for ; Mon, 21 May 2018 11:37:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2436D10EE6D6; Mon, 21 May 2018 15:37:34 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F87C10EE6D5; Mon, 21 May 2018 15:37:33 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 May 2018 17:37:13 +0200 Message-Id: <33d80bc593e56e8c0fe4f58c417d01fef62c1fd0.1526916651.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: stefanha@redhat.com Subject: [libvirt] [PATCH 3/9] Introduce virDomainNetDefNew X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 21 May 2018 15:40:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 A helper to allow initialization of virDomainNetDef. Use it for all new network definitions and pass xmlopt where applicable. Signed-off-by: J=C3=A1n Tomko --- src/bhyve/bhyve_parse_command.c | 2 +- src/conf/domain_conf.c | 15 ++++++++++++++- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/openvz/openvz_conf.c | 4 ++-- src/qemu/qemu_parse_command.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vmx/vmx.c | 2 +- src/xenconfig/xen_common.c | 2 +- src/xenconfig/xen_sxpr.c | 2 +- 10 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 14137d179b..476e8321bc 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -505,7 +505,7 @@ bhyveParsePCINet(virDomainDefPtr def, const char *separator =3D NULL; const char *mac =3D NULL; =20 - if (VIR_ALLOC(net) < 0) + if (!(net =3D virDomainNetDefNew(xmlopt)) goto cleanup; =20 /* As we only support interface type=3D'bridge' and cannot diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c0a8ae7898..f58d354ddd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2027,6 +2027,19 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr d= ef) VIR_FREE(def); } =20 + +virDomainNetDefPtr +virDomainNetDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) +{ + virDomainNetDefPtr net; + + if (VIR_ALLOC(net) < 0) + return NULL; + + return net; +} + + void virDomainNetDefClear(virDomainNetDefPtr def) { @@ -10941,7 +10954,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; =20 - if (VIR_ALLOC(def) < 0) + if (!(def =3D virDomainNetDefNew(xmlopt))) return NULL; =20 ctxt->node =3D node; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a78fdee40c..5de058c64d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2788,6 +2788,7 @@ bool virDomainControllerIsPSeriesPHB(const virDomainC= ontrollerDef *cont); virDomainFSDefPtr virDomainFSDefNew(void); void virDomainFSDefFree(virDomainFSDefPtr def); void virDomainActualNetDefFree(virDomainActualNetDefPtr def); +virDomainNetDefPtr virDomainNetDefNew(virDomainXMLOptionPtr xmlopt); void virDomainNetDefClear(virDomainNetDefPtr def); void virDomainNetDefFree(virDomainNetDefPtr def); void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3dece252df..b4c86b60cc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -447,6 +447,7 @@ virDomainNetBandwidthUpdate; virDomainNetDefClear; virDomainNetDefFormat; virDomainNetDefFree; +virDomainNetDefNew; virDomainNetFind; virDomainNetFindByName; virDomainNetFindIdx; diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 5ed2b423cb..28fd64895e 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -219,7 +219,7 @@ openvzReadNetworkConf(virDomainDefPtr def, } else if (ret > 0) { token =3D strtok_r(temp, " ", &saveptr); while (token !=3D NULL) { - if (VIR_ALLOC(net) < 0) + if (!(net =3D virDomainNetDefNew(NULL))) goto error; =20 net->type =3D VIR_DOMAIN_NET_TYPE_ETHERNET; @@ -248,7 +248,7 @@ openvzReadNetworkConf(virDomainDefPtr def, token =3D strtok_r(temp, ";", &saveptr); while (token !=3D NULL) { /*add new device to list*/ - if (VIR_ALLOC(net) < 0) + if (!(net =3D virDomainNetDefNew(NULL))) goto error; =20 net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 351425fedd..de349954cf 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1037,7 +1037,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, nkeywords =3D 0; } =20 - if (VIR_ALLOC(def) < 0) + if (!(def =3D virDomainNetDefNew(xmlopt))) goto cleanup; =20 /* 'tap' could turn into libvirt type=3Dethernet, type=3Dbridge or diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 72a24a3464..28a50b477b 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3690,7 +3690,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *= adapter) char *utf8 =3D NULL; virDomainNetDefPtr net =3D NULL; =20 - if (VIR_ALLOC(net) < 0) + if (!(net =3D virDomainNetDefNew(NULL))) return NULL; =20 gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &attachmentType); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index df6a58a474..e6026edc56 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2628,7 +2628,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, = virDomainNetDefPtr *def) if (! present/* && ! startConnected*/) return 0; =20 - if (VIR_ALLOC(*def) < 0) + if (!(*def =3D virDomainNetDefNew(NULL))) return -1; =20 /* vmx:connectionType -> def:type */ diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index a2b0708ee3..80bc267bbe 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -942,7 +942,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def, const= char *vif_typename) key =3D nextkey; } =20 - if (VIR_ALLOC(net) < 0) + if (!(net =3D virDomainNetDefNew(NULL))) goto cleanup; =20 if (mac[0]) { diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index e868c05695..54dd7fc3ed 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -600,7 +600,7 @@ xenParseSxprNets(virDomainDefPtr def, model =3D sexpr_node(node, "device/vif/model"); type =3D sexpr_node(node, "device/vif/type"); =20 - if (VIR_ALLOC(net) < 0) + if (!(net =3D virDomainNetDefNew(NULL))) goto cleanup; =20 if (tmp !=3D NULL || --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list