From patchwork Tue Oct 8 16:22:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175517 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5920362ill; Tue, 8 Oct 2019 09:24:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJ3DwACo1hpYZZkWGzYGBztCwX5V8/JQI2yBUaCDVoQYMAuM0jFrzHTUNDDK5idYclwOyS X-Received: by 2002:a92:5c0c:: with SMTP id q12mr37340743ilb.111.1570551897339; Tue, 08 Oct 2019 09:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570551897; cv=none; d=google.com; s=arc-20160816; b=dfV96o+WMeKxFSDkVCqGSX7OqzYkF3LK7Nw9zZhcdxBe4Ii9U+tGruXBEFx6c4eUGp dmsN/0v4pdqukRqmYaxRrEEkXAhXBS7DQnitAgK7iov0rSneeSQy0tSp0mbMFntypsds zQNJv1f6S/xruxLxPWRn6wZpfN8mFIbkpNtXffuqQgTCfeHpIorbeso69xDRzXQ+yXOX TIMg1Wdn7csWiBK1IoN6MXzLLnRgGJFw2TU+A4bRGly5jQlO3pNCqxhYroZTazbwnNJl SE/6j+fioGjc+dvO4gLZt6WrzbvCs/gt22Eh+xjHYlArgRStD2ZJkE3vqfP2c6n8HWis YdAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=es76ZI2E/BjmvJsH8rYC9oiUmpuJ4nCYU+RoTAsOyQQ=; b=jmxoDbI6LJXxWPu3rDbJloe7URO20Ze5RQWJEBTnBdoP3Vo0WsmFN5/ympYC8ho6E3 sLneCtgoC4VSnlWFj0g1zu1DiXe+gL/kcmIQUrSxpVLD82tM4jgTWfAUk4ZEz0Cd0+Wc SphYP7LJP97XEypiinoRq+EZUyXpavzhfG8Rrj5JV4jxKKioJT7VBL8PuhLlDhLbzCa4 RTM1O2jB16Hia8v/0lfG5AvDy8MYedPD9ru2337bSHafHRNye4Dd7MgKj4xuF63+p9pt NkEOfHcAxkMQi7kCswVJH46HAp4ynWNqYT88R+jfNfZMjaZzNu5hIXkAAJ5V6tOnGm4s o/mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id a15si20105391ila.159.2019.10.08.09.24.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 09:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 mx1.redhat.com (Postfix) with ESMTPS id BD2AA4627A; Tue, 8 Oct 2019 16:24:55 +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 62AFB5D9CD; Tue, 8 Oct 2019 16:24:53 +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 D825218089DC; Tue, 8 Oct 2019 16:24:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x98GLxSM008659 for ; Tue, 8 Oct 2019 12:21:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3CD5D60606; Tue, 8 Oct 2019 16:21:59 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.bos.redhat.com (dhcp-17-175.bos.redhat.com [10.18.17.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C90F760605; Tue, 8 Oct 2019 16:21:58 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 8 Oct 2019 12:22:21 -0400 Message-Id: <7c867f70bebe5913f18413154e428231150eaf55.1570551720.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: christian.ehrhardt@canonical.com Subject: [libvirt] [PATCH 1/7] conf: Move -virDomainDiskDefForeachPath to virt-aa-helper 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 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Oct 2019 16:24:56 +0000 (UTC) It is the only user. Rename it to match the local style Signed-off-by: Cole Robinson --- 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(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a53cd6a725..5fe03ea866 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29486,48 +29486,6 @@ virDomainUSBDeviceDefForeach(virDomainDefPtr def, } -/* 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. */ -int -virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, - bool ignoreOpenFailure, - virDomainDiskDefPathIterator 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; -} - - /* Copy src into a new definition; with the quality of the copy * depending on the migratable flag (false for transitions between * persistent and active, true for transitions across save files or diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2884af49d8..653dcaf2bc 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3327,11 +3327,6 @@ int virDomainChrDefForeach(virDomainDefPtr def, virDomainChrDefIterator iter, void *opaque); -typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk, - const char *path, - size_t depth, - void *opaque); - typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info, void *opaque); int virDomainUSBDeviceDefForeach(virDomainDefPtr def, @@ -3339,11 +3334,6 @@ int virDomainUSBDeviceDefForeach(virDomainDefPtr def, void *opaque, bool skipHubs); -int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, - bool ignoreOpenFailure, - virDomainDiskDefPathIterator iter, - void *opaque); - void virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason) ATTRIBUTE_NONNULL(1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c818bc807a..5949cba08d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -334,7 +334,6 @@ virDomainDiskCacheTypeFromString; virDomainDiskCacheTypeToString; virDomainDiskDefAssignAddress; virDomainDiskDefCheckDuplicateInfo; -virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDefNew; virDomainDiskDefParse; 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. */ - if (virDomainDiskDefForeachPath(disk, true, add_file_path, &buf) < 0) + if (disk_foreach_path(disk, true, add_file_path, &buf) < 0) goto cleanup; }