Skip to content

Commit

Permalink
T3501: Allow using more than one tuned profile
Browse files Browse the repository at this point in the history
  • Loading branch information
natali-rs1985 committed Oct 28, 2024
1 parent ceb64f3 commit 6c5fa76
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 9 deletions.
2 changes: 1 addition & 1 deletion interface-definitions/include/version/system-version.xml.i
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- include start from include/version/system-version.xml.i -->
<syntaxVersion component='system' version='27'></syntaxVersion>
<syntaxVersion component='system' version='28'></syntaxVersion>
<!-- include end -->
21 changes: 17 additions & 4 deletions interface-definitions/system_option.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,32 @@
<properties>
<help>Tune system performance</help>
<completionHelp>
<list>throughput latency</list>
<list>network-throughput network-latency powersave virtual-host virtual-guest</list>
</completionHelp>
<valueHelp>
<format>throughput</format>
<format>network-throughput</format>
<description>Tune for maximum network throughput</description>
</valueHelp>
<valueHelp>
<format>latency</format>
<format>network-latency</format>
<description>Tune for low network latency</description>
</valueHelp>
<valueHelp>
<format>powersave</format>
<description>Tune for low power consumption</description>
</valueHelp>
<valueHelp>
<format>virtual-guest</format>
<description>Tune for running inside a virtual guest</description>
</valueHelp>
<valueHelp>
<format>virtual-host</format>
<description>Tune for running KVM guests</description>
</valueHelp>
<constraint>
<regex>(throughput|latency)</regex>
<regex>(network-throughput|network-latency|powersave|virtual-guest|virtual-host)</regex>
</constraint>
<multi/>
</properties>
</leafNode>
<node name="http-client">
Expand Down
2 changes: 1 addition & 1 deletion smoketest/config-tests/dialup-router-wireguard-ipv6
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ set system login user vyos authentication encrypted-password '$6$2Ta6TWHd/U$NmrX
set system login user vyos authentication plaintext-password ''
set system name-server '172.16.254.30'
set system option ctrl-alt-delete 'ignore'
set system option performance 'latency'
set system option performance 'network-latency'
set system option reboot-on-panic
set system option startup-beep
set system syslog global facility all level 'debug'
Expand Down
2 changes: 1 addition & 1 deletion smoketest/configs/dialup-router-wireguard-ipv6
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ system {
}
option {
ctrl-alt-delete ignore
performance latency
performance network-latency
reboot-on-panic
startup-beep
}
Expand Down
2 changes: 1 addition & 1 deletion smoketest/scripts/cli/test_system_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_performance(self):
self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh2', 'value', gc_thresh2])
self.cli_set(['system', 'sysctl', 'parameter', 'net.ipv4.neigh.default.gc_thresh3', 'value', gc_thresh3])

self.cli_set(base_path + ['performance', 'throughput'])
self.cli_set(base_path + ['performance', 'network-throughput'])
self.cli_commit()

self.assertTrue(is_systemd_service_active(tuned_service))
Expand Down
3 changes: 2 additions & 1 deletion src/conf_mode/system_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def apply(options):
# wait until daemon has started before sending configuration
while not is_systemd_service_running('tuned.service'):
sleep(0.250)
cmd('tuned-adm profile network-{performance}'.format(**options))
performance = ' '.join(options['performance'])
cmd(f'tuned-adm profile {performance}')
else:
cmd('systemctl stop tuned.service')

Expand Down
33 changes: 33 additions & 0 deletions src/migration-scripts/system/27-to-28
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023-2024 VyOS maintainers and contributors <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.

# rename 'system option performance' leaf nodes to new names

from vyos.configtree import ConfigTree

base = ['system', 'option', 'performance']

def migrate(config: ConfigTree) -> None:
if not config.exists(base):
return

replace = {
'throughput' : 'network-throughput',
'latency' : 'network-latency'
}

for old_name, new_name in replace.items():
if config.return_value(base) == old_name:
config.set(base, new_name)

0 comments on commit 6c5fa76

Please sign in to comment.