qemu: Use '-machine hpet=off' instead of '-no-hpet'

qemu is about to deprecate the '-no-hpet' option in favor of configuring
the timer via '-machine'.

Use the QEMU_CAPS_MACHINE_HPET capability to switch to the new syntax
and mask out the old QEMU_CAPS_NO_HPET capability at the same time to
prevent using the old syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Peter Krempa 2023-01-03 10:03:06 +01:00
parent 3c508e7d43
commit 24cc9cda82
8 changed files with 38 additions and 12 deletions

View File

@ -5410,6 +5410,11 @@ virQEMUCapsInitProcessCapsInterlock(virQEMUCaps *qemuCaps)
* on a not entirely related witness. */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_JSON))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_COMPAT_DEPRECATED);
/* Modern-style config of the HPET timer overrides support for the '-no-hpet'
* option */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_HPET))
virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_HPET);
}

View File

@ -5860,7 +5860,10 @@ qemuBuildClockCommandLine(virCommand *cmd,
break;
case VIR_DOMAIN_TIMER_NAME_HPET:
/* the only meaningful attribute for hpet is "present". If present
/* Modern qemu versions configure the HPET timer via -machine. See
* qemuBuildMachineCommandLine.
*
* the only meaningful attribute for hpet is "present". If present
* is VIR_TRISTATE_BOOL_ABSENT, that means it wasn't specified, and
* should be left at the default for the hypervisor. "default" when
* -no-hpet exists is VIR_TRISTATE_BOOL_YES, and when -no-hpet
@ -6744,6 +6747,7 @@ qemuBuildMachineCommandLine(virCommand *cmd,
{
virCPUDef *cpu = def->cpu;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
virCommandAddArg(cmd, "-machine");
virBufferAdd(&buf, def->os.machine, -1);
@ -6829,6 +6833,29 @@ qemuBuildMachineCommandLine(virCommand *cmd,
virBufferAddLit(&buf, ",graphics=off");
}
for (i = 0; i < def->clock.ntimers; i++) {
switch ((virDomainTimerNameType)def->clock.timers[i]->name) {
case VIR_DOMAIN_TIMER_NAME_HPET:
/* qemuBuildClockCommandLine handles the old-style config via '-no-hpet' */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_HPET) &&
def->clock.timers[i]->present != VIR_TRISTATE_BOOL_ABSENT) {
virBufferAsprintf(&buf, ",hpet=%s",
virTristateSwitchTypeToString(def->clock.timers[i]->present));
}
break;
case VIR_DOMAIN_TIMER_NAME_PLATFORM:
case VIR_DOMAIN_TIMER_NAME_TSC:
case VIR_DOMAIN_TIMER_NAME_KVMCLOCK:
case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
case VIR_DOMAIN_TIMER_NAME_RTC:
case VIR_DOMAIN_TIMER_NAME_PIT:
case VIR_DOMAIN_TIMER_NAME_LAST:
break;
}
}
virCommandAddArgBuffer(cmd, &buf);
return 0;

View File

@ -5,7 +5,6 @@
<selfvers>0</selfvers>
<flag name='kvm'/>
<flag name='sdl'/>
<flag name='no-hpet'/>
<flag name='spice'/>
<flag name='hda-duplex'/>
<flag name='ccid-emulated'/>

View File

@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-virt-manager-basic/.config \
-name guest=virt-manager-basic,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-virt-manager-basic/master-key.aes"}' \
-machine q35,usb=off,vmport=off,dump-guest-core=off,memory-backend=pc.ram \
-machine q35,usb=off,vmport=off,dump-guest-core=off,memory-backend=pc.ram,hpet=off \
-accel kvm \
-cpu qemu64 \
-m 4096 \
@ -24,7 +24,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-virt-manager-basic/.config \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew \
-global kvm-pit.lost_tick_policy=delay \
-no-hpet \
-no-shutdown \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \

View File

@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-name guest=guest,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-guest/master-key.aes"}' \
-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \
-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,hpet=off \
-accel tcg \
-cpu qemu64 \
-m 4096 \
@ -24,7 +24,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew \
-global kvm-pit.lost_tick_policy=delay \
-no-hpet \
-no-shutdown \
-global PIIX4_PM.disable_s3=1 \
-global PIIX4_PM.disable_s4=1 \

View File

@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-name guest=guest,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-guest/master-key.aes"}' \
-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \
-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,hpet=off \
-accel tcg \
-cpu qemu64 \
-m 4096 \
@ -25,7 +25,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew \
-global kvm-pit.lost_tick_policy=delay \
-no-hpet \
-no-shutdown \
-global PIIX4_PM.disable_s3=1 \
-global PIIX4_PM.disable_s4=1 \

View File

@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-name guest=guest,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-guest/master-key.aes"}' \
-machine q35,usb=off,dump-guest-core=off,memory-backend=pc.ram \
-machine q35,usb=off,dump-guest-core=off,memory-backend=pc.ram,hpet=off \
-accel tcg \
-cpu qemu64 \
-m 4096 \
@ -24,7 +24,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew \
-global kvm-pit.lost_tick_policy=delay \
-no-hpet \
-no-shutdown \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \

View File

@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-name guest=guest,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-guest/master-key.aes"}' \
-machine q35,usb=off,dump-guest-core=off,memory-backend=pc.ram \
-machine q35,usb=off,dump-guest-core=off,memory-backend=pc.ram,hpet=off \
-accel tcg \
-cpu qemu64 \
-m 4096 \
@ -25,7 +25,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew \
-global kvm-pit.lost_tick_policy=delay \
-no-hpet \
-no-shutdown \
-global ICH9-LPC.disable_s3=1 \
-global ICH9-LPC.disable_s4=1 \