Post

Short: Azure Migrate - XenServer

Introduction

I recently did a migration of a XenServer 8.x environment to Azure using the Azure Migrate service. I won’t deep dive into the process of using the Azure Migrate tool - there are a lot of other resources out there that does a great job of that already 👌

But because I ran into a few issues along the way, I thought I’d share my experience here. This is a brief overview of the process and some of the issues I encountered.

The environment I was migrating consisted of Windows Server 2016 and 2019 VM’s running on Citrix XenServer 8.2 LTSR.

80% of the VM’s migrated just fine, but 20% of them wouldn’t boot up.

In Azure the VM would show as “running” but status was [vm] virtual machine agent status is not ready. Status not ready

According to the Azure logs, they were crashing and rebooting over and over again.

Even though I uninstalled Citrix XenTools from the VM’s, they were still trying to load the drivers when booting.

So… I had to do some digging to find out what was going on and here’s how to fix it!

Be aware that removing the Xen drivers will revert the NIC to use a Realtek driver, so you are limited to 100Mbps network speed 🐢

But if it works, it works, right? 👊


The manual way

Download the DriverStoreExplorer tool from here

Select all drivers named xen and check the Force Delete checkbox.
Force delete

Refresh afterwards and delete any remaining drivers named xen - most likely xenbus.inf will still be there.

Second step is to uninstall XenTools, PV tools etc.

Then search the following registry path for a value named xenfilt in the UpperFilters entries. HKLM:\SYSTEM\CurrentControlSet
Remove the whole upperfilter registry entry if they contain xenfilt.

Finally - stop the XenAgent service and remember to disable Windows Update in case it tries to install the Xen drivers again.


The scripted way

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Uninstall Xen-related programs
(Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Citrix PV Drivers'").Uninstall()
(Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Citrix PV Tools'").Uninstall()
(Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Citrix XenServer Tools'").Uninstall()
(Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Citrix XenServer PV Drivers'").Uninstall()
(Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Citrix XenServer PV Tools'").Uninstall()
(Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Citrix XenServer Windows Management Agent'").Uninstall()

# Remove drivers
Get-WmiObject Win32_PnPSignedDriver | Where-Object {$_.devicename -like '*XenServer PV Network Device*'} | ForEach-Object {pnputil.exe -f -d $_.InfName; .\devcon.exe remove $_.CompatID}
Get-WmiObject Win32_PnPSignedDriver | Where-Object {$_.devicename -like '*XenServer PV Storage Host Adapter*'} | ForEach-Object {pnputil.exe -f -d $_.InfName; .\devcon.exe remove $_.CompatID}
Get-WmiObject Win32_PnPSignedDriver | Where-Object {$_.devicename -like '*XenServer PV Network Class*'} | ForEach-Object {pnputil.exe -f -d $_.InfName; .\devcon.exe remove $_.CompatID}
Get-WmiObject Win32_PnPSignedDriver | Where-Object {$_.devicename -like '*XenServer Interface*'} | ForEach-Object {pnputil.exe -f -d $_.InfName; .\devcon.exe remove $_.CompatID}
Get-WmiObject Win32_PnPSignedDriver | Where-Object {$_.devicename -like '*XenServer PV Bus*'} | ForEach-Object {pnputil.exe -f -d $_.InfName; .\devcon.exe remove $_.CompatID}

# Remove the Storage Host Adapter again... Sometimes it doesn't get removed the first time
Get-WmiObject Win32_PnPSignedDriver | Where-Object {$_.devicename -like '*XenServer PV Storage Host Adapter*'} | ForEach-Object {pnputil.exe -f -d $_.InfName; .\devcon.exe remove $_.CompatID}

# Remove files from driver store
Remove-Item -Path C:\Windows\System32\DriverStore\FileRepository -Include *xen* -Recurse -Force

# Delete UpperFilters registry key
Get-ChildItem -Path "HKLM:\SYSTEM\CurrentControlSet\" -Recurse | ForEach-Object {
    $key = $_.PsPath
    if ((Test-Path -Path "$key\UpperFilters") -and ((Get-ItemProperty -Path $key -Name UpperFilters).UpperFilters -eq 'xenfilt')) {
        Remove-ItemProperty -Path $key -Name UpperFilters -ErrorAction SilentlyContinue
    }
}

# Stop XenAgent service and remove any remaining files
Stop-Service -Name xenagent -Force
Remove-Service -Name xenagent -Force
Remove-Item -Path C:\Windows\System32\* -Include xen*.* -Force
Remove-Item -Path C:\Windows\drivers\* -Include xen*.* -Force

# Disable Windows Update to prevent re-installation of Xen drivers
Set-Service -Name "wuauserv" -StartupType Disabled

Reboot the VM, and shut it down afterwards.

Now you can migrate the VM to Azure and it should boot up just fine 😊👌