Signed-off-by: Clementine Hayat <clem(a)lse.epita.fr>
---
src/bhyve/bhyve_driver.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 24c4a9c80..8aff0c65c 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -883,11 +883,8 @@ bhyveDomainCreateWithFlags(virDomainPtr dom,
if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("Domain is already running"));
+ if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
- }
ret = virBhyveProcessStart(dom->conn, privconn, vm,
VIR_DOMAIN_RUNNING_BOOTED,
@@ -996,11 +993,8 @@ bhyveDomainDestroy(virDomainPtr dom)
if (virDomainDestroyEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("Domain is not running"));
+ if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
- }
ret = virBhyveProcessStop(privconn, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
event = virDomainEventLifecycleNewFromObj(vm,
@@ -1031,11 +1025,8 @@ bhyveDomainShutdown(virDomainPtr dom)
if (virDomainShutdownEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("Domain is not running"));
+ if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
- }
ret = virBhyveProcessShutdown(vm);
@@ -1062,11 +1053,8 @@ bhyveDomainOpenConsole(virDomainPtr dom,
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
+ if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
- }
if (!vm->def->nserials) {
virReportError(VIR_ERR_INTERNAL_ERROR,
--
2.17.0