2013-03-18 05:06:52 +08: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-08-11 06:48:43 +08:00
_SENTINEL = - 1234
_allvariants = { }
def lookup_os ( key ) :
ret = _allvariants . get ( key )
if ret is None :
return ret
return ret
2013-04-14 02:34:52 +08:00
2013-08-12 02:52:30 +08:00
def _sort ( tosort , sortpref = None ) :
2013-03-18 05:06:52 +08:00
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 ( ) :
2013-08-12 02:52:30 +08:00
sortby = osinfo . sortby or key
2013-03-18 05:06:52 +08:00
sortby_mappings [ sortby ] = key
2013-09-27 05:44:30 +08:00
distro = osinfo . urldistro or " zzzzzzz "
2013-03-18 05:06:52 +08:00
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 ]
2013-08-12 02:52:30 +08:00
retlist . append ( tosort [ orig_key ] )
2013-03-18 05:06:52 +08:00
return retlist
2013-04-14 02:34:52 +08:00
2013-08-12 02:52:30 +08:00
def list_os ( list_types = False , typename = None ,
filtervars = None , only_supported = False ,
* * kwargs ) :
sortmap = { }
filtervars = filtervars or [ ]
for key , osinfo in _allvariants . items ( ) :
if list_types and not osinfo . is_type :
continue
if not list_types and osinfo . is_type :
continue
if typename and typename != osinfo . typename :
continue
if filtervars and osinfo . name not in filtervars :
continue
if only_supported and not osinfo . supported :
continue
sortmap [ key ] = osinfo
return _sort ( sortmap , * * kwargs )
2013-08-18 05:53:17 +08:00
def lookup_osdict_key ( variant , key , default ) :
val = _SENTINEL
2013-08-12 03:29:31 +08:00
if variant is not None :
val = getattr ( _allvariants [ variant ] , key )
if val == _SENTINEL :
val = default
return val
2013-03-18 05:06:52 +08:00
2013-08-10 06:14:42 +08:00
class _OSVariant ( object ) :
2013-08-12 03:29:31 +08:00
"""
Object tracking guest OS specific configuration bits .
@name : name of the object . This must be lowercase . This becomes part of
the virt - install command line API so we cannot remove any existing
name ( we could probably add aliases though )
@label : Pretty printed label . This is used in the virt - manager UI .
We can tweak this .
@is_type : virt - install historically had a distinction between an
os ' type ' ( windows , linux , etc ) , and an os ' variant ' ( fedora18 ,
winxp , etc ) . Back in 2009 we actually required the user to
specify - - os - type if specifying an - - os - variant even though we
could figure it out easily . This distinction isn ' t needed any
more , though it ' s still baked into the virt-manager UI where
it is still pretty useful , so we fake it here . New types should
not be added often .
@parent : Name of a pre - created variant that we want to extend . So
fedoraFOO would have parent fedoraFOO - 1. It ' s used for inheiriting
values .
@sortby : A different key to use for sorting the distro list . By default
it ' s ' name ' , so this doesn ' t need to be specified .
2013-09-27 05:44:30 +08:00
@urldistro : This is a distro class . It ' s wired up in urlfetcher to give
2013-08-12 03:29:31 +08:00
us a shortcut when detecting OS type from a URL .
@supported : If this distro is supported by it ' s owning organization,
like is it still receiving updates . We use this to limit the
distros we show in virt - manager by default , so old distros aren ' t
squeezing out current ones .
@three_stage_install : If True , this VM has a 3 stage install , AKA windows .
2013-08-18 05:53:17 +08:00
@xen_disable_acpi : If True , disable acpi / apic for this OS if on old xen .
2013-10-03 04:41:23 +08:00
This corresponds with the SUPPORT_CONN_SKIP_DEFAULT_ACPI check
2013-08-18 05:53:17 +08:00
@virtionet : If True , this OS supports virtionet out of the box
@virtiodisk : If True , this OS supports virtiodisk out of the box
2013-08-18 20:59:19 +08:00
@virtiommio : If True , this OS supports virtio - mmio out of the box ,
which provides virtio for certain ARM configurations
2013-08-12 03:29:31 +08:00
The rest of the parameters are about setting device / guest defaults
based on the OS . They should be self explanatory . See guest . py for
their usage .
"""
2013-08-11 06:48:43 +08:00
def __init__ ( self , name , label , is_type = False ,
sortby = None , parent = _SENTINEL ,
2013-09-27 05:44:30 +08:00
urldistro = _SENTINEL , supported = _SENTINEL ,
2013-08-12 03:29:31 +08:00
three_stage_install = _SENTINEL ,
acpi = _SENTINEL , apic = _SENTINEL , clock = _SENTINEL ,
netmodel = _SENTINEL , diskbus = _SENTINEL ,
inputtype = _SENTINEL , inputbus = _SENTINEL ,
2013-08-18 05:53:17 +08:00
videomodel = _SENTINEL , virtionet = _SENTINEL ,
2013-08-18 20:59:19 +08:00
virtiodisk = _SENTINEL , virtiommio = _SENTINEL ,
xen_disable_acpi = _SENTINEL ) :
2013-08-12 03:29:31 +08:00
if is_type :
if parent != _SENTINEL :
raise RuntimeError ( " OS types must not specify parent " )
parent = None
elif parent == _SENTINEL :
2013-08-11 02:44:20 +08:00
raise RuntimeError ( " Must specify explicit parent " )
2013-08-11 06:48:43 +08:00
else :
2013-08-11 02:44:20 +08:00
parent = _allvariants [ parent ]
2013-08-12 03:29:31 +08:00
def _get_default ( name , val , default = _SENTINEL ) :
2013-08-11 02:44:20 +08:00
if val == _SENTINEL :
2013-08-12 03:29:31 +08:00
if not parent :
return default
return getattr ( parent , name )
2013-08-11 02:44:20 +08:00
return val
2013-08-12 03:29:31 +08:00
if name != name . lower ( ) :
raise RuntimeError ( " OS dictionary wants lowercase name, not "
" ' %s ' " % name )
self . name = name
2013-08-10 06:14:42 +08:00
self . label = label
self . sortby = sortby
2013-08-11 06:48:43 +08:00
self . is_type = bool ( is_type )
2013-08-12 03:29:31 +08:00
self . typename = _get_default ( " typename " ,
self . is_type and self . name or _SENTINEL )
2013-08-11 06:48:43 +08:00
2013-08-12 03:29:31 +08: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-11 06:48:43 +08:00
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-09-27 05:44:30 +08:00
self . urldistro = _get_default ( " urldistro " , urldistro , None )
2013-08-12 03:29:31 +08:00
self . supported = _get_default ( " supported " , supported , False )
self . three_stage_install = _get_default ( " three_stage_install " ,
three_stage_install )
2013-08-10 06:14:42 +08:00
2013-08-12 03:29:31 +08:00
self . acpi = _get_default ( " acpi " , acpi )
self . apic = _get_default ( " apic " , apic )
self . clock = _get_default ( " clock " , clock )
2013-08-12 02:52:30 +08:00
2013-08-12 03:29:31 +08:00
self . netmodel = _get_default ( " netmodel " , netmodel )
self . videomodel = _get_default ( " videomodel " , videomodel )
self . diskbus = _get_default ( " diskbus " , diskbus )
self . inputtype = _get_default ( " inputtype " , inputtype )
self . inputbus = _get_default ( " inputbus " , inputbus )
2013-08-12 02:52:30 +08:00
2013-08-18 05:53:17 +08:00
self . xen_disable_acpi = _get_default ( " xen_disable_acpi " ,
xen_disable_acpi )
self . virtiodisk = _get_default ( " virtiodisk " , virtiodisk )
self . virtionet = _get_default ( " virtionet " , virtionet )
2013-08-18 20:59:19 +08:00
self . virtiommio = _get_default ( " virtiommio " , virtiommio )
2013-08-18 05:53:17 +08:00
2013-08-12 02:52:30 +08:00
def _add_type ( * args , * * kwargs ) :
kwargs [ " is_type " ] = True
_t = _OSVariant ( * args , * * kwargs )
_allvariants [ _t . name ] = _t
def _add_var ( * args , * * kwargs ) :
v = _OSVariant ( * args , * * kwargs )
_allvariants [ v . name ] = v
2013-08-12 03:29:31 +08:00
_add_type ( " linux " , " Linux " )
2013-09-27 05:44:30 +08:00
_add_var ( " rhel2.1 " , " Red Hat Enterprise Linux 2.1 " , urldistro = " rhel " , parent = " linux " )
2013-08-12 02:52:30 +08:00
_add_var ( " rhel3 " , " Red Hat Enterprise Linux 3 " , parent = " rhel2.1 " )
_add_var ( " rhel4 " , " Red Hat Enterprise Linux 4 " , supported = True , parent = " rhel3 " )
_add_var ( " rhel5 " , " Red Hat Enterprise Linux 5 " , supported = False , parent = " rhel4 " )
2013-08-18 05:53:17 +08:00
_add_var ( " rhel5.4 " , " Red Hat Enterprise Linux 5.4 or later " , supported = True , virtiodisk = True , virtionet = True , parent = " rhel5 " )
_add_var ( " rhel6 " , " Red Hat Enterprise Linux 6 " , inputtype = " tablet " , inputbus = " usb " , parent = " rhel5.4 " )
2013-08-12 02:52:30 +08:00
_add_var ( " rhel7 " , " Red Hat Enterprise Linux 7 " , supported = False , parent = " rhel6 " )
2013-09-27 05:44:30 +08:00
_add_var ( " fedora5 " , " Fedora Core 5 " , sortby = " fedora05 " , urldistro = " fedora " , parent = " linux " )
2013-08-12 02:52:30 +08:00
_add_var ( " fedora6 " , " Fedora Core 6 " , sortby = " fedora06 " , parent = " fedora5 " )
_add_var ( " fedora7 " , " Fedora 7 " , sortby = " fedora07 " , parent = " fedora6 " )
_add_var ( " fedora8 " , " Fedora 8 " , sortby = " fedora08 " , parent = " fedora7 " )
2013-08-10 06:14:42 +08:00
# Apparently F9 has selinux errors when installing with virtio:
2013-08-18 20:59:19 +08:00
# https://bugzilla.redhat.com/show_bug.cgi?id=470386
2013-08-18 05:53:17 +08:00
_add_var ( " fedora9 " , " Fedora 9 " , sortby = " fedora09 " , virtionet = True , parent = " fedora8 " )
_add_var ( " fedora10 " , " Fedora 10 " , virtiodisk = True , parent = " fedora9 " )
_add_var ( " fedora11 " , " Fedora 11 " , inputtype = " tablet " , inputbus = " usb " , parent = " fedora10 " )
2013-08-12 02:52:30 +08:00
_add_var ( " fedora12 " , " Fedora 12 " , parent = " fedora11 " )
_add_var ( " fedora13 " , " Fedora 13 " , parent = " fedora12 " )
_add_var ( " fedora14 " , " Fedora 14 " , parent = " fedora13 " )
_add_var ( " fedora15 " , " Fedora 15 " , parent = " fedora14 " )
_add_var ( " fedora16 " , " Fedora 16 " , parent = " fedora15 " )
2013-08-13 01:32:30 +08:00
_add_var ( " fedora17 " , " Fedora 17 " , parent = " fedora16 " )
_add_var ( " fedora18 " , " Fedora 18 " , supported = True , parent = " fedora17 " )
2013-08-18 20:59:19 +08:00
_add_var ( " fedora19 " , " Fedora 19 " , virtiommio = True , parent = " fedora18 " )
2013-08-13 01:32:30 +08:00
_add_var ( " fedora20 " , " Fedora 20 " , parent = " fedora19 " )
2013-08-12 02:52:30 +08:00
2013-09-27 05:44:30 +08:00
_add_var ( " opensuse11 " , " openSuse 11 " , urldistro = " suse " , supported = True , virtiodisk = True , virtionet = True , parent = " linux " )
2013-08-12 02:52:30 +08:00
_add_var ( " opensuse12 " , " openSuse 12 " , parent = " opensuse11 " )
2013-09-27 05:44:30 +08:00
_add_var ( " sles10 " , " Suse Linux Enterprise Server " , urldistro = " suse " , supported = True , parent = " linux " )
2013-08-18 05:53:17 +08:00
_add_var ( " sles11 " , " Suse Linux Enterprise Server 11 " , supported = True , virtiodisk = True , virtionet = True , parent = " sles10 " )
2013-08-12 02:52:30 +08:00
2013-09-27 05:44:30 +08:00
_add_var ( " mandriva2009 " , " Mandriva Linux 2009 and earlier " , urldistro = " mandriva " , parent = " linux " )
2013-08-18 05:53:17 +08:00
_add_var ( " mandriva2010 " , " Mandriva Linux 2010 and later " , virtiodisk = True , virtionet = True , parent = " mandriva2009 " )
2013-08-12 02:52:30 +08:00
2013-09-27 05:44:30 +08:00
_add_var ( " mes5 " , " Mandriva Enterprise Server 5.0 " , urldistro = " mandriva " , parent = " linux " )
2013-08-18 05:53:17 +08:00
_add_var ( " mes5.1 " , " Mandriva Enterprise Server 5.1 and later " , supported = True , virtiodisk = True , virtionet = True , parent = " mes5 " )
2013-09-27 08:17:24 +08:00
_add_var ( " mbs1 " , " Mandriva Business Server 1 and later " , supported = True , virtiodisk = True , virtionet = True , parent = " linux " )
2013-08-12 02:52:30 +08:00
2013-09-27 05:44:30 +08:00
_add_var ( " mageia1 " , " Mageia 1 and later " , urldistro = " mandriva " , supported = True , virtiodisk = True , virtionet = True , inputtype = " tablet " , inputbus = " usb " , parent = " linux " )
2013-08-12 02:52:30 +08:00
2013-09-27 05:44:30 +08:00
_add_var ( " altlinux " , " ALT Linux " , urldistro = " altlinux " , supported = True , virtiodisk = True , virtionet = True , inputtype = " tablet " , inputbus = " usb " , parent = " linux " )
2013-08-12 02:52:30 +08:00
2013-09-27 05:44:30 +08:00
_add_var ( " debianetch " , " Debian Etch " , urldistro = " debian " , sortby = " debian4 " , parent = " linux " )
2013-08-18 05:53:17 +08:00
_add_var ( " debianlenny " , " Debian Lenny " , sortby = " debian5 " , supported = True , virtiodisk = True , virtionet = True , parent = " debianetch " )
_add_var ( " debiansqueeze " , " Debian Squeeze " , sortby = " debian6 " , virtiodisk = True , virtionet = True , inputtype = " tablet " , inputbus = " usb " , parent = " debianlenny " )
2013-08-12 02:52:30 +08:00
_add_var ( " debianwheezy " , " Debian Wheezy " , sortby = " debian7 " , parent = " debiansqueeze " )
2013-09-27 05:44:30 +08:00
_add_var ( " ubuntuhardy " , " Ubuntu 8.04 LTS (Hardy Heron) " , urldistro = " ubuntu " , virtionet = True , parent = " linux " )
2013-08-12 02:52:30 +08:00
_add_var ( " ubuntuintrepid " , " Ubuntu 8.10 (Intrepid Ibex) " , parent = " ubuntuhardy " )
2013-08-18 05:53:17 +08:00
_add_var ( " ubuntujaunty " , " Ubuntu 9.04 (Jaunty Jackalope) " , virtiodisk = True , parent = " ubuntuintrepid " )
2013-08-12 02:52:30 +08:00
_add_var ( " ubuntukarmic " , " Ubuntu 9.10 (Karmic Koala) " , parent = " ubuntujaunty " )
_add_var ( " ubuntulucid " , " Ubuntu 10.04 LTS (Lucid Lynx) " , supported = True , parent = " ubuntukarmic " )
_add_var ( " ubuntumaverick " , " Ubuntu 10.10 (Maverick Meerkat) " , supported = False , parent = " ubuntulucid " )
_add_var ( " ubuntunatty " , " Ubuntu 11.04 (Natty Narwhal) " , parent = " ubuntumaverick " )
_add_var ( " ubuntuoneiric " , " Ubuntu 11.10 (Oneiric Ocelot) " , parent = " ubuntunatty " )
_add_var ( " ubuntuprecise " , " Ubuntu 12.04 LTS (Precise Pangolin) " , supported = True , parent = " ubuntuoneiric " )
_add_var ( " ubuntuquantal " , " Ubuntu 12.10 (Quantal Quetzal) " , parent = " ubuntuprecise " )
2013-08-18 05:53:17 +08:00
_add_var ( " ubunturaring " , " Ubuntu 13.04 (Raring Ringtail) " , videomodel = " vmvga " , parent = " ubuntuquantal " )
2013-08-12 02:52:30 +08:00
_add_var ( " ubuntusaucy " , " Ubuntu 13.10 (Saucy Salamander) " , parent = " ubunturaring " )
_add_var ( " generic24 " , " Generic 2.4.x kernel " , parent = " linux " )
_add_var ( " generic26 " , " Generic 2.6.x kernel " , parent = " generic24 " )
2013-08-18 05:53:17 +08:00
_add_var ( " virtio26 " , " Generic 2.6.25 or later kernel with virtio " , sortby = " genericvirtio26 " , virtiodisk = True , virtionet = True , parent = " generic26 " )
2013-08-12 02:52:30 +08:00
2013-08-12 03:29:31 +08:00
_add_type ( " windows " , " Windows " , clock = " localtime " , three_stage_install = True , inputtype = " tablet " , inputbus = " usb " , videomodel = " vga " )
2013-08-18 05:53:17 +08:00
_add_var ( " win2k " , " Microsoft Windows 2000 " , sortby = " mswin4 " , xen_disable_acpi = True , parent = " windows " )
_add_var ( " winxp " , " Microsoft Windows XP " , sortby = " mswin5 " , supported = True , xen_disable_acpi = True , parent = " windows " )
2013-08-12 02:52:30 +08:00
_add_var ( " winxp64 " , " Microsoft Windows XP (x86_64) " , supported = True , sortby = " mswin564 " , parent = " windows " )
_add_var ( " win2k3 " , " Microsoft Windows Server 2003 " , supported = True , sortby = " mswinserv2003 " , parent = " windows " )
_add_var ( " win2k8 " , " Microsoft Windows Server 2008 " , supported = True , sortby = " mswinserv2008 " , parent = " windows " )
_add_var ( " vista " , " Microsoft Windows Vista " , supported = True , sortby = " mswin6 " , parent = " windows " )
_add_var ( " win7 " , " Microsoft Windows 7 " , supported = True , sortby = " mswin7 " , parent = " windows " )
2013-08-12 03:29:31 +08:00
_add_type ( " solaris " , " Solaris " , clock = " localtime " )
2013-08-12 02:52:30 +08:00
_add_var ( " solaris9 " , " Sun Solaris 9 " , parent = " solaris " )
2013-08-12 03:29:31 +08:00
_add_var ( " solaris10 " , " Sun Solaris 10 " , inputtype = " tablet " , inputbus = " usb " , parent = " solaris " )
2013-08-17 22:37:59 +08:00
# https://bugzilla.redhat.com/show_bug.cgi?id=894017 claims tablet doesn't work for solaris 11
_add_var ( " solaris11 " , " Sun Solaris 11 " , inputtype = None , inputbus = None , parent = " solaris " )
2013-08-12 03:29:31 +08:00
_add_var ( " opensolaris " , " Sun OpenSolaris " , inputtype = " tablet " , inputbus = " usb " , parent = " solaris " )
2013-08-12 02:52:30 +08:00
2013-08-12 03:29:31 +08:00
_add_type ( " unix " , " UNIX " )
2013-08-10 06:14:42 +08:00
# http: //www.nabble.com/Re%3A-Qemu%3A-bridging-on-FreeBSD-7.0-STABLE-p15919603.html
2013-08-12 03:29:31 +08:00
_add_var ( " freebsd6 " , " FreeBSD 6.x " , netmodel = " ne2k_pci " , parent = " unix " )
2013-08-12 02:52:30 +08:00
_add_var ( " freebsd7 " , " FreeBSD 7.x " , parent = " freebsd6 " )
2013-08-12 03:29:31 +08:00
_add_var ( " freebsd8 " , " FreeBSD 8.x " , supported = True , netmodel = " e1000 " , parent = " freebsd7 " )
2013-08-12 02:52:30 +08:00
_add_var ( " freebsd9 " , " FreeBSD 9.x " , parent = " freebsd8 " )
2013-08-18 05:53:17 +08:00
_add_var ( " freebsd10 " , " FreeBSD 10.x " , supported = False , virtiodisk = True , virtionet = True , parent = " freebsd9 " )
2013-08-10 06:14:42 +08: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-12 03:29:31 +08:00
_add_var ( " openbsd4 " , " OpenBSD 4.x " , netmodel = " pcnet " , parent = " unix " )
2013-08-10 06:14:42 +08:00
2013-08-12 03:29:31 +08:00
_add_type ( " other " , " Other " )
2013-08-12 02:52:30 +08:00
_add_var ( " msdos " , " MS-DOS " , acpi = False , apic = False , parent = " other " )
_add_var ( " netware4 " , " Novell Netware 4 " , parent = " other " )
_add_var ( " netware5 " , " Novell Netware 5 " , parent = " other " )
_add_var ( " netware6 " , " Novell Netware 6 " , parent = " other " )
_add_var ( " generic " , " Generic " , supported = True , parent = " other " )