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>
return 0;
}
+int
+virDomainObjCheckActive(virDomainObjPtr dom)
+{
+ if (!virDomainObjIsActive(dom)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ return -1;
+ }
+ return 0;
+}
+
/**
* virDomainDeviceLoadparmIsValid
return dom->def->id != -1;
}
+int virDomainObjCheckActive(virDomainObjPtr dom);
+
int virDomainDefSetVcpusMax(virDomainDefPtr def,
unsigned int vcpus,
virDomainXMLOptionPtr xmlopt);
virDomainNostateReasonTypeToString;
virDomainObjAssignDef;
virDomainObjBroadcast;
+virDomainObjCheckActive;
virDomainObjCopyPersistentDef;
virDomainObjEndAPI;
virDomainObjFormat;