[PATCH 05/12] qemu: Convert boolean flags to enum flags in qemuDomainStorageSourceAccessModify

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Upcoming patches will add a few more flags. Add an enum to collect them
so that we don't end up with multiple bools.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b4c59b9a74..6644c1418b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9211,16 +9211,21 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
 }


+typedef enum {
+    /* revoke access to the image instead of allowing it */
+    QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE = 1 << 0,
+} qemuDomainStorageSourceAccessFlags;
+
+
 /**
  * qemuDomainStorageSourceAccessModify:
  * @driver: qemu driver struct
  * @vm: domain object
  * @src: Source to prepare
- * @teardown: Teardown the access to @src instead of adding it to a vm
+ * @flags: bitwise or of qemuDomainStorageSourceAccessFlags
  *
  * Setup the locks, cgroups and security permissions on a disk source and its
- * backing chain. If @teardown is true, then the labels and cgroups are removed
- * instead.
+ * backing chain.
  *
  * Returns 0 on success and -1 on error. Reports libvirt error.
  */
@@ -9228,7 +9233,7 @@ static int
 qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     virStorageSourcePtr src,
-                                    bool teardown)
+                                    qemuDomainStorageSourceAccessFlags flags)
 {
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
     const char *srcstr = NULLSTR(src->path);
@@ -9236,7 +9241,7 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
     virErrorPtr orig_err = NULL;

     /* just tear down the disk access */
-    if (teardown) {
+    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE) {
         virErrorPreserveLast(&orig_err);
         ret = 0;
         goto rollback_cgroup;
@@ -9284,7 +9289,9 @@ qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
                                         virStorageSourcePtr src)
 {
-    return qemuDomainStorageSourceAccessModify(driver, vm, src, false);
+    qemuDomainStorageSourceAccessFlags flags = 0;
+
+    return qemuDomainStorageSourceAccessModify(driver, vm, src, flags);
 }


@@ -9293,7 +9300,9 @@ qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
                                          virDomainObjPtr vm,
                                          virStorageSourcePtr src)
 {
-    return qemuDomainStorageSourceAccessModify(driver, vm, src, true);
+    qemuDomainStorageSourceAccessFlags flags = QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE;
+
+    return qemuDomainStorageSourceAccessModify(driver, vm, src, flags);
 }


-- 
2.20.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux