mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 22:13:18 +00:00
virsh: Split out block pull implementation from blockJobImpl
This commit is contained in:
parent
a538ff8d9c
commit
bb5a145d2d
@ -1665,7 +1665,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VSH_CMD_BLOCK_JOB_PULL,
|
|
||||||
VSH_CMD_BLOCK_JOB_COMMIT,
|
VSH_CMD_BLOCK_JOB_COMMIT,
|
||||||
} vshCmdBlockJobMode;
|
} vshCmdBlockJobMode;
|
||||||
|
|
||||||
@ -1691,21 +1690,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VSH_CMD_BLOCK_JOB_PULL:
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
if (vshCommandOptBool(cmd, "keep-relative"))
|
|
||||||
flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
|
|
||||||
|
|
||||||
if (base || flags) {
|
|
||||||
if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
} else {
|
|
||||||
if (virDomainBlockPull(dom, path, bandwidth, 0) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case VSH_CMD_BLOCK_JOB_COMMIT:
|
case VSH_CMD_BLOCK_JOB_COMMIT:
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
|
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
|
vshCommandOptStringReq(ctl, cmd, "top", &top) < 0)
|
||||||
@ -2679,16 +2663,29 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|||||||
struct timeval start;
|
struct timeval start;
|
||||||
struct timeval curr;
|
struct timeval curr;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
|
const char *base = NULL;
|
||||||
|
unsigned long bandwidth = 0;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
int abort_flags = 0;
|
int abort_flags = 0;
|
||||||
int status = -1;
|
int status = -1;
|
||||||
int cb_id = -1;
|
int cb_id = -1;
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (vshCommandOptBool(cmd, "keep-relative"))
|
||||||
|
flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
|
||||||
|
|
||||||
if (blocking) {
|
if (blocking) {
|
||||||
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
|
|
||||||
return false;
|
|
||||||
if (vshCommandOptBool(cmd, "async"))
|
if (vshCommandOptBool(cmd, "async"))
|
||||||
abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC;
|
||||||
|
|
||||||
@ -2708,6 +2705,9 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
|
return false;
|
||||||
|
|
||||||
virConnectDomainEventGenericCallback cb =
|
virConnectDomainEventGenericCallback cb =
|
||||||
VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
|
VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
|
||||||
|
|
||||||
@ -2719,8 +2719,13 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|||||||
NULL)) < 0)
|
NULL)) < 0)
|
||||||
vshResetLibvirtError();
|
vshResetLibvirtError();
|
||||||
|
|
||||||
if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_PULL, &dom))
|
if (base || flags) {
|
||||||
|
if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
} else {
|
||||||
|
if (virDomainBlockPull(dom, path, bandwidth, 0) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!blocking) {
|
if (!blocking) {
|
||||||
vshPrint(ctl, "%s", _("Block Pull started"));
|
vshPrint(ctl, "%s", _("Block Pull started"));
|
||||||
@ -2778,7 +2783,6 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
cleanup:
|
cleanup:
|
||||||
if (dom)
|
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
if (blocking)
|
if (blocking)
|
||||||
sigaction(SIGINT, &old_sig_action, NULL);
|
sigaction(SIGINT, &old_sig_action, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user