From 78dbd08dd2115efcc488e8fbcaf9705697eb075b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 13 Aug 2013 22:28:28 +0100 Subject: [PATCH] Rename 'qemu' as 'hv', 'LIBGUESTFS_QEMU' as 'LIBGUESTFS_HV'. --- Makefile.am | 4 +- examples/guestfs-performance.pod | 2 +- fish/guestfish.pod | 10 ++- generator/actions.ml | 108 +++++++++++++++++++++---------- src/guestfs-internal.h | 16 ++--- src/guestfs.pod | 30 +++++---- src/handle.c | 51 ++++++++++----- src/launch-direct.c | 26 ++++---- src/launch-libvirt.c | 14 ++-- src/launch-uml.c | 18 +++--- src/launch-unix.c | 4 +- src/launch.c | 35 +++++----- test-tool/test-tool.c | 13 ++-- tests/regressions/rhbz790721.c | 4 +- 14 files changed, 203 insertions(+), 132 deletions(-) diff --git a/Makefile.am b/Makefile.am index f637bd9b0..8930ad0c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -344,7 +344,7 @@ check-release: check-valgrind \ check-direct \ check-valgrind-direct - $(MAKE) -j1 LIBGUESTFS_QEMU=$(HOME)/d/linux-um/vmlinux \ + $(MAKE) -j1 LIBGUESTFS_HV=$(HOME)/d/linux-um/vmlinux \ check-uml \ check-valgrind-uml $(MAKE) -j1 \ @@ -407,7 +407,7 @@ check-with-upstream-qemu: check-with-upstream-qemu-1: $(top_builddir)/qemu-wrapper.sh $(QEMUBINARY) --version - $(MAKE) LIBGUESTFS_QEMU=$(abs_top_builddir)/qemu-wrapper.sh check + $(MAKE) LIBGUESTFS_HV=$(abs_top_builddir)/qemu-wrapper.sh check $(top_builddir)/qemu-wrapper.sh: Makefile rm -f $@ $@-t diff --git a/examples/guestfs-performance.pod b/examples/guestfs-performance.pod index f60d8bf63..d61fcf2a8 100644 --- a/examples/guestfs-performance.pod +++ b/examples/guestfs-performance.pod @@ -508,7 +508,7 @@ options, so use a qemu wrapper script like this: Now run guestfish or another libguestfs tool with the qemu wrapper (see L to understand what this is doing): - LIBGUESTFS_QEMU=/path/to/qemu-wrapper guestfish -a /dev/null -v run + LIBGUESTFS_HV=/path/to/qemu-wrapper guestfish -a /dev/null -v run This should pause just after qemu launches. In another window, attach to qemu using gdb: diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 79c1f0637..6551bc544 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -1410,6 +1410,12 @@ See also L, L. Set C to enable verbose messages. This has the same effect as using the B<-v> option. +=item LIBGUESTFS_HV + +Set the default hypervisor (usually qemu) binary that libguestfs uses. +If not set, then the qemu which was found at compile time by the +configure script is used. + =item LIBGUESTFS_MEMSIZE Set the memory allocated to the qemu process, in megabytes. For @@ -1424,9 +1430,7 @@ See the discussion of paths in L. =item LIBGUESTFS_QEMU -Set the default qemu binary that libguestfs uses. If not set, then -the qemu which was found at compile time by the configure script is -used. +This is the old way to set C. =item LIBGUESTFS_TMPDIR diff --git a/generator/actions.ml b/generator/actions.ml index 57313449e..4de0aefda 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -199,11 +199,8 @@ You probably don't want to call this function." }; name = "launch"; style = RErr, [], []; fish_alias = ["run"]; progress = true; config_only = true; - shortdesc = "launch the qemu subprocess"; + shortdesc = "launch the backend"; longdesc = "\ -Internally libguestfs is implemented by running a virtual machine -using L. - You should call this after configuring the handle (eg. adding drives) but before performing any actions. @@ -218,7 +215,7 @@ very cheap to create, so create a new one for each launch." }; visibility = VStateTest; deprecated_by = Some "launch"; blocking = false; - shortdesc = "wait until the qemu subprocess launches (no op)"; + shortdesc = "wait until the hypervisor launches (no op)"; longdesc = "\ This function is a no op. @@ -235,9 +232,9 @@ versions of the API." }; name = "kill_subprocess"; style = RErr, [], []; deprecated_by = Some "shutdown"; - shortdesc = "kill the qemu subprocess"; + shortdesc = "kill the hypervisor"; longdesc = "\ -This kills the qemu subprocess. +This kills the hypervisor. Do not call this. See: C instead." }; @@ -267,56 +264,99 @@ automatically." }; { defaults with name = "config"; - style = RErr, [String "qemuparam"; OptString "qemuvalue"], []; + style = RErr, [String "hvparam"; OptString "hvvalue"], []; config_only = true; blocking = false; - shortdesc = "add qemu parameters"; + shortdesc = "add hypervisor parameters"; longdesc = "\ -This can be used to add arbitrary qemu command line parameters -of the form I<-param value>. Actually it's not quite arbitrary - we +This can be used to add arbitrary hypervisor parameters of the +form I<-param value>. Actually it's not quite arbitrary - we prevent you from setting some parameters which would interfere with parameters that we use. -The first character of C string must be a C<-> (dash). +The first character of C string must be a C<-> (dash). -C can be NULL." }; +C can be NULL." }; { defaults with name = "set_qemu"; - style = RErr, [OptString "qemu"], []; + style = RErr, [OptString "hv"], []; fish_alias = ["qemu"]; config_only = true; blocking = false; - shortdesc = "set the qemu binary"; + deprecated_by = Some "set_hv"; + shortdesc = "set the hypervisor binary (usually qemu)"; longdesc = "\ -Set the qemu binary that we will use. +Set the hypervisor binary (usually qemu) that we will use. The default is chosen when the library was compiled by the configure script. -You can also override this by setting the C +You can also override this by setting the C environment variable. -Setting C to C restores the default qemu binary. +Setting C to C restores the default qemu binary. Note that you should call this function as early as possible after creating the handle. This is because some pre-launch operations depend on testing qemu features (by running C). If the qemu binary changes, we don't retest features, and so you might see inconsistent results. Using the environment -variable C is safest of all since that picks +variable C is safest of all since that picks the qemu binary at the same time as the handle is created." }; { defaults with name = "get_qemu"; - style = RConstString "qemu", [], []; + style = RConstString "hv", [], []; blocking = false; + deprecated_by = Some "get_hv"; tests = [ InitNone, Always, TestRun ( [["get_qemu"]]), [] ]; - shortdesc = "get the qemu binary"; + shortdesc = "get the hypervisor binary (usually qemu)"; longdesc = "\ -Return the current qemu binary. +Return the current hypervisor binary (usually qemu). + +This is always non-NULL. If it wasn't set already, then this will +return the default qemu binary name." }; + + { defaults with + name = "set_hv"; + style = RErr, [String "hv"], []; + fish_alias = ["hv"]; config_only = true; + blocking = false; + shortdesc = "set the hypervisor binary"; + longdesc = "\ +Set the hypervisor binary that we will use. The hypervisor +depends on the backend, but is usually the location of the +qemu/KVM hypervisor. For the uml backend, it is the location +of the C or C binary. + +The default is chosen when the library was compiled by the +configure script. + +You can also override this by setting the C +environment variable. + +Note that you should call this function as early as possible +after creating the handle. This is because some pre-launch +operations depend on testing qemu features (by running C). +If the qemu binary changes, we don't retest features, and +so you might see inconsistent results. Using the environment +variable C is safest of all since that picks +the qemu binary at the same time as the handle is created." }; + + { defaults with + name = "get_hv"; + style = RString "hv", [], []; + blocking = false; + tests = [ + InitNone, Always, TestRun ( + [["get_hv"]]), [] + ]; + shortdesc = "get the hypervisor binary"; + longdesc = "\ +Return the current hypervisor binary. This is always non-NULL. If it wasn't set already, then this will return the default qemu binary name." }; @@ -512,10 +552,10 @@ For more information on states, see L." }; style = RErr, [Int "memsize"], []; fish_alias = ["memsize"]; config_only = true; blocking = false; - shortdesc = "set memory allocated to the qemu subprocess"; + shortdesc = "set memory allocated to the hypervisor"; longdesc = "\ This sets the memory size in megabytes allocated to the -qemu subprocess. This only has any effect if called before +hypervisor. This only has any effect if called before C. You can also change this by setting the environment @@ -533,10 +573,10 @@ see L." }; InitNone, Always, TestResult ( [["get_memsize"]], "ret >= 256"), [] ]; - shortdesc = "get memory allocated to the qemu subprocess"; + shortdesc = "get memory allocated to the hypervisor"; longdesc = "\ This gets the memory size in megabytes allocated to the -qemu subprocess. +hypervisor. If C was not called on this handle, and if C was not set, @@ -550,10 +590,10 @@ see L." }; style = RInt "pid", [], []; fish_alias = ["pid"]; blocking = false; - shortdesc = "get PID of qemu subprocess"; + shortdesc = "get PID of hypervisor"; longdesc = "\ -Return the process ID of the qemu subprocess. If there is no -qemu subprocess, then this will return an error. +Return the process ID of the hypervisor. If there is no +hypervisor running, then this will return an error. This is an internal call used for debugging and testing." }; @@ -697,7 +737,7 @@ Return the direct appliance mode flag." }; longdesc = "\ If this is called with the parameter C then C does not create a recovery process. The -purpose of the recovery process is to stop runaway qemu +purpose of the recovery process is to stop runaway hypervisor processes in the case where the main program aborts abruptly. This only has any effect if called before C, @@ -707,7 +747,7 @@ About the only time when you would want to disable this is if the main process will fork itself into the background (\"daemonize\" itself). In this case the recovery process thinks that the main program has disappeared and so kills -qemu, which is not very helpful." }; +the hypervisor, which is not very helpful." }; { defaults with name = "get_recovery_proc"; @@ -2288,7 +2328,7 @@ Other strings are returned unmodified." }; { defaults with name = "shutdown"; style = RErr, [], []; - shortdesc = "shutdown the qemu subprocess"; + shortdesc = "shutdown the hypervisor"; longdesc = "\ This is the opposite of C. It performs an orderly shutdown of the backend process(es). If the autosync flag is set @@ -4606,7 +4646,7 @@ as for the L I<-o> and I<-t> flags." }; longdesc = "\ The C command exposes some internals of C (the guestfs daemon) that runs inside the -qemu subprocess. +hypervisor. There is no comprehensive help for this command. You have to look at the file C in the libguestfs source @@ -5049,7 +5089,7 @@ running the program." }; shortdesc = "ping the guest daemon"; longdesc = "\ This is a test probe into the guestfs daemon running inside -the qemu subprocess. Calling this function checks that the +the hypervisor. Calling this function checks that the daemon responds to the ping message, without affecting the daemon or attached block device(s) in any other way." }; diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 7572e4ca9..8a178e165 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -187,12 +187,12 @@ struct drive { void (*free_priv) (void *); }; -/* Extra qemu parameters (from guestfs_config). */ -struct qemu_param { - struct qemu_param *next; +/* Extra hv parameters (from guestfs_config). */ +struct hv_param { + struct hv_param *next; - char *qemu_param; - char *qemu_value; /* May be NULL. */ + char *hv_param; + char *hv_value; /* May be NULL. */ }; /* Backend operations. */ @@ -279,14 +279,14 @@ struct guestfs_h bool pgroup; /* Create process group for children? */ bool close_on_exit; /* Is this handle on the atexit list? */ - int smp; /* If > 1, -smp flag passed to qemu. */ + int smp; /* If > 1, -smp flag passed to hv. */ int memsize; /* Size of RAM (megabytes). */ char *path; /* Path to the appliance. */ - char *qemu; /* Qemu binary. */ + char *hv; /* Hypervisor (HV) binary. */ char *append; /* Append to kernel command line. */ - struct qemu_param *qemu_params; /* Extra qemu parameters. */ + struct hv_param *hv_params; /* Extra hv parameters. */ char *program; /* Program name. */ diff --git a/src/guestfs.pod b/src/guestfs.pod index 9ca05a938..f0620d899 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -1364,10 +1364,10 @@ qemu from source: exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "$@" Save this script as C (or wherever), C, -and then use it by setting the LIBGUESTFS_QEMU environment variable. +and then use it by setting the LIBGUESTFS_HV environment variable. For example: - LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish + LIBGUESTFS_HV=/tmp/qemu.wrapper guestfish Note that libguestfs also calls qemu with the -help and -version options in order to determine features. @@ -1443,7 +1443,7 @@ hotplugging (see L) and sVirt. =item C Run the User-Mode Linux kernel. The location of the kernel is set -using C<$LIBGUESTFS_QEMU> or using the L API (note +using C<$LIBGUESTFS_HV> or using the L API (note that qemu is not involved, we just reuse the same variable in the handle for convenience). @@ -1537,7 +1537,7 @@ Setting the following environment variables (or the equivalent in the API) selects the User-Mode Linux backend: export LIBGUESTFS_BACKEND=uml - export LIBGUESTFS_QEMU=/path/to/vmlinux + export LIBGUESTFS_HV=/path/to/vmlinux C (or it may be called C) is the Linux binary, compiled to run as a userspace process. Note that we reuse the qemu @@ -1582,7 +1582,7 @@ the image. make ARCH=um This will leave a file called C or C in the top-level -directory. This is the UML kernel. You should set C +directory. This is the UML kernel. You should set C to point to this file. =back @@ -4061,15 +4061,15 @@ default appliance back-end. Runs all tests using the User-Mode Linux backend. As there is no standard location for the User-Mode Linux kernel, you -I to set C to point to the kernel image, eg: +I to set C to point to the kernel image, eg: - make check-uml LIBGUESTFS_QEMU=~/d/linux-um/vmlinux + make check-uml LIBGUESTFS_HV=~/d/linux-um/vmlinux =item C Runs all tests using the User-Mode Linux backend, under valgrind. -As above, you have to set C to point to the kernel. +As above, you have to set C to point to the kernel. =item C @@ -4579,6 +4579,14 @@ See also L, L. Set C to enable verbose messages. This has the same effect as calling C. +=item LIBGUESTFS_HV + +Set the default hypervisor (usually qemu) binary that libguestfs uses. +If not set, then the qemu which was found at compile time by the +configure script is used. + +See also L above. + =item LIBGUESTFS_MEMSIZE Set the memory allocated to the qemu process, in megabytes. For @@ -4593,11 +4601,7 @@ See the discussion of paths in section L above. =item LIBGUESTFS_QEMU -Set the default qemu binary that libguestfs uses. If not set, then -the qemu which was found at compile time by the configure script is -used. - -See also L above. +This is the old way to set C. =item LIBGUESTFS_TMPDIR diff --git a/src/handle.c b/src/handle.c index 698ca173c..4e61e2cbc 100644 --- a/src/handle.c +++ b/src/handle.c @@ -108,8 +108,8 @@ guestfs_create_flags (unsigned flags, ...) g->path = strdup (GUESTFS_DEFAULT_PATH); if (!g->path) goto error; - g->qemu = strdup (QEMU); - if (!g->qemu) goto error; + g->hv = strdup (QEMU); + if (!g->hv) goto error; /* Get program name. */ #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1 @@ -154,7 +154,7 @@ guestfs_create_flags (unsigned flags, ...) free (g->backend_arg); free (g->program); free (g->path); - free (g->qemu); + free (g->hv); free (g->append); free (g); return NULL; @@ -200,9 +200,14 @@ parse_environment (guestfs_h *g, if (str) guestfs_set_path (g, str); - str = do_getenv (data, "LIBGUESTFS_QEMU"); + str = do_getenv (data, "LIBGUESTFS_HV"); if (str) - guestfs_set_qemu (g, str); + guestfs_set_hv (g, str); + else { + str = do_getenv (data, "LIBGUESTFS_QEMU"); + if (str) + guestfs_set_hv (g, str); + } str = do_getenv (data, "LIBGUESTFS_APPEND"); if (str) @@ -267,7 +272,7 @@ guestfs__parse_environment_list (guestfs_h *g, char * const *strings) void guestfs_close (guestfs_h *g) { - struct qemu_param *qp, *qp_next; + struct hv_param *hp, *hp_next; guestfs_h **gg; if (g->state == NO_HANDLE) { @@ -321,11 +326,11 @@ guestfs_close (guestfs_h *g) guestfs___free_inspect_info (g); guestfs___free_drives (g); - for (qp = g->qemu_params; qp; qp = qp_next) { - free (qp->qemu_param); - free (qp->qemu_value); - qp_next = qp->next; - free (qp); + for (hp = g->hv_params; hp; hp = hp_next) { + free (hp->hv_param); + free (hp->hv_value); + hp_next = hp->next; + free (hp); } while (g->error_cb_stack) @@ -342,7 +347,7 @@ guestfs_close (guestfs_h *g) free (g->last_error); free (g->program); free (g->path); - free (g->qemu); + free (g->hv); free (g->append); free (g); } @@ -445,17 +450,29 @@ guestfs__get_path (guestfs_h *g) int guestfs__set_qemu (guestfs_h *g, const char *qemu) { - free (g->qemu); - g->qemu = NULL; - - g->qemu = qemu == NULL ? safe_strdup (g, QEMU) : safe_strdup (g, qemu); + free (g->hv); + g->hv = qemu == NULL ? safe_strdup (g, QEMU) : safe_strdup (g, qemu); return 0; } const char * guestfs__get_qemu (guestfs_h *g) { - return g->qemu; + return g->hv; +} + +int +guestfs__set_hv (guestfs_h *g, const char *hv) +{ + free (g->hv); + g->hv = safe_strdup (g, hv); + return 0; +} + +char * +guestfs__get_hv (guestfs_h *g) +{ + return safe_strdup (g, g->hv); } int diff --git a/src/launch-direct.c b/src/launch-direct.c index 6a940d34c..0e61b0ba6 100644 --- a/src/launch-direct.c +++ b/src/launch-direct.c @@ -92,7 +92,7 @@ alloc_cmdline (guestfs_h *g) { g->direct.cmdline_size = 1; g->direct.cmdline = safe_malloc (g, sizeof (char *)); - g->direct.cmdline[0] = g->qemu; + g->direct.cmdline[0] = g->hv; } static void @@ -258,7 +258,7 @@ launch_direct (guestfs_h *g, const char *arg) if (r == 0) { /* Child (qemu). */ char buf[256]; int virtio_scsi = qemu_supports_virtio_scsi (g); - struct qemu_param *qp; + struct hv_param *hp; bool has_kvm; /* Set up the full command line. Do this in the subprocess so we @@ -475,10 +475,10 @@ launch_direct (guestfs_h *g, const char *arg) add_cmdline_shell_unquoted (g, QEMU_OPTIONS); /* Add any qemu parameters. */ - for (qp = g->qemu_params; qp; qp = qp->next) { - add_cmdline (g, qp->qemu_param); - if (qp->qemu_value) - add_cmdline (g, qp->qemu_value); + for (hp = g->hv_params; hp; hp = hp->next) { + add_cmdline (g, hp->hv_param); + if (hp->hv_value) + add_cmdline (g, hp->hv_value); } /* Finish off the command line. */ @@ -530,8 +530,8 @@ launch_direct (guestfs_h *g, const char *arg) TRACE0 (launch_run_qemu); - execv (g->qemu, g->direct.cmdline); /* Run qemu. */ - perror (g->qemu); + execv (g->hv, g->direct.cmdline); /* Run qemu. */ + perror (g->hv); _exit (EXIT_FAILURE); } @@ -791,7 +791,7 @@ test_qemu (guestfs_h *g) free (g->direct.qemu_devices); g->direct.qemu_devices = NULL; - guestfs___cmd_add_arg (cmd1, g->qemu); + guestfs___cmd_add_arg (cmd1, g->hv); guestfs___cmd_add_arg (cmd1, "-nographic"); guestfs___cmd_add_arg (cmd1, "-help"); guestfs___cmd_set_stdout_callback (cmd1, read_all, &g->direct.qemu_help, @@ -800,7 +800,7 @@ test_qemu (guestfs_h *g) if (r == -1 || !WIFEXITED (r) || WEXITSTATUS (r) != 0) goto error; - guestfs___cmd_add_arg (cmd2, g->qemu); + guestfs___cmd_add_arg (cmd2, g->hv); guestfs___cmd_add_arg (cmd2, "-nographic"); guestfs___cmd_add_arg (cmd2, "-version"); guestfs___cmd_set_stdout_callback (cmd2, read_all, &g->direct.qemu_version, @@ -811,7 +811,7 @@ test_qemu (guestfs_h *g) parse_qemu_version (g); - guestfs___cmd_add_arg (cmd3, g->qemu); + guestfs___cmd_add_arg (cmd3, g->hv); guestfs___cmd_add_arg (cmd3, "-nographic"); guestfs___cmd_add_arg (cmd3, "-machine"); guestfs___cmd_add_arg (cmd3, "accel=kvm:tcg"); @@ -831,7 +831,7 @@ test_qemu (guestfs_h *g) if (r == -1) return -1; - guestfs___external_command_failed (g, r, g->qemu, NULL); + guestfs___external_command_failed (g, r, g->hv, NULL); return -1; } @@ -1052,7 +1052,7 @@ shutdown_direct (guestfs_h *g, int check_for_errors) ret = -1; } else if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) { - guestfs___external_command_failed (g, status, g->qemu, NULL); + guestfs___external_command_failed (g, status, g->hv, NULL); ret = -1; } } diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index ac79dd0c6..8f1809c3c 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -577,7 +577,7 @@ parse_capabilities (guestfs_h *g, const char *capabilities_xml, static int is_custom_qemu (guestfs_h *g) { - return g->qemu && STRNEQ (g->qemu, QEMU); + return g->hv && STRNEQ (g->hv, QEMU); } #if HAVE_LIBSELINUX @@ -966,7 +966,7 @@ construct_libvirt_xml_devices (guestfs_h *g, */ if (is_custom_qemu (g)) { XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "emulator")); - XMLERROR (-1, xmlTextWriterWriteString (xo, BAD_CAST g->qemu)); + XMLERROR (-1, xmlTextWriterWriteString (xo, BAD_CAST g->hv)); XMLERROR (-1, xmlTextWriterEndElement (xo)); } @@ -1410,7 +1410,7 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g, const struct libvirt_xml_params *params, xmlTextWriterPtr xo) { - struct qemu_param *qp; + struct hv_param *hp; CLEANUP_FREE char *tmpdir = NULL; XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:commandline")); @@ -1460,18 +1460,18 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g, } /* The qemu command line arguments requested by the caller. */ - for (qp = g->qemu_params; qp; qp = qp->next) { + for (hp = g->hv_params; hp; hp = hp->next) { XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:arg")); XMLERROR (-1, xmlTextWriterWriteAttribute (xo, BAD_CAST "value", - BAD_CAST qp->qemu_param)); + BAD_CAST hp->hv_param)); XMLERROR (-1, xmlTextWriterEndElement (xo)); - if (qp->qemu_value) { + if (hp->hv_value) { XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:arg")); XMLERROR (-1, xmlTextWriterWriteAttribute (xo, BAD_CAST "value", - BAD_CAST qp->qemu_value)); + BAD_CAST hp->hv_value)); XMLERROR (-1, xmlTextWriterEndElement (xo)); } } diff --git a/src/launch-uml.c b/src/launch-uml.c index 5470ef43e..c8cbe2be1 100644 --- a/src/launch-uml.c +++ b/src/launch-uml.c @@ -52,7 +52,7 @@ alloc_cmdline (guestfs_h *g) { g->uml.cmdline_size = 1; g->uml.cmdline = safe_malloc (g, sizeof (char *)); - g->uml.cmdline[0] = g->qemu; + g->uml.cmdline[0] = g->hv; } static void @@ -196,7 +196,7 @@ launch_uml (guestfs_h *g, const char *arg) if (r == 0) { /* Child (vmlinux). */ char *buf; - struct qemu_param *qp; + struct hv_param *hp; char *term = getenv ("TERM"); /* Set up the full command line. Do this in the subprocess so we @@ -295,10 +295,10 @@ launch_uml (guestfs_h *g, const char *arg) #endif /* Add any vmlinux parameters. */ - for (qp = g->qemu_params; qp; qp = qp->next) { - add_cmdline (g, qp->qemu_param); - if (qp->qemu_value) - add_cmdline (g, qp->qemu_value); + for (hp = g->hv_params; hp; hp = hp->next) { + add_cmdline (g, hp->hv_param); + if (hp->hv_value) + add_cmdline (g, hp->hv_value); } /* Finish off the command line. */ @@ -345,8 +345,8 @@ launch_uml (guestfs_h *g, const char *arg) setenv ("LC_ALL", "C", 1); - execv (g->qemu, g->uml.cmdline); /* Run vmlinux. */ - perror (g->qemu); + execv (g->hv, g->uml.cmdline); /* Run vmlinux. */ + perror (g->hv); _exit (EXIT_FAILURE); } @@ -714,7 +714,7 @@ shutdown_uml (guestfs_h *g, int check_for_errors) */ else if (!(WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM) && !(WIFEXITED (status) && WEXITSTATUS (status) == 0)) { - guestfs___external_command_failed (g, status, g->qemu, NULL); + guestfs___external_command_failed (g, status, g->hv, NULL); ret = -1; } } diff --git a/src/launch-unix.c b/src/launch-unix.c index ed71ab47b..f967cfe32 100644 --- a/src/launch-unix.c +++ b/src/launch-unix.c @@ -41,8 +41,8 @@ launch_unix (guestfs_h *g, const char *sockpath) uint32_t size; void *buf = NULL; - if (g->qemu_params) { - error (g, _("cannot set qemu parameters with the 'unix:' backend")); + if (g->hv_params) { + error (g, _("cannot set hv parameters with the 'unix:' backend")); return -1; } diff --git a/src/launch.c b/src/launch.c index 80a9a6e2e..fa97f06ff 100644 --- a/src/launch.c +++ b/src/launch.c @@ -241,35 +241,38 @@ guestfs__get_state (guestfs_h *g) /* Add arbitrary qemu parameters. Useful for testing. */ int guestfs__config (guestfs_h *g, - const char *qemu_param, const char *qemu_value) + const char *hv_param, const char *hv_value) { - struct qemu_param *qp; + struct hv_param *hp; - if (qemu_param[0] != '-') { + /* + XXX For qemu this made sense, but not for uml. + if (hv_param[0] != '-') { error (g, _("parameter must begin with '-' character")); return -1; } + */ /* A bit fascist, but the user will probably break the extra * parameters that we add if they try to set any of these. */ - if (STREQ (qemu_param, "-kernel") || - STREQ (qemu_param, "-initrd") || - STREQ (qemu_param, "-nographic") || - STREQ (qemu_param, "-serial") || - STREQ (qemu_param, "-full-screen") || - STREQ (qemu_param, "-std-vga") || - STREQ (qemu_param, "-vnc")) { - error (g, _("parameter '%s' isn't allowed"), qemu_param); + if (STREQ (hv_param, "-kernel") || + STREQ (hv_param, "-initrd") || + STREQ (hv_param, "-nographic") || + STREQ (hv_param, "-serial") || + STREQ (hv_param, "-full-screen") || + STREQ (hv_param, "-std-vga") || + STREQ (hv_param, "-vnc")) { + error (g, _("parameter '%s' isn't allowed"), hv_param); return -1; } - qp = safe_malloc (g, sizeof *qp); - qp->qemu_param = safe_strdup (g, qemu_param); - qp->qemu_value = qemu_value ? safe_strdup (g, qemu_value) : NULL; + hp = safe_malloc (g, sizeof *hp); + hp->hv_param = safe_strdup (g, hv_param); + hp->hv_value = hv_value ? safe_strdup (g, hv_value) : NULL; - qp->next = g->qemu_params; - g->qemu_params = qp; + hp->next = g->hv_params; + g->hv_params = hp; return 0; } diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index 8ad75d361..2e783de6e 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -245,12 +245,14 @@ main (int argc, char *argv[]) printf ("guestfs_get_cachedir: %s\n", p ? : "(null)"); free (p); printf ("guestfs_get_direct: %d\n", guestfs_get_direct (g)); + p = guestfs_get_hv (g); + printf ("guestfs_get_hv: %s\n", p); + free (p); printf ("guestfs_get_memsize: %d\n", guestfs_get_memsize (g)); printf ("guestfs_get_network: %d\n", guestfs_get_network (g)); printf ("guestfs_get_path: %s\n", guestfs_get_path (g) ? : "(null)"); printf ("guestfs_get_pgroup: %d\n", guestfs_get_pgroup (g)); printf ("guestfs_get_program: %s\n", guestfs_get_program (g)); - printf ("guestfs_get_qemu: %s\n", guestfs_get_qemu (g)); printf ("guestfs_get_recovery_proc: %d\n", guestfs_get_recovery_proc (g)); printf ("guestfs_get_selinux: %d\n", guestfs_get_selinux (g)); printf ("guestfs_get_smp: %d\n", guestfs_get_smp (g)); @@ -338,9 +340,10 @@ set_qemu (guestfs_h *g, const char *path, int use_wrapper) int fd; FILE *fp; - if (getenv ("LIBGUESTFS_QEMU")) { + if (getenv ("LIBGUESTFS_QEMU") != NULL || + getenv ("LIBGUESTFS_HV") != NULL) { fprintf (stderr, - _("LIBGUESTFS_QEMU environment variable is already set, so\n" + _("LIBGUESTFS_HV/LIBGUESTFS_QEMU environment variable is already set, so\n" "--qemu/--qemudir options cannot be used.\n")); exit (EXIT_FAILURE); } @@ -353,7 +356,7 @@ set_qemu (guestfs_h *g, const char *path, int use_wrapper) exit (EXIT_FAILURE); } - guestfs_set_qemu (g, path); + guestfs_set_hv (g, path); return; } @@ -391,6 +394,6 @@ set_qemu (guestfs_h *g, const char *path, int use_wrapper) host_cpu, path); fclose (fp); - guestfs_set_qemu (g, qemuwrapper); + guestfs_set_hv (g, qemuwrapper); atexit (cleanup_wrapper); } diff --git a/tests/regressions/rhbz790721.c b/tests/regressions/rhbz790721.c index 08d531ea0..370ca49f1 100644 --- a/tests/regressions/rhbz790721.c +++ b/tests/regressions/rhbz790721.c @@ -137,8 +137,8 @@ start_thread (void *vi) pthread_exit (vi); } - /* Fake out qemu. */ - if (guestfs_set_qemu (g, "/bin/true") == -1) { + /* Fake out hypervisor. */ + if (guestfs_set_hv (g, "/bin/true") == -1) { *(int *)vi = -1; pthread_exit (vi); }