Replace nbd_server_string() with its only possible output "nbdkit".
Ref:
https://listman.redhat.com/archives/libguestfs/2022-March/028475.html
Suggested-by: Richard W.M. Jones <rjones(a)redhat.com>
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
Reviewed-by: Richard W.M. Jones <rjones(a)redhat.com>
---
Notes:
v2:
- pick up Rich's R-b
nbd.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/nbd.c b/nbd.c
index 7d8abf3cbbb0..48926d4aec1d 100644
--- a/nbd.c
+++ b/nbd.c
@@ -50,21 +50,6 @@ enum nbd_server {
NBDKIT = 1,
};
-static const char *
-nbd_server_string (enum nbd_server s)
-{
- const char *ret = NULL;
-
- switch (s) {
- case NBDKIT: ret = "nbdkit"; break;
- }
-
- if (ret == NULL)
- abort ();
-
- return ret;
-}
-
/* We use this standard list of nbd server types. Must match the documentation
* in virt-p2v(1).
*/
@@ -121,67 +106,67 @@ void
test_nbd_servers (void)
{
size_t i;
int r;
const enum nbd_server *servers;
/* Initialize nbd_local_port. */
if (is_iso_environment)
/* The p2v ISO should allow us to open up just about any port, so
* we can fix a port number in that case. Using a predictable
* port number in this case should avoid rare errors if the port
* colides with another (ie. it'll either always fail or never
* fail).
*/
nbd_local_port = 50123;
else
/* When testing on the local machine, choose a random port. */
nbd_local_port = 50000 + (random () % 10000);
servers = standard_servers;
use_server = 0;
for (i = 0; servers[i] != 0; ++i) {
#if DEBUG_STDERR
- fprintf (stderr, "checking for %s ...\n", nbd_server_string (servers[i]));
+ fprintf (stderr, "checking for nbdkit ...\n");
#endif
switch (servers[i]) {
case NBDKIT: /* with socket activation */
r = system ("nbdkit file --version"
#ifndef DEBUG_STDERR
" >/dev/null 2>&1"
#endif
);
if (r == 0) {
use_server = servers[i];
goto finish;
}
break;
default:
abort ();
}
}
finish:
if (use_server == 0) {
fprintf (stderr,
_("%s: no working NBD server was found, cannot continue.\n"),
g_get_prgname ());
exit (EXIT_FAILURE);
}
#if DEBUG_STDERR
- fprintf (stderr, "picked %s\n", nbd_server_string (use_server));
+ fprintf (stderr, "picked nbdkit\n");
#endif
}
/**
* Start the NBD server.
*
* We previously tested all NBD servers (see C<test_nbd_servers>) and
* hopefully found one which will work.
*
* Returns the process ID (E<gt> 0) or C<0> if there is an error.
*/
--
2.19.1.3.g30247aa5d201