mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
devices: Switch to normal _XML_PROP_ORDER
Drop the register_device stuff, rename virtual_device_type
This commit is contained in:
parent
7b61c45d3b
commit
f69b823fad
2
virt-xml
2
virt-xml
@ -230,7 +230,7 @@ def action_build_xml(conn, options, parserclass):
|
||||
|
||||
|
||||
def setup_device(dev):
|
||||
if getattr(dev, "virtual_device_type", None) != "disk":
|
||||
if getattr(dev, "DEVICE_TYPE", None) != "disk":
|
||||
return
|
||||
if getattr(dev, "virt_xml_setup", None) is True:
|
||||
return
|
||||
|
@ -1101,8 +1101,8 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
return _("Panic Notifier")
|
||||
|
||||
if page == PAGE_CHAR:
|
||||
char_class = self._get_char_class()
|
||||
return _("%s Device") % char_class.virtual_device_type.capitalize()
|
||||
devclass = self._get_char_class()(self.conn.get_backend())
|
||||
return _("%s Device") % devclass.DEVICE_TYPE.capitalize()
|
||||
if page == PAGE_HOSTDEV:
|
||||
row = self._get_hw_selection()
|
||||
if row and row[5] == "pci":
|
||||
@ -1196,14 +1196,15 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
}
|
||||
|
||||
char_class = self._get_char_class()
|
||||
ischan = char_class.virtual_device_type == "channel"
|
||||
iscon = char_class.virtual_device_type == "console"
|
||||
show_auto = (devtype == "unix" and ischan and
|
||||
self.conn.check_support(self.conn.SUPPORT_CONN_AUTOSOCKET))
|
||||
|
||||
self._dev = char_class(self.conn.get_backend())
|
||||
self._dev.type = devtype
|
||||
|
||||
ischan = self._dev.DEVICE_TYPE == "channel"
|
||||
iscon = self._dev.DEVICE_TYPE == "console"
|
||||
show_auto = (devtype == "unix" and ischan and
|
||||
self.conn.check_support(self.conn.SUPPORT_CONN_AUTOSOCKET))
|
||||
|
||||
for param_name, widget_name in char_widget_mappings.items():
|
||||
make_visible = self._dev.supports_property(param_name)
|
||||
uiutil.set_grid_row_visible(self.widget(widget_name + "-label"),
|
||||
@ -1257,7 +1258,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _setup_device(self, asyncjob):
|
||||
poolname = None
|
||||
if (self._dev.virtual_device_type == "disk" and
|
||||
if (self._dev.DEVICE_TYPE == "disk" and
|
||||
self._dev.wants_storage_creation() and
|
||||
self._dev.get_parent_pool()):
|
||||
poolname = self._dev.get_parent_pool().name()
|
||||
@ -1666,7 +1667,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
except Exception as e:
|
||||
return self.err.val_err(
|
||||
_("%s device parameter error") %
|
||||
char_class.virtual_device_type.capitalize(), e)
|
||||
devclass.DEVICE_TYPE.capitalize(), e)
|
||||
|
||||
def _validate_page_video(self):
|
||||
conn = self.conn.get_backend()
|
||||
|
@ -882,7 +882,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
def _console_menu_toggled(self, src, dev):
|
||||
self.widget("details-pages").set_current_page(DETAILS_PAGE_CONSOLE)
|
||||
|
||||
if dev.virtual_device_type == "graphics":
|
||||
if dev.DEVICE_TYPE == "graphics":
|
||||
self.widget("console-pages").set_current_page(_CONSOLE_PAGE_VIEWER)
|
||||
return
|
||||
|
||||
@ -925,7 +925,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
active_label = self._serial_consoles[serial_page].name
|
||||
|
||||
for dev in devs:
|
||||
if dev.virtual_device_type == "console":
|
||||
if dev.DEVICE_TYPE == "console":
|
||||
label = _("Text Console %d") % (dev.vmmindex + 1)
|
||||
else:
|
||||
label = _("Serial %d") % (dev.vmmindex + 1)
|
||||
|
@ -150,7 +150,7 @@ _remove_tooltip = _("Remove this device from the virtual machine")
|
||||
|
||||
|
||||
def _label_for_device(dev):
|
||||
devtype = dev.virtual_device_type
|
||||
devtype = dev.DEVICE_TYPE
|
||||
|
||||
if devtype == "disk":
|
||||
busstr = virtinst.DeviceDisk.pretty_disk_bus(dev.bus) or ""
|
||||
@ -241,7 +241,7 @@ def _label_for_device(dev):
|
||||
|
||||
|
||||
def _icon_for_device(dev):
|
||||
devtype = dev.virtual_device_type
|
||||
devtype = dev.DEVICE_TYPE
|
||||
|
||||
if devtype == "disk":
|
||||
if dev.device == "cdrom":
|
||||
@ -2820,9 +2820,9 @@ class vmmDetails(vmmGObjectUI):
|
||||
if not chardev:
|
||||
return
|
||||
|
||||
show_target_type = not (chardev.virtual_device_type in
|
||||
show_target_type = not (chardev.DEVICE_TYPE in
|
||||
["serial", "parallel"])
|
||||
show_target_name = chardev.virtual_device_type == "channel"
|
||||
show_target_name = chardev.DEVICE_TYPE == "channel"
|
||||
|
||||
def show_ui(param, val=None):
|
||||
widgetname = "char-" + param.replace("_", "-")
|
||||
@ -2853,7 +2853,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
ret += ":%s" % str(port)
|
||||
return ret
|
||||
|
||||
char_type = chardev.virtual_device_type.capitalize()
|
||||
char_type = chardev.DEVICE_TYPE.capitalize()
|
||||
target_port = chardev.target_port
|
||||
dev_type = chardev.type or "pty"
|
||||
primary = hasattr(chardev, "virtmanager_console_dup")
|
||||
@ -2871,7 +2871,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
typelabel = _("%s Device") % char_type.capitalize()
|
||||
|
||||
if (target_port is not None and
|
||||
chardev.virtual_device_type == "console"):
|
||||
chardev.DEVICE_TYPE == "console"):
|
||||
typelabel += " %s" % (int(target_port) + 1)
|
||||
if target_port is not None and not show_target_type:
|
||||
typelabel += " %s" % (int(target_port) + 1)
|
||||
|
@ -57,7 +57,7 @@ def compare_device(origdev, newdev, idx):
|
||||
if not isinstance(origdev, type(newdev)):
|
||||
return False
|
||||
|
||||
for devprop in devprops[origdev.virtual_device_type]:
|
||||
for devprop in devprops[origdev.DEVICE_TYPE]:
|
||||
origval = getattr(origdev, devprop)
|
||||
if devprop == "vmmindex":
|
||||
newval = idx
|
||||
@ -71,7 +71,7 @@ def compare_device(origdev, newdev, idx):
|
||||
|
||||
|
||||
def _find_device(guest, origdev):
|
||||
devlist = getattr(guest.devices, origdev.virtual_device_type)
|
||||
devlist = getattr(guest.devices, origdev.DEVICE_TYPE)
|
||||
for idx, dev in enumerate(devlist):
|
||||
if compare_device(origdev, dev, idx):
|
||||
return dev
|
||||
@ -1269,8 +1269,8 @@ class vmmDomain(vmmLibvirtObject):
|
||||
devs = self.get_char_devices()
|
||||
devlist = []
|
||||
|
||||
devlist += [x for x in devs if x.virtual_device_type == "serial"]
|
||||
devlist += [x for x in devs if x.virtual_device_type == "console"]
|
||||
devlist += [x for x in devs if x.DEVICE_TYPE == "serial"]
|
||||
devlist += [x for x in devs if x.DEVICE_TYPE == "console"]
|
||||
return devlist
|
||||
|
||||
def _build_device_list(self, device_type,
|
||||
@ -1281,7 +1281,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
|
||||
for idx, dev in enumerate(devs):
|
||||
dev.vmmindex = idx
|
||||
dev.vmmidstr = dev.virtual_device_type + ("%.3d" % idx)
|
||||
dev.vmmidstr = dev.DEVICE_TYPE + ("%.3d" % idx)
|
||||
|
||||
return devs
|
||||
|
||||
|
@ -901,7 +901,7 @@ class _VirtCLIArgument(object):
|
||||
raise RuntimeError(
|
||||
_("Don't know how to match device type '%(device_type)s' "
|
||||
"property '%(property_name)s'") %
|
||||
{"device_type": getattr(inst, "virtual_device_type", ""),
|
||||
{"device_type": getattr(inst, "DEVICE_TYPE", ""),
|
||||
"property_name": self.key})
|
||||
|
||||
if self._virtarg.find_inst_cb:
|
||||
@ -2604,7 +2604,7 @@ class _ParserChar(VirtCLIParser):
|
||||
if not inst.supports_property(virtarg.attrname):
|
||||
raise ValueError(_("%(devtype)s type '%(chartype)s' does not "
|
||||
"support '%(optname)s' option.") %
|
||||
{"devtype": inst.virtual_device_type,
|
||||
{"devtype": inst.DEVICE_TYPE,
|
||||
"chartype": inst.type,
|
||||
"optname": virtarg.cliname})
|
||||
support_cb = support_check
|
||||
@ -2623,10 +2623,10 @@ class _ParserChar(VirtCLIParser):
|
||||
inst.set_friendly_target(val)
|
||||
|
||||
def _parse(self, inst):
|
||||
if self.optstr == "none" and inst.virtual_device_type == "console":
|
||||
if self.optstr == "none" and inst.DEVICE_TYPE == "console":
|
||||
self.guest.skip_default_console = True
|
||||
return
|
||||
if self.optstr == "none" and inst.virtual_device_type == "channel":
|
||||
if self.optstr == "none" and inst.DEVICE_TYPE == "channel":
|
||||
self.guest.skip_default_channel = True
|
||||
return
|
||||
|
||||
|
@ -244,7 +244,7 @@ class _DeviceChar(Device):
|
||||
default_cb=_get_default_protocol)
|
||||
|
||||
def _get_default_target_type(self):
|
||||
if self.virtual_device_type == "channel":
|
||||
if self.DEVICE_TYPE == "channel":
|
||||
return self.CHANNEL_TARGET_VIRTIO
|
||||
return None
|
||||
target_type = XMLProperty("./target/@type",
|
||||
@ -266,25 +266,19 @@ class _DeviceChar(Device):
|
||||
|
||||
|
||||
class DeviceConsole(_DeviceChar):
|
||||
virtual_device_type = "console"
|
||||
_XML_ROOT_NAME = "console"
|
||||
TYPES = [_DeviceChar.TYPE_PTY]
|
||||
|
||||
|
||||
class DeviceSerial(_DeviceChar):
|
||||
virtual_device_type = "serial"
|
||||
_XML_ROOT_NAME = "serial"
|
||||
|
||||
|
||||
class DeviceParallel(_DeviceChar):
|
||||
virtual_device_type = "parallel"
|
||||
_XML_ROOT_NAME = "parallel"
|
||||
|
||||
|
||||
class DeviceChannel(_DeviceChar):
|
||||
virtual_device_type = "channel"
|
||||
_XML_ROOT_NAME = "channel"
|
||||
TYPES = (_DeviceChar._TYPES_FOR_CHANNEL +
|
||||
_DeviceChar._TYPES_FOR_ALL)
|
||||
|
||||
|
||||
DeviceConsole.register_type()
|
||||
DeviceSerial.register_type()
|
||||
DeviceParallel.register_type()
|
||||
DeviceChannel.register_type()
|
||||
|
@ -10,7 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceController(Device):
|
||||
virtual_device_type = Device.DEVICE_CONTROLLER
|
||||
_XML_ROOT_NAME = "controller"
|
||||
|
||||
TYPE_IDE = "ide"
|
||||
TYPE_FDC = "fdc"
|
||||
@ -102,5 +102,3 @@ class DeviceController(Device):
|
||||
if self.type == "pci" and self.model == "pcie-root":
|
||||
ret = "PCIe"
|
||||
return ret
|
||||
|
||||
DeviceController.register_type()
|
||||
|
@ -103,63 +103,6 @@ class Device(XMLBuilder):
|
||||
"""
|
||||
Base class for all domain xml device objects.
|
||||
"""
|
||||
|
||||
DEVICE_DISK = "disk"
|
||||
DEVICE_NET = "interface"
|
||||
DEVICE_INPUT = "input"
|
||||
DEVICE_GRAPHICS = "graphics"
|
||||
DEVICE_AUDIO = "sound"
|
||||
DEVICE_HOSTDEV = "hostdev"
|
||||
DEVICE_SERIAL = "serial"
|
||||
DEVICE_PARALLEL = "parallel"
|
||||
DEVICE_CHANNEL = "channel"
|
||||
DEVICE_CONSOLE = "console"
|
||||
DEVICE_VIDEO = "video"
|
||||
DEVICE_CONTROLLER = "controller"
|
||||
DEVICE_WATCHDOG = "watchdog"
|
||||
DEVICE_FILESYSTEM = "filesystem"
|
||||
DEVICE_SMARTCARD = "smartcard"
|
||||
DEVICE_REDIRDEV = "redirdev"
|
||||
DEVICE_MEMBALLOON = "memballoon"
|
||||
DEVICE_TPM = "tpm"
|
||||
DEVICE_RNG = "rng"
|
||||
DEVICE_PANIC = "panic"
|
||||
DEVICE_MEMORY = "memory"
|
||||
|
||||
# Ordering in this list is important: it will be the order the
|
||||
# Guest class outputs XML. So changing this may upset the test suite
|
||||
virtual_device_types = [DEVICE_DISK,
|
||||
DEVICE_CONTROLLER,
|
||||
DEVICE_FILESYSTEM,
|
||||
DEVICE_NET,
|
||||
DEVICE_INPUT,
|
||||
DEVICE_GRAPHICS,
|
||||
DEVICE_SERIAL,
|
||||
DEVICE_PARALLEL,
|
||||
DEVICE_CONSOLE,
|
||||
DEVICE_CHANNEL,
|
||||
DEVICE_AUDIO,
|
||||
DEVICE_VIDEO,
|
||||
DEVICE_HOSTDEV,
|
||||
DEVICE_WATCHDOG,
|
||||
DEVICE_SMARTCARD,
|
||||
DEVICE_REDIRDEV,
|
||||
DEVICE_MEMBALLOON,
|
||||
DEVICE_TPM,
|
||||
DEVICE_RNG,
|
||||
DEVICE_PANIC,
|
||||
DEVICE_MEMORY]
|
||||
|
||||
virtual_device_classes = {}
|
||||
|
||||
@classmethod
|
||||
def register_type(cls):
|
||||
cls._XML_ROOT_NAME = cls.virtual_device_type
|
||||
Device.virtual_device_classes[cls.virtual_device_type] = cls
|
||||
|
||||
# General device type (disk, interface, etc.)
|
||||
virtual_device_type = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initialize device state
|
||||
@ -169,17 +112,13 @@ class Device(XMLBuilder):
|
||||
XMLBuilder.__init__(self, *args, **kwargs)
|
||||
self._XML_PROP_ORDER = self._XML_PROP_ORDER + ["alias", "address"]
|
||||
|
||||
if not self.virtual_device_type:
|
||||
raise ValueError(_("Virtual device type must be set in subclass."))
|
||||
|
||||
if self.virtual_device_type not in self.virtual_device_types:
|
||||
raise ValueError(_("Unknown virtual device type '%s'.") %
|
||||
self.virtual_device_type)
|
||||
|
||||
alias = XMLChildProperty(DeviceAlias, is_single=True)
|
||||
address = XMLChildProperty(DeviceAddress, is_single=True)
|
||||
boot = XMLChildProperty(DeviceBoot, is_single=True)
|
||||
|
||||
@property
|
||||
def DEVICE_TYPE(self):
|
||||
return self._XML_ROOT_NAME
|
||||
|
||||
def setup(self, meter=None):
|
||||
"""
|
||||
|
@ -99,7 +99,7 @@ class _DiskSeclabel(XMLBuilder):
|
||||
|
||||
|
||||
class DeviceDisk(Device):
|
||||
virtual_device_type = Device.DEVICE_DISK
|
||||
_XML_ROOT_NAME = "disk"
|
||||
|
||||
DRIVER_NAME_PHY = "phy"
|
||||
DRIVER_NAME_QEMU = "qemu"
|
||||
@ -1040,5 +1040,3 @@ class DeviceDisk(Device):
|
||||
else:
|
||||
raise ValueError(_("Only %s disks for bus '%s' are supported"
|
||||
% (maxnode, self.bus)))
|
||||
|
||||
DeviceDisk.register_type()
|
||||
|
@ -12,7 +12,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceFilesystem(Device):
|
||||
virtual_device_type = Device.DEVICE_FILESYSTEM
|
||||
_XML_ROOT_NAME = "filesystem"
|
||||
|
||||
TYPE_MOUNT = "mount"
|
||||
TYPE_TEMPLATE = "template"
|
||||
@ -132,6 +132,3 @@ class DeviceFilesystem(Device):
|
||||
# not the common case. so use mode=mapped
|
||||
if self.accessmode is None or self.accessmode == self.MODE_DEFAULT:
|
||||
self.accessmode = self.MODE_MAPPED
|
||||
|
||||
|
||||
DeviceFilesystem.register_type()
|
||||
|
@ -37,7 +37,7 @@ class _GraphicsListen(XMLBuilder):
|
||||
|
||||
|
||||
class DeviceGraphics(Device):
|
||||
virtual_device_type = Device.DEVICE_GRAPHICS
|
||||
_XML_ROOT_NAME = "graphics"
|
||||
|
||||
TYPE_SDL = "sdl"
|
||||
TYPE_VNC = "vnc"
|
||||
@ -237,5 +237,3 @@ class DeviceGraphics(Device):
|
||||
filetransfer_enable = XMLProperty("./filetransfer/@enable", is_yesno=True)
|
||||
gl = XMLProperty("./gl/@enable", is_yesno=True)
|
||||
rendernode = XMLProperty("./gl/@rendernode")
|
||||
|
||||
DeviceGraphics.register_type()
|
||||
|
@ -11,7 +11,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceHostdev(Device):
|
||||
virtual_device_type = Device.DEVICE_HOSTDEV
|
||||
_XML_ROOT_NAME = "hostdev"
|
||||
|
||||
def set_from_nodedev(self, nodedev):
|
||||
"""
|
||||
@ -132,6 +132,3 @@ class DeviceHostdev(Device):
|
||||
scsi_bus = XMLProperty("./source/address/@bus", is_int=True)
|
||||
scsi_target = XMLProperty("./source/address/@target", is_int=True)
|
||||
scsi_unit = XMLProperty("./source/address/@unit", is_int=True)
|
||||
|
||||
|
||||
DeviceHostdev.register_type()
|
||||
|
@ -10,7 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceInput(Device):
|
||||
virtual_device_type = Device.DEVICE_INPUT
|
||||
_XML_ROOT_NAME = "input"
|
||||
|
||||
TYPE_MOUSE = "mouse"
|
||||
TYPE_TABLET = "tablet"
|
||||
@ -37,6 +37,3 @@ class DeviceInput(Device):
|
||||
bus = XMLProperty("./@bus",
|
||||
default_cb=_default_bus,
|
||||
default_name=BUS_DEFAULT)
|
||||
|
||||
|
||||
DeviceInput.register_type()
|
||||
|
@ -113,7 +113,7 @@ class _VirtualPort(XMLBuilder):
|
||||
|
||||
|
||||
class DeviceInterface(Device):
|
||||
virtual_device_type = Device.DEVICE_NET
|
||||
_XML_ROOT_NAME = "interface"
|
||||
|
||||
TYPE_BRIDGE = "bridge"
|
||||
TYPE_VIRTUAL = "network"
|
||||
@ -315,6 +315,3 @@ class DeviceInterface(Device):
|
||||
self.type = self.TYPE_USER
|
||||
else:
|
||||
self.type, self.source = _default_network(self.conn)
|
||||
|
||||
|
||||
DeviceInterface.register_type()
|
||||
|
@ -11,7 +11,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceMemballoon(Device):
|
||||
virtual_device_type = Device.DEVICE_MEMBALLOON
|
||||
_XML_ROOT_NAME = "memballoon"
|
||||
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["virtio", "xen", "none"]
|
||||
@ -19,6 +19,3 @@ class DeviceMemballoon(Device):
|
||||
model = XMLProperty("./@model",
|
||||
default_name=MODEL_DEFAULT,
|
||||
default_cb=lambda s: "virtio")
|
||||
|
||||
|
||||
DeviceMemballoon.register_type()
|
||||
|
@ -26,7 +26,7 @@ class _DeviceMemorySource(XMLBuilder):
|
||||
|
||||
|
||||
class DeviceMemory(Device):
|
||||
virtual_device_type = Device.DEVICE_MEMORY
|
||||
_XML_ROOT_NAME = "memory"
|
||||
|
||||
MODEL_DIMM = "dimm"
|
||||
MODEL_NVDIMM = "nvdimm"
|
||||
@ -41,6 +41,3 @@ class DeviceMemory(Device):
|
||||
|
||||
source = XMLChildProperty(_DeviceMemorySource, is_single=True)
|
||||
target = XMLChildProperty(_DeviceMemoryTarget, is_single=True)
|
||||
|
||||
|
||||
DeviceMemory.register_type()
|
||||
|
@ -10,8 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DevicePanic(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_PANIC
|
||||
_XML_ROOT_NAME = "panic"
|
||||
|
||||
MODEL_DEFAULT = "default"
|
||||
MODEL_ISA = "isa"
|
||||
@ -63,5 +62,3 @@ class DevicePanic(Device):
|
||||
type = XMLProperty("./address/@type",
|
||||
default_cb=_get_default_address_type)
|
||||
iobase = XMLProperty("./address/@iobase")
|
||||
|
||||
DevicePanic.register_type()
|
||||
|
@ -11,8 +11,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceRedirdev(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_REDIRDEV
|
||||
_XML_ROOT_NAME = "redirdev"
|
||||
|
||||
BUS_DEFAULT = "default"
|
||||
BUSES = ["usb"]
|
||||
@ -46,6 +45,3 @@ class DeviceRedirdev(Device):
|
||||
|
||||
host = XMLProperty("./source/@host")
|
||||
service = XMLProperty("./source/@service", is_int=True)
|
||||
|
||||
|
||||
DeviceRedirdev.register_type()
|
||||
|
@ -10,8 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceRng(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_RNG
|
||||
_XML_ROOT_NAME = "rng"
|
||||
|
||||
TYPE_RANDOM = "random"
|
||||
TYPE_EGD = "egd"
|
||||
@ -105,5 +104,3 @@ class DeviceRng(Device):
|
||||
rate_period = XMLProperty("./rate/@period")
|
||||
|
||||
device = XMLProperty("./backend[@model='random']")
|
||||
|
||||
DeviceRng.register_type()
|
||||
|
@ -11,8 +11,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceSmartcard(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_SMARTCARD
|
||||
_XML_ROOT_NAME = "smartcard"
|
||||
|
||||
# Default models list
|
||||
MODE_DEFAULT = "default"
|
||||
@ -35,6 +34,3 @@ class DeviceSmartcard(Device):
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=_default_type,
|
||||
default_name=TYPE_DEFAULT)
|
||||
|
||||
|
||||
DeviceSmartcard.register_type()
|
||||
|
@ -10,7 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceSound(Device):
|
||||
virtual_device_type = Device.DEVICE_AUDIO
|
||||
_XML_ROOT_NAME = "sound"
|
||||
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["es1370", "sb16", "pcspk", "ac97", "ich6", "ich9"]
|
||||
@ -18,5 +18,3 @@ class DeviceSound(Device):
|
||||
model = XMLProperty("./@model",
|
||||
default_cb=lambda s: "es1370",
|
||||
default_name=MODEL_DEFAULT)
|
||||
|
||||
DeviceSound.register_type()
|
||||
|
@ -14,8 +14,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceTpm(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_TPM
|
||||
_XML_ROOT_NAME = "tpm"
|
||||
|
||||
TYPE_PASSTHROUGH = "passthrough"
|
||||
TYPE_DEFAULT = "default"
|
||||
@ -50,6 +49,3 @@ class DeviceTpm(Device):
|
||||
default_cb=lambda s: s.MODEL_TIS)
|
||||
device_path = XMLProperty("./backend/device/@path",
|
||||
default_cb=lambda s: "/dev/tpm0")
|
||||
|
||||
|
||||
DeviceTpm.register_type()
|
||||
|
@ -10,8 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceVideo(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_VIDEO
|
||||
_XML_ROOT_NAME = "video"
|
||||
|
||||
# Default models list
|
||||
MODEL_DEFAULT = "default"
|
||||
@ -33,6 +32,3 @@ class DeviceVideo(Device):
|
||||
heads = XMLProperty("./model/@heads", is_int=True)
|
||||
vgamem = XMLProperty("./model/@vgamem", is_int=True)
|
||||
accel3d = XMLProperty("./model/acceleration/@accel3d", is_yesno=True)
|
||||
|
||||
|
||||
DeviceVideo.register_type()
|
||||
|
@ -10,8 +10,7 @@ from ..xmlbuilder import XMLProperty
|
||||
|
||||
|
||||
class DeviceWatchdog(Device):
|
||||
|
||||
virtual_device_type = Device.DEVICE_WATCHDOG
|
||||
_XML_ROOT_NAME = "watchdog"
|
||||
|
||||
MODEL_I6300 = "i6300esb"
|
||||
MODEL_IB700 = "ib700"
|
||||
@ -53,6 +52,3 @@ class DeviceWatchdog(Device):
|
||||
action = XMLProperty("./@action",
|
||||
default_name=ACTION_DEFAULT,
|
||||
default_cb=lambda s: s.ACTION_RESET)
|
||||
|
||||
|
||||
DeviceWatchdog.register_type()
|
||||
|
@ -23,10 +23,16 @@ from .domcapabilities import DomainCapabilities
|
||||
from .osdict import OSDB
|
||||
from .xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty
|
||||
|
||||
_ignore = Device
|
||||
|
||||
|
||||
class _DomainDevices(XMLBuilder):
|
||||
_XML_ROOT_NAME = "devices"
|
||||
_XML_PROP_ORDER = Device.virtual_device_types[:]
|
||||
_XML_PROP_ORDER = ['disk', 'controller', 'filesystem', 'interface',
|
||||
'input', 'graphics', 'serial', 'parallel', 'console', 'channel',
|
||||
'sound', 'video', 'hostdev', 'watchdog', 'smartcard', 'redirdev',
|
||||
'memballoon', 'tpm', 'rng', 'panic', 'memory']
|
||||
|
||||
|
||||
disk = XMLChildProperty(DeviceDisk)
|
||||
controller = XMLChildProperty(DeviceController)
|
||||
@ -262,7 +268,9 @@ class Guest(XMLBuilder):
|
||||
Return a list of all devices being installed with the guest
|
||||
"""
|
||||
retlist = []
|
||||
for devtype in Device.virtual_device_types:
|
||||
# pylint: disable=protected-access
|
||||
devtypes = _DomainDevices._XML_PROP_ORDER
|
||||
for devtype in devtypes:
|
||||
retlist.extend(getattr(self.devices, devtype))
|
||||
return retlist
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user