]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use '-machine hpet=off' instead of '-no-hpet'
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jan 2023 09:03:06 +0000 (10:03 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jan 2023 15:44:09 +0000 (16:44 +0100)
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>
src/qemu/qemu_capabilities.c
src/qemu/qemu_command.c
tests/qemucapabilitiesdata/caps_8.0.0.x86_64.xml
tests/qemuxml2argvdata/q35-virt-manager-basic.x86_64-latest.args
tests/qemuxml2argvdata/x86_64-pc-graphics.x86_64-latest.args
tests/qemuxml2argvdata/x86_64-pc-headless.x86_64-latest.args
tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args
tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args

index 7df68f85a1d8798a980fd8f4822bf3f8501554fb..3591e73e5b370336bd449e6b13712a86df6c5d78 100644 (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);
 }
 
 
index ee2e873b956263ba98c87a01979ab99481c43607..06e29ff8ae210a7e297e91d8e8fb17fe57292fb0 100644 (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;
index 31dc03a78037ebca295e075780c319f3a131087c..860ad2860a3726d506425ed34316dbc197cc422c 100644 (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'/>
index 2f75d797398cc5afee4d4d514851cf23f9f35935..8446abdb6e672b29d9b8da87186ca1cfb3aa5977 100644 (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 \
index ef0b9c620cc38f8870b69b1594b6f5358e97fb43..4c3c896f02e584c3a558f82c3ae0a5dc27f79a3a 100644 (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 \
index aee3161a751ca85d6dc2d350847813905f15b505..281d611f8b858c292c585e181a4c3e4e769daf94 100644 (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 \
index 337103d722dd9558ac164c34d6502fcd6beadca6..db56a837632a0614de5e261539a62514ded873e8 100644 (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 \
index bf8a2f3af976f75445252145753a87f0011d7667..dde31179d36472e30a3867b5f02a3b0557358b20 100644 (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 \