ba5dde9750
53a199d7-x86-EFI-allow-FPU-XMM-use-in-runtime-service-functions.patch - Upstream patches from Jan 538c338f-x86-amd_ucode-flip-revision-numbers-in-printk.patch 538ee637-ACPI-Prevent-acpi_table_entries-from-falling-into-a-infinite-loop.patch 5390917a-VT-d-honor-APEI-firmware-first-mode-in-XSA-59-workaround-code.patch 53909259-x86-domctl-two-functional-fixes-to-XEN_DOMCTL_-gs-etvcpuextstate.patch 5390927f-x86-fix-reboot-shutdown-with-running-HVM-guests.patch 5396d818-avoid-crash-on-HVM-domain-destroy-with-PCI-passthrough.patch 5396e805-x86-HVM-refine-SMEP-test-in-HVM_CR4_GUEST_RESERVED_BITS.patch 539ebe62-x86-EFI-improve-boot-time-diagnostics.patch 539ec004-x86-mce-don-t-spam-the-console-with-CPUx-Temperature-z.patch 53a040c6-page-alloc-scrub-pages-used-by-hypervisor-upon-freeing.patch (replaces xsa100.patch) 53a1990a-IOMMU-prevent-VT-d-device-IOTLB-operations-on-wrong-IOMMU.patch - Replace 'domUloader' with 'pygrub' when converting or importing Xen domains into libvirt with xen2libvirt. domUloader is no longer provided in xen-tools. Modified: xen2libvirt.py Thu Jun 13 15:50:19 MDT 2014 - cyliu@suse.com - fate#310956: Support Direct Kernel Boot for FV guests patches would go to upstream: qemu side: qemu-support-xen-hvm-direct-kernel-boot.patch xen side: xen-pass-kernel-initrd-to-qemu.patch - bnc#880751 - VUL-0: xen: Hypervisor heap contents leaked to guests xsa100.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=320
122 lines
4.2 KiB
Python
122 lines
4.2 KiB
Python
#!/usr/bin/env python
|
|
#
|
|
# Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
#
|
|
# This library is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
# License as published by the Free Software Foundation; either
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
#
|
|
# This library is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
# License along with this library. If not, see
|
|
# <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Authors:
|
|
# Jim Fehlig <jfehlig@suse.com>
|
|
#
|
|
# Read native Xen configuration format, convert to libvirt domXML, and
|
|
# import (virsh define <xml>) into libvirt.
|
|
|
|
import sys
|
|
import os
|
|
import argparse
|
|
import re
|
|
from xml.etree import ElementTree
|
|
|
|
try:
|
|
import libvirt
|
|
except ImportError:
|
|
print 'Unable to import the libvirt module. Is libvirt-python installed?'
|
|
sys.exit(1)
|
|
|
|
parser = argparse.ArgumentParser(description='Import Xen domain configuration into libvirt')
|
|
parser.add_argument('-c', '--convert-only', help='Convert Xen domain configuration into libvirt domXML, but do not import into libvirt', action='store_true', dest='convert_only')
|
|
parser.add_argument('-r', '--recursive', help='Operate recursivelly on all Xen domain configuration rooted at path', action='store_true')
|
|
parser.add_argument('-f', '--format', help='Format of Xen domain configuration. Supported formats are xm and sexpr', choices=['xm', 'sexpr'], default=None)
|
|
parser.add_argument('-v', '--verbose', help='Print information about the import process', action='store_true')
|
|
parser.add_argument('path', help='Path to Xen domain configuration')
|
|
|
|
|
|
def print_verbose(msg):
|
|
if args.verbose:
|
|
print msg
|
|
|
|
|
|
def check_config(path, config):
|
|
isbinary = os.system('file -b ' + path + ' | grep text > /dev/null')
|
|
|
|
if isbinary:
|
|
print 'File %s is not a text file containing Xen xm or sexpr configuration'
|
|
sys.exit(1)
|
|
|
|
if config.find('\(domain'):
|
|
return 'sexpr'
|
|
return 'xm'
|
|
|
|
|
|
def import_domain(conn, path, format=None, convert_only=False):
|
|
|
|
f = open(path, 'r')
|
|
config = f.read()
|
|
print_verbose('Xen domain configuration read from %s:\n %s' % (path, config))
|
|
if format is None:
|
|
format = check_config(path, config)
|
|
|
|
if format == 'sexpr':
|
|
print_verbose('scrubbing domin from configuration')
|
|
config = re.sub("\(domid [0-9]*\)", "", config)
|
|
print_verbose('scrubbed sexpr:\n %s' % config)
|
|
xml = conn.domainXMLFromNative('xen-sxpr', config, 0)
|
|
else:
|
|
# if format != sexpr, try xm
|
|
xml = conn.domainXMLFromNative('xen-xm', config, 0)
|
|
|
|
f.close()
|
|
|
|
# domUloader is no longer available in SLES12, replace with pygrub
|
|
tree = ElementTree.fromstring(xml)
|
|
bl = tree.find('.//bootloader')
|
|
if bl is not None and 'domUloader' in bl.text:
|
|
bl.text = 'pygrub'
|
|
xml = ElementTree.tostring(tree)
|
|
|
|
print_verbose('Successfully converted Xen domain configuration to '
|
|
'libvirt domXML:\n %s' % xml)
|
|
if convert_only:
|
|
print xml
|
|
else:
|
|
print_verbose('Importing converted libvirt domXML into libvirt...')
|
|
dom = conn.defineXML(xml)
|
|
if dom is None:
|
|
print 'Failed to define domain from converted domXML'
|
|
sys.exit(1)
|
|
print_verbose('domXML successfully imported into libvirt')
|
|
|
|
|
|
args = parser.parse_args()
|
|
path = args.path
|
|
|
|
# Connect to libvirt
|
|
conn = libvirt.open(None)
|
|
if conn is None:
|
|
print('Failed to open connection to the hypervisor')
|
|
sys.exit(1)
|
|
|
|
if args.recursive:
|
|
try:
|
|
for root, dirs, files in os.walk(path):
|
|
for name in files:
|
|
abs_name = os.path.join(root, name)
|
|
print_verbose('Processing file %s' % abs_name)
|
|
import_domain(conn, abs_name, args.format, args.convert_only)
|
|
except IOError:
|
|
print('Failed to open/read path %s' % path)
|
|
sys.exit(1)
|
|
else:
|
|
import_domain(conn, args.path, args.format, args.convert_only)
|