xs: extract out the common boilerplate

Signed-off-by: David Scott <dave.scott@citrix.com>