From nobody Fri May 3 07:32:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601628978; cv=none; d=zohomail.com; s=zohoarc; b=nx0oOPLGiL8HRi/IAxjIkz0stkD3RZv1Maz4eNBDo5rbtyULlCw0qZjukoAxlmiQo8Wz9mYPD06wVQ6Dl6pA726ckPXzI/GxxJFtavLeGSmG4wRbIiu4Cr2dUNml/pR0atpVzyEIOXwhkQPdawcZCn9AF7oQifiF8QyeeutkbEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601628978; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6OuYlp2ihP0v5efjswPrPsnz/OdtCA/mRXfmYhNFfqM=; b=WWOT/nY2zsROfuhUoOP/xhGwWzQ1qcIdYOU+2fJa2uy80kyevwM8JvAJ/cWv1YpgU/6TQ63mzipjbxdYVIlEgX7sV7sCV+v4dcmY4drbTt+xip3ysy1NdmiU5JZo3KrTpG8K8neX2czVmuoR/CbQ2bC4Xv5qUMhr5PeszsYXpkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601628978475439.053355025; Fri, 2 Oct 2020 01:56:18 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-LXQcFOXzP9y-srNovYHErA-1; Fri, 02 Oct 2020 04:56:15 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D95B3186DD2C; Fri, 2 Oct 2020 08:56:09 +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 B53BF19C78; Fri, 2 Oct 2020 08:56:09 +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 8132C181A06C; Fri, 2 Oct 2020 08:56:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928u8iR014668 for ; Fri, 2 Oct 2020 04:56:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3E845C1D7; Fri, 2 Oct 2020 08:56:08 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E21E5C1D0 for ; Fri, 2 Oct 2020 08:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601628977; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6OuYlp2ihP0v5efjswPrPsnz/OdtCA/mRXfmYhNFfqM=; b=cAlLaoG0LI8em4xAwy8VnB0t/tnrCik0OlxD9s4hC5GxMLVDqY+OeTDe1bsmhGCzrY/2Pc zL1QTrBSo5rwZ4VB3iOf2tKcJSfJ3++NSiQ3pMNqssgA3WP3RXG2UntwDNdUZcjYRqq1nO UrJTgpWPNiSEH/TZ+jrUkV6K5SwcT70= X-MC-Unique: LXQcFOXzP9y-srNovYHErA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/6] virBitmapNewCopy: Reimplement bitmap copying to prevent failure Date: Fri, 2 Oct 2020 10:55:57 +0200 Message-Id: <2c3247d567ed02646f584d6f1baa68343a3d2f5c.1601628907.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" virBitmapCopy has a failure condition, which is impossible to meet when creating a new copy. Copy the contents directly to make it obvious that virBitmapNewCopy can't fail. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virbitmap.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 74d1883d94..c62438a3a6 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -655,20 +655,14 @@ virBitmapParseUnlimited(const char *str) * virBitmapNewCopy: * @src: the source bitmap. * - * Makes a copy of bitmap @src. - * - * returns the copied bitmap on success, or NULL otherwise. Caller - * should call virBitmapFree to free the returned bitmap. + * Returns a copy of bitmap @src. */ virBitmapPtr virBitmapNewCopy(virBitmapPtr src) { virBitmapPtr dst =3D virBitmapNew(src->nbits); - if (virBitmapCopy(dst, src) !=3D 0) { - virBitmapFree(dst); - return NULL; - } + memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0])); return dst; } --=20 2.26.2 From nobody Fri May 3 07:32:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601628983; cv=none; d=zohomail.com; s=zohoarc; b=SaisBHZHNu+FpSNy37AejRkAkZV1Fv+pxLSKehvByeEnAlpQZvbUO4hEaNI8C8Z1/VUqpGeg4GcD5lUdU6nngvgtO0m471tTXqRwtrQXaqAybK3v/95l/ziG6fNay4RA3CtV0DUC6HKC3bzJLVgBtagZohjfjbmiNVrwCfvhTFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601628983; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LUhwRvSj5kG+AmrK1bJj/F4/iDM0NpjX4Cc+eAR8Ne4=; b=IYyEfQT20E7r3khYV+8t6QIfHqi/qlxYq0JwhTpf/Dz48wVRR3VtnGVqxJr03R6rJ1kldULiNEb9rOleB5IOeD9LNB2j3sjsVoj5pMxwLCkBVYRcDqoQ/0NI0WcwLlBxpL5arYU7+V5gynLbvqILC1m+p7zNZiUb2+/2pnA+C8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160162898356675.0906987424878; Fri, 2 Oct 2020 01:56:23 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-119-5nVBWHhlPMWw9FSI9GUNtw-1; Fri, 02 Oct 2020 04:56:19 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0D6E801AFB; Fri, 2 Oct 2020 08:56:13 +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 989E275120; Fri, 2 Oct 2020 08:56:12 +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 62E2644A4C; Fri, 2 Oct 2020 08:56:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928u9r3014678 for ; Fri, 2 Oct 2020 04:56:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4FAC5C1D7; Fri, 2 Oct 2020 08:56:09 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 380CF5C1D0 for ; Fri, 2 Oct 2020 08:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601628982; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LUhwRvSj5kG+AmrK1bJj/F4/iDM0NpjX4Cc+eAR8Ne4=; b=co92peUT20oNjwuwyC4dIuy0Oa+3fAV+d0IHtU/1c0G8tE27L81lceNVR5vInUQl88iqiI S6zP3wDTOwTzbBUtHJhrbhwbSaX+uAvUOmZL3Ie0w+TJ4ZJKLJus4LciMxgLMbx30dLx31 zGyqH2Bmgi1bdt4PQQjMpXOZze0OEuM= X-MC-Unique: 5nVBWHhlPMWw9FSI9GUNtw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] Don't check return value of virBitmapNewCopy Date: Fri, 2 Oct 2020 10:55:58 +0200 Message-Id: <6213f761474e5c5db966c965761ff5ca20b00473.1601628907.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function will not fail any more. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 3 +-- src/conf/domain_conf.c | 7 +------ src/conf/numa_conf.c | 4 ++-- src/qemu/qemu_driver.c | 13 +++---------- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_migration_cookie.c | 3 --- src/qemu/qemu_process.c | 3 +-- src/test/test_driver.c | 5 +---- src/util/virstoragefile.c | 5 ++--- 9 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 4a85c63628..da2633761d 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1823,8 +1823,7 @@ virCapabilitiesInitResctrlMemory(virCapsPtr caps) if (virResctrlInfoGetMemoryBandwidth(caps->host.resctrl, bank->level, &node->control) = > 0) { node->id =3D bank->id; - if (!(node->cpus =3D virBitmapNewCopy(bank->cpus))) - goto cleanup; + node->cpus =3D virBitmapNewCopy(bank->cpus); if (VIR_APPEND_ELEMENT(caps->host.memBW.nodes, caps->host.memBW.nnodes, node) < 0) { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2fbfd949fd..f716338efd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20928,12 +20928,7 @@ virDomainResctrlNew(xmlNodePtr node, if (VIR_ALLOC(resctrl) < 0) goto cleanup; - if (!(resctrl->vcpus =3D virBitmapNewCopy(vcpus))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to copy 'vcpus'")); - goto cleanup; - } - + resctrl->vcpus =3D virBitmapNewCopy(vcpus); resctrl->alloc =3D virObjectRef(alloc); ret =3D g_steal_pointer(&resctrl); diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index b5ddf2c134..6653ba05a6 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -582,8 +582,8 @@ virDomainNumatuneSet(virDomainNumaPtr numa, if (nodeset) { virBitmapFree(numa->memory.nodeset); - if (!(numa->memory.nodeset =3D virBitmapNewCopy(nodeset))) - return -1; + numa->memory.nodeset =3D virBitmapNewCopy(nodeset); + if (placement =3D=3D -1) placement =3D VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c23dca9970..542eabf05d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4543,8 +4543,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, goto cleanup; } - if (!(tmpmap =3D virBitmapNewCopy(cpumap))) - goto cleanup; + tmpmap =3D virBitmapNewCopy(cpumap); if (!(str =3D virBitmapFormat(cpumap))) goto cleanup; @@ -4782,10 +4781,7 @@ qemuDomainPinEmulator(virDomainPtr dom, goto endjob; virBitmapFree(def->cputune.emulatorpin); - def->cputune.emulatorpin =3D NULL; - - if (!(def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap))) - goto endjob; + def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap); if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto endjob; @@ -4802,10 +4798,7 @@ qemuDomainPinEmulator(virDomainPtr dom, if (persistentDef) { virBitmapFree(persistentDef->cputune.emulatorpin); - persistentDef->cputune.emulatorpin =3D NULL; - - if (!(persistentDef->cputune.emulatorpin =3D virBitmapNewCopy(pcpu= map))) - goto endjob; + persistentDef->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap); ret =3D virDomainDefSave(persistentDef, driver->xmlopt, cfg->confi= gDir); goto endjob; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 86ccb9bac4..82845736b1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6424,8 +6424,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr d= ef, ssize_t next =3D -1; size_t i; - if (!(map =3D virBitmapNewCopy(vcpus))) - return NULL; + map =3D virBitmapNewCopy(vcpus); /* make sure that all selected vcpus are in the correct state */ while ((next =3D virBitmapNextSetBit(map, next)) >=3D 0) { diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 4b73a98f7e..afbb3526e9 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -568,9 +568,6 @@ qemuMigrationCookieAddCaps(qemuMigrationCookiePtr mig, mig->caps->automatic =3D qemuMigrationParamsGetAlwaysOnCaps(party); - if (!mig->caps->supported || !mig->caps->automatic) - return -1; - mig->flags |=3D QEMU_MIGRATION_COOKIE_CAPS; return 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8814e61314..8d28d67692 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2562,8 +2562,7 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm) if (virNumaNodesetToCPUset(nodeset, &cpumapToSet) < 0) return -1; } else if (vm->def->cputune.emulatorpin) { - if (!(cpumapToSet =3D virBitmapNewCopy(vm->def->cputune.emulatorpi= n))) - return -1; + cpumapToSet =3D virBitmapNewCopy(vm->def->cputune.emulatorpin); } else { settingAll =3D true; if (qemuProcessGetAllCpuAffinity(&cpumapToSet) < 0) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index af8fd03308..7824e44ed9 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2743,10 +2743,7 @@ testDomainPinEmulator(virDomainPtr dom, } virBitmapFree(def->cputune.emulatorpin); - def->cputune.emulatorpin =3D NULL; - - if (!(def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap))) - goto cleanup; + def->cputune.emulatorpin =3D virBitmapNewCopy(pcpumap); ret =3D 0; cleanup: diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a669b4ca99..459a7be5e4 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2422,9 +2422,8 @@ virStorageSourceCopy(const virStorageSource *src, !(def->srcpool =3D virStorageSourcePoolDefCopy(src->srcpool))) return NULL; - if (src->features && - !(def->features =3D virBitmapNewCopy(src->features))) - return NULL; + if (src->features) + def->features =3D virBitmapNewCopy(src->features); if (src->encryption && !(def->encryption =3D virStorageEncryptionCopy(src->encryption))) --=20 2.26.2 From nobody Fri May 3 07:32:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601628986; cv=none; d=zohomail.com; s=zohoarc; b=bFEMTrngyHpPbU1UqtxcxnpJwyaV6mU/KRzDD+Ui7Pa1fg7aHLmjwrjBKk2sG0UntqjrJQWQcIUFwLWTOf8dJv9a7jLCvufb6bq8zYelr7+Jih4dxuAEORaaqFYT58OCVAvgP5cxVVEwHKJCXLBnUye+htky6mqi+jg8Go6Tli0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601628986; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OWRyGtpwv2pJs6o8M8XEQolPevd6q4k9NsSI6dzeEf4=; b=bNfRrhzUpdC2bA+XhRoJ4NKbQrs3PQqPlL9T3gde6WQlqGkjrAruIMMRRs7BCCpX1ZYgGn18/s0Swrg0I0p0O/rS4jIHZs3UVzliDhJqZLDU4nAC+3gtMJhKEBRhzV2mjagJ6COBPIn0+PNLq+2d18qZe5Tn4ErKnblf2qLxFJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601628986424407.61203760073613; Fri, 2 Oct 2020 01:56:26 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-B0OwtMIdM_2drz7GGgO4dw-1; Fri, 02 Oct 2020 04:56:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 506871019635; Fri, 2 Oct 2020 08:56: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 29BDD19931; Fri, 2 Oct 2020 08:56: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 E69B744A5E; Fri, 2 Oct 2020 08:56:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928uAQh014688 for ; Fri, 2 Oct 2020 04:56:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id F12B75C1D7; Fri, 2 Oct 2020 08:56:10 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49B3B5C1D0 for ; Fri, 2 Oct 2020 08:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601628985; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OWRyGtpwv2pJs6o8M8XEQolPevd6q4k9NsSI6dzeEf4=; b=Ti9I1QkbgMu3YmnDiVpsHALs9MoCqavG9Qx9AaT5OSzok6IV1kOfJQn5YVvnx5ME+929xm XxYacmea0dCmX9+vjLQjHbyugMYyRUaKKONmJHeeIfHDeJPRW4dJ85lttKC9GpsB9xARhB nP/pk24GFoEJ8Rhc4M6quhrio7HuH+s= X-MC-Unique: B0OwtMIdM_2drz7GGgO4dw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/6] Use 'virBitmapNewCopy' instead of 'virBitmapCopy' Date: Fri, 2 Oct 2020 10:55:59 +0200 Message-Id: <9331caba899751ab638278ad64168ddd4781a5be.1601628908.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are only 3 places using the function. Two can use virBitmapNewCopy directly. In case of the qemu capabilities code we need to free the old bitmap first. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 3 +-- src/qemu/qemu_capabilities.c | 3 ++- src/util/virresctrl.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index da2633761d..0ba7323ee8 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1589,8 +1589,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr ca= ps) cpus[cid].die_id =3D 0; cpus[cid].socket_id =3D s; cpus[cid].core_id =3D c; - cpus[cid].siblings =3D virBitmapNew(ncpus); - virBitmapCopy(cpus[cid].siblings, siblings); + cpus[cid].siblings =3D virBitmapNewCopy(siblings); cid++; } diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e3a934363b..29cb78a388 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1932,7 +1932,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemu= Caps) ret->ctime =3D qemuCaps->ctime; - virBitmapCopy(ret->flags, qemuCaps->flags); + virBitmapFree(ret->flags); + ret->flags =3D virBitmapNewCopy(qemuCaps->flags); ret->version =3D qemuCaps->version; ret->kvmVersion =3D qemuCaps->kvmVersion; diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index dabfa9990e..aea3fe8687 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1158,9 +1158,9 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr alloc, return -1; if (!a_type->masks[cache]) - a_type->masks[cache] =3D virBitmapNew(virBitmapSize(mask)); + a_type->masks[cache] =3D virBitmapNewCopy(mask); - return virBitmapCopy(a_type->masks[cache], mask); + return 0; } --=20 2.26.2 From nobody Fri May 3 07:32:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601628987; cv=none; d=zohomail.com; s=zohoarc; b=L4R9y7VQFBn4beDpMvQCZfwFUm1eKJMnDxNkAkNvkjUCLuTiNs3n4Z+sz5jisE8kwdTo1f2TQxf2GoCxQMtOD3VGVm8vBk6T8o9K6VwrW9JXf7v1UtZwXcCsGNQ7CbuftDNdygv+EWf+1oSODITGw3NGLQZL4STl3UbnyIQZwg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601628987; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7ccvjF2mMhpUg8PHyFjZ381gqilAEqnlnnvdlwRbHOA=; b=anjOdxc4M76ic06GuCDxtgXWg7D8jHZm1b22k1Pw9RR2rUPDJvz+ed2aapdM2SoWGypw0ghaokYe8YbbMAyBbAsjlHuymTkeI2YMYM77dAl643IkW8zvmO0I7TO8Zz6EcMi5le5VhNyplXLOM3qtyZvlCyUBwcbQ6yyuWEcEqHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601628987210848.8231278082112; Fri, 2 Oct 2020 01:56:27 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-WHWJMMg7P4ekYxR59qpZPA-1; Fri, 02 Oct 2020 04:56:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6FFB81019633; Fri, 2 Oct 2020 08:56:15 +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 4FCD85C1D0; Fri, 2 Oct 2020 08:56: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 1C8A4181A06E; Fri, 2 Oct 2020 08:56:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928uC8T014693 for ; Fri, 2 Oct 2020 04:56:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C45F5C1D7; Fri, 2 Oct 2020 08:56:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 642015C1D0 for ; Fri, 2 Oct 2020 08:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601628986; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7ccvjF2mMhpUg8PHyFjZ381gqilAEqnlnnvdlwRbHOA=; b=gpJiPdU4jn22+KGXJNaYAwlb0PmJBTyX33Pu2qvrhqA9dt2ABr/NMX8bnHRXqyNhDysHXT z0DpxcyuQj6HOraOH9aLisU5JwbKYI9gUp8HwrOHn1a5QtWemdIPqy+YQHPzSC3RqjVROQ ZCznPOXSrTOEQUmFypUcyZe33jvfsWQ= X-MC-Unique: WHWJMMg7P4ekYxR59qpZPA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] util: virbitmap: Remove virBitmapCopy Date: Fri, 2 Oct 2020 10:56:00 +0200 Message-Id: <06af4561be5004302c6f4187d46f176aa002a4ee.1601628908.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function is now unused. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virbitmap.c | 23 ----------------------- src/util/virbitmap.h | 6 ------ 3 files changed, 30 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 01ae3cad93..7cf8bea962 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1668,7 +1668,6 @@ virAuthConfigNewData; virBitmapClearAll; virBitmapClearBit; virBitmapClearBitExpand; -virBitmapCopy; virBitmapCountBits; virBitmapDataFormat; virBitmapEqual; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index c62438a3a6..3666033bac 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -100,29 +100,6 @@ virBitmapFree(virBitmapPtr bitmap) } -/** - * virBitmapCopy: - * @dst: destination bitmap - * @src: source bitmap - * - * Copies contents of @src to @dst. @dst must have the same size as @src. - * Returns -1 if the size is not the same or 0 on success. - */ -int -virBitmapCopy(virBitmapPtr dst, - virBitmapPtr src) -{ - if (dst->nbits !=3D src->nbits) { - errno =3D EINVAL; - return -1; - } - - memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0])); - - return 0; -} - - /** * virBitmapSetBit: * @bitmap: Pointer to bitmap diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index cd5caa6f61..67a433672d 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -39,12 +39,6 @@ virBitmapPtr virBitmapNew(size_t size); */ void virBitmapFree(virBitmapPtr bitmap); -/* - * Copy all bits from @src to @dst. The bitmap sizes - * must be the same - */ -int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src); - /* * Set bit position @b in @bitmap */ --=20 2.26.2 From nobody Fri May 3 07:32:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629030; cv=none; d=zohomail.com; s=zohoarc; b=Nmldwtj0WhGBrS8PgPd6UFTW8LhEh2dY3YNZvmXwf+Dch5IgMjlj/xkdo36hKCkHxN9vBcoLi041QKrOIyT1mvDpDRN5LYjby4Bnt/jd17BfGC1x0XonKMvdwf92De/0XlhjvuQKwQYWCRD5zHNDYAJnx4ZKtokTXgE57HmzAcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629030; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UHPETvdikeedmxkXQVT4mXI4Tbw5YK0asDpV4gmcIZg=; b=Ibc/d9/7fD8LZEs5jq1JeO+SR0SYvNHTVKC90sTDXWGRbozzPIY7rDbkNRq5arK+zojka/KhzbWDrnILIRdXzT0RRyCaKnggHNYmQiQivKfnYKydTm97uL20G3MB18VnrRCT/RT7dpa5MyCpj/CEhMQB7HlipT0u4QZ7DhTwoaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629030085814.3301547922231; Fri, 2 Oct 2020 01:57:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-OyBHIqXSMO6vAF8GDTUKJA-1; Fri, 02 Oct 2020 04:56:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AFB3B1074671; Fri, 2 Oct 2020 08:56: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 8CEE61002C01; Fri, 2 Oct 2020 08:56: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 5C1C444A5F; Fri, 2 Oct 2020 08:56:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928uDPO014701 for ; Fri, 2 Oct 2020 04:56:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 273665C1D0; Fri, 2 Oct 2020 08:56:13 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 700185C1D7 for ; Fri, 2 Oct 2020 08:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629028; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UHPETvdikeedmxkXQVT4mXI4Tbw5YK0asDpV4gmcIZg=; b=HG34de9egF0TJOuErFCLB1wl9NvMCpZAtVjQ+kAtuhf5w2STn1WiuMg33qW17FbG6VNILe MNWHXdfoapT6H/xu4GaPsTnSLEnLYnugsXlubfn6jLila/QdA7/RPRdBp6c6smIWExu8GZ kIeTmnmcdBsXGTtrVDvq1gdhUozpE5o= X-MC-Unique: OyBHIqXSMO6vAF8GDTUKJA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] virDomainResctrlNew: Refactor allocation to remove 'cleanup' label Date: Fri, 2 Oct 2020 10:56:01 +0200 Message-Id: <71765967b1f7f165cffa573db1e12e2c4de17ef7.1601628908.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If we use g_new0 there's no need for the 'cleanup' label as there's nothing to fail after the allocation. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f716338efd..0d93ae3341 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20900,7 +20900,6 @@ virDomainResctrlNew(xmlNodePtr node, unsigned int flags) { virDomainResctrlDefPtr resctrl =3D NULL; - virDomainResctrlDefPtr ret =3D NULL; g_autofree char *vcpus_str =3D NULL; g_autofree char *alloc_id =3D NULL; @@ -20923,18 +20922,13 @@ virDomainResctrlNew(xmlNodePtr node, } if (virResctrlAllocSetID(alloc, alloc_id) < 0) - goto cleanup; - - if (VIR_ALLOC(resctrl) < 0) - goto cleanup; + return NULL; + resctrl =3D g_new0(virDomainResctrlDef, 1); resctrl->vcpus =3D virBitmapNewCopy(vcpus); resctrl->alloc =3D virObjectRef(alloc); - ret =3D g_steal_pointer(&resctrl); - cleanup: - virDomainResctrlDefFree(resctrl); - return ret; + return g_steal_pointer(&resctrl); } --=20 2.26.2 From nobody Fri May 3 07:32:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601628989; cv=none; d=zohomail.com; s=zohoarc; b=Qk7W0Dp0jEbbsYZfQnBV0zOwPXMfFom8bbZWS1z3x/WqsNiCwE2EJ7MVWNC3wjHYJxtOisL/QWUTsXDVS77mG9XiyxQd5LX6ZLTKBFj9v0Jh2txlWUHrMXVtX834ZTGjuFVQIYg0PSeAXIT8cwzgEzfn0/Tv3HAVGCEtFVr+xCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601628989; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TEdvMSplRfXhWI7IjQWYmU8KII3qWMRbD6st8EA3w9Y=; b=V0wLVClBzqKpmDfEn2LsCcsNfWtv4n4lvn4EbiT+HDwMk2JJSAZnWfcYifMpMQmlLJGVQSLvoyq2QCcHtVQhQavDCWIy7u7kgPCuUiZEzQIOFcJDsw2/y2hEx4eCjKtm4rR75gVe2aUj7iFSfgQ5SQSMurbus/HlaNrMwnah4to= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601628989032460.49909234529184; Fri, 2 Oct 2020 01:56:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-JJqwuApwOfyN7ag70wUsMw-1; Fri, 02 Oct 2020 04:56:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76148803F49; Fri, 2 Oct 2020 08:56:18 +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 51ACF10023A5; Fri, 2 Oct 2020 08:56: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 1D2F544A62; Fri, 2 Oct 2020 08:56:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928uEd8014709 for ; Fri, 2 Oct 2020 04:56:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 376CB5C1DA; Fri, 2 Oct 2020 08:56:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9467D5C1D0 for ; Fri, 2 Oct 2020 08:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601628987; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TEdvMSplRfXhWI7IjQWYmU8KII3qWMRbD6st8EA3w9Y=; b=IEQmwFJn4wDjZmJmSTzyRK9FQKXgbIpDrToztqlgg2djEqHJGi2iyKY7hiFfmqf9tHHaZg OLyRShS8EE6Q8sUTuj/Uk+udlxRlnMy9UD/8Ky92ganjtRzOR7zbvqkUl9Q9FYIlND2UcJ bovSJkCxAp8D8sg4y94SWzYnAdhsHMM= X-MC-Unique: JJqwuApwOfyN7ag70wUsMw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/6] qemuDomainFilterHotplugVcpuEntities: Refactor memory freeing to remove 'cleanup' label Date: Fri, 2 Oct 2020 10:56:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" After recent refactors the function can be refactored to remove the 'cleanup' label by using autoptr for the 'map' variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 82845736b1..dbaf3b7666 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6419,13 +6419,10 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr= def, { qemuDomainVcpuPrivatePtr vcpupriv; virDomainVcpuDefPtr vcpu; - virBitmapPtr map =3D NULL; - virBitmapPtr ret =3D NULL; + g_autoptr(virBitmap) map =3D virBitmapNewCopy(vcpus); ssize_t next =3D -1; size_t i; - map =3D virBitmapNewCopy(vcpus); - /* make sure that all selected vcpus are in the correct state */ while ((next =3D virBitmapNextSetBit(map, next)) >=3D 0) { if (!(vcpu =3D virDomainDefGetVcpu(def, next))) @@ -6434,13 +6431,13 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr= def, if (vcpu->online =3D=3D state) { virReportError(VIR_ERR_INVALID_ARG, _("vcpu '%zd' is already in requested state"), = next); - goto cleanup; + return NULL; } if (vcpu->online && !vcpu->hotpluggable) { virReportError(VIR_ERR_INVALID_ARG, _("vcpu '%zd' can't be hotunplugged"), next); - goto cleanup; + return NULL; } } @@ -6457,7 +6454,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr d= ef, virReportError(VIR_ERR_INVALID_ARG, _("vcpu '%zd' belongs to a larger hotpluggable = entity, " "but siblings were not selected"), next); - goto cleanup; + return NULL; } for (i =3D next + 1; i < next + vcpupriv->vcpus; i++) { @@ -6467,7 +6464,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr d= ef, "hotpluggable entity '%zd-%zd' which was " "partially selected"), i, next, next + vcpupriv->vcpus - 1); - goto cleanup; + return NULL; } /* clear the subthreads */ @@ -6475,11 +6472,7 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr = def, } } - ret =3D g_steal_pointer(&map); - - cleanup: - virBitmapFree(map); - return ret; + return g_steal_pointer(&map); } --=20 2.26.2