From nobody Mon Nov 25 16:25:17 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=1600868107; cv=none; d=zohomail.com; s=zohoarc; b=IXo3VQJktD4zUw5L5kmMjY3Z5F33G1HJEATXMvGWY05+KjPok9JO5s6DlpMofLZ2ej47esnFafdrTkrCaQnjPo+o/CwJWBcPAll4LpT1gjQMWVgq8IqKIO7D6pQnVmt4QOFEO2YP46ULw7Zvos7/0TPGBrkml8qBe0ZO2Wjrktk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868107; 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=5B+NwoKkKvIBaOHeo9z9LZbl93ODDAcbKGNzunarT68=; b=fipUUiN8GmPHjw0M4lsvvfqb3Za2sap9mTRRsoE6N3w1HITPBB4wkNMEmemrZPEv9dZFGsDquQ6fCjr58s+MLyVx1w6Fw25cJp14QyrYhNHh8Wcw07BebmU21f5dF/QYJMPnU/Y+t1CBxmZ9C+zLJOOLto5PGbR+R8IXA6YNrZc= 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 16008681074201004.0946416582442; Wed, 23 Sep 2020 06:35:07 -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-146-fGdnyGhEO1KkRhwF8MDXNg-1; Wed, 23 Sep 2020 09:34:13 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C864E5705B; Wed, 23 Sep 2020 13:34:06 +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 A82A77368B; Wed, 23 Sep 2020 13:34:06 +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 75E458C7D8; Wed, 23 Sep 2020 13:34:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NDXwNK013925 for ; Wed, 23 Sep 2020 09:33:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B71641002C04; Wed, 23 Sep 2020 13:33:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDBC0100239F for ; Wed, 23 Sep 2020 13:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868106; 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=5B+NwoKkKvIBaOHeo9z9LZbl93ODDAcbKGNzunarT68=; b=TDzIz2aq6k+LdhvHM10stGxD3P4bb16l4DtVdNOVGukX/zbXYXocC9QjlUCdrsz5Dz8GGG l6G1HS+ROG2NfXZIr41AQTQKwg2NZQYgC3wRfWOi85r7ED2nwI8ulOLFTVfV0TkMg0JEzr EYbmQN54uy5qviH1uh1r8hvBk2Q25h4= X-MC-Unique: fGdnyGhEO1KkRhwF8MDXNg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/13] virDomainSnapshotAlignDisks: Add 'domdef' local variable Date: Wed, 23 Sep 2020 15:33:39 +0200 Message-Id: <14d0e2a4ad28d500a3d31999bd2c904ce32dbba2.1600867955.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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 multiple places accessing the domain definition. Extract it to a local variable so that it's more clear what's happening. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index c835ec7333..a1cee01944 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -649,33 +649,34 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, int default_snapshot, bool require_match) { + virDomainDefPtr domdef =3D snapdef->parent.dom; g_autoptr(virBitmap) map =3D NULL; size_t i; int ndisks; - if (!snapdef->parent.dom) { + if (!domdef) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); return -1; } - if (snapdef->ndisks > snapdef->parent.dom->ndisks) { + if (snapdef->ndisks > domdef->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("too many disk snapshot requests for domain")); return -1; } /* Unlikely to have a guest without disks but technically possible. */ - if (!snapdef->parent.dom->ndisks) + if (!domdef->ndisks) return 0; - if (!(map =3D virBitmapNew(snapdef->parent.dom->ndisks))) + if (!(map =3D virBitmapNew(domdef->ndisks))) return -1; /* Double check requested disks. */ for (i =3D 0; i < snapdef->ndisks; i++) { virDomainSnapshotDiskDefPtr snapdisk =3D &snapdef->disks[i]; - int idx =3D virDomainDiskIndexByName(snapdef->parent.dom, snapdisk= ->name, false); + int idx =3D virDomainDiskIndexByName(domdef, snapdisk->name, false= ); int disk_snapshot; if (idx < 0) { @@ -693,7 +694,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, ignore_value(virBitmapSetBit(map, idx)); snapdisk->idx =3D idx; - disk_snapshot =3D snapdef->parent.dom->disks[idx]->snapshot; + disk_snapshot =3D domdef->disks[idx]->snapshot; if (!snapdisk->snapshot) { if (disk_snapshot && (!require_match || @@ -721,33 +722,33 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, snapdisk->src->path, snapdisk->name); return -1; } - if (STRNEQ(snapdisk->name, snapdef->parent.dom->disks[idx]->dst)) { + if (STRNEQ(snapdisk->name, domdef->disks[idx]->dst)) { VIR_FREE(snapdisk->name); - snapdisk->name =3D g_strdup(snapdef->parent.dom->disks[idx]->d= st); + snapdisk->name =3D g_strdup(domdef->disks[idx]->dst); } } /* Provide defaults for all remaining disks. */ ndisks =3D snapdef->ndisks; if (VIR_EXPAND_N(snapdef->disks, snapdef->ndisks, - snapdef->parent.dom->ndisks - snapdef->ndisks) < 0) + domdef->ndisks - snapdef->ndisks) < 0) return -1; - for (i =3D 0; i < snapdef->parent.dom->ndisks; i++) { + for (i =3D 0; i < domdef->ndisks; i++) { virDomainSnapshotDiskDefPtr snapdisk; if (virBitmapIsBitSet(map, i)) continue; snapdisk =3D &snapdef->disks[ndisks++]; snapdisk->src =3D virStorageSourceNew(); - snapdisk->name =3D g_strdup(snapdef->parent.dom->disks[i]->dst); + snapdisk->name =3D g_strdup(domdef->disks[i]->dst); snapdisk->idx =3D i; /* Don't snapshot empty drives */ - if (virStorageSourceIsEmpty(snapdef->parent.dom->disks[i]->src)) + if (virStorageSourceIsEmpty(domdef->disks[i]->src)) snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; else - snapdisk->snapshot =3D snapdef->parent.dom->disks[i]->snapshot; + snapdisk->snapshot =3D domdef->disks[i]->snapshot; snapdisk->src->type =3D VIR_STORAGE_TYPE_FILE; if (!snapdisk->snapshot) --=20 2.26.2