On 9/12/19 5:02 AM, Richard W.M. Jones wrote:
The test interop-qemu-nbd-tls-certs frequently fails on slow (32
bit)
machines in Fedora Koji. (Is crypto slow on these already overloaded
machines?)
As we cannot wait for a signal when qemu-nbd is ready start serving,
we have to use a sleep. The current sleep is 5 seconds, which is not
long enough. Making the sleep longer would work but is inconsiderate
for people using faster machines. Therefore replace this with a retry
loop with exponential backoff.
I tested this with a simple wrapper around qemu-nbd which did:
sleep 5; exec /usr/bin/qemu-nbd "$@"
---
interop/interop.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
/* Unfortunately there's no good way to wait for qemu-nbd to
start
- * serving, so ...
+ * serving, so we need to retry here.
*/
qemu 4.1 added --pid-file, where you can test for that file existing to
know when the server is up and running. But we still want an adaptive
exponential backoff whether we test for a file or just try connections,
so this patch is fine.
- sleep (5);
-
- if (nbd_connect_tcp (nbd, "localhost", port_str) == -1) {
- fprintf (stderr, "%s\n", nbd_get_error ());
- goto out;
+ for (retry = 0; retry < 5; ++retry) {
+ sleep (1 << retry);
+ if (nbd_connect_tcp (nbd, "localhost", port_str) == -1) {
+ fprintf (stderr, "%s\n", nbd_get_error ());
+ if (nbd_get_errno () != ECONNREFUSED)
+ goto out;
+ }
+ else break;
}
+ if (retry == 5)
+ goto out;
#else /* !SERVE_OVER_TCP */
ACK series
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org