diff --git a/applets/compiler_vm/host/devices/add-serials b/applets/compiler_vm/host/devices/add-serials
index b321cf58..26d143ca 100755
--- a/applets/compiler_vm/host/devices/add-serials
+++ b/applets/compiler_vm/host/devices/add-serials
@@ -1,2 +1,15 @@
-virsh attach-device --config pbot-vm serial-2.xml
-virsh attach-device --config pbot-vm serial-3.xml
+#!/bin/sh
+
+DOMAIN="${PBOTVM_DOMAIN:-pbot-vm}"
+SERIAL="${PBOTVM_SERIAL:-5555}"
+HEART="${PBOTVM_HEART:-5556}"
+
+install_serial() {
+ file=$1 port=$2
+ sed -i.1 "s/[\$]PORT[\$]/$port/" $file
+ virsh attach-device --config $DOMAIN $file
+ mv $file.1 $file
+}
+
+install_serial serial-2.xml $SERIAL
+install_serial serial-3.xml $HEART
diff --git a/applets/compiler_vm/host/devices/serial-2.xml b/applets/compiler_vm/host/devices/serial-2.xml
index 45ec745f..7d9e08ef 100644
--- a/applets/compiler_vm/host/devices/serial-2.xml
+++ b/applets/compiler_vm/host/devices/serial-2.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/applets/compiler_vm/host/devices/serial-3.xml b/applets/compiler_vm/host/devices/serial-3.xml
index 229be48d..34f0e1b7 100644
--- a/applets/compiler_vm/host/devices/serial-3.xml
+++ b/applets/compiler_vm/host/devices/serial-3.xml
@@ -1,5 +1,5 @@
-
+