ignore_value(safewrite(data->writefd, &ret, sizeof(ret)));
}
+static bool
+vshWatchJob(vshControl *ctl,
+ virDomainPtr dom,
+ bool verbose,
+ int pipe_fd,
+ int timeout,
+ jobWatchTimeoutFunc timeout_func,
+ void *opaque,
+ const char *label)
+{
+ struct sigaction sig_action;
+ struct sigaction old_sig_action;
+ struct pollfd pollfd;
+ struct timeval start, curr;
+ virDomainJobInfo jobinfo;
+ int ret = -1;
+ char retchar;
+ bool functionReturn = false;
+ sigset_t sigmask, oldsigmask;
+
+ sigemptyset(&sigmask);
+ sigaddset(&sigmask, SIGINT);
+
+ intCaught = 0;
+ sig_action.sa_sigaction = vshCatchInt;
+ sig_action.sa_flags = SA_SIGINFO;
+ sigemptyset(&sig_action.sa_mask);
+ sigaction(SIGINT, &sig_action, &old_sig_action);
+
+ pollfd.fd = pipe_fd;
+ pollfd.events = POLLIN;
+ pollfd.revents = 0;
+
+ GETTIMEOFDAY(&start);
+ while (1) {
+repoll:
+ ret = poll(&pollfd, 1, 500);
+ if (ret > 0) {
+ if (pollfd.revents & POLLIN &&
+ saferead(pipe_fd, &retchar, sizeof(retchar)) > 0 &&
+ retchar == '0') {
+ if (verbose) {
+ /* print [100 %] */
+ print_job_progress(label, 0, 1);
+ }
+ break;
+ }
+ goto cleanup;
+ }
+
+ if (ret < 0) {
+ if (errno == EINTR) {
+ if (intCaught) {
+ virDomainAbortJob(dom);
+ intCaught = 0;
+ } else {
+ goto repoll;
+ }
+ }
+ goto cleanup;
+ }
+
+ GETTIMEOFDAY(&curr);
+ if (timeout && (((int)(curr.tv_sec - start.tv_sec) * 1000 +
+ (int)(curr.tv_usec - start.tv_usec) / 1000) >
+ timeout * 1000)) {
+ /* suspend the domain when migration timeouts. */
+ vshDebug(ctl, VSH_ERR_DEBUG, "%s timeout", label);
+ if (timeout_func)
+ (timeout_func)(ctl, dom, opaque);
+ timeout = 0;
+ }
+
+ if (verbose) {
+ pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask);
+ ret = virDomainGetJobInfo(dom, &jobinfo);
+ pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
+ if (ret == 0)
+ print_job_progress(label, jobinfo.dataRemaining,
+ jobinfo.dataTotal);
+ }
+ }
+
+ functionReturn = true;
+
+cleanup:
+ sigaction(SIGINT, &old_sig_action, NULL);
+ return functionReturn;
+}
+
static bool
cmdSave(vshControl *ctl, const vshCmd *cmd)
{
virDomainSuspend(dom);
}
-static bool
-vshWatchJob(vshControl *ctl,
- virDomainPtr dom,
- bool verbose,
- int pipe_fd,
- int timeout,
- jobWatchTimeoutFunc timeout_func,
- void *opaque,
- const char *label)
-{
- struct sigaction sig_action;
- struct sigaction old_sig_action;
- struct pollfd pollfd;
- struct timeval start, curr;
- virDomainJobInfo jobinfo;
- int ret = -1;
- char retchar;
- bool functionReturn = false;
- sigset_t sigmask, oldsigmask;
-
- sigemptyset(&sigmask);
- sigaddset(&sigmask, SIGINT);
-
- intCaught = 0;
- sig_action.sa_sigaction = vshCatchInt;
- sig_action.sa_flags = SA_SIGINFO;
- sigemptyset(&sig_action.sa_mask);
- sigaction(SIGINT, &sig_action, &old_sig_action);
-
- pollfd.fd = pipe_fd;
- pollfd.events = POLLIN;
- pollfd.revents = 0;
-
- GETTIMEOFDAY(&start);
- while (1) {
-repoll:
- ret = poll(&pollfd, 1, 500);
- if (ret > 0) {
- if (pollfd.revents & POLLIN &&
- saferead(pipe_fd, &retchar, sizeof(retchar)) > 0 &&
- retchar == '0') {
- if (verbose) {
- /* print [100 %] */
- print_job_progress(label, 0, 1);
- }
- break;
- }
- goto cleanup;
- }
-
- if (ret < 0) {
- if (errno == EINTR) {
- if (intCaught) {
- virDomainAbortJob(dom);
- intCaught = 0;
- } else {
- goto repoll;
- }
- }
- goto cleanup;
- }
-
- GETTIMEOFDAY(&curr);
- if (timeout && (((int)(curr.tv_sec - start.tv_sec) * 1000 +
- (int)(curr.tv_usec - start.tv_usec) / 1000) >
- timeout * 1000)) {
- /* suspend the domain when migration timeouts. */
- vshDebug(ctl, VSH_ERR_DEBUG, "%s timeout", label);
- if (timeout_func)
- (timeout_func)(ctl, dom, opaque);
- timeout = 0;
- }
-
- if (verbose) {
- pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask);
- ret = virDomainGetJobInfo(dom, &jobinfo);
- pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
- if (ret == 0)
- print_job_progress(label, jobinfo.dataRemaining,
- jobinfo.dataTotal);
- }
- }
-
- functionReturn = true;
-
-cleanup:
- sigaction(SIGINT, &old_sig_action, NULL);
- return functionReturn;
-}
-
static bool
cmdMigrate(vshControl *ctl, const vshCmd *cmd)
{
#define vshStrcasecmp(S1, S2) strcasecmp(S1, S2)
static int vshDomainState(vshControl *ctl, virDomainPtr dom, int *reason);
-static const char *vshDomainStateToString(int state);
-static const char *vshDomainStateReasonToString(int state, int reason);
-static const char *vshDomainControlStateToString(int state);
-static const char *vshDomainVcpuStateToString(int state);
static bool vshConnectionUsability(vshControl *ctl, virConnectPtr conn);
static virTypedParameterPtr vshFindTypedParamByName(const char *name,
virTypedParameterPtr list,
typedef void (*jobWatchTimeoutFunc) (vshControl *ctl, virDomainPtr dom,
void *opaque);
-static bool
-vshWatchJob(vshControl *ctl,
- virDomainPtr dom,
- bool verbose,
- int pipe_fd,
- int timeout,
- jobWatchTimeoutFunc timeout_func,
- void *opaque,
- const char *label);
-
static void *_vshMalloc(vshControl *ctl, size_t sz, const char *filename, int line);
#define vshMalloc(_ctl, _sz) _vshMalloc(_ctl, _sz, __FILE__, __LINE__)
static char *_vshStrdup(vshControl *ctl, const char *s, const char *filename, int line);
#define vshStrdup(_ctl, _s) _vshStrdup(_ctl, _s, __FILE__, __LINE__)
-static int parseRateStr(const char *rateStr, virNetDevBandwidthRatePtr rate);
-
static void *
_vshMalloc(vshControl *ctl, size_t size, const char *filename, int line)
{