From nobody Sun Feb 8 16:36:11 2026 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=1611257791; cv=none; d=zohomail.com; s=zohoarc; b=dUJOLUd8pU9pBp+TCH27ew1YL+xmIoCiCBZmjs5qC5ojhgyqZpToqkMFVA/tkxucuZNc5DrxeIEka4iK78Vw4og6NOnddeLddQiDo1NgyX/EZNPDIExzfsQmO2iD54KpHYRwEYY+5gmWtBEZ0VUA8JFqRF/CKuL09azcOxlHK9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611257791; 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=O4YI1EEst7ASM2nPbCotL+WvyY6JhbbLhX7WIfk9tp0=; b=CSSU73TUleXodlKNPQiQ4ejn9KBN0I4kD4LSPw+Xp8PcnbAjlwirMDjQaSZFPW3rUmSXUVr7NKfQSz609L4pMWoOxbo3axrGHfJCoPHclcXk2A+jXPS2rmrT/tEN+UHU/uiMmktBkhQr+RyqZfTzPw0TMbQPJyjM2i7jefFUimE= 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 1611257791685579.0544190860344; Thu, 21 Jan 2021 11:36:31 -0800 (PST) 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-Wtrd9L8COTmMZ4jiPi67_A-1; Thu, 21 Jan 2021 14:35:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 255948030B5; Thu, 21 Jan 2021 19:35:00 +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 A2A8F5D9E3; Thu, 21 Jan 2021 19:34: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 3C7C950036; Thu, 21 Jan 2021 19:34: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 10LJYspu023301 for ; Thu, 21 Jan 2021 14:34:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id B764C10023B9; Thu, 21 Jan 2021 19:34:54 +0000 (UTC) Received: from antique-laptop.redhat.com (unknown [10.40.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACAEF100AE40 for ; Thu, 21 Jan 2021 19:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611257790; 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=O4YI1EEst7ASM2nPbCotL+WvyY6JhbbLhX7WIfk9tp0=; b=gCqoYP5IUrrxL+i22DPyrxe6pZtmkjWMT6CrSSbv4uexRaStqv3gPHRhKz/aOxuqRI8dXH qvifwpbRuNq6AgIXp8z/AQ/xqsU6ZarWXgmFkxUhmF7a1yEr3sP+hQ0fxxccXqBuPLrewU 2AFi1ONVs2hnvMbxrfIvTcNPZvsgTG4= X-MC-Unique: Wtrd9L8COTmMZ4jiPi67_A-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/13] storage_source: use virStorageSource prefix for all functions Date: Thu, 21 Jan 2021 20:34:27 +0100 Message-Id: <081d955537d3ff8ab37c5180e7f61bdcbfbe7147.1611257578.git.phrdina@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.14 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: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 42 ++--- src/qemu/qemu_backup.c | 8 +- src/qemu/qemu_block.c | 6 +- src/qemu/qemu_domain.c | 16 +- src/qemu/qemu_driver.c | 66 +++---- src/qemu/qemu_hotplug.c | 4 +- src/qemu/qemu_process.c | 4 +- src/qemu/qemu_snapshot.c | 20 +-- src/security/virt-aa-helper.c | 2 +- src/storage/storage_backend_gluster.c | 4 +- src/storage/storage_util.c | 6 +- src/storage_file/storage_source.c | 250 +++++++++++++------------- src/storage_file/storage_source.h | 90 +++++----- tests/virstoragetest.c | 18 +- 14 files changed, 268 insertions(+), 268 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 088474d54b..41fa8ae5ba 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1686,30 +1686,30 @@ virStorageFileProbeGetMetadata; =20 =20 # storage_file/storage_source.h -virStorageFileAccess; -virStorageFileChainLookup; -virStorageFileChown; -virStorageFileCreate; -virStorageFileDeinit; -virStorageFileGetBackingStoreStr; -virStorageFileGetMetadata; -virStorageFileGetMetadataFromBuf; -virStorageFileGetMetadataFromFD; -virStorageFileGetRelativeBackingPath; -virStorageFileGetUniqueIdentifier; -virStorageFileInit; -virStorageFileInitAs; -virStorageFileRead; -virStorageFileReportBrokenChain; -virStorageFileStat; -virStorageFileSupportsAccess; -virStorageFileSupportsBackingChainTraversal; -virStorageFileSupportsCreate; -virStorageFileSupportsSecurityDriver; -virStorageFileUnlink; +virStorageSourceAccess; +virStorageSourceChainLookup; +virStorageSourceChown; +virStorageSourceCreate; +virStorageSourceDeinit; +virStorageSourceGetBackingStoreStr; +virStorageSourceGetMetadata; +virStorageSourceGetMetadataFromBuf; +virStorageSourceGetMetadataFromFD; +virStorageSourceGetRelativeBackingPath; +virStorageSourceGetUniqueIdentifier; +virStorageSourceInit; +virStorageSourceInitAs; virStorageSourceNewFromBacking; virStorageSourceNewFromBackingAbsolute; virStorageSourceParseRBDColonString; +virStorageSourceRead; +virStorageSourceReportBrokenChain; +virStorageSourceStat; +virStorageSourceSupportsAccess; +virStorageSourceSupportsBackingChainTraversal; +virStorageSourceSupportsCreate; +virStorageSourceSupportsSecurityDriver; +virStorageSourceUnlink; virStorageSourceUpdateBackingSizes; virStorageSourceUpdateCapacity; virStorageSourceUpdatePhysicalSize; diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 4a07f6a5f4..423de9c719 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -135,7 +135,7 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm, } =20 if (dd->created) { - if (virStorageFileUnlink(dd->store) < 0) + if (virStorageSourceUnlink(dd->store) < 0) VIR_WARN("Unable to remove just-created %s", NULLSTR(dd->s= tore->path)); } =20 @@ -144,7 +144,7 @@ qemuBackupDiskDataCleanupOne(virDomainObjPtr vm, } =20 if (dd->initialized) - virStorageFileDeinit(dd->store); + virStorageSourceDeinit(dd->store); =20 if (dd->blockjob) qemuBlockJobStartupFinalize(vm, dd->blockjob); @@ -429,7 +429,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObjPtr vm, =20 if (!reuse_external && dd->store->type =3D=3D VIR_STORAGE_TYPE_FILE && - virStorageFileSupportsCreate(dd->store)) { + virStorageSourceSupportsCreate(dd->store)) { =20 if (virFileExists(dd->store->path)) { virReportError(VIR_ERR_INVALID_ARG, @@ -443,7 +443,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObjPtr vm, =20 dd->initialized =3D true; =20 - if (virStorageFileCreate(dd->store) < 0) { + if (virStorageSourceCreate(dd->store) < 0) { virReportSystemError(errno, _("failed to create image file '%s'"), NULLSTR(dd->store->path)); diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index fafa35071c..15019657e4 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3426,15 +3426,15 @@ qemuBlockUpdateRelativeBacking(virDomainObjPtr vm, if (n->backingStore->relPath) break; =20 - if (!virStorageFileSupportsBackingChainTraversal(n)) + if (!virStorageSourceSupportsBackingChainTraversal(n)) continue; =20 if (qemuDomainStorageFileInit(driver, vm, n, topsrc) < 0) return -1; =20 - rc =3D virStorageFileGetBackingStoreStr(n, &backingStoreStr); + rc =3D virStorageSourceGetBackingStoreStr(n, &backingStoreStr); =20 - virStorageFileDeinit(n); + virStorageSourceDeinit(n); =20 if (rc < 0) return rc; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 165321858e..0c078a9388 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7160,7 +7160,7 @@ qemuDomainStorageFileInit(virQEMUDriverPtr driver, =20 qemuDomainGetImageIds(cfg, vm, src, parent, &uid, &gid); =20 - if (virStorageFileInitAs(src, uid, gid) < 0) + if (virStorageSourceInitAs(src, uid, gid) < 0) return -1; =20 return 0; @@ -7298,7 +7298,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, =20 if (!virFileExists(disksrc->path)) { if (report_broken) - virStorageFileReportBrokenChain(errno, disksrc, disksrc); + virStorageSourceReportBrokenChain(errno, disksrc, disksrc); =20 return -1; } @@ -7322,7 +7322,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, /* skip to the end of the chain if there is any */ while (virStorageSourceHasBacking(src)) { if (report_broken) { - int rv =3D virStorageFileSupportsAccess(src); + int rv =3D virStorageSourceSupportsAccess(src); =20 if (rv < 0) return -1; @@ -7331,13 +7331,13 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr drive= r, if (qemuDomainStorageFileInit(driver, vm, src, disksrc) < = 0) return -1; =20 - if (virStorageFileAccess(src, F_OK) < 0) { - virStorageFileReportBrokenChain(errno, src, disksrc); - virStorageFileDeinit(src); + if (virStorageSourceAccess(src, F_OK) < 0) { + virStorageSourceReportBrokenChain(errno, src, disksrc); + virStorageSourceDeinit(src); return -1; } =20 - virStorageFileDeinit(src); + virStorageSourceDeinit(src); } } src =3D src->backingStore; @@ -7354,7 +7354,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, =20 qemuDomainGetImageIds(cfg, vm, src, disksrc, &uid, &gid); =20 - if (virStorageFileGetMetadata(src, uid, gid, report_broken) < 0) + if (virStorageSourceGetMetadata(src, uid, gid, report_broken) < 0) return -1; =20 for (n =3D src->backingStore; virStorageSourceIsBacking(n); n =3D n->b= ackingStore) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8048c86632..ed966cf7e3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -253,20 +253,20 @@ qemuSecurityChownCallback(const virStorageSource *src, return 0; } =20 - if ((rv =3D virStorageFileSupportsSecurityDriver(src)) <=3D 0) + if ((rv =3D virStorageSourceSupportsSecurityDriver(src)) <=3D 0) return rv; =20 if (!(cpy =3D virStorageSourceCopy(src, false))) return -1; =20 /* src file init reports errors, return -2 on failure */ - if (virStorageFileInit(cpy) < 0) + if (virStorageSourceInit(cpy) < 0) return -2; =20 - ret =3D virStorageFileChown(cpy, uid, gid); + ret =3D virStorageSourceChown(cpy, uid, gid); =20 save_errno =3D errno; - virStorageFileDeinit(cpy); + virStorageSourceDeinit(cpy); errno =3D save_errno; =20 return ret; @@ -10620,7 +10620,7 @@ qemuDomainBlockPeek(virDomainPtr dom, if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL) < 0) goto cleanup; =20 - if ((nread =3D virStorageFileRead(disk->src, offset, size, &tmpbuf)) <= 0) { + if ((nread =3D virStorageSourceRead(disk->src, offset, size, &tmpbuf))= < 0) { if (nread =3D=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, _("storage file reading is not supported for " @@ -10644,7 +10644,7 @@ qemuDomainBlockPeek(virDomainPtr dom, =20 cleanup: if (disk) - virStorageFileDeinit(disk->src); + virStorageSourceDeinit(disk->src); virDomainObjEndAPI(&vm); return ret; } @@ -10776,14 +10776,14 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, return -1; } } else { - if (skipInaccessible && virStorageFileSupportsBackingChainTraversa= l(src) <=3D 0) + if (skipInaccessible && virStorageSourceSupportsBackingChainTraver= sal(src) <=3D 0) return 0; =20 - if (virStorageFileInitAs(src, cfg->user, cfg->group) < 0) + if (virStorageSourceInitAs(src, cfg->user, cfg->group) < 0) return -1; =20 - if (virStorageFileStat(src, ret_sb) < 0) { - virStorageFileDeinit(src); + if (virStorageSourceStat(src, ret_sb) < 0) { + virStorageSourceDeinit(src); virReportSystemError(errno, _("failed to stat remote file '%s'= "), NULLSTR(src->path)); return -1; @@ -10808,7 +10808,7 @@ qemuDomainStorageCloseStat(virStorageSourcePtr src, if (virStorageSourceIsLocalStorage(src)) VIR_FORCE_CLOSE(*fd); else - virStorageFileDeinit(src); + virStorageSourceDeinit(src); } =20 =20 @@ -10908,7 +10908,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver, goto cleanup; } } else { - if ((len =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, &b= uf)) < 0) + if ((len =3D virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, = &buf)) < 0) goto cleanup; } =20 @@ -14449,8 +14449,8 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, =20 if (base && (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < 0 || - !(baseSource =3D virStorageFileChainLookup(disk->src, disk->src, - base, baseIndex, NULL)))) + !(baseSource =3D virStorageSourceChainLookup(disk->src, disk->src, + base, baseIndex, NULL)= ))) goto endjob; =20 if (baseSource) { @@ -14466,9 +14466,9 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, qemuBlockUpdateRelativeBacking(vm, disk->src, disk->src) <= 0) goto endjob; =20 - if (virStorageFileGetRelativeBackingPath(disk->src->backingSto= re, - baseSource, - &backingPath) < 0) + if (virStorageSourceGetRelativeBackingPath(disk->src->backingS= tore, + baseSource, + &backingPath) < 0) goto endjob; =20 if (!backingPath) { @@ -14839,7 +14839,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSourceP= tr mirror, if (!virStorageSourceIsLocalStorage(mirror)) return 0; =20 - if (virStorageFileAccess(mirror, F_OK) < 0) { + if (virStorageSourceAccess(mirror, F_OK) < 0) { if (errno !=3D ENOENT) { virReportSystemError(errno, "%s", _("unable to verify existence of " @@ -14854,7 +14854,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSourceP= tr mirror, return -1; } } else { - if (virStorageFileStat(mirror, &st) < 0) { + if (virStorageSourceStat(mirror, &st) < 0) { virReportSystemError(errno, _("unable to stat block copy target '%s'"= ), mirror->path); @@ -15058,9 +15058,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, goto endjob; } =20 - supports_access =3D virStorageFileSupportsAccess(mirror) =3D=3D 1; - supports_create =3D virStorageFileSupportsCreate(mirror) =3D=3D 1; - supports_detect =3D virStorageFileSupportsBackingChainTraversal(mirror= ) =3D=3D 1; + supports_access =3D virStorageSourceSupportsAccess(mirror) =3D=3D 1; + supports_create =3D virStorageSourceSupportsCreate(mirror) =3D=3D 1; + supports_detect =3D virStorageSourceSupportsBackingChainTraversal(mirr= or) =3D=3D 1; =20 if (supports_access || supports_create || supports_detect) { if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0) @@ -15104,7 +15104,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, * required so that libvirt can properly label the image for access by= qemu */ if (!existing) { if (supports_create) { - if (virStorageFileCreate(mirror) < 0) { + if (virStorageSourceCreate(mirror) < 0) { virReportSystemError(errno, "%s", _("failed to create copy= target")); goto endjob; } @@ -15247,7 +15247,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, =20 /* Update vm in place to match changes. */ need_unlink =3D false; - virStorageFileDeinit(mirror); + virStorageSourceDeinit(mirror); disk->mirror =3D g_steal_pointer(&mirror); disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY; qemuBlockJobStarted(job, vm); @@ -15266,9 +15266,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (need_revoke) qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror); } - if (need_unlink && virStorageFileUnlink(mirror) < 0) + if (need_unlink && virStorageSourceUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); - virStorageFileDeinit(mirror); + virStorageSourceDeinit(mirror); qemuDomainObjEndJob(driver, vm); qemuBlockJobStartupFinalize(vm, job); =20 @@ -15541,9 +15541,9 @@ qemuDomainBlockCommit(virDomainPtr dom, if (!top || STREQ(top, disk->dst)) topSource =3D disk->src; else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 = || - !(topSource =3D virStorageFileChainLookup(disk->src, NULL, - top, topIndex, - &top_parent))) + !(topSource =3D virStorageSourceChainLookup(disk->src, NULL, + top, topIndex, + &top_parent))) goto endjob; =20 if (topSource =3D=3D disk->src) { @@ -15576,8 +15576,8 @@ qemuDomainBlockCommit(virDomainPtr dom, if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) baseSource =3D topSource->backingStore; else if (virStorageFileParseChainIndex(disk->dst, base, &baseIndex) < = 0 || - !(baseSource =3D virStorageFileChainLookup(disk->src, topSour= ce, - base, baseIndex, NUL= L))) + !(baseSource =3D virStorageSourceChainLookup(disk->src, topSo= urce, + base, baseIndex, N= ULL))) goto endjob; =20 if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) && @@ -15611,8 +15611,8 @@ qemuDomainBlockCommit(virDomainPtr dom, qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) goto endjob; =20 - if (virStorageFileGetRelativeBackingPath(topSource, baseSource, - &backingPath) < 0) + if (virStorageSourceGetRelativeBackingPath(topSource, baseSource, + &backingPath) < 0) goto endjob; =20 if (!backingPath) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 99950a1360..882e5d2384 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4375,8 +4375,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, VIR_DEBUG("Removing transient overlay '%s' of disk '%s'", disk->src->path, disk->dst); if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL) >=3D 0)= { - virStorageFileUnlink(disk->src); - virStorageFileDeinit(disk->src); + virStorageSourceUnlink(disk->src); + virStorageSourceDeinit(disk->src); } } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 14e1f5d962..f87a3c0f60 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7887,8 +7887,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, VIR_DEBUG("Removing transient overlay '%s' of disk '%s'", disk->src->path, disk->dst); if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL)= >=3D 0) { - virStorageFileUnlink(disk->src); - virStorageFileDeinit(disk->src); + virStorageSourceUnlink(disk->src); + virStorageSourceDeinit(disk->src); } } } diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 699090ae40..1c8b1a70f8 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -567,13 +567,13 @@ qemuSnapshotPrepareDiskExternal(virDomainObjPtr vm, } =20 if (virStorageSourceIsLocalStorage(snapdisk->src)) { - if (virStorageFileInit(snapdisk->src) < 0) + if (virStorageSourceInit(snapdisk->src) < 0) return -1; =20 - rc =3D virStorageFileStat(snapdisk->src, &st); + rc =3D virStorageSourceStat(snapdisk->src, &st); err =3D errno; =20 - virStorageFileDeinit(snapdisk->src); + virStorageSourceDeinit(snapdisk->src); =20 if (rc < 0) { if (err !=3D ENOENT) { @@ -867,13 +867,13 @@ qemuSnapshotDiskCleanup(qemuSnapshotDiskDataPtr data, } =20 if (data[i].created && - virStorageFileUnlink(data[i].src) < 0) { + virStorageSourceUnlink(data[i].src) < 0) { VIR_WARN("Unable to remove just-created %s", NULLSTR(data[i].src->path)); } =20 if (data[i].initialized) - virStorageFileDeinit(data[i].src); + virStorageSourceDeinit(data[i].src); =20 if (data[i].prepared) qemuDomainStorageSourceAccessRevoke(driver, vm, data[i].sr= c); @@ -1072,13 +1072,13 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm, return -1; } =20 - supportsCreate =3D virStorageFileSupportsCreate(dd->src); + supportsCreate =3D virStorageSourceSupportsCreate(dd->src); =20 /* relative backing store paths need to be updated so that relative * block commit still works. With blockdev we must update it when doing * commit anyways so it's skipped here */ if (!blockdev && - virStorageFileSupportsBackingChainTraversal(dd->src)) + virStorageSourceSupportsBackingChainTraversal(dd->src)) updateRelativeBacking =3D true; =20 if (supportsCreate || updateRelativeBacking) { @@ -1091,7 +1091,7 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm, if (updateRelativeBacking) { g_autofree char *backingStoreStr =3D NULL; =20 - if (virStorageFileGetBackingStoreStr(dd->src, &backingStor= eStr) < 0) + if (virStorageSourceGetBackingStoreStr(dd->src, &backingSt= oreStr) < 0) return -1; if (backingStoreStr !=3D NULL) { if (virStorageFileIsRelative(backingStoreStr)) @@ -1101,7 +1101,7 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm, } else { /* pre-create the image file so that we can label it before ha= nding it to qemu */ if (supportsCreate && dd->src->type !=3D VIR_STORAGE_TYPE_BLOC= K) { - if (virStorageFileCreate(dd->src) < 0) { + if (virStorageSourceCreate(dd->src) < 0) { virReportSystemError(errno, _("failed to create image = file '%s'"), NULLSTR(dd->src->path)); return -1; @@ -1251,7 +1251,7 @@ qemuSnapshotDiskUpdateSource(virDomainObjPtr vm, =20 /* storage driver access won'd be needed */ if (dd->initialized) - virStorageFileDeinit(dd->src); + virStorageSourceDeinit(dd->src); =20 if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) = < 0) VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name); diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 6525baf193..f71fe6f23b 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -939,7 +939,7 @@ get_files(vahControl * ctl) * so that the open could be re-tried as that user:group. */ if (!virStorageSourceHasBacking(disk->src)) - virStorageFileGetMetadata(disk->src, -1, -1, false); + virStorageSourceGetMetadata(disk->src, -1, -1, false); =20 /* XXX should handle open errors more careful than just ignoring = them. */ diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 554c76ddb4..8de0cb8a6b 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -272,8 +272,8 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlu= sterStatePtr state, &header)) < 0) goto cleanup; =20 - if (!(meta =3D virStorageFileGetMetadataFromBuf(name, header, len, - VIR_STORAGE_FILE_AUTO))) + if (!(meta =3D virStorageSourceGetMetadataFromBuf(name, header, len, + VIR_STORAGE_FILE_AUTO)= )) goto cleanup; =20 if (meta->backingStoreRaw) { diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 10c04e1257..3d8de16341 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3427,9 +3427,9 @@ storageBackendProbeTarget(virStorageSourcePtr target, } } =20 - if (!(meta =3D virStorageFileGetMetadataFromFD(target->path, - fd, - VIR_STORAGE_FILE_AUTO))) + if (!(meta =3D virStorageSourceGetMetadataFromFD(target->path, + fd, + VIR_STORAGE_FILE_AUTO))) return -1; =20 if (meta->backingStoreRaw) { diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index ffc7fe8ea5..71bff1e55e 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -46,8 +46,8 @@ VIR_LOG_INIT("storage_source"); =20 =20 static virStorageSourcePtr -virStorageFileMetadataNew(const char *path, - int format) +virStorageSourceMetadataNew(const char *path, + int format) { g_autoptr(virStorageSource) def =3D virStorageSourceNew(); =20 @@ -61,7 +61,7 @@ virStorageFileMetadataNew(const char *path, =20 =20 /** - * virStorageFileGetMetadataFromBuf: + * virStorageSourceGetMetadataFromBuf: * @path: name of file, for error messages * @buf: header bytes from @path * @len: length of @buf @@ -83,14 +83,14 @@ virStorageFileMetadataNew(const char *path, * Caller MUST free the result after use via virObjectUnref. */ virStorageSourcePtr -virStorageFileGetMetadataFromBuf(const char *path, - char *buf, - size_t len, - int format) +virStorageSourceGetMetadataFromBuf(const char *path, + char *buf, + size_t len, + int format) { virStorageSourcePtr ret =3D NULL; =20 - if (!(ret =3D virStorageFileMetadataNew(path, format))) + if (!(ret =3D virStorageSourceMetadataNew(path, format))) return NULL; =20 if (virStorageFileProbeGetMetadata(ret, buf, len) < 0) { @@ -103,7 +103,7 @@ virStorageFileGetMetadataFromBuf(const char *path, =20 =20 /** - * virStorageFileGetMetadataFromFD: + * virStorageSourceGetMetadataFromFD: * * Extract metadata about the storage volume with the specified * image format. If image format is VIR_STORAGE_FILE_AUTO, it @@ -116,9 +116,9 @@ virStorageFileGetMetadataFromBuf(const char *path, * Caller MUST free the result after use via virObjectUnref. */ virStorageSourcePtr -virStorageFileGetMetadataFromFD(const char *path, - int fd, - int format) +virStorageSourceGetMetadataFromFD(const char *path, + int fd, + int format) =20 { ssize_t len =3D VIR_STORAGE_MAX_HEADER; @@ -132,7 +132,7 @@ virStorageFileGetMetadataFromFD(const char *path, return NULL; } =20 - if (!(meta =3D virStorageFileMetadataNew(path, format))) + if (!(meta =3D virStorageSourceMetadataNew(path, format))) return NULL; =20 if (S_ISDIR(sb.st_mode)) { @@ -177,11 +177,11 @@ virStorageFileGetMetadataFromFD(const char *path, * found. */ virStorageSourcePtr -virStorageFileChainLookup(virStorageSourcePtr chain, - virStorageSourcePtr startFrom, - const char *name, - unsigned int idx, - virStorageSourcePtr *parent) +virStorageSourceChainLookup(virStorageSourcePtr chain, + virStorageSourcePtr startFrom, + const char *name, + unsigned int idx, + virStorageSourcePtr *parent) { virStorageSourcePtr prev; const char *start =3D chain->path; @@ -1794,8 +1794,8 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr sr= c, =20 if (format =3D=3D VIR_STORAGE_FILE_RAW && !src->encryption) { src->capacity =3D src->physical; - } else if ((meta =3D virStorageFileGetMetadataFromBuf(src->path, buf, - len, format))) { + } else if ((meta =3D virStorageSourceGetMetadataFromBuf(src->path, buf, + len, format))) { src->capacity =3D meta->capacity ? meta->capacity : src->physical; if (src->encryption && meta->encryption) src->encryption->payload_offset =3D meta->encryption->payload_= offset; @@ -1811,7 +1811,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr sr= c, =20 =20 /** - * virStorageFileRemoveLastPathComponent: + * virStorageSourceRemoveLastPathComponent: * * @path: Path string to remove the last component from * @@ -1820,7 +1820,7 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr sr= c, * responsible to free the returned string. */ static char * -virStorageFileRemoveLastPathComponent(const char *path) +virStorageSourceRemoveLastPathComponent(const char *path) { char *ret; =20 @@ -1833,7 +1833,7 @@ virStorageFileRemoveLastPathComponent(const char *pat= h) =20 =20 /* - * virStorageFileGetRelativeBackingPath: + * virStorageSourceGetRelativeBackingPath: * * Resolve relative path to be written to the overlay of @top image when * collapsing the backing chain between @top and @base. @@ -1841,9 +1841,9 @@ virStorageFileRemoveLastPathComponent(const char *pat= h) * Returns 0 on success; 1 if backing chain isn't relative and -1 on error. */ int -virStorageFileGetRelativeBackingPath(virStorageSourcePtr top, - virStorageSourcePtr base, - char **relpath) +virStorageSourceGetRelativeBackingPath(virStorageSourcePtr top, + virStorageSourcePtr base, + char **relpath) { virStorageSourcePtr next; g_autofree char *tmp =3D NULL; @@ -1855,7 +1855,7 @@ virStorageFileGetRelativeBackingPath(virStorageSource= Ptr top, if (!next->relPath) return 1; =20 - if (!(tmp =3D virStorageFileRemoveLastPathComponent(path))) + if (!(tmp =3D virStorageSourceRemoveLastPathComponent(path))) return -1; =20 VIR_FREE(path); @@ -1881,14 +1881,14 @@ virStorageFileGetRelativeBackingPath(virStorageSour= cePtr top, =20 =20 static bool -virStorageFileIsInitialized(const virStorageSource *src) +virStorageSourceIsInitialized(const virStorageSource *src) { return src && src->drv; } =20 =20 /** - * virStorageFileGetBackendForSupportCheck: + * virStorageSourceGetBackendForSupportCheck: * @src: storage source to check support for * @backend: pointer to the storage backend for @src if it's supported * @@ -1896,8 +1896,8 @@ virStorageFileIsInitialized(const virStorageSource *s= rc) * 1 if it is supported and -1 on error with an error reported. */ static int -virStorageFileGetBackendForSupportCheck(const virStorageSource *src, - virStorageFileBackendPtr *backend) +virStorageSourceGetBackendForSupportCheck(const virStorageSource *src, + virStorageFileBackendPtr *backen= d) { int actualType; =20 @@ -1926,12 +1926,12 @@ virStorageFileGetBackendForSupportCheck(const virSt= orageSource *src, =20 =20 int -virStorageFileSupportsBackingChainTraversal(const virStorageSource *src) +virStorageSourceSupportsBackingChainTraversal(const virStorageSource *src) { virStorageFileBackendPtr backend; int rv; =20 - if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + if ((rv =3D virStorageSourceGetBackendForSupportCheck(src, &backend)) = < 1) return rv; =20 return backend->storageFileGetUniqueIdentifier && @@ -1941,7 +1941,7 @@ virStorageFileSupportsBackingChainTraversal(const vir= StorageSource *src) =20 =20 /** - * virStorageFileSupportsSecurityDriver: + * virStorageSourceSupportsSecurityDriver: * * @src: a storage file structure * @@ -1949,12 +1949,12 @@ virStorageFileSupportsBackingChainTraversal(const v= irStorageSource *src) * driver to perform labelling */ int -virStorageFileSupportsSecurityDriver(const virStorageSource *src) +virStorageSourceSupportsSecurityDriver(const virStorageSource *src) { virStorageFileBackendPtr backend; int rv; =20 - if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + if ((rv =3D virStorageSourceGetBackendForSupportCheck(src, &backend)) = < 1) return rv; =20 return backend->storageFileChown ? 1 : 0; @@ -1962,7 +1962,7 @@ virStorageFileSupportsSecurityDriver(const virStorage= Source *src) =20 =20 /** - * virStorageFileSupportsAccess: + * virStorageSourceSupportsAccess: * * @src: a storage file structure * @@ -1970,12 +1970,12 @@ virStorageFileSupportsSecurityDriver(const virStora= geSource *src) * for the given vm. */ int -virStorageFileSupportsAccess(const virStorageSource *src) +virStorageSourceSupportsAccess(const virStorageSource *src) { virStorageFileBackendPtr backend; int rv; =20 - if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + if ((rv =3D virStorageSourceGetBackendForSupportCheck(src, &backend)) = < 1) return rv; =20 return backend->storageFileAccess ? 1 : 0; @@ -1983,19 +1983,19 @@ virStorageFileSupportsAccess(const virStorageSource= *src) =20 =20 /** - * virStorageFileSupportsCreate: + * virStorageSourceSupportsCreate: * @src: a storage file structure * * Check if the storage driver supports creating storage described by @src - * via virStorageFileCreate. + * via virStorageSourceCreate. */ int -virStorageFileSupportsCreate(const virStorageSource *src) +virStorageSourceSupportsCreate(const virStorageSource *src) { virStorageFileBackendPtr backend; int rv; =20 - if ((rv =3D virStorageFileGetBackendForSupportCheck(src, &backend)) < = 1) + if ((rv =3D virStorageSourceGetBackendForSupportCheck(src, &backend)) = < 1) return rv; =20 return backend->storageFileCreate ? 1 : 0; @@ -2003,11 +2003,11 @@ virStorageFileSupportsCreate(const virStorageSource= *src) =20 =20 void -virStorageFileDeinit(virStorageSourcePtr src) +virStorageSourceDeinit(virStorageSourcePtr src) { virStorageDriverDataPtr drv =3D NULL; =20 - if (!virStorageFileIsInitialized(src)) + if (!virStorageSourceIsInitialized(src)) return; =20 drv =3D src->drv; @@ -2021,7 +2021,7 @@ virStorageFileDeinit(virStorageSourcePtr src) =20 =20 /** - * virStorageFileInitAs: + * virStorageSourceInitAs: * * @src: storage source definition * @uid: uid used to access the file, or -1 for current uid @@ -2034,8 +2034,8 @@ virStorageFileDeinit(virStorageSourcePtr src) * initialization failed. Libvirt error is reported. */ int -virStorageFileInitAs(virStorageSourcePtr src, - uid_t uid, gid_t gid) +virStorageSourceInitAs(virStorageSourcePtr src, + uid_t uid, gid_t gid) { int actualType =3D virStorageSourceGetActualType(src); virStorageDriverDataPtr drv =3D g_new0(virStorageDriverData, 1); @@ -2071,20 +2071,20 @@ virStorageFileInitAs(virStorageSourcePtr src, =20 =20 /** - * virStorageFileInit: + * virStorageSourceInit: * - * See virStorageFileInitAs. The file is initialized to be accessed by the + * See virStorageSourceInitAs. The file is initialized to be accessed by t= he * current user. */ int -virStorageFileInit(virStorageSourcePtr src) +virStorageSourceInit(virStorageSourcePtr src) { - return virStorageFileInitAs(src, -1, -1); + return virStorageSourceInitAs(src, -1, -1); } =20 =20 /** - * virStorageFileCreate: Creates an empty storage file via storage driver + * virStorageSourceCreate: Creates an empty storage file via storage driver * * @src: file structure pointing to the file * @@ -2092,12 +2092,12 @@ virStorageFileInit(virStorageSourcePtr src) * -1 on other failure. Errno is set in case of failure. */ int -virStorageFileCreate(virStorageSourcePtr src) +virStorageSourceCreate(virStorageSourcePtr src) { virStorageDriverDataPtr drv =3D NULL; int ret; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { errno =3D ENOSYS; return -2; } @@ -2119,7 +2119,7 @@ virStorageFileCreate(virStorageSourcePtr src) =20 =20 /** - * virStorageFileUnlink: Unlink storage file via storage driver + * virStorageSourceUnlink: Unlink storage file via storage driver * * @src: file structure pointing to the file * @@ -2129,12 +2129,12 @@ virStorageFileCreate(virStorageSourcePtr src) * -1 on other failure. Errno is set in case of failure. */ int -virStorageFileUnlink(virStorageSourcePtr src) +virStorageSourceUnlink(virStorageSourcePtr src) { virStorageDriverDataPtr drv =3D NULL; int ret; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { errno =3D ENOSYS; return -2; } @@ -2156,7 +2156,7 @@ virStorageFileUnlink(virStorageSourcePtr src) =20 =20 /** - * virStorageFileStat: returns stat struct of a file via storage driver + * virStorageSourceStat: returns stat struct of a file via storage driver * * @src: file structure pointing to the file * @stat: stat structure to return data @@ -2165,13 +2165,13 @@ virStorageFileUnlink(virStorageSourcePtr src) * -1 on other failure. Errno is set in case of failure. */ int -virStorageFileStat(virStorageSourcePtr src, - struct stat *st) +virStorageSourceStat(virStorageSourcePtr src, + struct stat *st) { virStorageDriverDataPtr drv =3D NULL; int ret; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { errno =3D ENOSYS; return -2; } @@ -2193,7 +2193,7 @@ virStorageFileStat(virStorageSourcePtr src, =20 =20 /** - * virStorageFileRead: read bytes from a file into a buffer + * virStorageSourceRead: read bytes from a file into a buffer * * @src: file structure pointing to the file * @offset: number of bytes to skip in the storage file @@ -2205,15 +2205,15 @@ virStorageFileStat(virStorageSourcePtr src, * Libvirt error is reported on failure. */ ssize_t -virStorageFileRead(virStorageSourcePtr src, - size_t offset, - size_t len, - char **buf) +virStorageSourceRead(virStorageSourcePtr src, + size_t offset, + size_t len, + char **buf) { virStorageDriverDataPtr drv =3D NULL; ssize_t ret; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage file backend not initialized")); return -1; @@ -2234,7 +2234,7 @@ virStorageFileRead(virStorageSourcePtr src, =20 =20 /* - * virStorageFileGetUniqueIdentifier: Get a unique string describing the v= olume + * virStorageSourceGetUniqueIdentifier: Get a unique string describing the= volume * * @src: file structure pointing to the file * @@ -2242,11 +2242,11 @@ virStorageFileRead(virStorageSourcePtr src, * The string shall not be freed and is valid until the storage file is * deinitialized. Returns NULL on error and sets a libvirt error code */ const char * -virStorageFileGetUniqueIdentifier(virStorageSourcePtr src) +virStorageSourceGetUniqueIdentifier(virStorageSourcePtr src) { virStorageDriverDataPtr drv =3D NULL; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage file backend not initialized")); return NULL; @@ -2268,7 +2268,7 @@ virStorageFileGetUniqueIdentifier(virStorageSourcePtr= src) =20 =20 /** - * virStorageFileAccess: Check accessibility of a storage file + * virStorageSourceAccess: Check accessibility of a storage file * * @src: storage file to check access permissions * @mode: accessibility check options (see man 2 access) @@ -2278,12 +2278,12 @@ virStorageFileGetUniqueIdentifier(virStorageSourceP= tr src) * by libvirt storage backend. */ int -virStorageFileAccess(virStorageSourcePtr src, - int mode) +virStorageSourceAccess(virStorageSourcePtr src, + int mode) { virStorageDriverDataPtr drv =3D NULL; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { errno =3D ENOSYS; return -2; } @@ -2300,7 +2300,7 @@ virStorageFileAccess(virStorageSourcePtr src, =20 =20 /** - * virStorageFileChown: Change owner of a storage file + * virStorageSourceChown: Change owner of a storage file * * @src: storage file to change owner of * @uid: new owner id @@ -2311,13 +2311,13 @@ virStorageFileAccess(virStorageSourcePtr src, * by libvirt storage backend. */ int -virStorageFileChown(const virStorageSource *src, - uid_t uid, - gid_t gid) +virStorageSourceChown(const virStorageSource *src, + uid_t uid, + gid_t gid) { virStorageDriverDataPtr drv =3D NULL; =20 - if (!virStorageFileIsInitialized(src)) { + if (!virStorageSourceIsInitialized(src)) { errno =3D ENOSYS; return -2; } @@ -2337,7 +2337,7 @@ virStorageFileChown(const virStorageSource *src, =20 =20 /** - * virStorageFileReportBrokenChain: + * virStorageSourceReportBrokenChain: * * @errcode: errno when accessing @src * @src: inaccessible file in the backing chain of @parent @@ -2347,9 +2347,9 @@ virStorageFileChown(const virStorageSource *src, * for @parent. */ void -virStorageFileReportBrokenChain(int errcode, - virStorageSourcePtr src, - virStorageSourcePtr parent) +virStorageSourceReportBrokenChain(int errcode, + virStorageSourcePtr src, + virStorageSourcePtr parent) { if (src->drv) { virStorageDriverDataPtr drv =3D src->drv; @@ -2383,27 +2383,27 @@ virStorageFileReportBrokenChain(int errcode, =20 =20 static int -virStorageFileGetMetadataRecurseReadHeader(virStorageSourcePtr src, - virStorageSourcePtr parent, - uid_t uid, - gid_t gid, - char **buf, - size_t *headerLen, - GHashTable *cycle) +virStorageSourceGetMetadataRecurseReadHeader(virStorageSourcePtr src, + virStorageSourcePtr parent, + uid_t uid, + gid_t gid, + char **buf, + size_t *headerLen, + GHashTable *cycle) { int ret =3D -1; const char *uniqueName; ssize_t len; =20 - if (virStorageFileInitAs(src, uid, gid) < 0) + if (virStorageSourceInitAs(src, uid, gid) < 0) return -1; =20 - if (virStorageFileAccess(src, F_OK) < 0) { - virStorageFileReportBrokenChain(errno, src, parent); + if (virStorageSourceAccess(src, F_OK) < 0) { + virStorageSourceReportBrokenChain(errno, src, parent); goto cleanup; } =20 - if (!(uniqueName =3D virStorageFileGetUniqueIdentifier(src))) + if (!(uniqueName =3D virStorageSourceGetUniqueIdentifier(src))) goto cleanup; =20 if (virHashHasEntry(cycle, uniqueName)) { @@ -2416,26 +2416,26 @@ virStorageFileGetMetadataRecurseReadHeader(virStora= geSourcePtr src, if (virHashAddEntry(cycle, uniqueName, NULL) < 0) goto cleanup; =20 - if ((len =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, buf)) = < 0) + if ((len =3D virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, buf)= ) < 0) goto cleanup; =20 *headerLen =3D len; ret =3D 0; =20 cleanup: - virStorageFileDeinit(src); + virStorageSourceDeinit(src); return ret; } =20 =20 -/* Recursive workhorse for virStorageFileGetMetadata. */ +/* Recursive workhorse for virStorageSourceGetMetadata. */ static int -virStorageFileGetMetadataRecurse(virStorageSourcePtr src, - virStorageSourcePtr parent, - uid_t uid, gid_t gid, - bool report_broken, - GHashTable *cycle, - unsigned int depth) +virStorageSourceGetMetadataRecurse(virStorageSourcePtr src, + virStorageSourcePtr parent, + uid_t uid, gid_t gid, + bool report_broken, + GHashTable *cycle, + unsigned int depth) { virStorageFileFormat orig_format =3D src->format; size_t headerLen; @@ -2451,7 +2451,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, src->format =3D VIR_STORAGE_FILE_AUTO; =20 /* exit if we can't load information about the current image */ - rv =3D virStorageFileSupportsBackingChainTraversal(src); + rv =3D virStorageSourceSupportsBackingChainTraversal(src); if (rv <=3D 0) { if (orig_format =3D=3D VIR_STORAGE_FILE_AUTO) return -2; @@ -2459,8 +2459,8 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, return rv; } =20 - if (virStorageFileGetMetadataRecurseReadHeader(src, parent, uid, gid, - &buf, &headerLen, cycle= ) < 0) + if (virStorageSourceGetMetadataRecurseReadHeader(src, parent, uid, gid, + &buf, &headerLen, cyc= le) < 0) return -1; =20 if (virStorageFileProbeGetMetadata(src, buf, headerLen) < 0) @@ -2484,10 +2484,10 @@ virStorageFileGetMetadataRecurse(virStorageSourcePt= r src, if (rv =3D=3D 1) return 0; =20 - if ((rv =3D virStorageFileGetMetadataRecurse(backingStore, parent, - uid, gid, - report_broken, - cycle, depth + 1)) < 0)= { + if ((rv =3D virStorageSourceGetMetadataRecurse(backingStore, paren= t, + uid, gid, + report_broken, + cycle, depth + 1)) < = 0) { if (!report_broken) return 0; =20 @@ -2513,7 +2513,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, =20 =20 /** - * virStorageFileGetMetadata: + * virStorageSourceGetMetadata: * * Extract metadata about the storage volume with the specified * image format. If image format is VIR_STORAGE_FILE_AUTO, it @@ -2534,9 +2534,9 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, * Caller MUST free result after use via virObjectUnref. */ int -virStorageFileGetMetadata(virStorageSourcePtr src, - uid_t uid, gid_t gid, - bool report_broken) +virStorageSourceGetMetadata(virStorageSourcePtr src, + uid_t uid, gid_t gid, + bool report_broken) { GHashTable *cycle =3D NULL; virStorageType actualType =3D virStorageSourceGetActualType(src); @@ -2556,8 +2556,8 @@ virStorageFileGetMetadata(virStorageSourcePtr src, src->format =3D VIR_STORAGE_FILE_RAW; } =20 - ret =3D virStorageFileGetMetadataRecurse(src, src, uid, gid, - report_broken, cycle, 1); + ret =3D virStorageSourceGetMetadataRecurse(src, src, uid, gid, + report_broken, cycle, 1); =20 virHashFree(cycle); return ret; @@ -2565,7 +2565,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src, =20 =20 /** - * virStorageFileGetBackingStoreStr: + * virStorageSourceGetBackingStoreStr: * @src: storage object * * Extracts the backing store string as stored in the storage volume descr= ibed @@ -2574,8 +2574,8 @@ virStorageFileGetMetadata(virStorageSourcePtr src, * returned. */ int -virStorageFileGetBackingStoreStr(virStorageSourcePtr src, - char **backing) +virStorageSourceGetBackingStoreStr(virStorageSourcePtr src, + char **backing) { ssize_t headerLen; int rv; @@ -2585,19 +2585,19 @@ virStorageFileGetBackingStoreStr(virStorageSourcePt= r src, *backing =3D NULL; =20 /* exit if we can't load information about the current image */ - if (!virStorageFileSupportsBackingChainTraversal(src)) + if (!virStorageSourceSupportsBackingChainTraversal(src)) return 0; =20 - rv =3D virStorageFileAccess(src, F_OK); + rv =3D virStorageSourceAccess(src, F_OK); if (rv =3D=3D -2) return 0; if (rv < 0) { - virStorageFileReportBrokenChain(errno, src, src); + virStorageSourceReportBrokenChain(errno, src, src); return -1; } =20 - if ((headerLen =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, - &buf)) < 0) { + if ((headerLen =3D virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, + &buf)) < 0) { if (headerLen =3D=3D -2) return 0; return -1; diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_s= ource.h index 5d6ad4606d..480333d37a 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -28,23 +28,23 @@ #endif =20 virStorageSourcePtr -virStorageFileGetMetadataFromFD(const char *path, - int fd, - int format); +virStorageSourceGetMetadataFromFD(const char *path, + int fd, + int format); =20 virStorageSourcePtr -virStorageFileGetMetadataFromBuf(const char *path, - char *buf, - size_t len, - int format) +virStorageSourceGetMetadataFromBuf(const char *path, + char *buf, + size_t len, + int format) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 virStorageSourcePtr -virStorageFileChainLookup(virStorageSourcePtr chain, - virStorageSourcePtr startFrom, - const char *name, - unsigned int idx, - virStorageSourcePtr *parent) +virStorageSourceChainLookup(virStorageSourcePtr chain, + virStorageSourcePtr startFrom, + const char *name, + unsigned int idx, + virStorageSourcePtr *parent) ATTRIBUTE_NONNULL(1); =20 int @@ -72,9 +72,9 @@ virStorageSourceParseRBDColonString(const char *rbdstr, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int -virStorageFileGetRelativeBackingPath(virStorageSourcePtr top, - virStorageSourcePtr base, - char **relpath) +virStorageSourceGetRelativeBackingPath(virStorageSourcePtr top, + virStorageSourcePtr base, + char **relpath) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 int @@ -82,67 +82,67 @@ virStorageSourceNewFromBackingAbsolute(const char *path, virStorageSourcePtr *src); =20 int -virStorageFileInit(virStorageSourcePtr src); +virStorageSourceInit(virStorageSourcePtr src); =20 int -virStorageFileInitAs(virStorageSourcePtr src, - uid_t uid, gid_t gid); +virStorageSourceInitAs(virStorageSourcePtr src, + uid_t uid, gid_t gid); =20 void -virStorageFileDeinit(virStorageSourcePtr src); +virStorageSourceDeinit(virStorageSourcePtr src); =20 int -virStorageFileCreate(virStorageSourcePtr src); +virStorageSourceCreate(virStorageSourcePtr src); =20 int -virStorageFileUnlink(virStorageSourcePtr src); +virStorageSourceUnlink(virStorageSourcePtr src); =20 int -virStorageFileStat(virStorageSourcePtr src, - struct stat *st); +virStorageSourceStat(virStorageSourcePtr src, + struct stat *st); =20 ssize_t -virStorageFileRead(virStorageSourcePtr src, - size_t offset, - size_t len, - char **buf); +virStorageSourceRead(virStorageSourcePtr src, + size_t offset, + size_t len, + char **buf); =20 const char * -virStorageFileGetUniqueIdentifier(virStorageSourcePtr src); +virStorageSourceGetUniqueIdentifier(virStorageSourcePtr src); =20 int -virStorageFileAccess(virStorageSourcePtr src, - int mode); +virStorageSourceAccess(virStorageSourcePtr src, + int mode); =20 int -virStorageFileChown(const virStorageSource *src, - uid_t uid, - gid_t gid); +virStorageSourceChown(const virStorageSource *src, + uid_t uid, + gid_t gid); =20 int -virStorageFileSupportsSecurityDriver(const virStorageSource *src); +virStorageSourceSupportsSecurityDriver(const virStorageSource *src); =20 int -virStorageFileSupportsAccess(const virStorageSource *src); +virStorageSourceSupportsAccess(const virStorageSource *src); =20 int -virStorageFileSupportsCreate(const virStorageSource *src); +virStorageSourceSupportsCreate(const virStorageSource *src); =20 int -virStorageFileSupportsBackingChainTraversal(const virStorageSource *src); +virStorageSourceSupportsBackingChainTraversal(const virStorageSource *src); =20 int -virStorageFileGetMetadata(virStorageSourcePtr src, - uid_t uid, gid_t gid, - bool report_broken) +virStorageSourceGetMetadata(virStorageSourcePtr src, + uid_t uid, gid_t gid, + bool report_broken) ATTRIBUTE_NONNULL(1); =20 int -virStorageFileGetBackingStoreStr(virStorageSourcePtr src, - char **backing) +virStorageSourceGetBackingStoreStr(virStorageSourcePtr src, + char **backing) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 void -virStorageFileReportBrokenChain(int errcode, - virStorageSourcePtr src, - virStorageSourcePtr parent); +virStorageSourceReportBrokenChain(int errcode, + virStorageSourcePtr src, + virStorageSourcePtr parent); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 5c2f211557..0e168ce730 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -101,7 +101,7 @@ testStorageFileGetMetadata(const char *path, =20 def->path =3D g_strdup(path); =20 - if (virStorageFileGetMetadata(def, uid, gid, true) < 0) + if (virStorageSourceGetMetadata(def, uid, gid, true) < 0) return NULL; =20 return g_steal_pointer(&def); @@ -366,9 +366,9 @@ testStorageLookup(const void *args) } =20 /* Test twice to ensure optional parameter doesn't cause NULL deref. = */ - result =3D virStorageFileChainLookup(data->chain, data->from, - idx ? NULL : data->name, - idx, NULL); + result =3D virStorageSourceChainLookup(data->chain, data->from, + idx ? NULL : data->name, + idx, NULL); =20 if (!data->expResult) { if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) { @@ -395,8 +395,8 @@ testStorageLookup(const void *args) ret =3D -1; } =20 - result =3D virStorageFileChainLookup(data->chain, data->from, - data->name, idx, &actualParent); + result =3D virStorageSourceChainLookup(data->chain, data->from, + data->name, idx, &actualParent); if (!data->expResult) virResetLastError(); =20 @@ -552,9 +552,9 @@ testPathRelative(const void *args) const struct testPathRelativeBacking *data =3D args; g_autofree char *actual =3D NULL; =20 - if (virStorageFileGetRelativeBackingPath(data->top, - data->base, - &actual) < 0) { + if (virStorageSourceGetRelativeBackingPath(data->top, + data->base, + &actual) < 0) { fprintf(stderr, "relative backing path resolution failed\n"); return -1; } --=20 2.29.2