2013-03-18 01:06:52 +04:00
#
2013-10-28 00:59:46 +04:00
# Copyright 2010, 2013 Red Hat, Inc.
2013-03-18 01:06:52 +04:00
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2013-03-18 01:06:52 +04:00
2018-03-20 22:10:04 +03:00
from . . xmlbuilder import XMLBuilder , XMLProperty
2013-03-18 01:06:52 +04:00
2013-04-13 22:34:52 +04:00
2013-07-14 02:56:09 +04:00
class DomainFeatures ( XMLBuilder ) :
2013-03-18 01:06:52 +04:00
"""
Class for generating < features > XML
"""
2018-03-21 17:53:34 +03:00
XML_NAME = " features "
2016-06-10 03:22:25 +03:00
_XML_PROP_ORDER = [ " acpi " , " apic " , " pae " , " gic_version " ]
2013-03-18 01:06:52 +04:00
2018-09-02 16:02:32 +03:00
acpi = XMLProperty ( " ./acpi " , is_bool = True )
apic = XMLProperty ( " ./apic " , is_bool = True )
pae = XMLProperty ( " ./pae " , is_bool = True )
2016-06-10 03:22:25 +03:00
gic_version = XMLProperty ( " ./gic/@version " )
2013-09-27 23:35:27 +04:00
hap = XMLProperty ( " ./hap " , is_bool = True )
viridian = XMLProperty ( " ./viridian " , is_bool = True )
privnet = XMLProperty ( " ./privnet " , is_bool = True )
2015-09-29 00:12:42 +03:00
pmu = XMLProperty ( " ./pmu/@state " , is_onoff = True )
2013-09-27 23:35:27 +04:00
eoi = XMLProperty ( " ./apic/@eoi " , is_onoff = True )
2017-03-27 16:55:42 +03:00
hyperv_reset = XMLProperty ( " ./hyperv/reset/@state " , is_onoff = True )
2013-09-27 23: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 21:17:15 +03:00
hyperv_synic = XMLProperty ( " ./hyperv/synic/@state " , is_onoff = True )
2015-04-03 01:04:04 +03:00
2018-09-02 16:02:32 +03:00
vmport = XMLProperty ( " ./vmport/@state " , is_onoff = True )
2015-09-08 13:03:04 +03:00
kvm_hidden = XMLProperty ( " ./kvm/hidden/@state " , is_onoff = True )
2019-08-13 09:57:13 +03:00
kvm_hint_dedicated = XMLProperty ( " ./kvm/hint-dedicated/@state " , is_onoff = True )
2021-05-27 07:01:48 +03:00
kvm_poll_control = XMLProperty ( " ./kvm/poll-control/@state " , is_onoff = True )
2015-10-01 10:07:42 +03:00
pvspinlock = XMLProperty ( " ./pvspinlock/@state " , is_onoff = True )
2017-01-26 17:08:36 +03:00
smm = XMLProperty ( " ./smm/@state " , is_onoff = True )
2019-05-12 02:57:33 +03:00
vmcoreinfo = XMLProperty ( " ./vmcoreinfo/@state " , is_onoff = True )
2022-01-11 20:21:39 +03:00
ioapic_driver = XMLProperty ( " ./ioapic/@driver " )
2018-09-02 16:02:32 +03: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-07 02:07:15 +03:00
capsinfo = guest . lookup_capsinfo ( )
2018-09-02 16:02:32 +03:00
if self . _prop_is_unset ( " acpi " ) :
2018-09-07 02:07:15 +03:00
self . acpi = capsinfo . guest . supports_acpi ( )
2018-09-02 16:02:32 +03:00
if self . _prop_is_unset ( " apic " ) :
2018-09-07 02:07:15 +03:00
self . apic = capsinfo . guest . supports_apic ( )
2018-09-02 16:02:32 +03: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-07 02:07:15 +03:00
self . pae = capsinfo . guest . supports_pae ( )
2018-09-02 16:02:32 +03:00
if ( guest . hyperv_supported ( ) and
2019-06-07 23:06:52 +03:00
self . conn . support . conn_hyperv_vapic ( ) ) :
2018-09-02 16:02:32 +03: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