1
0

qemu: validate: Validate maximum start time for <clock offset='absolute'>

Glib can internally convert only unix timestamps up to
9999-12-31T23:59:59 (253402300799). Validate that the user doesn't use
more than that as otherwise we cause an assertion failure:

 (process:1183396): GLib-CRITICAL **: 14:25:00.906: g_date_time_format: assertion 'datetime != NULL' failed

Additionally adjust the schema to allow bigger values as we use
'unsigned long long' to parse the value.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2128993
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-11-03 16:04:17 +01:00
parent cca6787b15
commit 9acd9fa733
5 changed files with 21 additions and 4 deletions

View File

@ -1312,7 +1312,7 @@
<value>absolute</value> <value>absolute</value>
</attribute> </attribute>
<attribute name="start"> <attribute name="start">
<ref name="unsignedInt"/> <ref name="unsignedLong"/>
</attribute> </attribute>
</group> </group>
</choice> </choice>

View File

@ -663,6 +663,23 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
} }
} }
switch ((virDomainClockOffsetType) def->clock.offset) {
case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE:
/* maximum timestamp glib can convert is 9999-12-31T23:59:59 */
if (def->clock.data.starttime > 253402300799) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("The maximum 'start' value for <clock offset='absolute'> is 253402300799"));
return -1;
}
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE:
case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
case VIR_DOMAIN_CLOCK_OFFSET_LAST:
break;
}
return 0; return 0;
} }

View File

@ -23,7 +23,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-nodefaults \ -nodefaults \
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ -chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
-mon chardev=charmonitor,id=monitor,mode=control \ -mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=1970-01-01T00:20:34 \ -rtc base=9999-12-31T23:59:59 \
-no-shutdown \ -no-shutdown \
-no-acpi \ -no-acpi \
-boot strict=on \ -boot strict=on \

View File

@ -8,7 +8,7 @@
<type arch='x86_64' machine='pc'>hvm</type> <type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/> <boot dev='hd'/>
</os> </os>
<clock offset='absolute' start='1234'/> <clock offset='absolute' start='253402300799'/>
<on_poweroff>destroy</on_poweroff> <on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot> <on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash> <on_crash>destroy</on_crash>

View File

@ -11,7 +11,7 @@
<cpu mode='custom' match='exact' check='none'> <cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>qemu64</model> <model fallback='forbid'>qemu64</model>
</cpu> </cpu>
<clock offset='absolute' start='1234'/> <clock offset='absolute' start='253402300799'/>
<on_poweroff>destroy</on_poweroff> <on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot> <on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash> <on_crash>destroy</on_crash>