From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759466981994.1463246981674; Thu, 29 Jun 2017 11:04:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF4A170D8C; Thu, 29 Jun 2017 18:04:22 +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 74BB2174A6; Thu, 29 Jun 2017 18:04:22 +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 06F68184383E; Thu, 29 Jun 2017 18:04:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4DS5006661 for ; Thu, 29 Jun 2017 14:04:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC3F7179DE; Thu, 29 Jun 2017 18:04:12 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74B5B179DB for ; Thu, 29 Jun 2017 18:04:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF4A170D8C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BF4A170D8C From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:03:54 +0200 Message-Id: <1498759443-10136-2-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/10] conf: Make virDomainDeviceGetInfo() private 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 29 Jun 2017 18:04:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There are no external users. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 21 ++++++++++++--------- src/conf/domain_conf.h | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c3149f9..d9aea83 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1322,6 +1322,18 @@ bool virDomainObjTaint(virDomainObjPtr obj, return true; } =20 + +static void +virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) +{ + VIR_FREE(info->alias); + memset(&info->addr, 0, sizeof(info->addr)); + info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; + VIR_FREE(info->romfile); + VIR_FREE(info->loadparm); +} + + static void virDomainDeviceInfoFree(virDomainDeviceInfoPtr info) { @@ -3591,15 +3603,6 @@ virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, return 0; } =20 -void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) -{ - VIR_FREE(info->alias); - memset(&info->addr, 0, sizeof(info->addr)); - info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; - VIR_FREE(info->romfile); - VIR_FREE(info->loadparm); -} - =20 static bool virDomainSkipBackcompatConsole(virDomainDefPtr def, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 964bc02..9dc64b2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2701,7 +2701,6 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfo= Ptr info, virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device= ); int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, virDomainDeviceInfoPtr src); -void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); void virDomainTPMDefFree(virDomainTPMDefPtr def); =20 typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def, --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759458074584.6076325737803; Thu, 29 Jun 2017 11:04:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E1E5C0C4264; Thu, 29 Jun 2017 18:04:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D1E617174; Thu, 29 Jun 2017 18:04:15 +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 9CFC53FADE; Thu, 29 Jun 2017 18:04:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4DDn006673 for ; Thu, 29 Jun 2017 14:04:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDC89179E8; Thu, 29 Jun 2017 18:04:13 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4562D179DE for ; Thu, 29 Jun 2017 18:04:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7E1E5C0C4264 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7E1E5C0C4264 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:03:55 +0200 Message-Id: <1498759443-10136-3-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/10] conf: Rename virDomainHostdevDefAlloc() to virDomainHostdevDefNew() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 29 Jun 2017 18:04:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" All other virDomain*Def follow this naming convention for their allocation function. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 2 +- src/libvirt_private.syms | 2 +- src/lxc/lxc_native.c | 2 +- src/qemu/qemu_parse_command.c | 4 ++-- src/vbox/vbox_common.c | 2 +- src/xenconfig/xen_common.c | 2 +- src/xenconfig/xen_sxpr.c | 2 +- src/xenconfig/xen_xl.c | 2 +- tests/virhostdevtest.c | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d9aea83..15dd285 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2378,7 +2378,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def) =20 =20 virDomainHostdevDefPtr -virDomainHostdevDefAlloc(virDomainXMLOptionPtr xmlopt) +virDomainHostdevDefNew(virDomainXMLOptionPtr xmlopt) { virDomainHostdevDefPtr def =3D NULL; =20 @@ -13801,7 +13801,7 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr x= mlopt, =20 ctxt->node =3D node; =20 - if (!(def =3D virDomainHostdevDefAlloc(xmlopt))) + if (!(def =3D virDomainHostdevDefNew(xmlopt))) goto error; =20 if (mode) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9dc64b2..cbcffa4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2684,7 +2684,7 @@ void virDomainMemballoonDefFree(virDomainMemballoonDe= fPtr def); void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def); void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); void virDomainVideoDefFree(virDomainVideoDefPtr def); -virDomainHostdevDefPtr virDomainHostdevDefAlloc(virDomainXMLOptionPtr xmlo= pt); +virDomainHostdevDefPtr virDomainHostdevDefNew(virDomainXMLOptionPtr xmlopt= ); void virDomainHostdevDefClear(virDomainHostdevDefPtr def); void virDomainHostdevDefFree(virDomainHostdevDefPtr def); void virDomainHubDefFree(virDomainHubDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 888412a..e92fe52 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -366,9 +366,9 @@ virDomainGraphicsVNCSharePolicyTypeFromString; virDomainGraphicsVNCSharePolicyTypeToString; virDomainHasNet; virDomainHostdevCapsTypeToString; -virDomainHostdevDefAlloc; virDomainHostdevDefClear; virDomainHostdevDefFree; +virDomainHostdevDefNew; virDomainHostdevFind; virDomainHostdevInsert; virDomainHostdevModeTypeToString; diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 8f44168..7bcdf1f 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -394,7 +394,7 @@ lxcCreateNetDef(const char *type, static virDomainHostdevDefPtr lxcCreateHostdevDef(int mode, int type, const char *data) { - virDomainHostdevDefPtr hostdev =3D virDomainHostdevDefAlloc(NULL); + virDomainHostdevDefPtr hostdev =3D virDomainHostdevDefNew(NULL); =20 if (!hostdev) return NULL; diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index af9063c..90e8d09 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1162,7 +1162,7 @@ qemuParseCommandLinePCI(const char *val) int bus =3D 0, slot =3D 0, func =3D 0; const char *start; char *end; - virDomainHostdevDefPtr def =3D virDomainHostdevDefAlloc(NULL); + virDomainHostdevDefPtr def =3D virDomainHostdevDefNew(NULL); =20 if (!def) goto error; @@ -1212,7 +1212,7 @@ qemuParseCommandLinePCI(const char *val) static virDomainHostdevDefPtr qemuParseCommandLineUSB(const char *val) { - virDomainHostdevDefPtr def =3D virDomainHostdevDefAlloc(NULL); + virDomainHostdevDefPtr def =3D virDomainHostdevDefNew(NULL); virDomainHostdevSubsysUSBPtr usbsrc; int first =3D 0, second =3D 0; const char *start; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index c46e71b..92ee371 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -2989,7 +2989,7 @@ vboxHostDeviceGetXMLDesc(vboxDriverPtr data, virDomai= nDefPtr def, IMachine *mach goto release_filters; =20 for (i =3D 0; i < def->nhostdevs; i++) { - def->hostdevs[i] =3D virDomainHostdevDefAlloc(NULL); + def->hostdevs[i] =3D virDomainHostdevDefNew(NULL); if (!def->hostdevs[i]) goto release_hostdevs; } diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 72ffb30..6d7dc2c 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -458,7 +458,7 @@ xenParsePCI(virConfPtr conf, virDomainDefPtr def) goto skippci; if (virStrToLong_i(func, NULL, 16, &funcID) < 0) goto skippci; - if (!(hostdev =3D virDomainHostdevDefAlloc(NULL))) + if (!(hostdev =3D virDomainHostdevDefNew(NULL))) return -1; =20 hostdev->managed =3D false; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index baa68b1..fefa61a 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1110,7 +1110,7 @@ xenParseSxprPCI(virDomainDefPtr def, goto error; } =20 - if (!(dev =3D virDomainHostdevDefAlloc(NULL))) + if (!(dev =3D virDomainHostdevDefNew(NULL))) goto error; =20 dev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index cac440c..fa3f1d0 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -733,7 +733,7 @@ xenParseXLUSB(virConfPtr conf, virDomainDefPtr def) goto skipusb; if (virStrToLong_i(device, NULL, 16, &devNum) < 0) goto skipusb; - if (!(hostdev =3D virDomainHostdevDefAlloc(NULL))) + if (!(hostdev =3D virDomainHostdevDefNew(NULL))) return -1; =20 hostdev->managed =3D false; diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index b3beee9..655991c 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -87,7 +87,7 @@ myInit(void) =20 for (i =3D 0; i < nhostdevs; i++) { virDomainHostdevSubsys subsys; - hostdevs[i] =3D virDomainHostdevDefAlloc(NULL); + hostdevs[i] =3D virDomainHostdevDefNew(NULL); if (!hostdevs[i]) goto cleanup; hostdevs[i]->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759465525830.5135125910165; Thu, 29 Jun 2017 11:04:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 098171176D6; Thu, 29 Jun 2017 18:04:19 +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 D4B05179DE; Thu, 29 Jun 2017 18:04:18 +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 4E3AC1841C41; Thu, 29 Jun 2017 18:04:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4E59006680 for ; Thu, 29 Jun 2017 14:04:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C94C179DB; Thu, 29 Jun 2017 18:04:14 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1643117C75 for ; Thu, 29 Jun 2017 18:04:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 098171176D6 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 098171176D6 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:03:56 +0200 Message-Id: <1498759443-10136-4-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/10] conf: Clean up virDomainHostdevDefNew() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 29 Jun 2017 18:04:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Follow the same style as other similar functions. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 15dd285..ccd3c27 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2380,25 +2380,26 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def) virDomainHostdevDefPtr virDomainHostdevDefNew(virDomainXMLOptionPtr xmlopt) { - virDomainHostdevDefPtr def =3D NULL; + virDomainHostdevDefPtr def; =20 - if (VIR_ALLOC(def) < 0 || - VIR_ALLOC(def->info) < 0) { - VIR_FREE(def); + if (VIR_ALLOC(def) < 0) return NULL; - } + + if (VIR_ALLOC(def->info) < 0) + goto error; =20 if (xmlopt && xmlopt->privateData.hostdevNew && !(def->privateData =3D xmlopt->privateData.hostdevNew())) goto error; =20 + cleanup: return def; =20 error: VIR_FREE(def->info); VIR_FREE(def); - return NULL; + goto cleanup; } =20 =20 --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759474405453.80555999486717; Thu, 29 Jun 2017 11:04:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31E60C0C9A62; Thu, 29 Jun 2017 18:04:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F03358D569; Thu, 29 Jun 2017 18:04:25 +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 1881F3FAE1; Thu, 29 Jun 2017 18:04:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4Fx1006688 for ; Thu, 29 Jun 2017 14:04:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D14C179DB; Thu, 29 Jun 2017 18:04:15 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB36A17C75 for ; Thu, 29 Jun 2017 18:04:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 31E60C0C9A62 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 31E60C0C9A62 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:03:57 +0200 Message-Id: <1498759443-10136-5-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/10] conf: Clean up virDomain{Memory, Shmem}DefParseXML() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 29 Jun 2017 18:04:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Follow the same style as other similar functions. Signed-off-by: Andrea Bolognani --- src/conf/domain_conf.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ccd3c27..fdb919d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13143,8 +13143,7 @@ virDomainShmemDefParseXML(xmlNodePtr node, unsigned int flags) { char *tmp =3D NULL; - virDomainShmemDefPtr def =3D NULL; - virDomainShmemDefPtr ret =3D NULL; + virDomainShmemDefPtr def; xmlNodePtr msi =3D NULL; xmlNodePtr save =3D ctxt->node; xmlNodePtr server =3D NULL; @@ -13163,7 +13162,7 @@ virDomainShmemDefParseXML(xmlNodePtr node, if ((def->model =3D virDomainShmemModelTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Unknown shmem model type '%s'"), tmp); - goto cleanup; + goto error; } =20 VIR_FREE(tmp); @@ -13172,12 +13171,12 @@ virDomainShmemDefParseXML(xmlNodePtr node, if (!(def->name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("shmem element must contain 'name' attribute")); - goto cleanup; + goto error; } =20 if (virDomainParseScaledValue("./size[1]", NULL, ctxt, &def->size, 1, ULLONG_MAX, false) < 0) - goto cleanup; + goto error; =20 if ((server =3D virXPathNode("./server[1]", ctxt))) { def->server.enabled =3D true; @@ -13197,7 +13196,7 @@ virDomainShmemDefParseXML(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, _("invalid number of vectors for shmem: '%s'"), tmp); - goto cleanup; + goto error; } VIR_FREE(tmp); =20 @@ -13208,7 +13207,7 @@ virDomainShmemDefParseXML(xmlNodePtr node, virReportError(VIR_ERR_XML_ERROR, _("invalid msi ioeventfd setting for shmem:= '%s'"), tmp); - goto cleanup; + goto error; } def->msi.ioeventfd =3D val; } @@ -13219,20 +13218,21 @@ virDomainShmemDefParseXML(xmlNodePtr node, if (def->msi.enabled && !def->server.enabled) { virReportError(VIR_ERR_XML_ERROR, "%s", _("msi option is only supported with a server")); - goto cleanup; + goto error; } =20 if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) - goto cleanup; - + goto error; =20 - ret =3D def; - def =3D NULL; cleanup: - ctxt->node =3D save; VIR_FREE(tmp); + ctxt->node =3D save; + return def; + + error: virDomainShmemDefFree(def); - return ret; + def =3D NULL; + goto cleanup; } =20 static int @@ -14394,7 +14394,6 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, =20 def->access =3D val; } - VIR_FREE(tmp); =20 /* source */ if ((node =3D virXPathNode("./source", ctxt)) && @@ -14414,14 +14413,15 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, if (virDomainDeviceInfoParseXML(memdevNode, NULL, &def->info, flags) <= 0) goto error; =20 + cleanup: + VIR_FREE(tmp); ctxt->node =3D save; return def; =20 error: - VIR_FREE(tmp); virDomainMemoryDefFree(def); - ctxt->node =3D save; - return NULL; + def =3D NULL; + goto cleanup; } =20 =20 --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759478817226.08357101404488; Thu, 29 Jun 2017 11:04:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EF8AF6259; Thu, 29 Jun 2017 18:04:29 +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 D92388E238; Thu, 29 Jun 2017 18:04:28 +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 EF6181853E33; Thu, 29 Jun 2017 18:04:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4GX7006703 for ; Thu, 29 Jun 2017 14:04:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C1A6179F1; Thu, 29 Jun 2017 18:04:16 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2E34179DB for ; Thu, 29 Jun 2017 18:04:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4EF8AF6259 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4EF8AF6259 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:03:58 +0200 Message-Id: <1498759443-10136-6-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/10] conf: Move some virDomainDeviceInfo functions 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 29 Jun 2017 18:04:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The virDomainDeviceInfo struct is defined in device_conf, so generic functions that operate on it should also be defined there rather than in domain_conf. Signed-off-by: Andrea Bolognani --- src/conf/device_conf.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ src/conf/device_conf.h | 8 ++++ src/conf/domain_conf.c | 114 -------------------------------------------= ---- src/conf/domain_conf.h | 7 --- src/libvirt_private.syms | 4 +- 5 files changed, 119 insertions(+), 123 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index f58b9d0..4644580 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -32,6 +32,115 @@ =20 #define VIR_FROM_THIS VIR_FROM_DEVICE =20 +void +virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) +{ + VIR_FREE(info->alias); + memset(&info->addr, 0, sizeof(info->addr)); + info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; + VIR_FREE(info->romfile); + VIR_FREE(info->loadparm); +} + +int +virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, + virDomainDeviceInfoPtr src) +{ + /* Assume that dst is already cleared */ + + /* first a shallow copy of *everything* */ + *dst =3D *src; + + /* then redo the two fields that are pointers */ + dst->alias =3D NULL; + dst->romfile =3D NULL; + + if (VIR_STRDUP(dst->alias, src->alias) < 0 || + VIR_STRDUP(dst->romfile, src->romfile) < 0) + return -1; + return 0; +} + +void +virDomainDeviceInfoFree(virDomainDeviceInfoPtr info) +{ + if (info) { + virDomainDeviceInfoClear(info); + VIR_FREE(info); + } +} + +bool +virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a, + const virDomainDeviceInfo *b) +{ + if (a->type !=3D b->type) + return false; + + switch ((virDomainDeviceAddressType) a->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: + /* address types below don't have any specific data */ + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: + /* the 'multi' field shouldn't be checked */ + if (a->addr.pci.domain !=3D b->addr.pci.domain || + a->addr.pci.bus !=3D b->addr.pci.bus || + a->addr.pci.slot !=3D b->addr.pci.slot || + a->addr.pci.function !=3D b->addr.pci.function) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + if (memcmp(&a->addr.drive, &b->addr.drive, sizeof(a->addr.drive))) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: + if (memcmp(&a->addr.vioserial, &b->addr.vioserial, sizeof(a->addr.= vioserial))) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: + if (memcmp(&a->addr.ccid, &b->addr.ccid, sizeof(a->addr.ccid))) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: + if (memcmp(&a->addr.usb, &b->addr.usb, sizeof(a->addr.usb))) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: + if (memcmp(&a->addr.spaprvio, &b->addr.spaprvio, sizeof(a->addr.sp= aprvio))) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: + /* the 'assigned' field denotes that the address was generated */ + if (a->addr.ccw.cssid !=3D b->addr.ccw.cssid || + a->addr.ccw.ssid !=3D b->addr.ccw.ssid || + a->addr.ccw.devno !=3D b->addr.ccw.devno) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: + if (memcmp(&a->addr.isa, &b->addr.isa, sizeof(a->addr.isa))) + return false; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: + if (memcmp(&a->addr.dimm, &b->addr.dimm, sizeof(a->addr.dimm))) + return false; + break; + } + + return true; +} + int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, bool report) { diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 48782be..53abe1b 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -170,6 +170,14 @@ struct _virDomainDeviceInfo { char *loadparm; }; =20 +void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); +int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, + virDomainDeviceInfoPtr src); +void virDomainDeviceInfoFree(virDomainDeviceInfoPtr info); + +bool virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a, + const virDomainDeviceInfo *b) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, bool report); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fdb919d..6a89fab 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1324,27 +1324,6 @@ bool virDomainObjTaint(virDomainObjPtr obj, =20 =20 static void -virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) -{ - VIR_FREE(info->alias); - memset(&info->addr, 0, sizeof(info->addr)); - info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; - VIR_FREE(info->romfile); - VIR_FREE(info->loadparm); -} - - -static void -virDomainDeviceInfoFree(virDomainDeviceInfoPtr info) -{ - if (info) { - virDomainDeviceInfoClear(info); - VIR_FREE(info); - } -} - - -static void virDomainGraphicsAuthDefClear(virDomainGraphicsAuthDefPtr def) { if (!def) @@ -3495,77 +3474,6 @@ virDomainDeviceInfoNeedsFormat(virDomainDeviceInfoPt= r info, unsigned int flags) return false; } =20 -bool -virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a, - const virDomainDeviceInfo *b) -{ - if (a->type !=3D b->type) - return false; - - switch ((virDomainDeviceAddressType) a->type) { - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: - /* address types below don't have any specific data */ - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - /* the 'multi' field shouldn't be checked */ - if (a->addr.pci.domain !=3D b->addr.pci.domain || - a->addr.pci.bus !=3D b->addr.pci.bus || - a->addr.pci.slot !=3D b->addr.pci.slot || - a->addr.pci.function !=3D b->addr.pci.function) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - if (memcmp(&a->addr.drive, &b->addr.drive, sizeof(a->addr.drive))) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: - if (memcmp(&a->addr.vioserial, &b->addr.vioserial, sizeof(a->addr.= vioserial))) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: - if (memcmp(&a->addr.ccid, &b->addr.ccid, sizeof(a->addr.ccid))) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - if (memcmp(&a->addr.usb, &b->addr.usb, sizeof(a->addr.usb))) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: - if (memcmp(&a->addr.spaprvio, &b->addr.spaprvio, sizeof(a->addr.sp= aprvio))) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: - /* the 'assigned' field denotes that the address was generated */ - if (a->addr.ccw.cssid !=3D b->addr.ccw.cssid || - a->addr.ccw.ssid !=3D b->addr.ccw.ssid || - a->addr.ccw.devno !=3D b->addr.ccw.devno) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: - if (memcmp(&a->addr.isa, &b->addr.isa, sizeof(a->addr.isa))) - return false; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: - if (memcmp(&a->addr.dimm, &b->addr.dimm, sizeof(a->addr.dimm))) - return false; - break; - } - - return true; -} - =20 static int virDomainDefHasDeviceAddressIterator(virDomainDefPtr def ATTRIBUTE_UNUSED, @@ -3583,28 +3491,6 @@ virDomainDefHasDeviceAddressIterator(virDomainDefPtr= def ATTRIBUTE_UNUSED, } =20 =20 -int -virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, - virDomainDeviceInfoPtr src) -{ - /* Assume that dst is already cleared */ - - /* first a shallow copy of *everything* */ - *dst =3D *src; - - /* then copy whatever's left */ - dst->alias =3D NULL; - dst->romfile =3D NULL; - dst->loadparm =3D NULL; - - if (VIR_STRDUP(dst->alias, src->alias) < 0 || - VIR_STRDUP(dst->romfile, src->romfile) < 0 || - VIR_STRDUP(dst->loadparm, src->loadparm) < 0) - return -1; - return 0; -} - - static bool virDomainSkipBackcompatConsole(virDomainDefPtr def, size_t idx, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index cbcffa4..00d0d65 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2699,8 +2699,6 @@ virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomai= nDeviceDefPtr src, int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device= ); -int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, - virDomainDeviceInfoPtr src); void virDomainTPMDefFree(virDomainTPMDefPtr def); =20 typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def, @@ -3323,11 +3321,6 @@ virDomainGetBlkioParametersAssignFromDef(virDomainDe= fPtr def, int *nparams, int maxparams); =20 -bool -virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a, - const virDomainDeviceInfo *b) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; - int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk, virDomainBlockIoTuneInfo *info); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e92fe52..178aefc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -89,6 +89,8 @@ virCPUModeTypeToString; =20 =20 # conf/device_conf.h +virDomainDeviceInfoAddressIsEqual; +virDomainDeviceInfoCopy; virInterfaceLinkFormat; virInterfaceLinkParseXML; virPCIDeviceAddressEqual; @@ -285,8 +287,6 @@ virDomainDeviceDefFree; virDomainDeviceDefParse; virDomainDeviceFindControllerModel; virDomainDeviceGetInfo; -virDomainDeviceInfoAddressIsEqual; -virDomainDeviceInfoCopy; virDomainDeviceInfoIterate; virDomainDeviceTypeToString; virDomainDiskBusTypeToString; --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759478710129.9521224338704; Thu, 29 Jun 2017 11:04:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 166FB9D768; Thu, 29 Jun 2017 18:04:34 +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 C280417ADD; Thu, 29 Jun 2017 18:04:33 +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 B00551853E36; Thu, 29 Jun 2017 18:04:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4HDp006708 for ; Thu, 29 Jun 2017 14:04:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35C9C179DE; Thu, 29 Jun 2017 18:04:17 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2D75179DB for ; Thu, 29 Jun 2017 18:04:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 166FB9D768 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 166FB9D768 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:03:59 +0200 Message-Id: <1498759443-10136-7-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/10] conf: Introduce virDomainDeviceInfoNew() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 29 Jun 2017 18:04:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It allocates and initializes a virDomainDeviceInfo struct in one fell swoop. Signed-off-by: Andrea Bolognani --- src/conf/device_conf.c | 13 +++++++++++++ src/conf/device_conf.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 4644580..6ead830 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -32,6 +32,19 @@ =20 #define VIR_FROM_THIS VIR_FROM_DEVICE =20 +virDomainDeviceInfoPtr +virDomainDeviceInfoNew(void) +{ + virDomainDeviceInfoPtr info; + + if (VIR_ALLOC(info) < 0) + return NULL; + + virDomainDeviceInfoClear(info); + + return info; +} + void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) { diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 53abe1b..8f641bc 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -170,6 +170,7 @@ struct _virDomainDeviceInfo { char *loadparm; }; =20 +virDomainDeviceInfoPtr virDomainDeviceInfoNew(void); void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, virDomainDeviceInfoPtr src); --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759480593357.2551087686569; Thu, 29 Jun 2017 11:04:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A267EC00AFB3; Thu, 29 Jun 2017 18:04:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6973717496; Thu, 29 Jun 2017 18:04:36 +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 22EDB3FAE7; Thu, 29 Jun 2017 18:04:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4Io7006715 for ; Thu, 29 Jun 2017 14:04:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04DF1179DB; Thu, 29 Jun 2017 18:04:18 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82CB5179DE for ; Thu, 29 Jun 2017 18:04:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A267EC00AFB3 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A267EC00AFB3 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:04:00 +0200 Message-Id: <1498759443-10136-8-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/10] conf: Clean up virDomainDeviceInfo functions 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 29 Jun 2017 18:04:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Mostly style changes to make them a little bit nicer. Signed-off-by: Andrea Bolognani --- src/conf/device_conf.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 6ead830..facde0e 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -45,21 +45,44 @@ virDomainDeviceInfoNew(void) return info; } =20 +/** + * virDomainDeviceInfoClear: + * @info: device info + * + * Reset @info to its default state: all members will be set to their defa= ult + * value, and any memory associated with @info will be released. @info its= elf + * will still be valid after this function returns. + * + * You only need to call this function if you're allocating a + * virDomainDeviceInfo on the stack or embedding one inside your own struc= t: + * virDomainDeviceInfoNew() already takes care of calling it for you. + */ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) { - VIR_FREE(info->alias); - memset(&info->addr, 0, sizeof(info->addr)); info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; + memset(&info->addr, 0, sizeof(info->addr)); + + VIR_FREE(info->alias); VIR_FREE(info->romfile); VIR_FREE(info->loadparm); } =20 +/** + * virDomainDeviceInfoCopy: + * @dst: destination virDomainDeviceInfo + * @src: source virDomainDeviceInfo + * + * Perform a deep copy of @src into @dst. + * + * Return: 0 on success, <0 on failure + */ int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, virDomainDeviceInfoPtr src) { - /* Assume that dst is already cleared */ + /* Clear the destination */ + virDomainDeviceInfoClear(dst); =20 /* first a shallow copy of *everything* */ *dst =3D *src; @@ -77,10 +100,11 @@ virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, void virDomainDeviceInfoFree(virDomainDeviceInfoPtr info) { - if (info) { - virDomainDeviceInfoClear(info); - VIR_FREE(info); - } + if (!info) + return; + + virDomainDeviceInfoClear(info); + VIR_FREE(info); } =20 bool --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759499728990.6685501401174; Thu, 29 Jun 2017 11:04:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77F36C013C29; Thu, 29 Jun 2017 18:04:54 +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 35C0460F92; Thu, 29 Jun 2017 18:04:54 +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 C75281853E3D; Thu, 29 Jun 2017 18:04:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4LQ3006738 for ; Thu, 29 Jun 2017 14:04:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5219E179F1; Thu, 29 Jun 2017 18:04:21 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF8BD179DE for ; Thu, 29 Jun 2017 18:04:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 77F36C013C29 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 77F36C013C29 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:04:01 +0200 Message-Id: <1498759443-10136-9-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/10] conf, qemu: Use virDomainDeviceInfoNew() 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 29 Jun 2017 18:04:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instances allocated on the stack or using VIR_ALLOC() directly skip the initialization process. Use the proper allocation function instead to ensure all virDomainDeviceInfo instances are properly initialized. Signed-off-by: Andrea Bolognani --- src/conf/domain_addr.c | 6 ++++-- src/conf/domain_conf.c | 4 ++-- src/libvirt_private.syms | 2 ++ src/qemu/qemu_domain_address.c | 29 +++++++++++++++++------------ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 639168e..0c6e8c3 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1427,8 +1427,8 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def, bool portOnly) { int ret =3D -1; - virDomainDeviceInfo nfo =3D { NULL }; - virDomainDeviceInfoPtr ptr =3D allowZero ? &nfo : info; + virDomainDeviceInfoPtr nfo =3D virDomainDeviceInfoNew(); + virDomainDeviceInfoPtr ptr =3D allowZero ? nfo : info; =20 ptr->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL; =20 @@ -1448,6 +1448,8 @@ virDomainVirtioSerialAddrAssign(virDomainDefPtr def, ret =3D 0; =20 cleanup: + virDomainDeviceInfoFree(nfo); + return ret; } =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6a89fab..11c4627 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2364,7 +2364,7 @@ virDomainHostdevDefNew(virDomainXMLOptionPtr xmlopt) if (VIR_ALLOC(def) < 0) return NULL; =20 - if (VIR_ALLOC(def->info) < 0) + if (!(def->info =3D virDomainDeviceInfoNew())) goto error; =20 if (xmlopt && @@ -2376,7 +2376,7 @@ virDomainHostdevDefNew(virDomainXMLOptionPtr xmlopt) return def; =20 error: - VIR_FREE(def->info); + virDomainDeviceInfoFree(def->info); VIR_FREE(def); goto cleanup; } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 178aefc..48e9e33 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -91,6 +91,8 @@ virCPUModeTypeToString; # conf/device_conf.h virDomainDeviceInfoAddressIsEqual; virDomainDeviceInfoCopy; +virDomainDeviceInfoFree; +virDomainDeviceInfoNew; virInterfaceLinkFormat; virInterfaceLinkParseXML; virPCIDeviceAddressEqual; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index b5b863f..93ab304 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1983,6 +1983,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, int ret =3D -1; virDomainPCIAddressSetPtr addrs =3D NULL; qemuDomainObjPrivatePtr priv =3D NULL; + virDomainDeviceInfoPtr info =3D virDomainDeviceInfoNew(); int max_idx =3D -1; int nbuses =3D 0; size_t i; @@ -2031,16 +2032,15 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, */ =20 if (qemuDomainHasPCIRoot(def)) { - /* This is a dummy info used to reserve a slot for a + bool buses_reserved =3D true; + + /* The dummy info is used to reserve a slot for a * legacy PCI device that doesn't exist, but may in the * future, e.g. if another device is hotplugged into the * domain. */ - virDomainDeviceInfo info =3D { - .pciConnectFlags =3D (VIR_PCI_CONNECT_HOTPLUGGABLE | - VIR_PCI_CONNECT_TYPE_PCI_DEVICE) - }; - bool buses_reserved =3D true; + info->pciConnectFlags =3D (VIR_PCI_CONNECT_HOTPLUGGABLE | + VIR_PCI_CONNECT_TYPE_PCI_DEVICE); =20 for (i =3D 0; i < addrs->nbuses; i++) { if (!qemuDomainPCIBusFullyReserved(&addrs->buses[i])) { @@ -2049,7 +2049,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, } } if (!buses_reserved && - qemuDomainPCIAddressReserveNextAddr(addrs, &info) < 0) + qemuDomainPCIAddressReserveNextAddr(addrs, info) < 0) goto cleanup; } =20 @@ -2073,15 +2073,19 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, if (max_idx <=3D 0 && addrs->nbuses > max_idx + 1 && qemuDomainHasPCIeRoot(def)) { - virDomainDeviceInfo info =3D { - .pciConnectFlags =3D (VIR_PCI_CONNECT_HOTPLUGGABLE | - VIR_PCI_CONNECT_TYPE_PCIE_DEVICE) - }; + + /* The dummy info is used to reserve a slot for a + * PCI Express device that doesn't exist, but may in the + * future, e.g. if another device is hotplugged into the + * domain. + */ + info->pciConnectFlags =3D (VIR_PCI_CONNECT_HOTPLUGGABLE | + VIR_PCI_CONNECT_TYPE_PCIE_DEVICE); =20 /* if there isn't an empty pcie-root-port, this will * cause one to be added */ - if (qemuDomainPCIAddressReserveNextAddr(addrs, &info) < 0) + if (qemuDomainPCIAddressReserveNextAddr(addrs, info) < 0) goto cleanup; } =20 @@ -2234,6 +2238,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, ret =3D 0; =20 cleanup: + virDomainDeviceInfoFree(info); virDomainPCIAddressSetFree(addrs); =20 return ret; --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 04:57:35 2024 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759471758984.8678611655521; Thu, 29 Jun 2017 11:04:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78D24AB497; Thu, 29 Jun 2017 18:04:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A2F617AD9; Thu, 29 Jun 2017 18:04:26 +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 B8F663FAE2; Thu, 29 Jun 2017 18:04:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4OBk006756 for ; Thu, 29 Jun 2017 14:04:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7EAF617CC4; Thu, 29 Jun 2017 18:04:24 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE5354F6B3 for ; Thu, 29 Jun 2017 18:04:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78D24AB497 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 78D24AB497 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:04:02 +0200 Message-Id: <1498759443-10136-10-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/10] conf: Provide missing virDomain*DefNew() functions 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 29 Jun 2017 18:04:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Same as virDomainDeviceInfo itself, any struct that embeds it needs to be initialized properly before use; however, none of the structs in question even had a proper allocation function defined. Implement an allocation function for all structs embedding a virDomainDeviceInfo and use them instead of plain VIR_ALLOC() everywhere. Signed-off-by: Andrea Bolognani --- src/bhyve/bhyve_parse_command.c | 4 +- src/conf/domain_conf.c | 280 +++++++++++++++++++++++++++++++-----= ---- src/conf/domain_conf.h | 15 +++ src/libvirt_private.syms | 11 ++ src/openvz/openvz_conf.c | 2 +- src/qemu/qemu_command.c | 12 +- src/qemu/qemu_domain.c | 11 +- src/qemu/qemu_domain_address.c | 2 +- src/qemu/qemu_hotplug.c | 5 +- src/qemu/qemu_parse_command.c | 27 ++-- src/vbox/vbox_common.c | 12 +- src/vmx/vmx.c | 2 +- src/vz/vz_sdk.c | 6 +- src/xen/xen_driver.c | 2 +- src/xenapi/xenapi_driver.c | 2 +- src/xenconfig/xen_common.c | 2 +- src/xenconfig/xen_sxpr.c | 8 +- src/xenconfig/xen_xl.c | 2 +- src/xenconfig/xen_xm.c | 2 +- 19 files changed, 303 insertions(+), 104 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index fcaaed2..b9e8bc6 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -432,7 +432,7 @@ bhyveParsePCIDisk(virDomainDefPtr def, int idx =3D -1; virDomainDiskDefPtr disk =3D NULL; =20 - if (VIR_ALLOC(disk) < 0) + if (!(disk =3D virDomainDiskDefNew(NULL))) goto cleanup; if (VIR_ALLOC(disk->src) < 0) goto error; @@ -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())) 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 11c4627..055fde9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1389,6 +1389,17 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPt= r def) VIR_FREE(def); } =20 +virDomainInputDefPtr +virDomainInputDefNew(void) +{ + virDomainInputDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainInputDefFree(virDomainInputDefPtr def) { if (!def) @@ -2021,6 +2032,17 @@ virDomainNetDefClear(virDomainNetDefPtr def) virNetDevVlanClear(&def->vlan); } =20 +virDomainNetDefPtr +virDomainNetDefNew(void) +{ + virDomainNetDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainNetDefFree(virDomainNetDefPtr def) { @@ -2248,6 +2270,17 @@ void virDomainChrDefFree(virDomainChrDefPtr def) VIR_FREE(def); } =20 +virDomainSmartcardDefPtr +virDomainSmartcardDefNew(void) +{ + virDomainSmartcardDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def) { size_t i; @@ -2285,6 +2318,17 @@ void virDomainSoundCodecDefFree(virDomainSoundCodecD= efPtr def) VIR_FREE(def); } =20 +virDomainSoundDefPtr +virDomainSoundDefNew(void) +{ + virDomainSoundDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainSoundDefFree(virDomainSoundDefPtr def) { if (!def) @@ -2300,6 +2344,17 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def) VIR_FREE(def); } =20 +virDomainMemballoonDefPtr +virDomainMemballoonDefNew(void) +{ + virDomainMemballoonDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def) { if (!def) @@ -2311,6 +2366,17 @@ void virDomainMemballoonDefFree(virDomainMemballoonD= efPtr def) VIR_FREE(def); } =20 +virDomainNVRAMDefPtr +virDomainNVRAMDefNew(void) +{ + virDomainNVRAMDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def) { if (!def) @@ -2321,6 +2387,17 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def) VIR_FREE(def); } =20 +virDomainWatchdogDefPtr +virDomainWatchdogDefNew(void) +{ + virDomainWatchdogDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def) { if (!def) @@ -2331,6 +2408,50 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPt= r def) VIR_FREE(def); } =20 +virDomainRNGDefPtr +virDomainRNGDefNew(void) +{ + virDomainRNGDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + +void +virDomainRNGDefFree(virDomainRNGDefPtr def) +{ + if (!def) + return; + + switch ((virDomainRNGBackend) def->backend) { + case VIR_DOMAIN_RNG_BACKEND_RANDOM: + VIR_FREE(def->source.file); + break; + case VIR_DOMAIN_RNG_BACKEND_EGD: + virDomainChrSourceDefFree(def->source.chardev); + break; + case VIR_DOMAIN_RNG_BACKEND_LAST: + break; + } + + virDomainDeviceInfoClear(&def->info); + VIR_FREE(def->virtio); + VIR_FREE(def); +} + +virDomainShmemDefPtr +virDomainShmemDefNew(void) +{ + virDomainShmemDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainShmemDefFree(virDomainShmemDefPtr def) { if (!def) @@ -2342,6 +2463,17 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def) VIR_FREE(def); } =20 +virDomainVideoDefPtr +virDomainVideoDefNew(void) +{ + virDomainVideoDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainVideoDefFree(virDomainVideoDefPtr def) { if (!def) @@ -2457,6 +2589,17 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr= def) def->privateData =3D NULL; } =20 +virDomainTPMDefPtr +virDomainTPMDefNew(void) +{ + virDomainTPMDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainTPMDefFree(virDomainTPMDefPtr def) { if (!def) @@ -2489,6 +2632,17 @@ void virDomainHostdevDefFree(virDomainHostdevDefPtr = def) VIR_FREE(def); } =20 +virDomainHubDefPtr +virDomainHubDefNew(void) +{ + virDomainHubDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainHubDefFree(virDomainHubDefPtr def) { if (!def) @@ -2498,6 +2652,17 @@ void virDomainHubDefFree(virDomainHubDefPtr def) VIR_FREE(def); } =20 +virDomainRedirdevDefPtr +virDomainRedirdevDefNew(void) +{ + virDomainRedirdevDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def) { if (!def) @@ -2523,6 +2688,17 @@ void virDomainRedirFilterDefFree(virDomainRedirFilte= rDefPtr def) VIR_FREE(def); } =20 +virDomainMemoryDefPtr +virDomainMemoryDefNew(void) +{ + virDomainMemoryDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainMemoryDefFree(virDomainMemoryDefPtr def) { if (!def) @@ -2733,6 +2909,17 @@ virDomainResourceDefFree(virDomainResourceDefPtr res= ource) VIR_FREE(resource); } =20 +virDomainPanicDefPtr +virDomainPanicDefNew(void) +{ + virDomainPanicDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + void virDomainPanicDefFree(virDomainPanicDefPtr panic) { @@ -9732,8 +9919,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr oldnode =3D ctxt->node; int rv, val; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainNetDefNew())) + goto error; =20 ctxt->node =3D node; =20 @@ -11198,8 +11385,8 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, virDomainSmartcardDefPtr def; size_t i; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainSmartcardDefNew())) + goto error; =20 mode =3D virXMLPropString(node, "mode"); if (mode =3D=3D NULL) { @@ -11344,8 +11531,8 @@ virDomainTPMDefParseXML(xmlNodePtr node, xmlNodePtr *backends =3D NULL; int nbackends; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainTPMDefNew())) + goto error; =20 model =3D virXMLPropString(node, "model"); if (model !=3D NULL && @@ -11425,8 +11612,8 @@ virDomainPanicDefParseXML(xmlNodePtr node, virDomainPanicDefPtr panic; char *model =3D NULL; =20 - if (VIR_ALLOC(panic) < 0) - return NULL; + if (!(panic =3D virDomainPanicDefNew())) + goto error; =20 if (virDomainDeviceInfoParseXML(node, NULL, &panic->info, flags) < 0) goto error; @@ -11462,8 +11649,8 @@ virDomainInputDefParseXML(const virDomainDef *dom, char *type =3D NULL; char *bus =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainInputDefNew())) + goto error; =20 ctxt->node =3D node; =20 @@ -11606,8 +11793,8 @@ virDomainHubDefParseXML(xmlNodePtr node, unsigned i= nt flags) virDomainHubDefPtr def; char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainHubDefNew())) + goto error; =20 type =3D virXMLPropString(node, "type"); =20 @@ -12708,8 +12895,8 @@ virDomainSoundDefParseXML(xmlNodePtr node, virDomainSoundDefPtr def; xmlNodePtr save =3D ctxt->node; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainSoundDefNew())) + goto error; =20 ctxt->node =3D node; =20 @@ -12777,8 +12964,8 @@ virDomainWatchdogDefParseXML(xmlNodePtr node, char *action =3D NULL; virDomainWatchdogDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainWatchdogDefNew())) + goto error; =20 model =3D virXMLPropString(node, "model"); if (model =3D=3D NULL) { @@ -12835,8 +13022,8 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlop= t, xmlNodePtr *backends =3D NULL; int nbackends; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainRNGDefNew())) + goto error; =20 if (!(model =3D virXMLPropString(node, "model"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing RNG device mode= l")); @@ -12949,8 +13136,8 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, xmlNodePtr save =3D ctxt->node; unsigned int period =3D 0; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainMemballoonDefNew())) + goto error; =20 model =3D virXMLPropString(node, "model"); if (model =3D=3D NULL) { @@ -13010,8 +13197,8 @@ virDomainNVRAMDefParseXML(xmlNodePtr node, { virDomainNVRAMDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainNVRAMDefNew())) + goto error; =20 if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) goto error; @@ -13034,9 +13221,8 @@ virDomainShmemDefParseXML(xmlNodePtr node, xmlNodePtr save =3D ctxt->node; xmlNodePtr server =3D NULL; =20 - - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainShmemDefNew())) + goto error; =20 ctxt->node =3D node; =20 @@ -13550,8 +13736,8 @@ virDomainVideoDefParseXML(xmlNodePtr node, =20 ctxt->node =3D node; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainVideoDefNew())) + goto error; =20 cur =3D node->children; while (cur !=3D NULL) { @@ -13789,8 +13975,8 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, char *bus =3D NULL, *type =3D NULL; int remaining; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainRedirdevDefNew())) + goto error; =20 if (!(def->source =3D virDomainChrSourceDefNew(xmlopt))) goto error; @@ -14255,8 +14441,8 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, =20 ctxt->node =3D memdevNode; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + if (!(def =3D virDomainMemoryDefNew())) + goto error; =20 if (!(tmp =3D virXMLPropString(memdevNode, "model"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -16383,7 +16569,7 @@ virDomainDefAddController(virDomainDefPtr def, int = type, int idx, int model) cont->model =3D model; =20 if (VIR_APPEND_ELEMENT_COPY(def->controllers, def->ncontrollers, cont)= < 0) { - VIR_FREE(cont); + virDomainControllerDefFree(cont); return NULL; } =20 @@ -16477,14 +16663,14 @@ virDomainDefMaybeAddInput(virDomainDefPtr def, return 0; } =20 - if (VIR_ALLOC(input) < 0) + if (!(input =3D virDomainInputDefNew())) return -1; =20 input->type =3D type; input->bus =3D bus; =20 if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { - VIR_FREE(input); + virDomainInputDefFree(input); return -1; } =20 @@ -20827,14 +21013,14 @@ static int virDomainDefAddImplicitVideo(virDomainDefPtr def) { int ret =3D -1; - virDomainVideoDefPtr video =3D NULL; + virDomainVideoDefPtr video; =20 /* For backwards compatibility, if no