diff mbox series

[1/7] conf: Move -virDomainDiskDefForeachPath to virt-aa-helper

Message ID 7c867f70bebe5913f18413154e428231150eaf55.1570551720.git.crobinso@redhat.com
State Accepted
Commit cb757f9d32329c90ffa36f1aa6f7a60752610a76
Headers show
Series security: apparmor: prep for qcow2 data_file | expand

Commit Message

Cole Robinson Oct. 8, 2019, 4:22 p.m. UTC
It is the only user. Rename it to match the local style

Signed-off-by: Cole Robinson <crobinso@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(-)

-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Michal Prívozník Oct. 9, 2019, 2:22 p.m. UTC | #1
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@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

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;
     }