@johnnezero said:
WHAT: Automatically assigns CPU weights and I/O priorities based on assigned VM tag (i.e. replicating what vcenter did via resource pools etc.).
HOW: Run via cron for regular enforcement.
WHY: Automatically assign performance metrics on all pool VMs (as well as preventing configuration drift if settings are accidentally changed).
TAGS: The Performance Tiering Concept: 4-tier system with a naming convention that sorts logically in XO:
TAG CPU WEIGHT I/O PRIORITY USE CASE
0-core 2048 7 (Highest) Domain Controllers, DNS, DHCP, Core DBs
1-high 1024 7 Critical App Servers
2-normal 256 4 Standard Workloads
3-low 128 1 Dev/Test, Noisy Neighbors
Why the "0-" prefix? It forces core VMs to the top of the VM list in XO for easy visibility and management.
Important: CPU weights only matter during contention. When the host is under-utilized, all VMs get the performance they need regardless of weight. These are an insurance policy.
Script: set-performace.sh
bash
#!/bin/bash
# ============================================
# XCP-ng set-performace.sh script
# Tags: 0-core, 1-high, 2-normal, 3-low
# ============================================
# --- CONFIGURATION (Customize these for your environment) ---
CORE_TAG="0-core"
CORE_WEIGHT="2048"
CORE_IO_PRI="7"
HIGH_TAG="1-high"
HIGH_WEIGHT="1024"
HIGH_IO_PRI="7"
NORMAL_TAG="2-normal"
NORMAL_WEIGHT="256"
NORMAL_IO_PRI="4"
LOW_TAG="3-low"
LOW_WEIGHT="128"
LOW_IO_PRI="1"
LOW_QOS_KBPS="100000" # 100Mbps cap for noisy neighbors
# --- CORE CRITICAL VMs ---
echo "=== Applying $CORE_TAG CPU & I/O Priority ==="
xe vm-list tags:contains="$CORE_TAG" --minimal | tr ',' '\n' | while read uuid; do
[ -z "$uuid" ] && continue
xe vm-param-set uuid=$uuid VCPUs-params:weight=$CORE_WEIGHT
xe vm-param-set uuid=$uuid other-config:sched-pri=$CORE_IO_PRI
echo "CORE CRITICAL priority applied: $uuid"
done
# --- HIGH PRIORITY VMs ---
echo "=== Applying $HIGH_TAG CPU & I/O Priority ==="
xe vm-list tags:contains="$HIGH_TAG" --minimal | tr ',' '\n' | while read uuid; do
[ -z "$uuid" ] && continue
xe vm-param-set uuid=$uuid VCPUs-params:weight=$HIGH_WEIGHT
xe vm-param-set uuid=$uuid other-config:sched-pri=$HIGH_IO_PRI
echo "HIGH priority applied: $uuid"
done
# --- NORMAL PRIORITY VMs ---
echo "=== Applying $NORMAL_TAG CPU & I/O Priority ==="
xe vm-list tags:contains="$NORMAL_TAG" --minimal | tr ',' '\n' | while read uuid; do
[ -z "$uuid" ] && continue
xe vm-param-set uuid=$uuid VCPUs-params:weight=$NORMAL_WEIGHT
xe vm-param-set uuid=$uuid other-config:sched-pri=$NORMAL_IO_PRI
echo "NORMAL priority applied: $uuid"
done
# --- LOW PRIORITY VMs (with Network QoS cap) ---
echo "=== Applying $LOW_TAG CPU & I/O Priority ==="
xe vm-list tags:contains="$LOW_TAG" --minimal | tr ',' '\n' | while read uuid; do
[ -z "$uuid" ] && continue
xe vm-param-set uuid=$uuid VCPUs-params:weight=$LOW_WEIGHT
xe vm-param-set uuid=$uuid other-config:sched-pri=$LOW_IO_PRI
echo "LOW priority applied: $uuid"
done
echo "=== Performance Tuning Complete! ==="
How to Deploy:
1 Upload script
bash
# Copy to your pool master
scp set-performace.sh root@your-pool-master:/usr/local/bin/
chmod +x /usr/local/bin/set-performace.sh
2 Add to crontab
# Add to crontab (runs hourly)
*/60 * * * * root /usr/local/bin/set-performance.sh >> /var/log/set-performance.log 2>&1
3 Test
# Test it manually
/usr/local/bin/set-performace.sh
It would be even better if you could split the configuration section off, so that it’s in its own conf file. Would make it easier to manage, also if this ends up being used, by Vates in the Vates VMS software. There can then be a vendor recommended configuration with the option of customer’s own workflow based, configuration.