From nobody Fri May 16 01:20:07 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502895580405795.0245933597648; Wed, 16 Aug 2017 07:59:40 -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 4011B806CA; Wed, 16 Aug 2017 14:59:38 +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 7E850E9957; Wed, 16 Aug 2017 14:59:37 +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 280BF1800C8A; Wed, 16 Aug 2017 14:59:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw4CW008002 for ; Wed, 16 Aug 2017 10:58:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C8186FA89; Wed, 16 Aug 2017 14:58:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E6B06FA91; Wed, 16 Aug 2017 14:58:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4011B806CA 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/12] qemu: domain: Don't re-allocate qemuCaps in post parse callbacks 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]); Wed, 16 Aug 2017 14:59:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The domain post parse callback, domain address callback and the domain device callback (for every single device) would each grab qemuCaps for the current emulator. This is quite wasteful. Use the new callback to do this just once. --- src/qemu/qemu_domain.c | 54 +++++++++++++++++++++++-----------------------= ---- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9e395aec9..dc8041b86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2971,14 +2971,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, goto cleanup; } - if (qemuCaps) { - virObjectRef(qemuCaps); - } else { - if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator))) - goto cleanup; - } - if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0) goto cleanup; @@ -3004,7 +2996,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, ret =3D 0; cleanup: - virObjectUnref(qemuCaps); virObjectUnref(cfg); return ret; } @@ -3573,13 +3564,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); int ret =3D -1; - if (qemuCaps) { - virObjectRef(qemuCaps); - } else { - qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator); - } - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET && dev->data.net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && !dev->data.net->model) { @@ -3688,7 +3672,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, ret =3D 0; cleanup: - virObjectUnref(qemuCaps); virObjectUnref(cfg); return ret; } @@ -3703,29 +3686,42 @@ qemuDomainDefAssignAddresses(virDomainDef *def, { virQEMUDriverPtr driver =3D opaque; virQEMUCapsPtr qemuCaps =3D parseOpaque; - int ret =3D -1; bool newDomain =3D parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; - if (qemuCaps) { - virObjectRef(qemuCaps); - } else { - if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + return qemuDomainAssignAddresses(def, qemuCaps, driver, NULL, newDomai= n); +} + + +static int +qemuDomainPostParseDataAlloc(const virDomainDef *def, + virCapsPtr caps ATTRIBUTE_UNUSED, + unsigned int parseFlags ATTRIBUTE_UNUSED, + void *opaque, + void **parseOpaque) +{ + virQEMUDriverPtr driver =3D opaque; + + if (!(*parseOpaque =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) - goto cleanup; - } + return -1; - if (qemuDomainAssignAddresses(def, qemuCaps, driver, NULL, newDomain) = < 0) - goto cleanup; + return 0; +} + + +static void +qemuDomainPostParseDataFree(void *parseOpaque) +{ + virQEMUCapsPtr qemuCaps =3D parseOpaque; - ret =3D 0; - cleanup: virObjectUnref(qemuCaps); - return ret; } virDomainDefParserConfig virQEMUDriverDomainDefParserConfig =3D { .domainPostParseBasicCallback =3D qemuDomainDefPostParseBasic, + .domainPostParseDataAlloc =3D qemuDomainPostParseDataAlloc, + .domainPostParseDataFree =3D qemuDomainPostParseDataFree, .devicesPostParseCallback =3D qemuDomainDeviceDefPostParse, .domainPostParseCallback =3D qemuDomainDefPostParse, .assignAddressesCallback =3D qemuDomainDefAssignAddresses, --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list