Skip to content

Commit 20dce25

Browse files
Vineeth Pillaibryteise
authored andcommitted
ch_monitor: Minor fix in the vm ping retry logic
Signed-off-by: Vineeth Pillai <[email protected]>
1 parent daafe53 commit 20dce25

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/ch/ch_monitor.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242

4343
#define VIR_FROM_THIS VIR_FROM_CH
4444

45+
/*
46+
* Retry count for temporary failures observed
47+
* in Monitor code path.
48+
*/
49+
#define MONITOR_TMP_FAIL_RETRIES 5
50+
4551
VIR_LOG_INIT("ch.ch_monitor");
4652

4753
static virClassPtr virCHMonitorClass;
@@ -1094,14 +1100,14 @@ virCHMonitorNew(virDomainObjPtr vm, virCHDriverPtr driver)
10941100
/* get a curl handle */
10951101
mon->handle = curl_easy_init();
10961102

1097-
/* try to ping VMM socket 5 times to make sure it is ready */
1098-
while (pings < 5) {
1099-
if (virCHMonitorPingVMM(mon) == 0)
1100-
break;
1101-
if (pings == 5)
1102-
goto cleanup;
1103-
1104-
g_usleep(100 * 1000);
1103+
/* Try pinging the VMM to make sure it is ready */
1104+
while (virCHMonitorPingVMM(mon)) {
1105+
if (++pings < MONITOR_TMP_FAIL_RETRIES) {
1106+
g_usleep(100 * 1000);
1107+
continue;
1108+
}
1109+
VIR_WARN("Failed to ping VMM after %d retries", pings);
1110+
goto cleanup;
11051111
}
11061112

11071113
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)

0 commit comments

Comments
 (0)