summaryrefslogtreecommitdiff
path: root/virtinst/devices/sound.py
blob: c2f6435d7af2a37d82430c74e9fe47a45de915a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
# Copyright 2008-2009, 2013-2014 Red Hat, Inc.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.

from .device import Device
from ..xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty


class _Codec(XMLBuilder):
    """
    Class for generating <sound> child <codec> XML
    """
    XML_NAME = "codec"

    type = XMLProperty("./@type")


class DeviceSound(Device):
    XML_NAME = "sound"

    model = XMLProperty("./@model")
    codecs = XMLChildProperty(_Codec)
    audio_id = XMLProperty("./audio/@id")


    ##################
    # Default config #
    ##################

    @staticmethod
    def default_model(guest):
        if guest.defaults_to_pcie():
            return "ich9"
        return "ich6"

    def set_defaults(self, guest):
        if not self.model:
            self.model = self.default_model(guest)