mirror of
https://github.com/systemd/systemd.git
synced 2025-02-25 21:57:32 +03:00
core: Fix CPUQuotaPerSecUSec unit file serialization
CPUQuota= can deal with float percentages perfectly fine these days (up to two places after the dot), so let's take that into account when serializing the value to the transient unit file so we don't lose precision when specifying e.g. "CPUQuota=0.5%".
This commit is contained in:
parent
80313c5577
commit
1a48d8549f
@ -1312,11 +1312,10 @@ int bus_cgroup_set_property(
|
||||
if (c->cpu_quota_per_sec_usec == USEC_INFINITY)
|
||||
unit_write_setting(u, flags, "CPUQuota", "CPUQuota=");
|
||||
else
|
||||
/* config_parse_cpu_quota() requires an integer, so truncating division is used on
|
||||
* purpose here. */
|
||||
unit_write_settingf(u, flags, "CPUQuota",
|
||||
"CPUQuota=%0.f%%",
|
||||
(double) (c->cpu_quota_per_sec_usec / 10000));
|
||||
"CPUQuota=" USEC_FMT ".%02" PRI_USEC "%%",
|
||||
c->cpu_quota_per_sec_usec / 10000,
|
||||
(c->cpu_quota_per_sec_usec % 10000) / 100);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -241,7 +241,7 @@ systemctl revert "$UNIT_NAME"
|
||||
systemctl set-property --runtime "$UNIT_NAME" CPUAccounting=no CPUQuota=10%
|
||||
systemctl cat "$UNIT_NAME"
|
||||
grep -r "CPUAccounting=no" "/run/systemd/system.control/${UNIT_NAME}.d/"
|
||||
grep -r "CPUQuota=10%" "/run/systemd/system.control/${UNIT_NAME}.d/"
|
||||
grep -r "CPUQuota=10.00%" "/run/systemd/system.control/${UNIT_NAME}.d/"
|
||||
systemctl revert "$UNIT_NAME"
|
||||
(! grep -r "CPUAccounting=" "/run/systemd/system.control/${UNIT_NAME}.d/")
|
||||
(! grep -r "CPUQuota=" "/run/systemd/system.control/${UNIT_NAME}.d/")
|
||||
|
Loading…
x
Reference in New Issue
Block a user