Citrix XenServer – How to Convert HVM to PV

In order to take advantage of some XenServer features, you need to have a paravirtualization (PV) turned on for your guest host.  You maybe running in HVM because you installed your operating system from a disk and not a XenServer created template.  Now days xen is built into the linux kernel and we don’t need a special kernel installed.  We just need to change the settings in XenServer to boot the system.

Note: I tested this on Ubuntu 14.04 and 16.04 with systems that already had XenTools installed.  I’m assuming the procedure doesn’t change much to other distros.

  1. Find the UUID of the guest host you want to convert from HVM to PV
    xe vm-list name-label=<name of guest host>
  2. Print out the current parameters for the guest host and save them as a backup.
    xe vm-param-list uuid=<uuid from step 1>
  3. Update parameters to boot your system as paravirtualization
    xe vm-param-set uuid=<uuid from step 1> HVM-boot-policy=""
    xe vm-param-set uuid=<uuid from step 1> PV-bootloader=pygrub
    xe vm-param-set uuid=<uuid from step 1> PV-args="-- quiet console=hvc0"
  4. Find the UUID for your VDB boot disk
    xe vm-disk-list uuid=<uuid from step 1>
  5. Set the drive as bootable
    xe vbd-param-set uuid=<uuid from step 4> bootable=true
  6. Boot the system and review the console in XenCenter.  If the system boots, BUT you don't get the login window, you may need to complete create this config file.
    1. Create this file if it doesn't exist on your guest host: /etc/init/hvc0.conf
    2. # hvc0 - getty
      #
      # This service maintains a getty on hvc0 from the point the system is
      # started until it is shut down again.

      start on stopped rc RUNLEVEL=[2345]
      stop on runlevel [!2345]

      respawn
      exec /sbin/getty -L hvc0 9600 linux

    3. Reboot

How To Add A Static Route To NetApp Data OnTap

Use this command to add a static route for this network 10.3.50.0/24 to use the gateway 10.3.0.1

route add net 10.3.50.0/24 10.3.0.1 1

You must also update /etc/rc because you will lose this route on a reboot.  /etc/rc gets read at boot and sets up your network settings.

Use this command to read the file

rdfile /etc/rc

Copy all the text that it outputs.  Add your route command under your default gateway.  It should look something like this:

hostname netapp01
ifgrp create lacp ifgrp1 -b ip e0a e0b e0c e0d 
vlan create ifgrp1 3001 3002 3000
ifconfig ifgrp1-3001 `hostname`-ifgrp1-3001 netmask 255.255.255.0 partner ifgrp1-3001 mtusize 1500 -wins
ifconfig ifgrp1-3002 `hostname`-ifgrp1-3002 netmask 255.255.255.0 partner ifgrp1-3002 mtusize 1500 -wins
ifconfig ifgrp1-3000 `hostname`-ifgrp1-3000 netmask 255.255.255.0 partner ifgrp1-3000 mtusize 1500 -wins
route add default 10.3.2.254 1
route add net 10.3.50.0/24 10.3.0.1 1
routed on
options dns.domainname domain.someplace.com
options dns.enable on
options nis.enable off

In order to write your changes to the /etc/rc file, you need to use this command.  This command overwrites the file with everything you enter at this point.

wrfile /etc/rc

As a side note, the IPs for your interfaces are stored in the /etc/hosts file.

Citrix XenServer Error: The SR failed to complete the operation

Yesterday we started to run out of space on one of our storage repositories.  When we tried to move any VDI on that SR via XenCenter, we got the error “The SR failed to complete the operation”.  Which is a pretty generic error, par for xenserver errors.  I even got the same error when trying to do a ‘Rescan’.

I continued to troubleshoot, looking through logs and command outputs.  I finally found something to look into.

Ran the command (use the UUID of a SR you’re having issues with):
xe sr-param-list uuid=eb943814-a329-5f84-bd42-af1858d56632

Noticed this parameter:
other-config (MRW): dirty: ; auto-scan: false

I looked into this “dirty” param…  It means xenserver isn’t happy with the file names on the SR.   I listed the files on my SR and saw that someone created a copy of a VDI called: Copy of f897ebcf-9365-471b-8a30-e81f564c2536.vhd.

I fixed it by:

  • ls /run/sr-mount/eb943814-a329-5f84-bd42-af1858d56632
  • Found file that shouldn’t be here called Copy of f897ebcf-9365-471b-8a30-e81f564c2536.vhd
  • Removed the file Copy of f897ebcf-9365-471b-8a30-e81f564c2536.vhd
  •  Rescanning the SR
  •  I was then able to move the VDI from one SR to another with out error in xencenter.

Hope this helps with your day:

Citrix XenServer Upgrade From 6.1 to 6.2

This weekend I’ve updated from 6.1 to 6.2. Here are the steps I took to do the upgrade.

  1. Make sure you have upgraded your licenses to 6.2 (May require login).  They have changed to a per socket structure, for us we have two sockets per server, and was able to upgrade without paying extra.  The upgrade will warning you if you don’t have the 6.2 license, but you can continue on… just make sure you’ve got the new 6.2 license is applied to your license server.
  2. Download the XenServer-6.2.0-install-cd.iso file (May require login)
  3. I uploaded the file to a physical linux web server not part of my Xen pool
  4. Create a directory called ‘xen’ in the root of your web site
  5. Mount the ISO as a loop device:
    sudo mount -o loop XenServer-6.2.0-install-cd.iso xen/
  6. Update XenCenter.msi to the latest version. After updating XenCenter, “About XenCenter” shows my version as “6.2 (build 1377)”
  7. Backup your XenServer Pool, ssh into your pool master and run this command.  Copy into your backups on a file server
    xe pool-dump-database file-name=xenpool.backup.20140510
  8. Disable HA
  9. Shutdown any unneeded VMs, this will decrease the time it takes to preform the upgrade
  10. To preform the upgrade, in XenCenter goto Tools -> Rolling Pool Upgrade
  11. Select your pool
  12. Select ‘Automatic Mode’
  13. Obey the rules of the pre-check
  14. Run the upgrade.  I had a few issues and had to restart the rolling upgrade, which didn’t seem like an issue.  My issues were mostly VMs loosing their VDIs, which can be fixed via this article.

Citrix XenServer 6.1 Internal error: File “xapi_xenops.ml”, line 1788, characters 3-9: Assertion failed

Today I rebooted a xen host, everything came back up as I would expect, and after trying to live migrate VMs back onto the host I got this error message.

Internal error: File "xapi_xenops.ml", line 1788, characters 3-9: Assertion failed

I thought it was something wrong with xencenter, but then tried via command line and got this error:

Error code: SR_BACKEND_FAILURE_46
Error parameters: , The VDI is not available [opterr=VDI SOME-UUID already attached RW]

 

The message “The VDI is not available” I’ve seen many times before and I knew what to do.

 

 

Citrix XenServer PCI Passthrough

Sometimes you need to use a PCI device on a virtual machine. We have a vendor who has supplied a USB dongle for software licensing, which is really annoying. Their software doesn’t merit it’s own server, so we want to put it into our Xenserver pool.

    1. Shutdown the VM you want to attach your device too.
    2. SSH into the host that has your PCI device.  Use the following command to locate the PCI ID for your device.   Should look something like this “00:1d.7″
      lspci -v
    3. Now locate the UUID for the VM you want to attach the PCI device to with the following command
      xe vm-list
    4. Now use the following command to set the pass through
      xe vm-param-set other-config:pci=0/"PCI ID" uuid="UUID of VM"
    5. Now boot the VM and check if your device is now attached.  If not, make sure you are using the correct PCI ID.  USB devices can get tricky, as there maybe many USB devices listed.

Configure SNMP on Citrix XenServer 6.x

I love Cacti and use it all the time to monitor my system performance.  Here are the few steps needed to turn SNMP on with in your Citrix XenServer hosts.  This document assumes you already have Performance Monitoring Enhancements Pack for XenServer, SNMP, and Cacti already installed and functioning on your network.

  1. Edit: /etc/sysconfig/iptables
    Add the following lines AFTER the line “-A RH-Firewall-1-INPUT -p udp –dport 5353 -d 224.0.0.251 -j ACCEPT”
    -A RH-Firewall-1-INPUT -p udp --dport 161 -j ACCEPT
    -A RH-Firewall-1-INPUT -p udp --dport 162 -j ACCEPT
  2. Execute: service iptables restart
  3. Edit: /etc/snmp/snmpd.conf
    Replace the community with your current SNMP community if you have one.
    # sec.name source community
    com2sec notConfigUser default public
  4. Execute: chkconfig snmpd on
  5. Execute: service snmpd restart
  6. Test from another host: snmpwalk -v 2c -c public xenserver.someplace.com
    Note, replace public with your SNMP community!

Citrix XenServer Designate New Pool Master

Most of the time you don’t need to change the XenServer pool master but if need to do maintenance  it will require you to move the pool master to another host.

Make sure HA is disabled before proceeding if you are using it.  This can be done via xencenter.

xe pool-ha-disable

Find the UUID of the host you want to nominate as the new pool master

xe host-list

Use this command to set the new pool master with the UUID from step 2

xe pool-designate-new-master host-uuid=<uuid>

Re-enable HA if needed.  This can be done via xencenter as well.

xe pool-ha-enable