Skip to content

Commit

Permalink
Replace customize-vm service with boot script
Browse files Browse the repository at this point in the history
Currently the VM guests are configured on a service added on the
customize-vm script created in the image building process.
There is no real need for the script to run on that context, and it is
easier to manage if it runs as part of the cloud-init context.
This commits:
- Runs the boot script on the cloud-init context.
- Removes it from the images customize-vm scripts.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Jan 25, 2024
1 parent 9dfcf78 commit e764cbc
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 134 deletions.
1 change: 1 addition & 0 deletions pkg/internal/checkup/vmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,6 @@ func vmiUnderTestBootCommands(configDiskSerial string) []string {
fmt.Sprintf("mount /dev/$(lsblk --nodeps -no name,serial | grep %s | cut -f1 -d' ') %s", configDiskSerial, configMountDirectory),
fmt.Sprintf("cp %s %s", path.Join(configMountDirectory, config.BootScriptName), config.BootScriptBinDirectory),
fmt.Sprintf("chmod 744 %s", path.Join(config.BootScriptBinDirectory, config.BootScriptName)),
path.Join(config.BootScriptBinDirectory, config.BootScriptName),
}
}
67 changes: 0 additions & 67 deletions vms/traffic-gen/scripts/customize-vm
Original file line number Diff line number Diff line change
Expand Up @@ -57,74 +57,7 @@ set_unsafe_no_io_mmu_mode() {
echo "options vfio enable_unsafe_noiommu_mode=1" > /etc/modprobe.d/vfio-noiommu.conf
}

# Create and enable the boot checkup service
setup_boot_service() {
local service_name="dpdk-checkup-boot.service"
local checkup_boot_script_full_path="/usr/bin/dpdk-checkup-boot.sh"
local checkup_boot_service_full_path="/usr/lib/systemd/system/$service_name"

setup_checkup_boot_script "$checkup_boot_script_full_path"

cat <<EOF > "$checkup_boot_service_full_path"
[Unit]
Description=Checkup Boot Script
Before=qemu-guest-agent.service
[Service]
ExecStart=$checkup_boot_script_full_path
Restart=no
User=root
Group=root
[Install]
WantedBy=multi-user.target
EOF

systemctl enable "$checkup_boot_service_full_path"
systemctl start "$checkup_boot_service_full_path"
}

setup_checkup_boot_script() {
local checkup_boot_script_full_path=$1
cat <<'EOF' > "$checkup_boot_script_full_path"
#!/usr/bin/env bash
#
# This file is part of the kiagnose project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright 2024 Red Hat, Inc.
#
set -e
checkup_tuned_adm_set_marker_full_path="/var/dpdk-checkup-tuned-adm-set-marker"
driverctl set-override 0000:06:00.0 vfio-pci
driverctl set-override 0000:07:00.0 vfio-pci
if [ ! -f "$checkup_tuned_adm_set_marker_full_path" ]; then
echo "isolated_cores=2-7" > /etc/tuned/cpu-partitioning-variables.conf
tuned-adm profile cpu-partitioning
touch $checkup_tuned_adm_set_marker_full_path
reboot
fi
EOF

chmod +x "$checkup_boot_script_full_path"
}

disable_services
setup_hugepages
install_trex
set_unsafe_no_io_mmu_mode
setup_boot_service
67 changes: 0 additions & 67 deletions vms/vm-under-test/scripts/customize-vm
Original file line number Diff line number Diff line change
Expand Up @@ -40,73 +40,6 @@ set_unsafe_no_io_mmu_mode() {
echo "options vfio enable_unsafe_noiommu_mode=1" > /etc/modprobe.d/vfio-noiommu.conf
}

# Create and enable the boot checkup service
setup_boot_service() {
local service_name="dpdk-checkup-boot.service"
local checkup_boot_script_full_path="/usr/bin/dpdk-checkup-boot.sh"
local checkup_boot_service_full_path="/usr/lib/systemd/system/$service_name"

setup_checkup_boot_script "$checkup_boot_script_full_path"

cat <<EOF > "$checkup_boot_service_full_path"
[Unit]
Description=Checkup Boot Script
Before=qemu-guest-agent.service
[Service]
ExecStart=$checkup_boot_script_full_path
Restart=no
User=root
Group=root
[Install]
WantedBy=multi-user.target
EOF

systemctl enable "$checkup_boot_service_full_path"
systemctl start "$checkup_boot_service_full_path"
}

setup_checkup_boot_script() {
local checkup_boot_script_full_path=$1
cat <<'EOF' > "$checkup_boot_script_full_path"
#!/usr/bin/env bash
#
# This file is part of the kiagnose project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright 2024 Red Hat, Inc.
#
set -e
checkup_tuned_adm_set_marker_full_path="/var/dpdk-checkup-tuned-adm-set-marker"
driverctl set-override 0000:06:00.0 vfio-pci
driverctl set-override 0000:07:00.0 vfio-pci
if [ ! -f "$checkup_tuned_adm_set_marker_full_path" ]; then
echo "isolated_cores=2-7" > /etc/tuned/cpu-partitioning-variables.conf
tuned-adm profile cpu-partitioning
touch $checkup_tuned_adm_set_marker_full_path
reboot
fi
EOF

chmod +x "$checkup_boot_script_full_path"
}

disable_services
setup_hugepages
set_unsafe_no_io_mmu_mode
setup_boot_service

0 comments on commit e764cbc

Please sign in to comment.