On Thu, Apr 12, 2018 at 19:49:15 +0000, Clementine Hayat wrote:
Add a function named virDomainObjCheckIsActive in
src/conf/domain_conf.c.
It calls virDomainObjIsActive, raises error and returns.
There is a lot of occurence of this pattern and it will save 3 lines on
each call. Knowing that there is over 100 occurences, it will remove 300
lines from the code base.
Signed-off-by: Clementine Hayat <clem(a)lse.epita.fr>
---
Patch proposed for gsoc2018.
src/conf/domain_conf.c | 11 +++++
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 96 +++++++++-------------------------------
4 files changed, 34 insertions(+), 76 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d23182f18..86d28c26a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6003,6 +6003,17 @@ virDomainDefValidate(virDomainDefPtr def,
return 0;
}
+int
+virDomainObjCheckIsActive(virDomainObjPtr dom)
+{
+ if (!virDomainObjIsActive(dom)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ return -1;
You need to add one more space of indentation in the three lines above.
Jirka