2013-03-17 17:06:52 -04:00
#
2013-10-27 21:59:46 +01:00
# Copyright 2010, 2013 Red Hat, Inc.
2013-03-17 17:06:52 -04:00
#
2018-04-04 14:35:41 +01:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 15:00:02 -04:00
# See the COPYING file in the top-level directory.
2013-03-17 17:06:52 -04:00
2018-03-20 15:10:04 -04:00
from . . xmlbuilder import XMLBuilder , XMLProperty
2013-03-17 17:06:52 -04:00
2013-04-13 14:34:52 -04:00
2013-07-13 18:56:09 -04:00
class DomainFeatures ( XMLBuilder ) :
2013-03-17 17:06:52 -04:00
"""
Class for generating < features > XML
"""
2018-03-21 10:53:34 -04:00
XML_NAME = " features "
2016-06-10 02:22:25 +02:00
_XML_PROP_ORDER = [ " acpi " , " apic " , " pae " , " gic_version " ]
2013-03-17 17:06:52 -04:00
2018-09-02 09:02:32 -04:00
acpi = XMLProperty ( " ./acpi " , is_bool = True )
apic = XMLProperty ( " ./apic " , is_bool = True )
pae = XMLProperty ( " ./pae " , is_bool = True )
2016-06-10 02:22:25 +02:00
gic_version = XMLProperty ( " ./gic/@version " )
2013-09-27 15:35:27 -04:00
hap = XMLProperty ( " ./hap " , is_bool = True )
viridian = XMLProperty ( " ./viridian " , is_bool = True )
privnet = XMLProperty ( " ./privnet " , is_bool = True )
2015-09-28 17:12:42 -04:00
pmu = XMLProperty ( " ./pmu/@state " , is_onoff = True )
2013-09-27 15:35:27 -04:00
eoi = XMLProperty ( " ./apic/@eoi " , is_onoff = True )
2017-03-27 19:25:42 +05:30
hyperv_reset = XMLProperty ( " ./hyperv/reset/@state " , is_onoff = True )
2013-09-27 15:35:27 -04:00
hyperv_vapic = XMLProperty ( " ./hyperv/vapic/@state " , is_onoff = True )
hyperv_relaxed = XMLProperty ( " ./hyperv/relaxed/@state " , is_onoff = True )
hyperv_spinlocks = XMLProperty ( " ./hyperv/spinlocks/@state " , is_onoff = True )
hyperv_spinlocks_retries = XMLProperty ( " ./hyperv/spinlocks/@retries " ,
is_int = True )
2017-03-30 23:47:15 +05:30
hyperv_synic = XMLProperty ( " ./hyperv/synic/@state " , is_onoff = True )
2015-04-03 00:04:04 +02:00
2018-09-02 09:02:32 -04:00
vmport = XMLProperty ( " ./vmport/@state " , is_onoff = True )
2015-09-08 12:03:04 +02:00
kvm_hidden = XMLProperty ( " ./kvm/hidden/@state " , is_onoff = True )
2019-08-13 08:57:13 +02:00
kvm_hint_dedicated = XMLProperty ( " ./kvm/hint-dedicated/@state " , is_onoff = True )
2021-05-27 12:01:48 +08:00
kvm_poll_control = XMLProperty ( " ./kvm/poll-control/@state " , is_onoff = True )
2015-10-01 12:37:42 +05:30
pvspinlock = XMLProperty ( " ./pvspinlock/@state " , is_onoff = True )
2017-01-26 15:08:36 +01:00
smm = XMLProperty ( " ./smm/@state " , is_onoff = True )
2019-05-11 19:57:33 -04:00
vmcoreinfo = XMLProperty ( " ./vmcoreinfo/@state " , is_onoff = True )
2022-01-11 11:21:39 -06:00
ioapic_driver = XMLProperty ( " ./ioapic/@driver " )
2018-09-02 09:02:32 -04:00
##################
# Default config #
##################
def set_defaults ( self , guest ) :
if guest . os . is_container ( ) :
self . acpi = None
self . apic = None
self . pae = None
if guest . is_full_os_container ( ) and guest . type != " vz " :
self . privnet = True
return
if not guest . os . is_hvm ( ) :
return
2018-09-06 19:07:15 -04:00
capsinfo = guest . lookup_capsinfo ( )
2018-09-02 09:02:32 -04:00
if self . _prop_is_unset ( " acpi " ) :
2018-09-06 19:07:15 -04:00
self . acpi = capsinfo . guest . supports_acpi ( )
2018-09-02 09:02:32 -04:00
if self . _prop_is_unset ( " apic " ) :
2018-09-06 19:07:15 -04:00
self . apic = capsinfo . guest . supports_apic ( )
2018-09-02 09:02:32 -04:00
if self . _prop_is_unset ( " pae " ) :
if ( guest . os . is_hvm ( ) and
guest . type == " xen " and
guest . os . arch == " x86_64 " ) :
self . pae = True
else :
2018-09-06 19:07:15 -04:00
self . pae = capsinfo . guest . supports_pae ( )
2018-09-02 09:02:32 -04:00
if ( guest . hyperv_supported ( ) and
2019-06-07 16:06:52 -04:00
self . conn . support . conn_hyperv_vapic ( ) ) :
2018-09-02 09:02:32 -04:00
if self . hyperv_relaxed is None :
self . hyperv_relaxed = True
if self . hyperv_vapic is None :
self . hyperv_vapic = True
if self . hyperv_spinlocks is None :
self . hyperv_spinlocks = True
if self . hyperv_spinlocks_retries is None :
self . hyperv_spinlocks_retries = 8191