You want to kill a long running task in RHEV / oVirt Virtualization environment?. In oVirt/RHEV, a task is an operation that has state. If an operation can begin, process something and finish it is a Task.

VDSM Task Flow

There are two major types of operations in oVirt:

  1. Sync operations – This is not a task from the engine. It returns immediately after the request from Vdsm. The operation fails if failure occurred before the response is retrieved.
  2. Async Operations – The Vdsm and engine contain states for these operations. The states implies that the operation needs to pass some actions before returns. Most of those operations are storage related. Engine should correlate with Vdsm task’s IDs and states to distinguish the result by polling the information.

You can check a list of currently running tasks vdsm-client command.

$ sudo vdsm-client Host getAllTasksInfo
{
    "9022a6e0-06cf-4066-b9f7-cbe23ffe851e": {
        "verb": "copyImage",
        "id": "9022a6e0-06cf-4066-b9f7-cbe23ffe851e"
    },
    "954d8ea4-6ab6-4ec5-9d1a-3374ec106a8c": {
        "verb": "prepareMerge",
        "id": "954d8ea4-6ab6-4ec5-9d1a-3374ec106a8c"
    },
    "c3fb509c-0554-4f10-9f73-32d346ccf012": {
        "verb": "copyImage",
        "id": "c3fb509c-0554-4f10-9f73-32d346ccf012"
    }
}

Once you get the ID of a task, you can get task status with the command:

$ sudo vdsm-client Task getStatus taskID=<TASKID>

See example below.

$ sudo vdsm-client Task getStatus taskID=c3fb509c-0554-4f10-9f73-32d346ccf012
{
    "message": "running job 1 of 1",
    "code": 0,
    "taskID": "c3fb509c-0554-4f10-9f73-32d346ccf012",
    "taskResult": "",
    "taskState": "running"
}

To kill a Task in oVirt / RHEV, use:

sudo vdsm-client Task stop taskID=<TaskID>
sudo vdsm-client Task clear taskID=<TaskID>

Confirm if the task is still running or has been killed/terminated.

sudo vdsm-client Host getAllTasksInfo

Check other oVirt related guides:

How To Add NFS Data, ISO and Export Storage Domain to oVirt / RHEV

How To Install oVirt Guest Agent on CentOS 8 / RHEL 8

How To Provision VMs on oVirt / RHEV with Terraform

Install a Server or Virtual Machine from ISO on oVirt / RHEV

Create and Manage User Accounts on oVirt and RHEV