diff --git a/tools/virsh.c b/tools/virsh.c index 63721770e4..dea3f82493 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1562,20 +1562,20 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) !(cmd->def->flags & VSH_CMD_FLAG_NOCONNECT)) vshReconnect(ctl); + if (enable_timing) + GETTIMEOFDAY(&before); + if ((cmd->def->flags & VSH_CMD_FLAG_NOCONNECT) || vshConnectionUsability(ctl, ctl->conn)) { - if (enable_timing) - GETTIMEOFDAY(&before); - ret = cmd->def->handler(ctl, cmd); - - if (enable_timing) - GETTIMEOFDAY(&after); } else { /* connection is not usable, return error */ ret = false; } + if (enable_timing) + GETTIMEOFDAY(&after); + /* try to automatically catch disconnections */ if (!ret && ((last_error != NULL) &&