[PATCH 1/4] internal: introduce macro virCheckControllerGoto

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

 



From: Chen Hanxiao <chenhanxiao@xxxxxxxxx>

Introduce macro virCheckControllerGoto.
Jumps to a label if unsupported controller type were
passed to it.

Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxx>
---
 src/internal.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/internal.h b/src/internal.h
index d8cc5ad..a34f43e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -362,6 +362,25 @@
         }                                                               \
     } while (0)
 
+/**
+ * virCheckControllerGoto:
+ * @Cgp: virCgroupPtr pointer
+ * @CgpCtr: cgroup controller type enum
+ * @label: label to jump to on error
+ *
+ * Returns nothing. Jumps to a label if unsupported controller type were
+ * passed to it.
+ */
+# define virCheckControllerGoto(Cgp, CgpCtr, label)                    \
+    do {                                                               \
+        if (!virCgroupHasController(Cgp, CgpCtr)) {                    \
+            virReportError(VIR_ERR_OPERATION_INVALID,                  \
+                            _("cgroup %s controller is not mounted"),  \
+                           virCgroupControllerTypeToString(CgpCtr));   \
+            goto label;                                                \
+        }                                                              \
+    } while (0)
+
 /* Macros to help dealing with mutually exclusive flags. */
 
 /**
-- 
1.8.3.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