mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 22:13:18 +00:00
virsh: blockjob: Split out vshBlockJobSetSpeed from blockJobImpl
This commit is contained in:
parent
2f12cb9355
commit
42c9c6fcfc
@ -1666,7 +1666,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VSH_CMD_BLOCK_JOB_ABORT,
|
VSH_CMD_BLOCK_JOB_ABORT,
|
||||||
VSH_CMD_BLOCK_JOB_SPEED,
|
|
||||||
VSH_CMD_BLOCK_JOB_PULL,
|
VSH_CMD_BLOCK_JOB_PULL,
|
||||||
VSH_CMD_BLOCK_JOB_COMMIT,
|
VSH_CMD_BLOCK_JOB_COMMIT,
|
||||||
} vshCmdBlockJobMode;
|
} vshCmdBlockJobMode;
|
||||||
@ -1701,10 +1700,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
|
|||||||
if (virDomainBlockJobAbort(dom, path, flags) < 0)
|
if (virDomainBlockJobAbort(dom, path, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
case VSH_CMD_BLOCK_JOB_SPEED:
|
|
||||||
if (virDomainBlockJobSetSpeed(dom, path, bandwidth, 0) < 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;
|
||||||
@ -2536,6 +2531,24 @@ vshBlockJobInfo(vshControl *ctl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
vshBlockJobSetSpeed(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
virDomainPtr dom,
|
||||||
|
const char *path)
|
||||||
|
{
|
||||||
|
unsigned long bandwidth;
|
||||||
|
|
||||||
|
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (virDomainBlockJobSetSpeed(dom, path, bandwidth, 0) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
@ -2568,10 +2581,7 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (abortMode || pivot || async)
|
if (abortMode || pivot || async)
|
||||||
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
|
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_ABORT, NULL);
|
||||||
if (bandwidth)
|
|
||||||
return blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_SPEED, NULL);
|
|
||||||
|
|
||||||
/* Everything below here is for --info mode */
|
|
||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -2579,6 +2589,9 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (bandwidth)
|
||||||
|
ret = vshBlockJobSetSpeed(ctl, cmd, dom, path);
|
||||||
|
else
|
||||||
ret = vshBlockJobInfo(ctl, dom, path, raw, bytes);
|
ret = vshBlockJobInfo(ctl, dom, path, raw, bytes);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user