]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add function that raises error if domain is not active
authorClementine Hayat <clem@lse.epita.fr>
Tue, 17 Apr 2018 22:13:26 +0000 (22:13 +0000)
committerJán Tomko <jtomko@redhat.com>
Wed, 18 Apr 2018 08:22:07 +0000 (10:22 +0200)
Add a function named virDomainObjCheckIsActive in src/conf/domain_conf.c.
It calls virDomainObjIsActive, raises error if necessary and returns.

There is a lot of occurence of this pattern and it will save 3 lines on
each call.

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

index e2345bba17a4fd3db47a1506267ac67343cb3eab..ae2135263ecc86f8db12c5436aa689b908e165fa 100644 (file)
@@ -5997,6 +5997,17 @@ virDomainDefValidate(virDomainDefPtr def,
     return 0;
 }
 
+int
+virDomainObjCheckActive(virDomainObjPtr dom)
+{
+    if (!virDomainObjIsActive(dom)) {
+       virReportError(VIR_ERR_OPERATION_INVALID,
+                      "%s", _("domain is not running"));
+       return -1;
+    }
+    return 0;
+}
+
 
 /**
  * virDomainDeviceLoadparmIsValid
index bbaa24137d8551eb398d4745bccded2dc64a99af..122a051b2aff8c8376ee44400b290a04469dce39 100644 (file)
@@ -2722,6 +2722,8 @@ virDomainObjIsActive(virDomainObjPtr dom)
     return dom->def->id != -1;
 }
 
+int virDomainObjCheckActive(virDomainObjPtr dom);
+
 int virDomainDefSetVcpusMax(virDomainDefPtr def,
                             unsigned int vcpus,
                             virDomainXMLOptionPtr xmlopt);
index 0918e695254e84b69e89cfcc8df04954fadaf460..b31f599bd29e49712a60a85ed43b892488700763 100644 (file)
@@ -474,6 +474,7 @@ virDomainNostateReasonTypeFromString;
 virDomainNostateReasonTypeToString;
 virDomainObjAssignDef;
 virDomainObjBroadcast;
+virDomainObjCheckActive;
 virDomainObjCopyPersistentDef;
 virDomainObjEndAPI;
 virDomainObjFormat;