From 77e447a516a7f02bfdd2b8d774244b34e848162e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 17 Mar 2026 14:52:43 +0000 Subject: [PATCH] lib: Remove configure-time QEMU Remove the configure-time QEMU definition. No longer initialize g->hv = QEMU. g->hv may now be NULL if the user does not explicitly either call guestfs_set_hv or set LIBGUESTFS_HV. Remove any assumptions in the code that g->hv is always non-NULL. Fix one test that relied on the QEMU definition. --- lib/handle.c | 35 +++++++--------------------------- tests/regressions/rhbz501893.c | 2 -- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/lib/handle.c b/lib/handle.c index ab0e1289e..289fc4c81 100644 --- a/lib/handle.c +++ b/lib/handle.c @@ -118,17 +118,6 @@ guestfs_create_flags (unsigned flags, ...) g->path = strdup (GUESTFS_DEFAULT_PATH); if (!g->path) goto error; -#ifdef QEMU - g->hv = strdup (QEMU); -#else - /* configure --without-qemu, so set QEMU to something which will - * definitely fail. The user is expected to override the hypervisor - * by setting an environment variable or calling set_hv. - */ - g->hv = strdup ("false"); -#endif - if (!g->hv) goto error; - /* Get program name. */ if (STRPREFIX (getprogname (), "lt-")) /* Remove libtool (lt-*) prefix from short name. */ @@ -535,27 +524,17 @@ guestfs_impl_get_path (guestfs_h *g) int guestfs_impl_set_qemu (guestfs_h *g, const char *qemu) { - char *new_hv; - - /* Only this deprecated set_qemu API supports using NULL as a - * parameter, to mean set it back to the default QEMU. The new - * set_hv API does not allow callers to do this. + /* This deprecated API let you set qemu == NULL to mean "use the + * default qemu". set_hv doesn't allow this, although maybe it + * should. */ if (qemu == NULL) { -#ifdef QEMU - new_hv = safe_strdup (g, QEMU); -#else - error (g, _("configured --without-qemu so calling guestfs_set_qemu with qemu == NULL is an error")); - return -1; -#endif + free (g->hv); + g->hv = NULL; + return 0; } - else - new_hv = safe_strdup (g, qemu); - free (g->hv); - g->hv = new_hv; - - return 0; + return guestfs_impl_set_hv (g, qemu); } const char * diff --git a/tests/regressions/rhbz501893.c b/tests/regressions/rhbz501893.c index 4d8a3a71d..a2f0c5546 100644 --- a/tests/regressions/rhbz501893.c +++ b/tests/regressions/rhbz501893.c @@ -50,9 +50,7 @@ main (int argc, char *argv[]) assert (guestfs_set_path (g, NULL) == 0); assert (guestfs_set_append (g, NULL) == 0); -#ifdef QEMU assert (guestfs_set_qemu (g, NULL) == 0); -#endif guestfs_close (g); exit (EXIT_SUCCESS);