Skip to content

IDV services #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ https://github.com/ThunderSoft-SRIOV/sriov/blob/main/docs/deploy-windows-vm.md#m

### Further steps

For further steps to launch VMs, refer the README [here](idv/README.md)
For further steps to launch VMs, refer the README [here](idv-services/README.md)

12 changes: 3 additions & 9 deletions idv-services/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This file contains steps to launch virtual machines using a system service.

## Step 2: Enable and start `idv-init` service

The `idv-init` service initializes the environment by enumerating SR-IOV virtual functions, starting the X server and setting up permissions required to run the scripts to launch VMs. This is a prerequisite for launching the virtual machines.
The `idv-init` service initializes the environment by enumerating SR-IOV virtual functions, starting the X server. This is a prerequisite for launching the virtual machines.

- Run the following command to enable `idv-init` service

Expand Down Expand Up @@ -108,18 +108,12 @@ This file contains steps to launch virtual machines using a system service.
```bash
journalctl --user -xeu idv-init.service
```
Ensure that all required files are present in `/opt/idv`.
Ensure that all required files are present in `/usr/local/bin/idv`.


- If the VMs do not launch after starting the `idv-launcher` service, check the service logs using the following command:

```bash
journalctl --user -u idv-launcher.service
```

You can also check the `start_all_vms.log` in `/opt/idv/launcher` directory for errors using the command:

```bash
sudo cat /opt/idv/launcher/start_all_vms.log
sudo journalctl -t idv-services
```
Ensure that the `vm.conf` file is correctly configured and all required files (e.g., firmware and qcow2 files) are present and the file paths are valid.
22 changes: 11 additions & 11 deletions idv-services/copy_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

if [ ! -d /opt/idv ]; then
if [ ! -d /usr/local/bin/idv ]; then
echo "idv directory not found. Creating directory"
sudo mkdir /opt/idv
sudo mkdir /opt/idv/launcher
sudo mkdir /opt/idv/init
sudo mkdir /usr/local/bin/idv
sudo mkdir /usr/local/bin/idv/launcher
sudo mkdir /usr/local/bin/idv/init
fi

username=$(getent passwd 1000 | cut -d: -f1)

# create/copy launcher files
sudo cp -r launcher /opt/idv/
sudo touch /opt/idv/launcher/start_all_vms.log
sudo chmod +x /opt/idv/launcher/start_all_vms.log
sudo chown $username:$username /opt/idv/launcher/start_all_vms.log
sudo cp -r launcher /usr/local/bin/idv/
sudo touch /usr/local/bin/idv/launcher/start_all_vms.log
sudo chmod +x /usr/local/bin/idv/launcher/start_all_vms.log
sudo chown $username:$username /usr/local/bin/idv/launcher/start_all_vms.log

# create/copy init files
sudo cp -r init /opt/idv/
sudo touch /opt/idv/init/setup_sriov_vfs.log
sudo cp -r init /usr/local/bin/idv/
sudo touch /usr/local/bin/idv/init/setup_sriov_vfs.log

# copy service files
sudo cp etc/systemd/user/idv-init.service /etc/systemd/user/idv-init.service
sudo cp etc/systemd/user/idv-launcher.service /etc/systemd/user/idv-launcher.service

# allow scripts to be run without password
echo "$username ALL=(ALL) NOPASSWD: /usr/bin/X,/opt/idv/init/setup_sriov_vfs.sh,/opt/idv/init/setup_display.sh,/opt/idv/init/setup_file_permissions.sh,/opt/idv/launcher/start_vm.sh,/opt/idv/launcher/start_all_vms.sh,/opt/idv/launcher/stop_vm.sh,/opt/idv/launcher/stop_all_vms.sh" | sudo tee -a /etc/sudoers.d/guest > /dev/null
echo "$username ALL=(ALL) NOPASSWD: /usr/bin/X,/usr/local/bin/idv/init/setup_sriov_vfs.sh,/usr/local/bin/idv/init/setup_display.sh,/usr/local/bin/idv/launcher/start_vm.sh,/usr/local/bin/idv/launcher/start_all_vms.sh,/usr/local/bin/idv/launcher/stop_vm.sh,/usr/local/bin/idv/launcher/stop_all_vms.sh" | sudo tee -a /etc/sudoers.d/guest > /dev/null
5 changes: 2 additions & 3 deletions idv-services/etc/systemd/user/idv-init.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ After=graphical.target
[Service]
Type=simple
Environment=DISPLAY=:0
ExecStartPre=/bin/bash -c 'cd /opt/idv/init && /usr/bin/sudo ./setup_display.sh'
ExecStartPre=-/bin/bash -c 'cd /usr/local/bin/idv/init && /usr/bin/sudo ./setup_display.sh'
ExecStart=/usr/bin/sudo /usr/bin/X
ExecStartPost=/bin/bash -c 'cd /opt/idv/init && /usr/bin/sudo ./setup_file_permissions.sh'
ExecStartPost=/bin/bash -c 'cd /opt/idv/init && /usr/bin/sudo ./setup_sriov_vfs.sh'
ExecStartPost=/bin/bash -c 'cd /usr/local/bin/idv/init && /usr/bin/sudo ./setup_sriov_vfs.sh'
ExecStartPost=/usr/bin/xhost +
ExecStartPost=/bin/bash -c 'openbox &'
Restart=on-failure
Expand Down
4 changes: 2 additions & 2 deletions idv-services/etc/systemd/user/idv-launcher.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ After=idv-init.service
[Service]
Type=simple
Environment=DISPLAY=:0
ExecStart=/bin/bash -c 'sleep 5 && cd /opt/idv/launcher && /usr/bin/sudo ./start_all_vms.sh >> /opt/idv/launcher/start_all_vms.log 2>&1 '
ExecStop=/bin/bash -c 'cd /opt/idv/launcher && /usr/bin/sudo ./stop_all_vms.sh'
ExecStart=/bin/bash -c 'sleep 5 && cd /usr/local/bin/idv/launcher && /usr/bin/sudo ./start_all_vms.sh | systemd-cat -t idv-services'
ExecStop=/bin/bash -c 'cd /usr/local/bin/idv/launcher && /usr/bin/sudo ./stop_all_vms.sh'
Restart=always
RestartSec=5

Expand Down
94 changes: 94 additions & 0 deletions idv-services/idv-services-setup-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This document contains steps to enable and start idv services on an EMT image.

- If you are using an EMT image with the prebuilt `intel-idv-services` package, you can follow this guide to start the IDV services.

# Table of Contents

1. [Steps to setup idv services on an immutable EMT image](#steps-to-setup-idv-services-on-an-immutable-emt-image)
2. [Steps to setup idv services on a mutable EMT image](#steps-to-setup-idv-services-on-a-mutable-emt-image)
1. [Modify VM Configuration](#modify-vm-configuration)
2. [Reload System Daemon](#reload-system-daemon)
3. [Enable IDV Services](#enable-idv-services)
4. [Start `idv-init.service`](#start-idv-init-service)
5. [Start `idv-launcher.service`](#start-idv-launcher-service)
3. [Troubleshooting](#troubleshooting)

### Steps to setup idv services on an immutable EMT image

- To setup `idv-init` and `idv-launcher` services on an immutable image, the following has to be done via `cloud-init` -
1. Run the [setup_display](init/setup_display.sh) script to add xorg configuration files.
2. Enable `idv-init.service` and `idv-launcher.service`. Refer the [Enable IDV Services](#enable-idv-services) section for the commands to be run to enable both the services.
3. Start `idv-init.service` and `idv-launcher.service`. Refer the [Start `idv-init.service`](#start-idv-init-service) and [Start `idv-launcher.service`](#start-idv-launcher-service) sections for the commands to be run to start each service.

### Steps to setup idv services on a mutable EMT image

## Modify VM configuration

- Refer to the [Modify VM configuration file](modify-vm-config-file.md) for details on how to modify the VM configuration file.

## Reload system daemon

- Run the following command to reload system-daemon

```bash
systemctl --user daemon-reload
```

## Enable idv services

- Run the following command to enable `idv-init.service` and `idv-launcher.service`

```bash
systemctl --user preset-all
```

## Start `idv-init` service

The `idv-init` service initializes the environment by enumerating SR-IOV virtual functions, starting the X server. This is a prerequisite for launching the virtual machines.

- Run the following command to start `idv-init` service

```bash
systemctl --user start idv-init.service
```

- Verify that the service is running:

```bash
systemctl --user status idv-init.service
```
**Note**: After starting the idv-init service, the screen will go blank because X is running. Ensure you have SSH access to the machine for the next steps.

## Start `idv-launcher` service

The `idv-launcher` service launches the configured virtual machines in their respective monitors.

- Run the following command to start `idv-launcher` service

```bash
systemctl --user start idv-launcher.service
```

- Verify that the service is running:

```bash
systemctl --user status idv-launcher.service
```
**Note**: Once the idv-launcher service starts, all the VMs should be launched in respective monitors.

**Note**: Autologin is enabled for the `guest` user. If the `idv-init` and `idv-launcher` services were enabled in the previous steps, they will automatically start upon autologin of the `guest` user.

### Troubleshooting

- If the `idv-init` service fails to start, check the service logs using the following command:

```bash
journalctl --user -xeu idv-init.service
```

- If the VMs do not launch after starting the `idv-launcher` service, check the service logs using the following command:

```bash
sudo journalctl -t idv-services
```
Ensure that the `vm.conf` file is correctly configured and all required files (e.g., firmware and qcow2 files) are present and the file paths are valid.
1 change: 0 additions & 1 deletion idv-services/init/setup_display.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# These contents may have been developed with support from one or more
# Intel-operated generative artificial intelligence solutions.


extensions_file="/usr/share/X11/xorg.conf.d/10-extensions.conf"
serverflags_file="/usr/share/X11/xorg.conf.d/10-serverflags.conf"

Expand Down
12 changes: 0 additions & 12 deletions idv-services/init/setup_file_permissions.sh

This file was deleted.

5 changes: 4 additions & 1 deletion idv-services/init/setup_sriov_vfs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
#

# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# These contents may have been developed with support from one or more
# Intel-operated generative artificial intelligence solutions.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,54 @@
Name: idv-solution
Version: 1.0
Release: 1%{?dist}
Summary: A package to install scripts and systemd services
%define systemd_user_dir %{buildroot}/usr/lib/systemd/user
%define systemd_system_dir %{buildroot}/etc/systemd/system
%define local_bin_dir %{buildroot}/usr/local/bin

License: Proprietary
Name: intel-idv-services
Version: 0.1
Release: 1%{?dist}
Summary: A package to install scripts and systemd services for Intelligent Desktop Virtualization
Distribution: Edge Microvisor Toolkit
Vendor: Intel Corporation
License: Apache-2.0
URL: https://github.com/open-edge-platform/edge-desktop-virtualization
Source0: %{name}-%{version}.tar.gz
Source1: setup_permissions.sh

BuildArch: noarch
Requires(post): systemd
Requires(preun): systemd

%description
This package installs the scripts folder to /opt/idv, enables and starts a root-level systemd service, and enables and starts a user-level systemd service.
This package installs the scripts and services that are needed to run IDV solution

%prep
%setup -q

%build

%install
# Copy the scripts folder to /opt/idv
mkdir -p %{buildroot}/opt/idv
cp -r init %{buildroot}/opt/idv
cp -r launcher %{buildroot}/opt/idv

# Create log file
touch %{buildroot}/opt/idv/launcher/start_all_vms.log
# Copy the scripts folder to /usr/local/bin/idv
mkdir -p %{local_bin_dir}/idv
cp -r init /%{local_bin_dir}/idv
cp -r launcher %{local_bin_dir}/idv

# Install the idv-init service
mkdir -p %{buildroot}/usr/lib/systemd/user/
install -m 644 idv-init.service %{buildroot}/usr/lib/systemd/user/idv-init.service
mkdir -p %{systemd_user_dir}
install -m 644 idv-init.service %{systemd_user_dir}/idv-init.service

# Install the idv-launcher service
mkdir -p %{buildroot}/usr/lib/systemd/user/
install -m 644 idv-launcher.service %{buildroot}/usr/lib/systemd/user/idv-launcher.service
install -m 644 idv-launcher.service %{systemd_user_dir}/idv-launcher.service

# Install the autologin.conf file
mkdir -p %{buildroot}/etc/systemd/system/getty@tty1.service.d
install -m 644 autologin.conf %{buildroot}/etc/systemd/system/getty@tty1.service.d/autologin.conf

# Install the setup_permissions.sh file
mkdir -p %{buildroot}/usr/local/bin
install -m 755 %{SOURCE1} %{buildroot}/usr/local/bin/setup_permissions.sh
mkdir -p %{systemd_system_dir}/getty@tty1.service.d
install -m 644 autologin.conf %{systemd_system_dir}/getty@tty1.service.d/autologin.conf

%files
/opt/idv/
/usr/lib/systemd/user/idv-init.service
/usr/lib/systemd/user/idv-launcher.service
/usr/local/bin/setup_permissions.sh
/usr/local/bin/idv/
/usr/lib/systemd/user/idv-*.service
%config(noreplace) /etc/systemd/system/getty@tty1.service.d/autologin.conf

%post
systemctl daemon-reload

# Run setup_sudoers.sh script
/usr/local/bin/setup_permissions.sh

USER_ID=1000
USER=$(getent passwd 1000 | cut -d: -f1)
export XDG_RUNTIME_DIR=/run/user/$USER_ID
Expand All @@ -69,6 +61,7 @@ if [ -d "$XDG_RUNTIME_DIR" ]; then
fi

%preun
set -e
# Stop and disable the idv-init service before uninstalling
if [ $1 -eq 0 ]; then
USER_ID=$(id -u $SUDO_USER)
Expand All @@ -80,10 +73,20 @@ if [ $1 -eq 0 ]; then
sudo -u $SUDO_USER XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR systemctl --user stop idv-launcher.service
sudo -u $SUDO_USER XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR systemctl --user disable idv-launcher.service
fi

rm -rf /opt/idv/
fi

%changelog
* Fri Jun 13 2025 Dhanya A <dhanya.a@intel.com> - 1.0-1
* Fri Jun 20 2025 Dhanya A <dhanya.a@intel.com> - 0.1-6
- Update comment in spec file

* Thu Jun 19 2025 Dhanya A <dhanya.a@intel.com> - 0.1-5
- Copy scripts to bin directory, use macros for standard path, remove logs file

* Tue Jun 17 2025 Dhanya A <dhanya.a@intel.com> - 0.1-3
- Remove command to create logs file.

* Mon Jun 16 2025 Dhanya A <dhanya.a@intel.com> - 0.1-2
- Initial Edge Microvisor Toolkit import from Fedora 43 (license: MIT). License verified.

* Fri Jun 13 2025 Dhanya A <dhanya.a@intel.com> - 0.1-1
- Initial RPM package for scripts and systemd services
1 change: 0 additions & 1 deletion idv-services/launcher/start_all_vms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# These contents may have been developed with support from one or more
# Intel-operated generative artificial intelligence solutions.


source vm.conf

declare -A VM_LIST
Expand Down
1 change: 0 additions & 1 deletion idv-services/launcher/start_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# These contents may have been developed with support from one or more
# Intel-operated generative artificial intelligence solutions.


source vm.conf

set -eE
Expand Down
1 change: 0 additions & 1 deletion idv-services/launcher/stop_all_vms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# These contents may have been developed with support from one or more
# Intel-operated generative artificial intelligence solutions.


source vm.conf

declare -A VM_LIST
Expand Down
3 changes: 3 additions & 0 deletions idv-services/launcher/stop_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# These contents may have been developed with support from one or more
# Intel-operated generative artificial intelligence solutions.

# Kill QEMU process
grep_output=$(ps aux | grep qemu | grep -i $1)

Expand Down
2 changes: 1 addition & 1 deletion idv-services/launcher/vm.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
guest=3
guest=0

OVMF_CODE_FILE=/opt/qcow2/OVMF_CODE.fd

Expand Down
Loading
Loading