2013-03-18 01:06:52 +04:00
#
# List of OS Specific data
#
# Copyright 2006-2008 Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
2013-04-11 03:48:07 +04:00
from virtinst import support
2013-08-09 04:47:17 +04:00
from virtinst import VirtualDevice
2013-03-18 01:06:52 +04:00
HV_ALL = " all "
2013-04-12 16:26:21 +04:00
# Default values for OS_TYPES keys. Can be overwritten at os_type or
# variant level
2013-03-18 01:06:52 +04:00
NET = VirtualDevice . VIRTUAL_DEV_NET
DISK = VirtualDevice . VIRTUAL_DEV_DISK
INPUT = VirtualDevice . VIRTUAL_DEV_INPUT
SOUND = VirtualDevice . VIRTUAL_DEV_AUDIO
VIDEO = VirtualDevice . VIRTUAL_DEV_VIDEO
VIRTIO_DISK = {
" bus " : [
( support . SUPPORT_CONN_HV_VIRTIO , " virtio " ) ,
2013-04-13 22:34:52 +04:00
]
2013-03-18 01:06:52 +04:00
}
VIRTIO_NET = {
" model " : [
( support . SUPPORT_CONN_HV_VIRTIO , " virtio " ) ,
2013-04-13 22:34:52 +04:00
]
2013-03-18 01:06:52 +04:00
}
USB_TABLET = {
" type " : [
( HV_ALL , " tablet " ) ,
2013-04-13 22:34:52 +04:00
] ,
2013-03-18 01:06:52 +04:00
" bus " : [
( HV_ALL , " usb " ) ,
2013-04-13 22:34:52 +04:00
]
2013-03-18 01:06:52 +04:00
}
VGA_VIDEO = {
2013-07-15 19:07:40 +04:00
" model " : [
2013-03-18 01:06:52 +04:00
( HV_ALL , " vga " ) ,
2013-04-13 22:34:52 +04:00
]
2013-03-18 01:06:52 +04:00
}
2013-05-22 00:00:41 +04:00
VMVGA_VIDEO = {
2013-07-15 19:07:40 +04:00
" model " : [
2013-05-22 00:00:41 +04:00
( HV_ALL , " vmvga " ) ,
]
}
2013-03-18 01:06:52 +04:00
DEFAULTS = {
" acpi " : True ,
" apic " : True ,
" clock " : " utc " ,
2013-08-10 02:14:42 +04:00
" cont " : False ,
2013-03-18 01:06:52 +04:00
" distro " : None ,
" label " : None ,
" supported " : False ,
" devices " : {
2013-04-13 22:34:52 +04:00
# "devname" : {"attribute" : [(["applicable", "hv-type", list"],
# "recommended value for hv-types"),]},
2013-03-18 01:06:52 +04:00
INPUT : {
" type " : [
( HV_ALL , " mouse " )
2013-08-10 22:44:20 +04:00
] ,
2013-03-18 01:06:52 +04:00
" bus " : [
( HV_ALL , " ps2 " )
2013-04-13 22:34:52 +04:00
] ,
} ,
2013-03-18 01:06:52 +04:00
DISK : {
" bus " : [
( HV_ALL , None )
2013-04-13 22:34:52 +04:00
] ,
} ,
2013-03-18 01:06:52 +04:00
NET : {
" model " : [
( HV_ALL , None )
2013-04-13 22:34:52 +04:00
] ,
} ,
2013-03-18 01:06:52 +04:00
SOUND : {
" model " : [
( support . SUPPORT_CONN_HV_SOUND_ICH6 , " ich6 " ) ,
( support . SUPPORT_CONN_HV_SOUND_AC97 , " ac97 " ) ,
( HV_ALL , " es1370 " ) ,
2013-04-13 22:34:52 +04:00
]
} ,
2013-03-18 01:06:52 +04:00
VIDEO : {
2013-07-15 19:07:40 +04:00
" model " : [
2013-03-18 01:06:52 +04:00
( HV_ALL , " cirrus " ) ,
2013-04-13 22:34:52 +04:00
]
} ,
}
2013-03-18 01:06:52 +04:00
}
2013-08-11 02:48:43 +04:00
_SENTINEL = - 1234
OS_TYPES = { }
_allvariants = { }
def lookup_os ( key ) :
ret = _allvariants . get ( key )
if ret is None :
return ret
return ret
2013-04-13 22:34:52 +04:00
2013-03-18 01:06:52 +04:00
def sort_helper ( tosort , sortpref = None ) :
"""
Helps properly sorting os dictionary entires
"""
sortby_mappings = { }
distro_mappings = { }
retlist = [ ]
sortpref = sortpref or [ ]
# Make sure we are sorting by 'sortby' if specified, and group distros
# by their 'distro' tag first and foremost
for key , osinfo in tosort . items ( ) :
if osinfo . get ( " skip " ) :
continue
sortby = osinfo . get ( " sortby " )
if not sortby :
sortby = key
sortby_mappings [ sortby ] = key
distro = osinfo . get ( " distro " ) or " zzzzzzz "
if distro not in distro_mappings :
distro_mappings [ distro ] = [ ]
distro_mappings [ distro ] . append ( sortby )
# We want returned lists to be sorted descending by 'distro', so we get
# debian5, debian4, fedora14, fedora13
# rather than
# debian4, debian5, fedora13, fedora14
for distro_list in distro_mappings . values ( ) :
distro_list . sort ( )
distro_list . reverse ( )
sorted_distro_list = distro_mappings . keys ( )
sorted_distro_list . sort ( )
sortpref . reverse ( )
for prefer in sortpref :
if not prefer in sorted_distro_list :
continue
sorted_distro_list . remove ( prefer )
sorted_distro_list . insert ( 0 , prefer )
for distro in sorted_distro_list :
distro_list = distro_mappings [ distro ]
for key in distro_list :
orig_key = sortby_mappings [ key ]
retlist . append ( orig_key )
return retlist
2013-04-13 22:34:52 +04:00
2013-03-18 01:06:52 +04:00
def parse_key_entry ( conn , hv_type , key_entry , defaults ) :
ret = None
found = False
if type ( key_entry ) == list :
# List of tuples with (support -> value) mappings
for tup in key_entry :
support_key = tup [ 0 ]
value = tup [ 1 ]
# HV_ALL means don't check for support, just return the value
if support_key != HV_ALL :
2013-07-06 19:20:28 +04:00
support_ret = conn . check_conn_hv_support ( support_key , hv_type )
2013-03-18 01:06:52 +04:00
2013-04-13 22:34:52 +04:00
if support_ret is not True :
2013-03-18 01:06:52 +04:00
continue
found = True
ret = value
break
else :
found = True
ret = key_entry
if not found and defaults :
ret = parse_key_entry ( conn , hv_type , defaults , None )
return ret
2013-04-13 22:34:52 +04:00
2013-08-11 02:48:43 +04:00
def lookup_osdict_key ( conn , hv_type , var , key ) :
2013-03-18 01:06:52 +04:00
defaults = DEFAULTS [ key ]
dictval = defaults
2013-08-11 02:48:43 +04:00
if var is not None :
vardict = _allvariants [ var ] . to_dict ( )
if key in vardict :
dictval = vardict [ key ]
2013-03-18 01:06:52 +04:00
return parse_key_entry ( conn , hv_type , dictval , defaults )
2013-08-11 02:48:43 +04:00
def lookup_device_param ( conn , hv_type , var , device_key , param ) :
os_devs = lookup_osdict_key ( conn , hv_type , var , " devices " )
2013-03-18 01:06:52 +04:00
defaults = DEFAULTS [ " devices " ]
for devs in [ os_devs , defaults ] :
if device_key not in devs :
continue
return parse_key_entry ( conn , hv_type , devs [ device_key ] [ param ] ,
defaults . get ( param ) )
raise RuntimeError ( _ ( " Invalid dictionary entry for device ' %s %s ' " %
( device_key , param ) ) )
2013-08-11 02:48:43 +04:00
# 'types' should rarely be altered, this check will make
# doubly sure that a new type isn't accidentally added
_approved_types = [ " linux " , " windows " , " unix " , " solaris " , " other " ]
2013-08-10 02:14:42 +04:00
def _add_type ( * args , * * kwargs ) :
kwargs [ " is_type " ] = True
_t = _OSVariant ( * args , * * kwargs )
2013-08-11 02:48:43 +04:00
if _t . name not in _approved_types :
raise RuntimeError ( " type ' %s ' not in list of approved distro types %s "
% ( t . name , _approved_types ) )
2013-08-10 02:14:42 +04:00
OS_TYPES [ _t . name ] = _t . to_dict ( )
OS_TYPES [ _t . name ] [ " variants " ] = { }
2013-08-10 22:44:20 +04:00
_allvariants [ _t . name ] = _t
2013-08-10 02:14:42 +04:00
return _t
class _OSVariant ( object ) :
2013-08-11 02:48:43 +04:00
def __init__ ( self , name , label , is_type = False ,
sortby = None , parent = _SENTINEL ,
2013-08-10 22:44:20 +04:00
distro = _SENTINEL , cont = _SENTINEL , supported = _SENTINEL ,
devices = _SENTINEL , acpi = _SENTINEL ,
apic = _SENTINEL , clock = _SENTINEL ) :
if parent == _SENTINEL :
raise RuntimeError ( " Must specify explicit parent " )
2013-08-11 02:48:43 +04:00
elif parent is None :
if not is_type :
raise RuntimeError ( " Only OS types can have parent=None " )
else :
2013-08-10 22:44:20 +04:00
parent = _allvariants [ parent ]
def _get_default ( name , val , default ) :
if val == _SENTINEL :
if parent :
return getattr ( parent , name )
return default
return val
2013-08-10 02:14:42 +04:00
self . name = name . lower ( )
self . label = label
self . sortby = sortby
2013-08-11 02:48:43 +04:00
self . is_type = bool ( is_type )
self . typename = _get_default ( " typename " , _SENTINEL , self . name )
if self . typename not in _approved_types :
raise RuntimeError ( " type ' %s ' for variant ' %s ' not in list "
" of approved distro types %s " %
( self . typename , self . name , _approved_types ) )
2013-08-10 22:44:20 +04:00
self . distro = _get_default ( " distro " , distro , None )
self . supported = bool ( _get_default ( " supported " , supported , False ) )
self . cont = bool ( _get_default ( " cont " , cont , False ) )
self . devices = _get_default ( " devices " , devices , None )
self . acpi = _get_default ( " acpi " , acpi , None )
self . apic = _get_default ( " apic " , apic , None )
self . clock = _get_default ( " clock " , clock , None )
2013-08-10 02:14:42 +04:00
def to_dict ( self ) :
ret = { }
allparams = [ " label " , " distro " , " sortby " , " supported " ,
" cont " , " devices " , " apic " , " acpi " , " clock " ]
canfalse = [ " apic " , " acpi " ]
for param in allparams :
val = getattr ( self , param )
if param in canfalse and val is False :
pass
elif not val :
continue
ret [ param ] = val
return ret
def add ( self , * args , * * kwargs ) :
v = _OSVariant ( * args , * * kwargs )
OS_TYPES [ self . name ] [ " variants " ] [ v . name ] = v . to_dict ( )
2013-08-10 22:44:20 +04:00
_allvariants [ v . name ] = v
t = _add_type ( " linux " , " Linux " , parent = None )
t . add ( " rhel2.1 " , " Red Hat Enterprise Linux 2.1 " , distro = " rhel " , parent = " linux " )
t . add ( " rhel3 " , " Red Hat Enterprise Linux 3 " , parent = " rhel2.1 " )
2013-08-11 02:48:43 +04:00
t . add ( " rhel4 " , " Red Hat Enterprise Linux 4 " , supported = True , parent = " rhel3 " )
2013-08-10 22:44:20 +04:00
t . add ( " rhel5 " , " Red Hat Enterprise Linux 5 " , supported = False , parent = " rhel4 " )
t . add ( " rhel5.4 " , " Red Hat Enterprise Linux 5.4 or later " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " rhel5 " )
t . add ( " rhel6 " , " Red Hat Enterprise Linux 6 " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET , INPUT : USB_TABLET } , parent = " rhel5.4 " )
t . add ( " rhel7 " , " Red Hat Enterprise Linux 7 " , supported = False , parent = " rhel6 " )
t . add ( " fedora5 " , " Fedora Core 5 " , sortby = " fedora05 " , distro = " fedora " , parent = " linux " )
t . add ( " fedora6 " , " Fedora Core 6 " , sortby = " fedora06 " , parent = " fedora5 " )
t . add ( " fedora7 " , " Fedora 7 " , sortby = " fedora07 " , parent = " fedora6 " )
t . add ( " fedora8 " , " Fedora 8 " , sortby = " fedora08 " , parent = " fedora7 " )
2013-08-10 02:14:42 +04:00
# Apparently F9 has selinux errors when installing with virtio:
# https: //bugzilla.redhat.com/show_bug.cgi?id=470386
2013-08-10 22:44:20 +04:00
t . add ( " fedora9 " , " Fedora 9 " , sortby = " fedora09 " , devices = { NET : VIRTIO_NET } , parent = " fedora8 " )
t . add ( " fedora10 " , " Fedora 10 " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " fedora9 " )
t . add ( " fedora11 " , " Fedora 11 " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET , INPUT : USB_TABLET } , parent = " fedora10 " )
t . add ( " fedora12 " , " Fedora 12 " , parent = " fedora11 " )
t . add ( " fedora13 " , " Fedora 13 " , parent = " fedora12 " )
t . add ( " fedora14 " , " Fedora 14 " , parent = " fedora13 " )
t . add ( " fedora15 " , " Fedora 15 " , parent = " fedora14 " )
t . add ( " fedora16 " , " Fedora 16 " , parent = " fedora15 " )
t . add ( " fedora17 " , " Fedora 17 " , supported = True , parent = " fedora16 " )
t . add ( " fedora18 " , " Fedora 18 " , parent = " fedora17 " )
t . add ( " fedora19 " , " Fedora 19 " , parent = " fedora18 " )
t . add ( " opensuse11 " , " openSuse 11 " , distro = " suse " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " linux " )
t . add ( " opensuse12 " , " openSuse 12 " , parent = " opensuse11 " )
t . add ( " sles10 " , " Suse Linux Enterprise Server " , distro = " suse " , supported = True , parent = " linux " )
t . add ( " sles11 " , " Suse Linux Enterprise Server 11 " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " sles10 " )
t . add ( " mandriva2009 " , " Mandriva Linux 2009 and earlier " , distro = " mandriva " , parent = " linux " )
t . add ( " mandriva2010 " , " Mandriva Linux 2010 and later " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " mandriva2009 " )
t . add ( " mes5 " , " Mandriva Enterprise Server 5.0 " , distro = " mandriva " , parent = " linux " )
t . add ( " mes5.1 " , " Mandriva Enterprise Server 5.1 and later " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " mes5 " )
t . add ( " mageia1 " , " Mageia 1 and later " , distro = " mageia " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET , INPUT : USB_TABLET } , parent = " linux " )
t . add ( " altlinux " , " ALT Linux " , distro = " altlinux " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET , INPUT : USB_TABLET } , parent = " linux " )
t . add ( " debianetch " , " Debian Etch " , distro = " debian " , sortby = " debian4 " , parent = " linux " )
t . add ( " debianlenny " , " Debian Lenny " , sortby = " debian5 " , supported = True , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " debianetch " )
t . add ( " debiansqueeze " , " Debian Squeeze " , sortby = " debian6 " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET , INPUT : USB_TABLET } , parent = " debianlenny " )
t . add ( " debianwheezy " , " Debian Wheezy " , sortby = " debian7 " , parent = " debiansqueeze " )
t . add ( " ubuntuhardy " , " Ubuntu 8.04 LTS (Hardy Heron) " , distro = " ubuntu " , devices = { NET : VIRTIO_NET } , parent = " linux " )
t . add ( " ubuntuintrepid " , " Ubuntu 8.10 (Intrepid Ibex) " , parent = " ubuntuhardy " )
t . add ( " ubuntujaunty " , " Ubuntu 9.04 (Jaunty Jackalope) " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " ubuntuintrepid " )
t . add ( " ubuntukarmic " , " Ubuntu 9.10 (Karmic Koala) " , parent = " ubuntujaunty " )
t . add ( " ubuntulucid " , " Ubuntu 10.04 LTS (Lucid Lynx) " , supported = True , parent = " ubuntukarmic " )
t . add ( " ubuntumaverick " , " Ubuntu 10.10 (Maverick Meerkat) " , supported = False , parent = " ubuntulucid " )
t . add ( " ubuntunatty " , " Ubuntu 11.04 (Natty Narwhal) " , parent = " ubuntumaverick " )
t . add ( " ubuntuoneiric " , " Ubuntu 11.10 (Oneiric Ocelot) " , parent = " ubuntunatty " )
t . add ( " ubuntuprecise " , " Ubuntu 12.04 LTS (Precise Pangolin) " , supported = True , parent = " ubuntuoneiric " )
t . add ( " ubuntuquantal " , " Ubuntu 12.10 (Quantal Quetzal) " , parent = " ubuntuprecise " )
t . add ( " ubunturaring " , " Ubuntu 13.04 (Raring Ringtail) " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET , VIDEO : VMVGA_VIDEO } , parent = " ubuntuquantal " )
t . add ( " ubuntusaucy " , " Ubuntu 13.10 (Saucy Salamander) " , parent = " ubunturaring " )
t . add ( " generic24 " , " Generic 2.4.x kernel " , parent = " linux " )
t . add ( " generic26 " , " Generic 2.6.x kernel " , parent = " generic24 " )
t . add ( " virtio26 " , " Generic 2.6.25 or later kernel with virtio " , sortby = " genericvirtio26 " , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " generic26 " )
t = _add_type ( " windows " , " Windows " , clock = " localtime " , cont = True , devices = { INPUT : USB_TABLET , VIDEO : VGA_VIDEO } , parent = None )
t . add ( " win2k " , " Microsoft Windows 2000 " , sortby = " mswin4 " , acpi = [ ( support . SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI , False ) ] , apic = [ ( support . SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI , False ) ] , parent = " windows " )
t . add ( " winxp " , " Microsoft Windows XP " , sortby = " mswin5 " , supported = True , acpi = [ ( support . SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI , False ) ] , apic = [ ( support . SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI , False ) ] , parent = " windows " )
t . add ( " winxp64 " , " Microsoft Windows XP (x86_64) " , supported = True , sortby = " mswin564 " , parent = " windows " )
t . add ( " win2k3 " , " Microsoft Windows Server 2003 " , supported = True , sortby = " mswinserv2003 " , parent = " windows " )
t . add ( " win2k8 " , " Microsoft Windows Server 2008 " , supported = True , sortby = " mswinserv2008 " , parent = " windows " )
t . add ( " vista " , " Microsoft Windows Vista " , supported = True , sortby = " mswin6 " , parent = " windows " )
t . add ( " win7 " , " Microsoft Windows 7 " , supported = True , sortby = " mswin7 " , parent = " windows " )
t = _add_type ( " solaris " , " Solaris " , clock = " localtime " , parent = None )
t . add ( " solaris9 " , " Sun Solaris 9 " , parent = " solaris " )
t . add ( " solaris10 " , " Sun Solaris 10 " , devices = { INPUT : USB_TABLET } , parent = " solaris " )
t . add ( " opensolaris " , " Sun OpenSolaris " , devices = { INPUT : USB_TABLET } , parent = " solaris " )
t = _add_type ( " unix " , " UNIX " , parent = None )
2013-08-10 02:14:42 +04:00
# http: //www.nabble.com/Re%3A-Qemu%3A-bridging-on-FreeBSD-7.0-STABLE-p15919603.html
2013-08-10 22:44:20 +04:00
t . add ( " freebsd6 " , " FreeBSD 6.x " , devices = { NET : { " model " : [ ( HV_ALL , " ne2k_pci " ) ] } } , parent = " unix " )
t . add ( " freebsd7 " , " FreeBSD 7.x " , parent = " freebsd6 " )
t . add ( " freebsd8 " , " FreeBSD 8.x " , supported = True , devices = { NET : { " model " : [ ( HV_ALL , " e1000 " ) ] } } , parent = " freebsd7 " )
t . add ( " freebsd9 " , " FreeBSD 9.x " , parent = " freebsd8 " )
t . add ( " freebsd10 " , " FreeBSD 10.x " , supported = False , devices = { DISK : VIRTIO_DISK , NET : VIRTIO_NET } , parent = " freebsd9 " )
2013-08-10 02:14:42 +04:00
# http: //calamari.reverse-dns.net: 980/cgi-bin/moin.cgi/OpenbsdOnQemu
# https: //www.redhat.com/archives/et-mgmt-tools/2008-June/msg00018.html
2013-08-10 22:44:20 +04:00
t . add ( " openbsd4 " , " OpenBSD 4.x " , devices = { NET : { " model " : [ ( HV_ALL , " pcnet " ) ] } } , parent = " unix " )
2013-08-10 02:14:42 +04:00
2013-08-10 22:44:20 +04:00
t = _add_type ( " other " , " Other " , parent = None )
t . add ( " msdos " , " MS-DOS " , acpi = False , apic = False , parent = " other " )
t . add ( " netware4 " , " Novell Netware 4 " , parent = " other " )
t . add ( " netware5 " , " Novell Netware 5 " , parent = " other " )
t . add ( " netware6 " , " Novell Netware 6 " , parent = " other " )
t . add ( " generic " , " Generic " , supported = True , parent = " other " )