From nobody Mon Nov 25 14:51: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=1600868051; cv=none; d=zohomail.com; s=zohoarc; b=lLHjV/DcISk7wwi64UsFVqhH/4JvYKOIlsCBAs1j42rG6zZwAzrRgGzP3jPDqwHVgEUxO0cq36RsuSZpB/ryUS7tKZRQ7BgkI0qlbIiwsBf2LaUYT3zwP70qzuuIAOEeVYkcuYJ4VSZL8A/2AECOwZt0r09UgXes9rHKqY1ti0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868051; 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=AmJhZJLZe8T+15VKh37oEMrOh0gcd0RMnQporL9/Ygw=; b=Ud0j7XLLCcgAdMKQo2u2lflaDVgkHTYQGYkR4UOMqcmds5JZbA+NGn4RsYOqf1GlRFXjaoM4boE17x+eUDQTnrhGUcMrFiB7NQ8fc+DODbHYzq23hgrLTxXlioADE+Nq3Dk8IJLRaPaS+jqGq1WO+9JqO1Gp//HBhWdHOSWNnN4= 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 1600868051190269.8184863529999; Wed, 23 Sep 2020 06:34:11 -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-75-POFrh-gvNUKfxLXbkweMIQ-1; Wed, 23 Sep 2020 09:34:07 -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 A89F9801AFD; Wed, 23 Sep 2020 13:34:00 +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 8604C10027AB; Wed, 23 Sep 2020 13:34:00 +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 5103C183D044; Wed, 23 Sep 2020 13:34:00 +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 08NDXpUr013854 for ; Wed, 23 Sep 2020 09:33:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0926C100239F; Wed, 23 Sep 2020 13:33:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0690100238E for ; Wed, 23 Sep 2020 13:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868049; 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=AmJhZJLZe8T+15VKh37oEMrOh0gcd0RMnQporL9/Ygw=; b=RpRhXsBaPByod+ASd/JigZOq8mMZ8R8ZA6204a4fx9hOb9H7GuQu+7KneqNSafhvfb63l6 ZdPmXSN8JLyv/xyCWQkUIiKngCcBTRLtNKiUB3bkyPcRmZjSwjNuoXHR+WyyQX7yVOUCIe xa8KS1pa6WesrBK7iQOo2u1pQlyilNg= X-MC-Unique: POFrh-gvNUKfxLXbkweMIQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/13] virStorageSourceNew: Abort on failure Date: Wed, 23 Sep 2020 15:33:32 +0200 Message-Id: <3f55638841ee33f0305b4e49eff97a1ae66f40c2.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.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" Add an abort() on the class/object allocation failures so that virStorageSourceNew() always returns a virStorageSource and remove checks from all callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/backup_conf.c | 7 ++---- src/conf/domain_conf.c | 21 ++++++------------ src/conf/snapshot_conf.c | 7 ++---- src/conf/storage_conf.c | 4 +--- src/qemu/qemu_domain.c | 21 ++++++------------ src/qemu/qemu_driver.c | 12 +++------- src/qemu/qemu_migration.c | 7 ++---- src/qemu/qemu_snapshot.c | 3 +-- src/storage/storage_backend_gluster.c | 5 +---- src/storage/storage_backend_logical.c | 4 +--- src/storage/storage_util.c | 10 +++------ src/util/virstoragefile.c | 32 ++++++++++----------------- tests/qemublocktest.c | 16 +++----------- tests/virstoragetest.c | 5 +---- 14 files changed, 46 insertions(+), 108 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 5caba621d8..5c475239ad 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -169,8 +169,7 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, def->state =3D tmp; } - if (!(def->store =3D virStorageSourceNew())) - return -1; + def->store =3D virStorageSourceNew(); if ((type =3D virXMLPropString(node, "type"))) { if ((def->store->type =3D virStorageTypeFromString(type)) <=3D 0) { @@ -500,9 +499,7 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDefPtr= disk, } } else if (!disk->store) { if (virStorageSourceGetActualType(src) =3D=3D VIR_STORAGE_TYPE_FIL= E) { - if (!(disk->store =3D virStorageSourceNew())) - return -1; - + disk->store =3D virStorageSourceNew(); disk->store->type =3D VIR_STORAGE_TYPE_FILE; disk->store->path =3D g_strdup_printf("%s.%s", src->path, suff= ix); } else { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9289c147fe..bbe3cddadf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2187,8 +2187,7 @@ virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt) if (VIR_ALLOC(ret) < 0) return NULL; - if (!(ret->src =3D virStorageSourceNew())) - goto error; + ret->src =3D virStorageSourceNew(); if (xmlopt && xmlopt->privateData.diskNew && @@ -2400,8 +2399,7 @@ virDomainFSDefNew(virDomainXMLOptionPtr xmlopt) if (VIR_ALLOC(ret) < 0) return NULL; - if (!(ret->src =3D virStorageSourceNew())) - goto cleanup; + ret->src =3D virStorageSourceNew(); if (xmlopt && xmlopt->privateData.fsNew && @@ -8325,9 +8323,8 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, if (flags & VIR_DOMAIN_DEF_PARSE_STATUS && xmlopt && xmlopt->privateData.storageParse) { if ((ctxt->node =3D virXPathNode("./privateData", ctxt))) { - if (!scsihostsrc->src && - !(scsihostsrc->src =3D virStorageSourceNew())) - return -1; + if (!scsihostsrc->src) + scsihostsrc->src =3D virStorageSourceNew(); if (xmlopt->privateData.storageParse(ctxt, scsihostsrc->src) <= 0) return -1; } @@ -8353,8 +8350,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr= sourcenode, /* For the purposes of command line creation, this needs to look * like a disk storage source */ - if (!(iscsisrc->src =3D virStorageSourceNew())) - return -1; + iscsisrc->src =3D virStorageSourceNew(); iscsisrc->src->type =3D VIR_STORAGE_TYPE_NETWORK; iscsisrc->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; @@ -9770,9 +9766,7 @@ virDomainStorageSourceParseBase(const char *type, { g_autoptr(virStorageSource) src =3D NULL; - if (!(src =3D virStorageSourceNew())) - return NULL; - + src =3D virStorageSourceNew(); src->type =3D VIR_STORAGE_TYPE_FILE; if (type && @@ -9960,8 +9954,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctx= t, /* terminator does not have a type */ if (!(type =3D virXMLPropString(ctxt->node, "type"))) { - if (!(src->backingStore =3D virStorageSourceNew())) - return -1; + src->backingStore =3D virStorageSourceNew(); return 0; } diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 1ee63b9141..87a00082ef 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -148,9 +148,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, ctxt->node =3D node; - if (!(def->src =3D virStorageSourceNew())) - goto cleanup; - + def->src =3D virStorageSourceNew(); def->name =3D virXMLPropString(node, "name"); if (!def->name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -744,8 +742,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, if (virBitmapIsBitSet(map, i)) continue; disk =3D &def->disks[ndisks++]; - if (!(disk->src =3D virStorageSourceNew())) - goto cleanup; + disk->src =3D virStorageSourceNew(); disk->name =3D g_strdup(def->parent.dom->disks[i]->dst); disk->idx =3D i; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 001f4f2bdd..2b00f09d73 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1350,9 +1350,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, } if ((backingStore =3D virXPathString("string(./backingStore/path)", ct= xt))) { - if (!(def->target.backingStore =3D virStorageSourceNew())) - return NULL; - + def->target.backingStore =3D virStorageSourceNew(); def->target.backingStore->type =3D VIR_STORAGE_TYPE_FILE; def->target.backingStore->path =3D backingStore; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9e0d3a15b2..c7a3e4f7cc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5273,9 +5273,8 @@ qemuDomainDeviceHostdevDefPostParseRestoreBackendAlia= s(virDomainHostdevDefPtr ho switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: - if (!scsisrc->u.host.src && - !(scsisrc->u.host.src =3D virStorageSourceNew())) - return -1; + if (!scsisrc->u.host.src) + scsisrc->u.host.src =3D virStorageSourceNew(); src =3D scsisrc->u.host.src; break; @@ -7167,9 +7166,8 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, } /* terminate the chain for such images as the code below would do = */ - if (!disksrc->backingStore && - !(disksrc->backingStore =3D virStorageSourceNew())) - return -1; + if (!disksrc->backingStore) + disksrc->backingStore =3D virStorageSourceNew(); /* host cdrom requires special treatment in qemu, so we need to ch= eck * whether a block device is a cdrom */ @@ -10456,8 +10454,7 @@ qemuDomainPrepareHostdev(virDomainHostdevDefPtr hos= tdev, switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: virObjectUnref(scsisrc->u.host.src); - if (!(scsisrc->u.host.src =3D virStorageSourceNew())) - return -1; + scsisrc->u.host.src =3D virStorageSourceNew(); src =3D scsisrc->u.host.src; break; @@ -10850,9 +10847,7 @@ qemuDomainInitializePflashStorageSource(virDomainOb= jPtr vm) if (!virDomainDefHasOldStyleUEFI(def)) return 0; - if (!(pflash0 =3D virStorageSourceNew())) - return -1; - + pflash0 =3D virStorageSourceNew(); pflash0->type =3D VIR_STORAGE_TYPE_FILE; pflash0->format =3D VIR_STORAGE_FILE_RAW; pflash0->path =3D g_strdup(def->os.loader->path); @@ -10862,9 +10857,7 @@ qemuDomainInitializePflashStorageSource(virDomainOb= jPtr vm) if (def->os.loader->nvram) { - if (!(pflash1 =3D virStorageSourceNew())) - return -1; - + pflash1 =3D virStorageSourceNew(); pflash1->type =3D VIR_STORAGE_TYPE_FILE; pflash1->format =3D VIR_STORAGE_FILE_RAW; pflash1->path =3D g_strdup(def->os.loader->nvram); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ae715c01d7..9b5ff3a65c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14895,10 +14895,8 @@ qemuDomainBlockCopyCommonValidateUserMirrorBacking= Store(virStorageSourcePtr mirr { if (!virStorageSourceHasBacking(mirror)) { /* for deep copy there won't be backing chain so we can terminate = it */ - if (!mirror->backingStore && - !shallow && - !(mirror->backingStore =3D virStorageSourceNew())) - return -1; + if (!mirror->backingStore && !shallow) + mirror->backingStore =3D virStorageSourceNew(); /* When reusing an external image we document that the user must e= nsure * that the image must expose data as the original image = did @@ -15149,9 +15147,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_SNAPSHOT= _ALLOW_WRITE_ONLY)) { g_autoptr(virStorageSource) terminator =3D virStorageSourc= eNew(); - if (!terminator) - goto endjob; - if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlo= ckdevTop(mirror, = terminator, = priv->qemuCaps))) @@ -15296,8 +15291,7 @@ qemuDomainBlockRebase(virDomainPtr dom, const char = *path, const char *base, return qemuDomainBlockPullCommon(vm, path, base, bandwidth, flags); /* If we got here, we are doing a block copy rebase. */ - if (!(dest =3D virStorageSourceNew())) - goto cleanup; + dest =3D virStorageSourceNew(); dest->type =3D (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) ? VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE; dest->path =3D g_strdup(base); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a530c17582..5708334d2f 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -837,15 +837,12 @@ qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(v= irDomainDiskDefPtr disk, { g_autoptr(virStorageSource) copysrc =3D NULL; - if (!(copysrc =3D virStorageSourceNew())) - return NULL; - + copysrc =3D virStorageSourceNew(); copysrc->type =3D VIR_STORAGE_TYPE_NETWORK; copysrc->protocol =3D VIR_STORAGE_NET_PROTOCOL_NBD; copysrc->format =3D VIR_STORAGE_FILE_RAW; - if (!(copysrc->backingStore =3D virStorageSourceNew())) - return NULL; + copysrc->backingStore =3D virStorageSourceNew(); if (!(copysrc->path =3D qemuAliasDiskDriveFromDisk(disk))) return NULL; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5f49fd17a4..a6e091dd09 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -894,8 +894,7 @@ qemuSnapshotDiskPrepareOneBlockdev(virQEMUDriverPtr dri= ver, /* create a terminator for the snapshot disks so that qemu does not try * to open them at first */ - if (!(terminator =3D virStorageSourceNew())) - return -1; + terminator =3D virStorageSourceNew(); if (qemuDomainPrepareStorageSourceBlockdev(dd->disk, dd->src, priv, cfg) < 0) diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 70e6f2b086..4763a569e3 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -279,11 +279,8 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGl= usterStatePtr state, goto cleanup; if (meta->backingStoreRaw) { - if (!(vol->target.backingStore =3D virStorageSourceNew())) - goto cleanup; - + vol->target.backingStore =3D virStorageSourceNew(); vol->target.backingStore->type =3D VIR_STORAGE_TYPE_NETWORK; - vol->target.backingStore->path =3D g_steal_pointer(&meta->backingS= toreRaw); vol->target.backingStore->format =3D meta->backingStoreRawFormat; diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 43cf3a1598..e3debc390c 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -282,9 +282,7 @@ virStorageBackendLogicalMakeVol(char **const groups, * lv is created with "--virtualsize"). */ if (groups[1] && STRNEQ(groups[1], "") && (groups[1][0] !=3D '[')) { - if (!(vol->target.backingStore =3D virStorageSourceNew())) - goto cleanup; - + vol->target.backingStore =3D virStorageSourceNew(); vol->target.backingStore->path =3D g_strdup_printf("%s/%s", def->target.path,= groups[1]); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 9171cb084f..08d9bd4172 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3389,8 +3389,7 @@ storageBackendProbeTarget(virStorageSourcePtr target, return -1; if (meta->backingStoreRaw) { - if (virStorageSourceNewFromBacking(meta, &target->backingStore) < = 0) - return -1; + virStorageSourceNewFromBacking(meta, &target->backingStore); /* XXX: Remote storage doesn't play nicely with volumes backed by * remote storage. To avoid trouble, just fake the backing store i= s RAW @@ -3398,9 +3397,7 @@ storageBackendProbeTarget(virStorageSourcePtr target, if (!virStorageSourceIsLocalStorage(target->backingStore)) { virObjectUnref(target->backingStore); - if (!(target->backingStore =3D virStorageSourceNew())) - return -1; - + target->backingStore =3D virStorageSourceNew(); target->backingStore->type =3D VIR_STORAGE_TYPE_NETWORK; target->backingStore->path =3D meta->backingStoreRaw; meta->backingStoreRaw =3D NULL; @@ -3568,8 +3565,7 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr po= ol) goto cleanup; VIR_DIR_CLOSE(dir); - if (!(target =3D virStorageSourceNew())) - goto cleanup; + target =3D virStorageSourceNew(); if ((fd =3D open(def->target.path, O_RDONLY)) < 0) { virReportSystemError(errno, diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 42341150e5..229de14935 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1084,10 +1084,7 @@ static virStorageSourcePtr virStorageFileMetadataNew(const char *path, int format) { - g_autoptr(virStorageSource) def =3D NULL; - - if (!(def =3D virStorageSourceNew())) - return NULL; + g_autoptr(virStorageSource) def =3D virStorageSourceNew(); def->format =3D format; def->type =3D VIR_STORAGE_TYPE_FILE; @@ -2368,10 +2365,7 @@ virStorageSourcePtr virStorageSourceCopy(const virStorageSource *src, bool backingChain) { - g_autoptr(virStorageSource) def =3D NULL; - - if (!(def =3D virStorageSourceNew())) - return NULL; + g_autoptr(virStorageSource) def =3D virStorageSourceNew(); def->id =3D src->id; def->type =3D src->type; @@ -2746,10 +2740,15 @@ VIR_ONCE_GLOBAL_INIT(virStorageSource); virStorageSourcePtr virStorageSourceNew(void) { + virStorageSourcePtr ret; + if (virStorageSourceInitialize() < 0) - return NULL; + abort(); + + if (!(ret =3D virObjectNew(virStorageSourceClass))) + abort(); - return virObjectNew(virStorageSourceClass); + return ret; } @@ -2758,10 +2757,7 @@ virStorageSourceNewFromBackingRelative(virStorageSou= rcePtr parent, const char *rel) { g_autofree char *dirname =3D NULL; - g_autoptr(virStorageSource) def =3D NULL; - - if (!(def =3D virStorageSourceNew())) - return NULL; + g_autoptr(virStorageSource) def =3D virStorageSourceNew(); /* store relative name */ def->relPath =3D g_strdup(rel); @@ -3980,13 +3976,10 @@ virStorageSourceNewFromBackingAbsolute(const char *= path, const char *json; const char *dirpath; int rc =3D 0; - g_autoptr(virStorageSource) def =3D NULL; + g_autoptr(virStorageSource) def =3D virStorageSourceNew(); *src =3D NULL; - if (!(def =3D virStorageSourceNew())) - return -1; - if (virStorageIsFile(path)) { def->type =3D VIR_STORAGE_TYPE_FILE; @@ -5317,8 +5310,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, src->backingStore =3D g_steal_pointer(&backingStore); } else { /* add terminator */ - if (!(src->backingStore =3D virStorageSourceNew())) - return -1; + src->backingStore =3D virStorageSourceNew(); } return 0; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 0685b703a1..7bde613843 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -67,9 +67,7 @@ testBackingXMLjsonXML(const void *args) if (data->legacy) backendpropsflags |=3D QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEG= ACY; - if (!(xmlsrc =3D virStorageSourceNew())) - return -1; - + xmlsrc =3D virStorageSourceNew(); xmlsrc->type =3D data->type; if (!(xml =3D virXMLParseStringCtxt(data->xml, "(test storage source X= ML)", &ctxt))) @@ -673,10 +671,7 @@ testQemuBitmapListPrint(const char *title, static virStorageSourcePtr testQemuBackupIncrementalBitmapCalculateGetFakeImage(size_t idx) { - virStorageSourcePtr ret; - - if (!(ret =3D virStorageSourceNew())) - abort(); + virStorageSourcePtr ret =3D virStorageSourceNew(); ret->id =3D idx; ret->type =3D VIR_STORAGE_TYPE_FILE; @@ -755,9 +750,7 @@ testQemuBackupIncrementalBitmapCalculate(const void *op= aque) return -1; } - if (!(target =3D virStorageSourceNew())) - return -1; - + target =3D virStorageSourceNew(); target->nodeformat =3D g_strdup_printf("target_node"); if (qemuBackupDiskPrepareOneBitmapsChain(data->chain, @@ -889,9 +882,6 @@ testQemuBlockBitmapBlockcopy(const void *opaque) g_autoptr(virStorageSource) fakemirror =3D virStorageSourceNew(); g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - if (!fakemirror) - return -1; - fakemirror->nodeformat =3D g_strdup("mirror-format-node"); expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index e0f8b6d621..2e466ecb99 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -85,10 +85,7 @@ testStorageFileGetMetadata(const char *path, uid_t uid, gid_t gid) { struct stat st; - g_autoptr(virStorageSource) def =3D NULL; - - if (!(def =3D virStorageSourceNew())) - return NULL; + g_autoptr(virStorageSource) def =3D virStorageSourceNew(); def->type =3D VIR_STORAGE_TYPE_FILE; def->format =3D format; --=20 2.26.2 From nobody Mon Nov 25 14:51:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1600868045; cv=none; d=zohomail.com; s=zohoarc; b=fLCfpzkbus9G0jIUZMRev7psPfAzO7fFcTePoBQOkgCFMqszLWh8ZatVdUBTR5Xg/pyksioF0eolZPeCCvgv3Rjwq+0fqgkHgNZ4x9/cBIQG+dk0VE1ig1iTJf3xqnEo8pV6gKbYerEPR2FIzFBLW7A1xKdi7JiIVJ8xrcsm6Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868045; 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=jklZL/eXuhby3n7lRCWwll+RY01rqpe23ET9f358kwM=; b=NjlXHWJzyVIXnXVh4UxQUy6spNxHe/YFhhM0fWNqM4i/8n+xDiK5UvUBxQvx8sTfYRTf/AS0h8YLam/vbXBKudMyFg8sVBAMPlbp89CnkFucPSpMvb3MKyuPfEqhkjBZHw93ka3WyVOc48nc312vp/LeQ1EUydbT7j0Gg5ZBKck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1600868045468438.77040935169236; Wed, 23 Sep 2020 06:34:05 -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-352-LNpoTNgrOxSZXBXJWpXNPg-1; Wed, 23 Sep 2020 09:34:01 -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 BB20310BBECD; Wed, 23 Sep 2020 13:33:56 +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 9444C10027A5; Wed, 23 Sep 2020 13:33:56 +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 6BF568C7AE; Wed, 23 Sep 2020 13:33:55 +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 08NDXqhr013863 for ; Wed, 23 Sep 2020 09:33:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AEC3100238E; Wed, 23 Sep 2020 13:33:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 773341002C04 for ; Wed, 23 Sep 2020 13:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868044; 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=jklZL/eXuhby3n7lRCWwll+RY01rqpe23ET9f358kwM=; b=ghNw2Lv/fcwaGxoa1fvD7tMulrMOrbqrVidMVQUguSY00m0Ln39n0XeU0+qVoC6fmByh3f hJN3ZV8Zr4JmG5IZ8OR8nfVbBvm8nmzUzkgTBGhWSAAYVD61BcLHfTH8LdSIzgAecdccCf rXJ3RQOO9ESPmT13mUfhu8G2mZ1gdcM= X-MC-Unique: LNpoTNgrOxSZXBXJWpXNPg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/13] virStorageVolDefParseXML: Use g_steal_pointer Date: Wed, 23 Sep 2020 15:33:33 +0200 Message-Id: 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.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" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/storage_conf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 2b00f09d73..d53d50479b 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1352,9 +1352,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, if ((backingStore =3D virXPathString("string(./backingStore/path)", ct= xt))) { def->target.backingStore =3D virStorageSourceNew(); def->target.backingStore->type =3D VIR_STORAGE_TYPE_FILE; - - def->target.backingStore->path =3D backingStore; - backingStore =3D NULL; + def->target.backingStore->path =3D g_steal_pointer(&backingStore); if (options->formatFromString) { g_autofree char *format =3D NULL; --=20 2.26.2 From nobody Mon Nov 25 14:51: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=1600868107; cv=none; d=zohomail.com; s=zohoarc; b=f43csaVwe58Zdv7LP/zGLgyec1QDdi+ZHUJrJSZOyQjzE4XJM9d6m3HWEyzH20D1GdvLV4rmTzeLjPWlHh7yX6aj9CPUAhdv8Tcrrlk7W+MRvi6J1spu/z98ofZM3LY+iBUzGNkqllOtlDOecws+5WzYAp0k3ghHxAU6vJ45bxg= 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=sxGnnUEw1pislmJCMufLCMR7v0vLkNoXhBin1dQ0Bnc=; b=apaH1D6B+8++JOiWnkZVnx99EJJYG2Yo0IAzOodjwfnQxFKUlReFWpZikH7Kws1TM1XilEfB1DFxrya/+mUHdr7XZ0uBe4p3fskn/RPNu6B/q6y8u4WjlO86C/uQDMX2sWL9uARIDpFjpH+J+uS5ED7bDyciYzMhkUfltOZ4qe8= 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 1600868107056987.5497324254742; 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-168-OPrGh5x3O5eCC_cm6ewU_g-1; Wed, 23 Sep 2020 09:34:10 -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 72096801AF2; Wed, 23 Sep 2020 13:34:03 +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 492B9100239F; Wed, 23 Sep 2020 13:34:03 +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 141E28C7D5; Wed, 23 Sep 2020 13:34:03 +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 08NDXrsR013871 for ; Wed, 23 Sep 2020 09:33:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2AECE10021AA; Wed, 23 Sep 2020 13:33:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 859D310027A5 for ; Wed, 23 Sep 2020 13:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868105; 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=sxGnnUEw1pislmJCMufLCMR7v0vLkNoXhBin1dQ0Bnc=; b=ZH7b3skexM+zGRCjXOBCuEdmLNfWZfOugxrCniIpvCEBP7AfKcjLyyT4wF8xzYliNYwF6f q+RTGD7Zv3Ue3RsPzHwixvKJ4VHpbT2eSVH8+zHEqiqQB3+f6Nyh2Qrfaz/jm8C2L3prKi V+pwKQPUCx2t8NuQrkyCsByuaLAOHwA= X-MC-Unique: OPrGh5x3O5eCC_cm6ewU_g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/13] qemuDomainBlockRebase: Replace ternary operator with if/else Date: Wed, 23 Sep 2020 15:33:34 +0200 Message-Id: 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.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" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9b5ff3a65c..40d11aced6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15292,8 +15292,10 @@ qemuDomainBlockRebase(virDomainPtr dom, const char= *path, const char *base, /* If we got here, we are doing a block copy rebase. */ dest =3D virStorageSourceNew(); - dest->type =3D (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) ? - VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE; + if (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) + dest->type =3D VIR_STORAGE_TYPE_BLOCK; + else + dest->type =3D VIR_STORAGE_TYPE_FILE; dest->path =3D g_strdup(base); if (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_RAW) dest->format =3D VIR_STORAGE_FILE_RAW; --=20 2.26.2 From nobody Mon Nov 25 14:51: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=1600868052; cv=none; d=zohomail.com; s=zohoarc; b=TJ/EMdMRIirZt3CGUs0f9itCHY+8FA4+kjblVN6LfQt1ZGmHd9EusBFTCdVaIXyC7TofzwH4brGkyRlhkE0xCSTt7w5qaHmO0snRU3aiZoMjJH/GKEE0T4soZ0ij1TVTs90JpxFBdIJNW2fog8YzxeQFiJ65LOnezhkuDI0SsL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868052; 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=d66vPxTgEQejEvWY2pqbA/PQJommdKhEJZrx/tR1zE8=; b=TMYNsqg4UMsT9sdLWVDXJP5MiopJDjkcEZkijBvTbvfoV9XPG1UCrBEwsh4BOT4A/XyCzEKRvOZda0Yw9mLe+4rMxqwNjx4v4REp5Yh0hu0mRp1/z+rJ8Z6GNwrecH7mbRi8d+jDO8bUqRdvK1KBZsx2jlGavzKGgxkDvvd3Ka4= 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 1600868052339730.8740114411733; Wed, 23 Sep 2020 06:34:12 -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-257-n6L_WNMSO-SgrKdi4qU_yg-1; Wed, 23 Sep 2020 09:34:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7ACE68ECE40; Wed, 23 Sep 2020 13:34:01 +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 5B8BB78816; Wed, 23 Sep 2020 13:34:01 +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 2A2AC8C7CA; Wed, 23 Sep 2020 13:34:01 +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 08NDXswK013880 for ; Wed, 23 Sep 2020 09:33:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3791310021AA; Wed, 23 Sep 2020 13:33:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9919010023A7 for ; Wed, 23 Sep 2020 13:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868051; 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=d66vPxTgEQejEvWY2pqbA/PQJommdKhEJZrx/tR1zE8=; b=J8rETr1Q1u6ZcJerLxBhY15OfxtjhBLXaCfnc/k486mvZi1UNFBZoLB9GRpsP5hfcDQg59 jCumb0+igQWvE9YK6OgfTVCa+xsQbAb9cUbtBhXfg3Cohyz0LtXmDYLMWpHkrHbikOgEGt 2rjvraqFZ0O2cGU4bVmYrBU7KDkzqH8= X-MC-Unique: n6L_WNMSO-SgrKdi4qU_yg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/13] qemuSnapshotCreateInactiveExternal: Don't access 'idx' of snapshot Date: Wed, 23 Sep 2020 15:33:35 +0200 Message-Id: <804bd3aa352e2855b7bd3f5e88f6e02156a81f1f.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.11 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 virDomainSnapshotAlignDisks is called the definitions of disks in the snapshot definition and in the domain definition are in the same order so they can be addressed using the same index. This frees up 'idx' to be removed later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index a6e091dd09..48a4e9dd41 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -171,7 +171,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriverPtr dri= ver, * create them correctly. */ for (i =3D 0; i < snapdef->ndisks && !reuse; i++) { snapdisk =3D &(snapdef->disks[i]); - defdisk =3D snapdef->parent.dom->disks[snapdisk->idx]; + defdisk =3D vm->def->disks[i]; if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; @@ -216,7 +216,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriverPtr dri= ver, g_autoptr(virStorageSource) newsrc =3D NULL; snapdisk =3D &(snapdef->disks[i]); - defdisk =3D vm->def->disks[snapdisk->idx]; + defdisk =3D vm->def->disks[i]; if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; --=20 2.26.2 From nobody Mon Nov 25 14:51: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=1600868048; cv=none; d=zohomail.com; s=zohoarc; b=YpqKUNH04+3J+pBBZe1yiUuiaeEGEq5SjsJY802tMfq8YsMNFwhd6lEmkwFhoIin4NZQnz+HU+XypA7iTQV5Q+B40HNk896ZM3jDdzhZgtzbUu9TgCGM11o4KGN/KEr/h7vrgMGDQXxfAW3UvIwXTY9K+oMqSBk4EixmZmffZp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868048; 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=XG51X0f/RI3xbqMaCH/2G+KZ/BoxRt4q0h521VaiPg8=; b=mFNbIwLbfWjQnCp3e02lh+FUgLXgeUQabEDnOiJ95EGV9Bv4qJuBisDelvnGAHA+8C9fXAuL1LFxtshqT/gzx40kclKCBZaepC1ADG67URyVxzgVghR5qope756O9AcgzLrCse9Rzus+EyfqGgyE3BOgie0Megu3a4LMGo9Mv0E= 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 1600868048786305.43954174734347; Wed, 23 Sep 2020 06:34:08 -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-72-rreKZGbzMX6aTmM222W3rA-1; Wed, 23 Sep 2020 09:34:05 -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 1F48E801AE9; Wed, 23 Sep 2020 13:34:00 +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 EC49A55777; Wed, 23 Sep 2020 13:33:59 +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 57024183D043; Wed, 23 Sep 2020 13:33:59 +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 08NDXtwn013891 for ; Wed, 23 Sep 2020 09:33:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42637100238E; Wed, 23 Sep 2020 13:33:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9981810021AA for ; Wed, 23 Sep 2020 13:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868047; 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=XG51X0f/RI3xbqMaCH/2G+KZ/BoxRt4q0h521VaiPg8=; b=dhcn6AH51Qv7KUR6XUtkB3ZnjQB81s2luF5md+bd3IS7HhCB6UP+4DSft4HHo04fRXOTWg QXWlRoz3IOkZuAkMFxRadFkvpyLR2zZlcleUlwIouwDwt5sZHPOMIsAOcTjhBB2AHuaCJu 8yXDtWtoP8jEEtCbD7G771GgDgN2P18= X-MC-Unique: rreKZGbzMX6aTmM222W3rA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/13] virDomainSnapshotAlignDisks: Refactor cleanup Date: Wed, 23 Sep 2020 15:33:36 +0200 Message-Id: <7a66077024983a0c79718cf7d7d13f1b78559b2f.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.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" Use automatic pointer for the bitmap and get rid of the 'cleanup' label and 'ret' variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 87a00082ef..160f2054a4 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -649,31 +649,28 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, int default_snapshot, bool require_match) { - int ret =3D -1; - virBitmapPtr map =3D NULL; + g_autoptr(virBitmap) map =3D NULL; size_t i; int ndisks; if (!def->parent.dom) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); - goto cleanup; + return -1; } if (def->ndisks > def->parent.dom->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("too many disk snapshot requests for domain")); - goto cleanup; + return -1; } /* Unlikely to have a guest without disks but technically possible. */ - if (!def->parent.dom->ndisks) { - ret =3D 0; - goto cleanup; - } + if (!def->parent.dom->ndisks) + return 0; if (!(map =3D virBitmapNew(def->parent.dom->ndisks))) - goto cleanup; + return -1; /* Double check requested disks. */ for (i =3D 0; i < def->ndisks; i++) { @@ -684,14 +681,14 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, if (idx < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("no disk named '%s'"), disk->name); - goto cleanup; + return -1; } if (virBitmapIsBitSet(map, idx)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' specified twice"), disk->name); - goto cleanup; + return -1; } ignore_value(virBitmapSetBit(map, idx)); disk->idx =3D idx; @@ -714,7 +711,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' must use snapshot mode '%s'"), disk->name, tmp); - goto cleanup; + return -1; } if (disk->src->path && disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { @@ -722,7 +719,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, _("file '%s' for disk '%s' requires " "use of external snapshot mode"), disk->src->path, disk->name); - goto cleanup; + return -1; } if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) { VIR_FREE(disk->name); @@ -734,7 +731,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, ndisks =3D def->ndisks; if (VIR_EXPAND_N(def->disks, def->ndisks, def->parent.dom->ndisks - def->ndisks) < 0) - goto cleanup; + return -1; for (i =3D 0; i < def->parent.dom->ndisks; i++) { virDomainSnapshotDiskDefPtr disk; @@ -762,13 +759,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr de= f, /* Generate default external file names for external snapshot location= s */ if (virDomainSnapshotDefAssignExternalNames(def) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virBitmapFree(map); - return ret; + return 0; } --=20 2.26.2 From nobody Mon Nov 25 14:51: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=1600868051; cv=none; d=zohomail.com; s=zohoarc; b=GM9gBMRZ9NAns95HmQUgAg7kCVIcwV+WTDrtyx0NgAvOQZw947VSfqTI+zQXbOcDhsRgRcehzhixKGGlXxl1lCl2Bx7Ht8A2ik8GuoIjBBb456rrAQ39ecuUT0+HQDHBN8Vx5OA7S7v6x/J/ST4HYWptPiitRpOu2JZl5EeheSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868051; 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=S6N6QNaICngVmM1NzTy4V66ApqZOAs+Cs93kWDoDAfU=; b=WG5kcUCJr3LL+2rQX+iY+W9AvKoiLOXqrO0iNUZ6p/ZOSc03GCMtLEGL1bZRyDWrFjXcchrilRTUZsS0hD8bZygk/LV/l5hEAzmxMeP/PxHvD+cSRJCEKo5Clwl3nnQLzol6R+3Om3QUi+lDjnSrCmriaymqd8YsD+cbiivFr9w= 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 1600868051261628.264317578537; Wed, 23 Sep 2020 06:34:11 -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-568-SJN2D5xdOnWXwwxcRg4Ynw-1; Wed, 23 Sep 2020 09:34:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E58718BA284; Wed, 23 Sep 2020 13:34:02 +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 4E69078816; Wed, 23 Sep 2020 13:34:02 +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 178968C7CE; Wed, 23 Sep 2020 13:34:02 +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 08NDXuQP013906 for ; Wed, 23 Sep 2020 09:33:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 671161002C05; Wed, 23 Sep 2020 13:33:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB5AB1002C04 for ; Wed, 23 Sep 2020 13:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868049; 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=S6N6QNaICngVmM1NzTy4V66ApqZOAs+Cs93kWDoDAfU=; b=KP0JQSrExp2zbGBUaTcErRwKTFyItmgmCPv0E7K/yYvwzS4ntQA26rbN8h85kd1wuCmtQP iKcWuuWbPezLiZvS6WRwKEiKgsLw7n9tOBiCFzc1X+e6NOPaBU8hiG5UpW2AZ2tBCCU3C/ u9HOBT/WXXLJcsAewKeBRmmUZ0U0ZK4= X-MC-Unique: SJN2D5xdOnWXwwxcRg4Ynw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/13] virDomainSnapshotAlignDisks: Rename 'def' -> 'snapdef' Date: Wed, 23 Sep 2020 15:33:37 +0200 Message-Id: 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.11 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" While this function resides in the snapshot config module the 'def' variable is referencing the VM definition in most places. Change the name to 'snapdef' to avoid ambiguity especially since we are also dealing with the domain definition in this function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 160f2054a4..77f53c4a1d 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -645,7 +645,7 @@ virDomainSnapshotCompareDiskIndex(const void *a, const = void *b) * dom->disks. If require_match, also ensure that there is no * conflicting requests for both internal and external snapshots. */ int -virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, +virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapdef, int default_snapshot, bool require_match) { @@ -653,29 +653,29 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, size_t i; int ndisks; - if (!def->parent.dom) { + if (!snapdef->parent.dom) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); return -1; } - if (def->ndisks > def->parent.dom->ndisks) { + if (snapdef->ndisks > snapdef->parent.dom->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 (!def->parent.dom->ndisks) + if (!snapdef->parent.dom->ndisks) return 0; - if (!(map =3D virBitmapNew(def->parent.dom->ndisks))) + if (!(map =3D virBitmapNew(snapdef->parent.dom->ndisks))) return -1; /* Double check requested disks. */ - for (i =3D 0; i < def->ndisks; i++) { - virDomainSnapshotDiskDefPtr disk =3D &def->disks[i]; - int idx =3D virDomainDiskIndexByName(def->parent.dom, disk->name, = false); + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDefPtr disk =3D &snapdef->disks[i]; + int idx =3D virDomainDiskIndexByName(snapdef->parent.dom, disk->na= me, false); int disk_snapshot; if (idx < 0) { @@ -693,7 +693,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, ignore_value(virBitmapSetBit(map, idx)); disk->idx =3D idx; - disk_snapshot =3D def->parent.dom->disks[idx]->snapshot; + disk_snapshot =3D snapdef->parent.dom->disks[idx]->snapshot; if (!disk->snapshot) { if (disk_snapshot && (!require_match || @@ -721,44 +721,44 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, disk->src->path, disk->name); return -1; } - if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) { + if (STRNEQ(disk->name, snapdef->parent.dom->disks[idx]->dst)) { VIR_FREE(disk->name); - disk->name =3D g_strdup(def->parent.dom->disks[idx]->dst); + disk->name =3D g_strdup(snapdef->parent.dom->disks[idx]->dst); } } /* Provide defaults for all remaining disks. */ - ndisks =3D def->ndisks; - if (VIR_EXPAND_N(def->disks, def->ndisks, - def->parent.dom->ndisks - def->ndisks) < 0) + ndisks =3D snapdef->ndisks; + if (VIR_EXPAND_N(snapdef->disks, snapdef->ndisks, + snapdef->parent.dom->ndisks - snapdef->ndisks) < 0) return -1; - for (i =3D 0; i < def->parent.dom->ndisks; i++) { + for (i =3D 0; i < snapdef->parent.dom->ndisks; i++) { virDomainSnapshotDiskDefPtr disk; if (virBitmapIsBitSet(map, i)) continue; - disk =3D &def->disks[ndisks++]; + disk =3D &snapdef->disks[ndisks++]; disk->src =3D virStorageSourceNew(); - disk->name =3D g_strdup(def->parent.dom->disks[i]->dst); + disk->name =3D g_strdup(snapdef->parent.dom->disks[i]->dst); disk->idx =3D i; /* Don't snapshot empty drives */ - if (virStorageSourceIsEmpty(def->parent.dom->disks[i]->src)) + if (virStorageSourceIsEmpty(snapdef->parent.dom->disks[i]->src)) disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; else - disk->snapshot =3D def->parent.dom->disks[i]->snapshot; + disk->snapshot =3D snapdef->parent.dom->disks[i]->snapshot; disk->src->type =3D VIR_STORAGE_TYPE_FILE; if (!disk->snapshot) disk->snapshot =3D default_snapshot; } - qsort(&def->disks[0], def->ndisks, sizeof(def->disks[0]), + qsort(&snapdef->disks[0], snapdef->ndisks, sizeof(snapdef->disks[0]), virDomainSnapshotCompareDiskIndex); /* Generate default external file names for external snapshot location= s */ - if (virDomainSnapshotDefAssignExternalNames(def) < 0) + if (virDomainSnapshotDefAssignExternalNames(snapdef) < 0) return -1; return 0; --=20 2.26.2 From nobody Mon Nov 25 14:51:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1600868104; cv=none; d=zohomail.com; s=zohoarc; b=iT1zsBxujr0pZ4KrLhqp5vUGOG2A7JrdcH1s7+5TIGvitROQTIjYoICQHuzfc/Y6KjkPx40ZJVkGjdYMFBhnJxE0/JQosOL7dHNpgGoLRAEkw9yz+l3VhzDycc1uFNN0Or4vo9UONDBDXDmku6c1UgD5lvOjtlqcTd9K30wXl80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868104; 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=2qLnHEVJlb1ybsoLy3FPVEzwWrk979qMsoaN58p4L0I=; b=QsD5guenbxq8whP+RKl89/DdjRUbZ/h5rLOx5E0joeUrestrfXKqAk+mtgsqKfstNOi4wct2lJPK5BEC5l3H2qAoA2WIfCDhrycobO2zkasg9BFMkirF0PB9E23Sb9AxtZf0htRTZGaPMDh6d7hnbPtS1FFT2EsSG/i1nmWpNZo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1600868104478420.4409246922602; Wed, 23 Sep 2020 06:35:04 -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-317-cdSrVZZbN5qKlIvrpd2KTg-1; Wed, 23 Sep 2020 09:34:09 -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 368D010BBED1; Wed, 23 Sep 2020 13:34:04 +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 1056819C4F; Wed, 23 Sep 2020 13:34:04 +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 CEA10183D047; Wed, 23 Sep 2020 13:34:03 +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 08NDXvcB013917 for ; Wed, 23 Sep 2020 09:33:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7807A10023A7; Wed, 23 Sep 2020 13:33:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D70E7100239F for ; Wed, 23 Sep 2020 13:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868103; 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=2qLnHEVJlb1ybsoLy3FPVEzwWrk979qMsoaN58p4L0I=; b=NZnRga1k5A9regrW+eo7bH4zVg1erQtYtTRHFLcAxY8JKX07w9lPF1VCFE6RwesyvPBTBM OLPagTHMSrIh2DioBgV5FdQqjZcOhiWN3K0RQCDUb1e6sQvHIt2efM6oKJB4Rg95QIGFxz P88G8fNlhTW3JrbkKOmiuOq1LBLqTbI= X-MC-Unique: cdSrVZZbN5qKlIvrpd2KTg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/13] virDomainSnapshotAlignDisks: Rename 'disk' -> 'snapdisk' Date: Wed, 23 Sep 2020 15:33:38 +0200 Message-Id: <9261fa0c70dabf00563132984ec5b3189951e336.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.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" The 'disk' variable usually refers to a definition of a disk from the domain definition. Rename it to 'snapdisk' to be clear that we are talking about the snapshot disk definition especially since this function also accesses the domain disk definition. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 77f53c4a1d..c835ec7333 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -674,56 +674,56 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, /* Double check requested disks. */ for (i =3D 0; i < snapdef->ndisks; i++) { - virDomainSnapshotDiskDefPtr disk =3D &snapdef->disks[i]; - int idx =3D virDomainDiskIndexByName(snapdef->parent.dom, disk->na= me, false); + virDomainSnapshotDiskDefPtr snapdisk =3D &snapdef->disks[i]; + int idx =3D virDomainDiskIndexByName(snapdef->parent.dom, snapdisk= ->name, false); int disk_snapshot; if (idx < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("no disk named '%s'"), disk->name); + _("no disk named '%s'"), snapdisk->name); return -1; } if (virBitmapIsBitSet(map, idx)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' specified twice"), - disk->name); + snapdisk->name); return -1; } ignore_value(virBitmapSetBit(map, idx)); - disk->idx =3D idx; + snapdisk->idx =3D idx; disk_snapshot =3D snapdef->parent.dom->disks[idx]->snapshot; - if (!disk->snapshot) { + if (!snapdisk->snapshot) { if (disk_snapshot && (!require_match || disk_snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE)) - disk->snapshot =3D disk_snapshot; + snapdisk->snapshot =3D disk_snapshot; else - disk->snapshot =3D default_snapshot; + snapdisk->snapshot =3D default_snapshot; } else if (require_match && - disk->snapshot !=3D default_snapshot && - !(disk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO= NE && + snapdisk->snapshot !=3D default_snapshot && + !(snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATIO= N_NONE && disk_snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NON= E)) { const char *tmp; tmp =3D virDomainSnapshotLocationTypeToString(default_snapshot= ); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' must use snapshot mode '%s'"), - disk->name, tmp); + snapdisk->name, tmp); return -1; } - if (disk->src->path && - disk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { + if (snapdisk->src->path && + snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("file '%s' for disk '%s' requires " "use of external snapshot mode"), - disk->src->path, disk->name); + snapdisk->src->path, snapdisk->name); return -1; } - if (STRNEQ(disk->name, snapdef->parent.dom->disks[idx]->dst)) { - VIR_FREE(disk->name); - disk->name =3D g_strdup(snapdef->parent.dom->disks[idx]->dst); + if (STRNEQ(snapdisk->name, snapdef->parent.dom->disks[idx]->dst)) { + VIR_FREE(snapdisk->name); + snapdisk->name =3D g_strdup(snapdef->parent.dom->disks[idx]->d= st); } } @@ -734,24 +734,24 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, return -1; for (i =3D 0; i < snapdef->parent.dom->ndisks; i++) { - virDomainSnapshotDiskDefPtr disk; + virDomainSnapshotDiskDefPtr snapdisk; if (virBitmapIsBitSet(map, i)) continue; - disk =3D &snapdef->disks[ndisks++]; - disk->src =3D virStorageSourceNew(); - disk->name =3D g_strdup(snapdef->parent.dom->disks[i]->dst); - disk->idx =3D i; + snapdisk =3D &snapdef->disks[ndisks++]; + snapdisk->src =3D virStorageSourceNew(); + snapdisk->name =3D g_strdup(snapdef->parent.dom->disks[i]->dst); + snapdisk->idx =3D i; /* Don't snapshot empty drives */ if (virStorageSourceIsEmpty(snapdef->parent.dom->disks[i]->src)) - disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; else - disk->snapshot =3D snapdef->parent.dom->disks[i]->snapshot; + snapdisk->snapshot =3D snapdef->parent.dom->disks[i]->snapshot; - disk->src->type =3D VIR_STORAGE_TYPE_FILE; - if (!disk->snapshot) - disk->snapshot =3D default_snapshot; + snapdisk->src->type =3D VIR_STORAGE_TYPE_FILE; + if (!snapdisk->snapshot) + snapdisk->snapshot =3D default_snapshot; } qsort(&snapdef->disks[0], snapdef->ndisks, sizeof(snapdef->disks[0]), --=20 2.26.2 From nobody Mon Nov 25 14:51: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=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 From nobody Mon Nov 25 14:51: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=1600868170; cv=none; d=zohomail.com; s=zohoarc; b=NYUVrmI0mO5F05spCg0L0hVWjPegmAm8wDLO/yDdO/n3I5RkqTPiAhxoOXotwnJnnGVs2u686m49BB7LId9mxUK4KhERxGcINJeiDKXidhi1Mjlb7JBxscisp1aN8UE5viCdQhy+L1492BjOxamL7Lr3KB0G2XtUwt2KNfUwI/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868170; 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=5B8jWBLc68MjQN1pVCrhlJSU0WaFKAJfkPhgNWY2Iqc=; b=Bvzl+uLAeSYep8xn3fhkFQVO3E5WYVQpMvj12YNU58ENVXCMAIhK395ZDepMrt0JHeDD38eop326fSRxLvrfCGVZ2APiymyLq53CHWvxtkpZyEwJ/nvg9z5WiEG/gJKUyyVh6zbrs+HO6POZ/6bKQfWYGM8E+u4aph8UCxuXnjs= 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 1600868170017680.0532560250875; Wed, 23 Sep 2020 06:36: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-14-Solg-SVvMCCjqoITLNjF7A-1; Wed, 23 Sep 2020 09:34:16 -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 74FF05705F; Wed, 23 Sep 2020 13:34: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 540B25C269; Wed, 23 Sep 2020 13:34: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 1E10F183D050; Wed, 23 Sep 2020 13:34:09 +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 08NDXxcc013934 for ; Wed, 23 Sep 2020 09:33:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id C82481002C05; Wed, 23 Sep 2020 13:33:59 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31BCF100238E for ; Wed, 23 Sep 2020 13:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868168; 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=5B8jWBLc68MjQN1pVCrhlJSU0WaFKAJfkPhgNWY2Iqc=; b=XJ93mUKPk2gXh4rdv5DBsLhxKxcA1so3ggbhbM9vmpic6hgHDRrKGAIJAVocBeJ454zIxp SsAzXjH4/Xp+UkBePL+X0gBbHBxi+WFWee+nyTDUwNMkL2efzj7CrBvVsM67txtGVhhvO7 dnHZjIQIISjqD66IVAyN9GUnWq5bLA8= X-MC-Unique: Solg-SVvMCCjqoITLNjF7A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/13] virDomainSnapshotAlignDisks: Extract domain disk definition to a local variable Date: Wed, 23 Sep 2020 15:33:40 +0200 Message-Id: <4914209ef3b185631a9eee25b54acbb2f48173f6.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.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" Extract the disk def to a local variable so that it's more obvious what's happening and it will also allow further simplification. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index a1cee01944..aeebe2fb33 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -677,6 +677,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, for (i =3D 0; i < snapdef->ndisks; i++) { virDomainSnapshotDiskDefPtr snapdisk =3D &snapdef->disks[i]; int idx =3D virDomainDiskIndexByName(domdef, snapdisk->name, false= ); + virDomainDiskDefPtr domdisk =3D NULL; int disk_snapshot; if (idx < 0) { @@ -685,6 +686,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, return -1; } + domdisk =3D domdef->disks[idx]; + if (virBitmapIsBitSet(map, idx)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' specified twice"), @@ -694,7 +697,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, ignore_value(virBitmapSetBit(map, idx)); snapdisk->idx =3D idx; - disk_snapshot =3D domdef->disks[idx]->snapshot; + disk_snapshot =3D domdisk->snapshot; if (!snapdisk->snapshot) { if (disk_snapshot && (!require_match || @@ -722,9 +725,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, snapdisk->src->path, snapdisk->name); return -1; } - if (STRNEQ(snapdisk->name, domdef->disks[idx]->dst)) { + if (STRNEQ(snapdisk->name, domdisk->dst)) { VIR_FREE(snapdisk->name); - snapdisk->name =3D g_strdup(domdef->disks[idx]->dst); + snapdisk->name =3D g_strdup(domdisk->dst); } } --=20 2.26.2 From nobody Mon Nov 25 14:51: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=1600868107; cv=none; d=zohomail.com; s=zohoarc; b=AAfN3UN6p+B0Xr10WPEfmdsn+yabnoL4UC3Wfbc0fBj5SSPJJiAnXt+nMN7rzm5DKGpCWVlLEli+uRBCunhYHkvJxUdt7M+lri3s7O/DeHrwo5QD8NolI0xy1YrO0eNHZcyrLDm+SwttHxUw9UPRP0hqy3UFHVr0Zseb3/8kAGw= 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=7ct5xk3PU6v1ZelXr+PLL+ZYfbVF1BJClQ8UWWah2Hc=; b=mDYeC7V1wZuIkjNrIAYS2x8gIQzvnlozcRsHKDtMJBDBncu/wEr3n4KTu0gij67qtHkyUIdgQZD6qZqR1W4aqbMhrHvKY67KgZh8o5q3aEYLn7RoqXyM/Rn1ptyioXrJAtZbCAO6c6HwFJXF/YG/rOw4qFa8NwyIrODaIMLxXaE= 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 1600868107036964.6040824296944; 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-255-h2CdEPb_P4yDxjdSa8Xakw-1; Wed, 23 Sep 2020 09:34:18 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13F7910BBECE; Wed, 23 Sep 2020 13:34:12 +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 E75E378823; Wed, 23 Sep 2020 13:34:11 +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 B33318C7DB; Wed, 23 Sep 2020 13:34:11 +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 08NDY03N013948 for ; Wed, 23 Sep 2020 09:34:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0AD410021AA; Wed, 23 Sep 2020 13:34:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35024100238E for ; Wed, 23 Sep 2020 13:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868105; 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=7ct5xk3PU6v1ZelXr+PLL+ZYfbVF1BJClQ8UWWah2Hc=; b=goD0F2gMedTtJHMcqBMc2A8QkyX+J2aQAqykY72fFKoo5qcNPTxqadZ7qveX+uNrwV9/Hl VExMKoLognkNMdA0P6N1mvcn9wSqYw1/DlbW1Y4e6ou84u0w1du/MRqwt8MDwzpZQhDH32 bQdfueIQlx2FJkK6Am/NuMsgwAvqzzM= X-MC-Unique: h2CdEPb_P4yDxjdSa8Xakw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/13] virDomainSnapshotAlignDisks: remove unnecessary 'tmp' variable Date: Wed, 23 Sep 2020 15:33:41 +0200 Message-Id: <924a719038330e12f8172f7376c13dcc65184dea.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.11 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 converted string is used exactly once so we can call the conversion without storing the result in a variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index aeebe2fb33..10eb584a1c 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -709,12 +709,10 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, snapdisk->snapshot !=3D default_snapshot && !(snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATIO= N_NONE && disk_snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NON= E)) { - const char *tmp; - - tmp =3D virDomainSnapshotLocationTypeToString(default_snapshot= ); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' must use snapshot mode '%s'"), - snapdisk->name, tmp); + snapdisk->name, + virDomainSnapshotLocationTypeToString(default_s= napshot)); return -1; } if (snapdisk->src->path && --=20 2.26.2 From nobody Mon Nov 25 14:51:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1600868053; cv=none; d=zohomail.com; s=zohoarc; b=IwZ1CWjVX5/3QadSNCXJ5dFW+P5AAByOkUHc57000c2vwCT+k7OWprnOOeSYXhH/BsMPm1C+KBkwBPmJZhAUtBNSruiywnTKLGWl1hpwNXHSi+61J/ob3TGI3dR9wADhwPHaXxnp8phdnDtdaZK7rYHyPTiBs+XhNnfZxcXtMXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868053; 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=ZeIUjHA8Z+PuvN8WjX69bh4W0/50QOTOhFloSfpn5cE=; b=NLuRbrUPZI4inC0zIClE4f2C1tpP/u8rTbf4QZu8Xza06SFTblaFwmVJ9XLDRGuUbRH7Ej9HLCBcp6faWezNfpf+CHGeBbNSuJWav3ZjTD/Ff1cCkLiA1jSQ1j/j7VnN9qrTNKnZo31hJ6VOShJmy5dC5htYFTw1eCkyoam1DNQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1600868053471338.1378182244264; Wed, 23 Sep 2020 06:34:13 -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-560-V5utqccVOVuyjhEi5sWvKQ-1; Wed, 23 Sep 2020 09:34:10 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 12F2E10BBECC; Wed, 23 Sep 2020 13:34:05 +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 E69DE60E1C; Wed, 23 Sep 2020 13:34:04 +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 B21C6183D04A; Wed, 23 Sep 2020 13:34:04 +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 08NDY1f2013957 for ; Wed, 23 Sep 2020 09:34:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD395100239F; Wed, 23 Sep 2020 13:34:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B35E100238E for ; Wed, 23 Sep 2020 13:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868052; 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=ZeIUjHA8Z+PuvN8WjX69bh4W0/50QOTOhFloSfpn5cE=; b=eYkcM69zAeZicCD6oyM7Y+s6bvN9pKEz20N7XEoOYB5SW7wtkYWuBR+bpILdSA8L4SD5ej 5XV3G7AbGOQjTNOcEwrM3DKAWcXX4YAxxQ7qbNNjQy/O5Xsh+sbqkBzS9wyTV9G3m34piq pbFNegyN/3ZYaXo0Nb00Fq4JUF9zz1o= X-MC-Unique: V5utqccVOVuyjhEi5sWvKQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/13] virDomainSnapshotAlignDisks: clarify handing of snapshot location Date: Wed, 23 Sep 2020 15:33:42 +0200 Message-Id: <10111b76774345f78ed64657b1f2a398af5ce63a.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.12 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" Remove the use of the 'disk_snapshot' temporary variable since accessing the disk definition now isn't that much longer to write and use expicit value checks instead of the (non-)zero check to make it more obvious what the code is doing. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 10eb584a1c..f6a827d2ff 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -678,7 +678,6 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, virDomainSnapshotDiskDefPtr snapdisk =3D &snapdef->disks[i]; int idx =3D virDomainDiskIndexByName(domdef, snapdisk->name, false= ); virDomainDiskDefPtr domdisk =3D NULL; - int disk_snapshot; if (idx < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -697,24 +696,25 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, ignore_value(virBitmapSetBit(map, idx)); snapdisk->idx =3D idx; - disk_snapshot =3D domdisk->snapshot; - if (!snapdisk->snapshot) { - if (disk_snapshot && + if (snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT= ) { + if (domdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAUL= T && (!require_match || - disk_snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE)) - snapdisk->snapshot =3D disk_snapshot; - else + domdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NON= E)) { + snapdisk->snapshot =3D domdisk->snapshot; + } else { snapdisk->snapshot =3D default_snapshot; + } } else if (require_match && snapdisk->snapshot !=3D default_snapshot && !(snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATIO= N_NONE && - disk_snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NON= E)) { + domdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' must use snapshot mode '%s'"), snapdisk->name, virDomainSnapshotLocationTypeToString(default_s= napshot)); return -1; } + if (snapdisk->src->path && snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, --=20 2.26.2 From nobody Mon Nov 25 14:51:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1600868224; cv=none; d=zohomail.com; s=zohoarc; b=PRETV505s20f64ByRQsKAFckp2FKzl8MymdcewmNMGIbHhy0tRMFUts6s6avnEZ0lJNkEa+ti8biXQOwnZweGWTm1Q/8O0bfL77GeFZDnwFYMcH2oSByBRMQdTqkNMtciDMluQB3MRYOYtwEjMhtYFOo0yU0h9przqC6AuoDZ/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868224; 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=MJNSfvpHuFIOCe7JtVnBLRCyllPWH05OKRo14D5TUUo=; b=NXt6DZT3XibbXu9RB8PiHHR6P7JfZJpThUSaIyn/uhIRVA/xRQ0l0+Q59NKCVUr6ChaBP1rhlbNZUBhrP3cfNLcnBajqRKvpkdAMlo04PaH2cQZgb1PIVjBtzRFj+Ghqo7gfZigAdooiZfCVi8rSP0NB/aHCGupyRUnKaOO2s7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 16008682246801010.5464770529754; Wed, 23 Sep 2020 06:37:04 -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-358-JjvTOsPGNI-SUdaEVbereg-1; Wed, 23 Sep 2020 09:34:14 -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 26F5318BA298; Wed, 23 Sep 2020 13:34:08 +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 0145610021AA; Wed, 23 Sep 2020 13:34:08 +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 B881B183D04D; Wed, 23 Sep 2020 13:34:07 +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 08NDY3nN013962 for ; Wed, 23 Sep 2020 09:34:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48A9310021AA; Wed, 23 Sep 2020 13:34:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F00D100238E for ; Wed, 23 Sep 2020 13:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868223; 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=MJNSfvpHuFIOCe7JtVnBLRCyllPWH05OKRo14D5TUUo=; b=Rxpa7g3yYJcsNVjwJm3LYUdz0urfwlkvG/aTifiMRALIM2wsAKHtWQ9mRQelJYSJ2xSR0F IXTKgNxDVdptXXX1HQRjoCzXvF1Z2wsh04Um6j8zg6FWH5srIYXe1eX/Wg0QcZI7PsUaNO AWyg7RC0feTUJ8ekNgRNtpiuVsnWa8U= X-MC-Unique: JjvTOsPGNI-SUdaEVbereg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/13] virDomainSnapshotAlignDisks: refactor extension to all disks Date: Wed, 23 Sep 2020 15:33:43 +0200 Message-Id: <05eff9e35655a36dcc32739dbe8ca9dadc92d7b8.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.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" Last step of the algorithm in virDomainSnapshotAlignDisks is to extend the array of disks to all VM's disk and provide defaults. This was done by extending the array, adding defaults at the end and then sorting it. This requires the 'idx' variable and also a separate sorting function. If we store the pointer to existing snapshot disk definitions in a hash table and create a new array of snapshot disk definitions, we can fill the new array directly by either copying the definition from the old array or adding the default. This avoids the sorting step and thus even the need to store the index of the domain disk altogether. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 48 +++++++++++++++------------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f6a827d2ff..7090e3a1b0 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -627,16 +627,6 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnaps= hotDefPtr def) } -static int -virDomainSnapshotCompareDiskIndex(const void *a, const void *b) -{ - const virDomainSnapshotDiskDef *diska =3D a; - const virDomainSnapshotDiskDef *diskb =3D b; - - /* Integer overflow shouldn't be a problem here. */ - return diska->idx - diskb->idx; -} - /* Align def->disks to def->parent.dom. Sort the list of def->disks, * filling in any missing disks or snapshot state defaults given by * the domain, with a fallback to a passed in default. Convert paths @@ -650,9 +640,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, bool require_match) { virDomainDefPtr domdef =3D snapdef->parent.dom; - g_autoptr(virBitmap) map =3D NULL; + g_autoptr(virHashTable) map =3D virHashNew(NULL); + g_autofree virDomainSnapshotDiskDefPtr olddisks =3D NULL; size_t i; - int ndisks; if (!domdef) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -670,9 +660,6 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, if (!domdef->ndisks) return 0; - 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]; @@ -687,14 +674,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, domdisk =3D domdef->disks[idx]; - if (virBitmapIsBitSet(map, idx)) { + if (virHashHasEntry(map, domdisk->dst)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' specified twice"), snapdisk->name); return -1; } - ignore_value(virBitmapSetBit(map, idx)); - snapdisk->idx =3D idx; + + if (virHashAddEntry(map, domdisk->dst, snapdisk) < 0) + return -1; if (snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT= ) { if (domdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAUL= T && @@ -729,21 +717,24 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr s= napdef, } } - /* Provide defaults for all remaining disks. */ - ndisks =3D snapdef->ndisks; - if (VIR_EXPAND_N(snapdef->disks, snapdef->ndisks, - domdef->ndisks - snapdef->ndisks) < 0) - return -1; + olddisks =3D g_steal_pointer(&snapdef->disks); + snapdef->disks =3D g_new0(virDomainSnapshotDiskDef, domdef->ndisks); + snapdef->ndisks =3D domdef->ndisks; for (i =3D 0; i < domdef->ndisks; i++) { - virDomainSnapshotDiskDefPtr snapdisk; + virDomainDiskDefPtr domdisk =3D domdef->disks[i]; + virDomainSnapshotDiskDefPtr snapdisk =3D snapdef->disks + i; + virDomainSnapshotDiskDefPtr existing; - if (virBitmapIsBitSet(map, i)) + /* copy existing disks */ + if ((existing =3D virHashLookup(map, domdisk->dst))) { + memcpy(snapdisk, existing, sizeof(*snapdisk)); continue; - snapdisk =3D &snapdef->disks[ndisks++]; + } + + /* Provide defaults for all remaining disks. */ snapdisk->src =3D virStorageSourceNew(); snapdisk->name =3D g_strdup(domdef->disks[i]->dst); - snapdisk->idx =3D i; /* Don't snapshot empty drives */ if (virStorageSourceIsEmpty(domdef->disks[i]->src)) @@ -756,9 +747,6 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr sna= pdef, snapdisk->snapshot =3D default_snapshot; } - qsort(&snapdef->disks[0], snapdef->ndisks, sizeof(snapdef->disks[0]), - virDomainSnapshotCompareDiskIndex); - /* Generate default external file names for external snapshot location= s */ if (virDomainSnapshotDefAssignExternalNames(snapdef) < 0) return -1; --=20 2.26.2 From nobody Mon Nov 25 14:51:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1600868061; cv=none; d=zohomail.com; s=zohoarc; b=MDHfjZ+D/FVTFIto4U1nV6TKMfm2SvbUt/WA8Ya+6FuWKPSNkQWsu+L9raO8JijOJEMK5jGkCstj8WxKVl2LvCjqbD17XFELvtyD/4/B/jo5D5Vje0bfrwRhM6scQUj1EtAzEHNWQ1qUOdgTGCLHnR0cpYcaGz4DWuhvVeGKC90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600868061; 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=lx1bejmHDzouXjENJZsF7co8BxiIkQl3wSGKjTPavYk=; b=izrjdu0ybzvJfL9Uoaf66WJYe3GHiRdZwmPpP8GoQQjq0l1XDZ94vbJii0xH3NgKN5GLdN5IMS7OVqyzoZ4YWQ/u5gGho/sLUphISnnwLDkltO4EfjeL6J4DOk+/AWa6/0YOssLxHo97HWV0SLpY0cKcmzlJfjU21bg3+wxQshY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1600868061601733.258690463704; Wed, 23 Sep 2020 06:34:21 -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-423-82z6ZDQxN7ySjxyu4B08Qw-1; Wed, 23 Sep 2020 09:34:16 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD3FD8ECE65; Wed, 23 Sep 2020 13:34:10 +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 9DBA378823; Wed, 23 Sep 2020 13:34:10 +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 6AEF6183D055; Wed, 23 Sep 2020 13:34:10 +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 08NDY43c013970 for ; Wed, 23 Sep 2020 09:34:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55E6410021AA; Wed, 23 Sep 2020 13:34:04 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B534710023A7 for ; Wed, 23 Sep 2020 13:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600868060; 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=lx1bejmHDzouXjENJZsF7co8BxiIkQl3wSGKjTPavYk=; b=MgKq38NRMZBLX9JnKPKwPfp/x8qgF9s3sKlTtzwE6fLelLhE2EZwRj/LQ/BiCLUPHNQFnq W2K2MgZ/qRz5xkjZQX5OmoXQwE5Dw6n4i+gGPftu7HJS/gre7zurst/sryL1CgW1OWlHDt Y6vC8BZtTwdpSPGDtUEFuZuX/FbTiMQ= X-MC-Unique: 82z6ZDQxN7ySjxyu4B08Qw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/13] virDomainSnapshotDiskDef: Remove 'idx' field Date: Wed, 23 Sep 2020 15:33:44 +0200 Message-Id: <5cd21bdb19b990edee339c3a73e91addb6f74c21.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.11 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" It's no longer needed and is valid only after virDomainSnapshotAlignDisks is called while holding the lock. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index b5b1ef2718..fbc9b17c54 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -63,7 +63,6 @@ typedef struct _virDomainSnapshotDiskDef virDomainSnapsho= tDiskDef; typedef virDomainSnapshotDiskDef *virDomainSnapshotDiskDefPtr; struct _virDomainSnapshotDiskDef { char *name; /* name matching the dom->disks that matches name= */ int snapshot; /* virDomainSnapshotLocation */ /* details of wrapper external file. src is always non-NULL. --=20 2.26.2