[libvirt] [PATCH 1/7] conf: Move -virDomainDiskDefForeachPath to virt-aa-helper
Michal Privoznik
mprivozn at redhat.com
Wed Oct 9 14:22:37 UTC 2019
On 10/8/19 6:22 PM, Cole Robinson wrote:
> It is the only user. Rename it to match the local style
>
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
> src/conf/domain_conf.c | 42 -----------------------------
> src/conf/domain_conf.h | 10 -------
> src/libvirt_private.syms | 1 -
> src/security/virt-aa-helper.c | 50 ++++++++++++++++++++++++++++++++++-
> 4 files changed, 49 insertions(+), 54 deletions(-)
>
> diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
> index 5853ad985f..6e358ff5b6 100644
> --- a/src/security/virt-aa-helper.c
> +++ b/src/security/virt-aa-helper.c
> @@ -934,6 +934,54 @@ add_file_path(virDomainDiskDefPtr disk,
> return ret;
> }
>
> +
> +typedef int (*disk_foreach_iterator)(virDomainDiskDefPtr disk,
> + const char *path,
> + size_t depth,
> + void *opaque);
> +
> +
> +/* Call iter(disk, name, depth, opaque) for each element of disk and
> + * its backing chain in the pre-populated disk->src.backingStore.
> + * ignoreOpenFailure determines whether to warn about a chain that
> + * mentions a backing file without also having metadata on that
> + * file. */
> +static int
> +disk_foreach_path(virDomainDiskDefPtr disk,
> + bool ignoreOpenFailure,
> + disk_foreach_iterator iter,
> + void *opaque)
> +{
> + size_t depth = 0;
> + virStorageSourcePtr tmp;
> + VIR_AUTOFREE(char *) brokenRaw = NULL;
> +
> + if (!ignoreOpenFailure) {
> + if (virStorageFileChainGetBroken(disk->src, &brokenRaw) < 0)
> + return -1;
> +
> + if (brokenRaw) {
> + virReportError(VIR_ERR_INTERNAL_ERROR,
> + _("unable to visit backing chain file %s"),
> + brokenRaw);
> + return -1;
> + }
> + }
> +
> + for (tmp = disk->src; virStorageSourceIsBacking(tmp); tmp = tmp->backingStore) {
> + /* execute the callback only for local storage */
> + if (virStorageSourceIsLocalStorage(tmp) &&
> + tmp->path) {
> + if (iter(disk, tmp->path, depth, opaque) < 0)
> + return -1;
> + }
> +
> + depth++;
> + }
> +
> + return 0;
> +}
> +
> static int
> get_files(vahControl * ctl)
> {
> @@ -977,7 +1025,7 @@ get_files(vahControl * ctl)
> * be passing ignoreOpenFailure = false and handle open errors more
> * careful than just ignoring them.
There's one occurrence of virDomainDiskDefForeachPath in this comment ^^^
> */
> - if (virDomainDiskDefForeachPath(disk, true, add_file_path, &buf) < 0)
> + if (disk_foreach_path(disk, true, add_file_path, &buf) < 0)
> goto cleanup;
> }
>
>
Michal
More information about the libvir-list
mailing list