lib/launch-direct.c: Remove unnecessary tests for ancient qemu features

We can safely assume that qemu supports -nodefaults and
-no-user-config, since these have been supported since forever.

-no-hpet was deprecated in qemu 8.0 and the option removed in early
2024, replaced with -machine hpet=off.  HPET defaults to 'on' in
upstream qemu, and to 'off' in downstream RHEL rebuilds.

Since (for libguestfs) we can assume an up to date Linux kernel is
running inside the guest, and that the kernel will do the right thing
with regards to timers, we don't need to mess with qemu defaults.  In
practice, Linux chooses kvm-clock.

Thanks: Thomas Huth, Daniel Berrange
This commit is contained in:
Richard W.M. Jones
2025-09-29 11:18:21 +01:00
committed by rwmjones
parent 1f1ac69b11
commit fc243a36bd

View File

@@ -579,19 +579,11 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
*/
arg ("-global", VIRTIO_DEVICE_NAME ("virtio-blk") ".scsi=off");
if (guestfs_int_qemu_supports (g, data->qemu_data, "-no-user-config"))
flag ("-no-user-config");
/* Newer versions of qemu (from around 2009/12) changed the
* behaviour of monitors so that an implicit '-monitor stdio' is
* assumed if we are in -nographic mode and there is no other
* -monitor option. Only a single stdio device is allowed, so
* this broke the '-serial stdio' option. There is a new flag
* called -nodefaults which gets rid of all this default crud, so
* let's use that to avoid this and any future surprises.
/* Disable qemu defaults and per-user configuration file so we get
* an unconfigured qemu.
*/
if (guestfs_int_qemu_supports (g, data->qemu_data, "-nodefaults"))
flag ("-nodefaults");
flag ("-no-user-config");
flag ("-nodefaults");
/* This disables the host-side display (SDL, Gtk). */
arg ("-display", "none");
@@ -646,8 +638,6 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
/* These are recommended settings, see RHBZ#1053847. */
arg ("-rtc", "driftfix=slew");
if (guestfs_int_qemu_supports (g, data->qemu_data, "-no-hpet"))
flag ("-no-hpet");
#if defined(__i386__) || defined(__x86_64__)
if (guestfs_int_version_ge (&data->qemu_version, 1, 3, 0))
arg ("-global", "kvm-pit.lost_tick_policy=discard");