intCaught = 1;
}
+static void
+vshBlockJobStatusHandler(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainPtr dom ATTRIBUTE_UNUSED,
+ const char *disk ATTRIBUTE_UNUSED,
+ int type ATTRIBUTE_UNUSED,
+ int status,
+ void *opaque)
+{
+ *(int *) opaque = status;
+}
+
/*
* "blockcommit" command
*/
const char *path = NULL;
bool quit = false;
int abort_flags = 0;
+ int status = -1;
+ int cb_id = -1;
blocking |= vshCommandOptBool(cmd, "timeout") || pivot || finish;
if (blocking) {
return false;
}
+ virConnectDomainEventGenericCallback cb =
+ VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
+
+ if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
+ dom,
+ VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
+ cb,
+ &status,
+ NULL)) < 0)
+ vshResetLibvirtError();
+
if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_COMMIT, &dom))
goto cleanup;
intCaught ? "interrupted" : "timeout");
intCaught = 0;
timeout = 0;
- quit = true;
+ status = VIR_DOMAIN_BLOCK_JOB_CANCELED;
if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
vshError(ctl, _("failed to abort job for disk %s"), path);
goto cleanup;
}
}
+ if (status == VIR_DOMAIN_BLOCK_JOB_CANCELED)
+ quit = true;
+
if (verbose && !quit) {
/* printf [100 %] */
vshPrintJobProgress(_("Block Commit"), 0, 1);
virDomainFree(dom);
if (blocking)
sigaction(SIGINT, &old_sig_action, NULL);
+ if (cb_id >= 0)
+ virConnectDomainEventDeregisterAny(ctl->conn, cb_id);
return ret;
}
char *xmlstr = NULL;
virTypedParameterPtr params = NULL;
int nparams = 0;
+ int status = -1;
+ int cb_id = -1;
if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
return false;
return false;
}
+ virConnectDomainEventGenericCallback cb =
+ VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
+
+ if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
+ dom,
+ VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
+ cb,
+ &status,
+ NULL)) < 0)
+ vshResetLibvirtError();
+
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup;
intCaught ? "interrupted" : "timeout");
intCaught = 0;
timeout = 0;
- quit = true;
+ status = VIR_DOMAIN_BLOCK_JOB_CANCELED;
if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
vshError(ctl, _("failed to abort job for disk %s"), path);
goto cleanup;
}
}
+ if (status == VIR_DOMAIN_BLOCK_JOB_CANCELED)
+ quit = true;
+
if (!quit && pivot) {
abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
virDomainFree(dom);
if (blocking)
sigaction(SIGINT, &old_sig_action, NULL);
+ if (cb_id >= 0)
+ virConnectDomainEventDeregisterAny(ctl->conn, cb_id);
return ret;
}
const char *path = NULL;
bool quit = false;
int abort_flags = 0;
+ int status = -1;
+ int cb_id = -1;
if (blocking) {
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
return false;
}
+ virConnectDomainEventGenericCallback cb =
+ VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
+
+ if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
+ dom,
+ VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
+ cb,
+ &status,
+ NULL)) < 0)
+ vshResetLibvirtError();
+
if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_PULL, &dom))
goto cleanup;
intCaught ? "interrupted" : "timeout");
intCaught = 0;
timeout = 0;
- quit = true;
+ status = VIR_DOMAIN_BLOCK_JOB_CANCELED;
if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
vshError(ctl, _("failed to abort job for disk %s"), path);
goto cleanup;
}
}
+ if (status == VIR_DOMAIN_BLOCK_JOB_CANCELED)
+ quit = true;
+
if (verbose && !quit) {
/* printf [100 %] */
vshPrintJobProgress(_("Block Pull"), 0, 1);
virDomainFree(dom);
if (blocking)
sigaction(SIGINT, &old_sig_action, NULL);
+ if (cb_id >= 0)
+ virConnectDomainEventDeregisterAny(ctl->conn, cb_id);
return ret;
}