Skip to content
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

VM agent tweaks #489

Merged
merged 2 commits into from
Feb 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ if [ ! -e "${PREFIX}/incus-agent" ] && [ -e "${PREFIX}/lxd-agent" ]; then
ln -s lxd-agent "${PREFIX}"/incus-agent
fi

# Attempt to restore SELinux labels.
restorecon -R "${PREFIX}" >/dev/null 2>&1 || true

exit 0
5 changes: 5 additions & 0 deletions internal/server/instance/drivers/agent-loader/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ cp systemd/incus-agent.service /lib/systemd/system/
cp systemd/incus-agent-setup /lib/systemd/
systemctl daemon-reload

# SELinux handling.
if getenforce >/dev/null 2>&1; then
semanage fcontext -a -t bin_t /var/run/incus_agent/incus-agent
fi

echo ""
echo "Incus agent has been installed, reboot to confirm setup."
echo "To start it now, unmount this filesystem and run: systemctl start incus-agent"
33 changes: 21 additions & 12 deletions internal/server/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,26 @@ func (d *qemu) generateConfigShare() error {
return err
}

// Add the NIC config.
if util.IsTrue(d.expandedConfig["agent.nic_config"]) {
sortedDevices := d.expandedDevices.Sorted()
for _, entry := range sortedDevices {
if entry.Config["type"] != "nic" {
continue // Only keep NIC devices.
}

dev, err := d.FillNetworkDevice(entry.Name, entry.Config)
if err != nil {
return err
}

err = d.writeNICDevConfig(dev["mtu"], entry.Name, dev["name"], dev["hwaddr"])
if err != nil {
return fmt.Errorf("Failed writing NIC config for device %q: %w", entry.Name, err)
}
}
}

// Writing the connection info the config drive allows the agent to start /dev/incus very
// early. This is important for systemd services which want or require /dev/incus/sock.
connInfo, err := d.getAgentConnectionInfo()
Expand Down Expand Up @@ -3965,7 +3985,7 @@ func (d *qemu) addNetDevConfig(busName string, qemuDev map[string]string, bootIn
reverter := revert.New()
defer reverter.Fail()

var devName, nicName, devHwaddr, pciSlotName, pciIOMMUGroup, vDPADevName, vhostVDPAPath, maxVQP, mtu, name string
var devName, nicName, devHwaddr, pciSlotName, pciIOMMUGroup, vDPADevName, vhostVDPAPath, maxVQP string
for _, nicItem := range nicConfig {
if nicItem.Key == "devName" {
devName = nicItem.Value
Expand All @@ -3983,17 +4003,6 @@ func (d *qemu) addNetDevConfig(busName string, qemuDev map[string]string, bootIn
vhostVDPAPath = nicItem.Value
} else if nicItem.Key == "maxVQP" {
maxVQP = nicItem.Value
} else if nicItem.Key == "mtu" {
mtu = nicItem.Value
} else if nicItem.Key == "name" {
name = nicItem.Value
}
}

if util.IsTrue(d.expandedConfig["agent.nic_config"]) {
err := d.writeNICDevConfig(mtu, devName, name, devHwaddr)
if err != nil {
return nil, fmt.Errorf("Failed writing NIC config for device %q: %w", devName, err)
}
}

Expand Down
Loading