Adding an e1000 NIC in XenServer 7

Datetime:2016-08-23 04:09:56          Topic: Xen           Share

*Note: This is not officially supported – do this at your own risk.*

Sometimes, virtual appliances or other random VMs in your lab need a simple, widely supported NIC and just wont boot (or install) without one. XenServer uses a Realtek RTL8139 10/100 card when you don’t have integration services installed. This is usually not an issue…but it certainly can be.

In older versions of XenServer, there was a patch available as mentioned in this thread  that allowed you to use a custom field to apply the e1000 NIC to individual VMs rather than every single VM – the patch is available here. (read the thread first for instructions)

Now that XenServer 7 is publicly available, the patch above no longer works and throws the following error:

So, it looks like it can’t find the qemu-dm-wrapper file – because it is in a different location in XS7. That being said, I have not re-written the patch to look in the correct location (my python-fu is not what it should be) but I will tell you how to get it working, and you will still need the code from the patch.

We are going to manually modify the qemu-dm-wrapper file – if you don’t feel comfortable doing that, DON’T. I’m not responsible for you hosing up your Dom0…you’ve been warned. ��

in XS7, the file is located here:


So SSH into your XenServer and fire up your favorite text editor on the above file. We need to add two things:

  1. The e1000_enabled_os function
  2. The if statement in the main function

You can type these in by hand, but you will be using the source from the original patch – you should end up with this:

Then you will need to add the ‘NicEmulation’ custom field into the VMs and populate it with the string ‘e1000’ to get an e1000 NIC on your virtual machine.

Original Patch Code (Thanks to WANSec)


--- /opt/xensource/libexec/qemu-dm-wrapper-orig 2014-01-08 00:39:55.000000000 -0600
+++ /opt/xensource/libexec/qemu-dm-wrapper      2014-01-08 00:41:59.000000000 -0600
@@ -75,9 +75,31 @@
        setrlimit(RLIMIT_CORE, (limit, oldlimits[1]))
        return limit

+def e1000_enabled_os(argv):
+        import re
+        import os
+        res ='((?:[A-Fa-f\d]{1,2}(?:[-:])?){6})', ' '.join(argv))
+        my_mac =
+        #print 'vif_uuid = xe vif-list MAC=' + my_mac + ' --minimal'
+        vif_uuid = os.popen('xe vif-list MAC=' + my_mac + ' --minimal').read().rstrip()
+        #print 'vm_uuid = xe vif-param-get uuid=' + vif_uuid + ' param-name=vm-uuid'
+        vm_uuid = os.popen('xe vif-param-get uuid=' + vif_uuid + ' param-name=vm-uuid').read().rstrip()
+        #print 'result = xe vm-param-get param-name=other-config param-key=XenCenter.CustomFields.NicEmulation uuid=' + vm_uuid
+        result = os.popen('xe vm-param-get param-name=other-config param-key=XenCenter.CustomFields.NicEmulation uuid=' + vm_uuid).read().rstrip()
+        if (result == 'e1000'):
+                return True
+        return False
 def main(argv):
        import os

+       if e1000_enabled_os(argv):
+               argv = [arg.replace('rtl8139','e1000') for arg in argv]
        qemu_env = os.environ
        qemu_dm = '/usr/lib/xen/bin/qemu-dm'
        domid = int(argv[1])


Once you have patched the file in Dom0, you need to add a Custom Field to the VM and enter the string ‘e1000’ to emulate an e1000 NIC, otherwise the Realtek NIC will be used.

About List