mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
Add function that raises error if domain is not active
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>
This commit is contained in:
parent
825bb9b842
commit
749282d400
@ -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
|
||||
|
@ -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);
|
||||
|
@ -474,6 +474,7 @@ virDomainNostateReasonTypeFromString;
|
||||
virDomainNostateReasonTypeToString;
|
||||
virDomainObjAssignDef;
|
||||
virDomainObjBroadcast;
|
||||
virDomainObjCheckActive;
|
||||
virDomainObjCopyPersistentDef;
|
||||
virDomainObjEndAPI;
|
||||
virDomainObjFormat;
|
||||
|
Loading…
Reference in New Issue
Block a user