mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
virsh: block job: separate abort from blockJobImpl
This commit is contained in:
parent
42c9c6fcfc
commit
a538ff8d9c
@ -1665,7 +1665,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VSH_CMD_BLOCK_JOB_ABORT,
|
|
||||||
VSH_CMD_BLOCK_JOB_PULL,
|
VSH_CMD_BLOCK_JOB_PULL,
|
||||||
VSH_CMD_BLOCK_JOB_COMMIT,
|
VSH_CMD_BLOCK_JOB_COMMIT,
|
||||||
} vshCmdBlockJobMode;
|
} vshCmdBlockJobMode;
|
||||||
@ -1692,14 +1691,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VSH_CMD_BLOCK_JOB_ABORT:
|
|
||||||
if (vshCommandOptBool(cmd, "async"))
|
|
||||||
flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
|
||||||
if (vshCommandOptBool(cmd, "pivot"))
|
|
||||||
flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
|
|
||||||
if (virDomainBlockJobAbort(dom, path, flags) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
break;
|
|
||||||
case VSH_CMD_BLOCK_JOB_PULL:
|
case VSH_CMD_BLOCK_JOB_PULL:
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2549,6 +2540,26 @@ vshBlockJobSetSpeed(vshControl *ctl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
vshBlockJobAbort(virDomainPtr dom,
|
||||||
|
const char *path,
|
||||||
|
bool pivot,
|
||||||
|
bool async)
|
||||||
|
{
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
if (async)
|
||||||
|
flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
||||||
|
if (pivot)
|
||||||
|
flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
|
||||||
|
|
||||||
|
if (virDomainBlockJobAbort(dom, path, flags) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
@ -2579,9 +2590,6 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
|||||||
/* XXX also support --bytes with bandwidth mode */
|
/* XXX also support --bytes with bandwidth mode */
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(bytes, bandwidth);
|
VSH_EXCLUSIVE_OPTIONS_VAR(bytes, bandwidth);
|
||||||
|
|
||||||
if (abortMode || pivot || async)
|
|
||||||
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
|
|
||||||
|
|
||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -2591,6 +2599,8 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (bandwidth)
|
if (bandwidth)
|
||||||
ret = vshBlockJobSetSpeed(ctl, cmd, dom, path);
|
ret = vshBlockJobSetSpeed(ctl, cmd, dom, path);
|
||||||
|
else if (abortMode || pivot || async)
|
||||||
|
ret = vshBlockJobAbort(dom, path, pivot, async);
|
||||||
else
|
else
|
||||||
ret = vshBlockJobInfo(ctl, dom, path, raw, bytes);
|
ret = vshBlockJobInfo(ctl, dom, path, raw, bytes);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user