2014-01-10 17:37:54 +08:00
|
|
|
#
|
|
|
|
# Copyright 2013 Fujitsu Limited.
|
|
|
|
# Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
|
|
|
|
#
|
2018-04-04 21:35:41 +08:00
|
|
|
# This work is licensed under the GNU GPLv2 or later.
|
2018-03-21 03:00:02 +08:00
|
|
|
# See the COPYING file in the top-level directory.
|
2014-01-10 17:37:54 +08:00
|
|
|
|
2018-03-21 00:18:35 +08:00
|
|
|
from .device import Device
|
2018-03-21 00:27:37 +08:00
|
|
|
from ..xmlbuilder import XMLProperty
|
2014-01-10 17:37:54 +08:00
|
|
|
|
|
|
|
|
2018-03-21 00:18:35 +08:00
|
|
|
class DevicePanic(Device):
|
2018-03-21 22:53:34 +08:00
|
|
|
XML_NAME = "panic"
|
2017-09-05 00:40:34 +08:00
|
|
|
|
|
|
|
MODEL_ISA = "isa"
|
2017-09-05 15:38:39 +08:00
|
|
|
MODEL_PSERIES = "pseries"
|
|
|
|
MODEL_HYPERV = "hyperv"
|
|
|
|
MODEL_S390 = "s390"
|
2014-01-10 17:37:54 +08:00
|
|
|
|
2019-06-10 03:29:44 +08:00
|
|
|
model = XMLProperty("./@model")
|
|
|
|
|
|
|
|
|
|
|
|
##################
|
|
|
|
# Default config #
|
|
|
|
##################
|
2014-01-10 17:37:54 +08:00
|
|
|
|
2017-09-05 15:38:39 +08:00
|
|
|
@staticmethod
|
2019-06-10 03:29:44 +08:00
|
|
|
def get_models(guest):
|
|
|
|
if guest.os.is_x86():
|
2018-03-21 00:18:35 +08:00
|
|
|
return [DevicePanic.MODEL_ISA,
|
|
|
|
DevicePanic.MODEL_HYPERV]
|
2019-06-10 03:29:44 +08:00
|
|
|
elif guest.os.is_pseries():
|
2018-03-21 00:18:35 +08:00
|
|
|
return [DevicePanic.MODEL_PSERIES]
|
2019-06-10 03:29:44 +08:00
|
|
|
elif guest.os.is_s390x():
|
2018-03-21 00:18:35 +08:00
|
|
|
return [DevicePanic.MODEL_S390]
|
2017-10-27 15:42:54 +08:00
|
|
|
return []
|
2017-09-05 15:38:39 +08:00
|
|
|
|
|
|
|
@staticmethod
|
2018-09-02 03:58:26 +08:00
|
|
|
def get_default_model(guest):
|
2019-06-10 03:29:44 +08:00
|
|
|
models = DevicePanic.get_models(guest)
|
2017-09-05 15:38:39 +08:00
|
|
|
if models:
|
|
|
|
return models[0]
|
|
|
|
return None
|
|
|
|
|
2018-09-02 03:58:26 +08:00
|
|
|
def set_defaults(self, guest):
|
2019-05-12 21:18:36 +08:00
|
|
|
if not self.address.type and self.address.iobase:
|
|
|
|
self.address.type = "isa"
|
2018-09-02 03:58:26 +08:00
|
|
|
if not self.model:
|
2019-06-10 04:39:15 +08:00
|
|
|
self.model = DevicePanic.get_default_model(guest)
|