Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodedev_xml: extend MdevXML with attr elements #3723

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions virttest/libvirt_xml/nodedev_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,42 @@ class MdevXML(CAPXML):
"""
class for capability whose type is mdev
"""
__slots__ = ('type_id', 'uuid')
__slots__ = ('type_id', 'uuid', 'attrs')

def __init__(self, virsh_instance=base.virsh):
accessors.XMLAttribute('type_id', self, parent_xpath='/',
tag_name='type', attribute='id')
accessors.XMLElementText('uuid', self, parent_xpath='/',
tag_name='uuid')
accessors.XMLElementList(property_name='attrs',
libvirtxml=self,
parent_xpath='/',
marshal_from=self.marshal_from_attrs,
marshal_to=self.marshal_to_attrs,
has_subclass=False)
super(MdevXML, self).__init__(virsh_instance=virsh_instance)
self.xml = (' <capability type=\'mdev\'></capability>')

@staticmethod
def marshal_from_attrs(item, index, libvirtxml):
"""Convert dictionary to an xml object"""
del index
del libvirtxml
if not isinstance(item, dict):
raise xcepts.LibvirtXMLError("Expected a dictionary of host"
" attributes, not a %s"
% str(item))
return ('attr', dict(item))

@staticmethod
def marshal_to_attrs(tag, attr_dict, index, libvirtxml):
"""Convert xml object to a dictionary"""
del index
del libvirtxml
if tag != 'attr':
return None
return dict(attr_dict)


class StorageXML(CAPXML):

Expand Down Expand Up @@ -315,7 +341,7 @@ def get_sysfs_sub_path(self):
Return the sysfs_subdir in .

Example:
pci_bus/0000\:00/device/0000\:00\:00.0/
pci_bus/0000:00/device/0000:00:00.0/
"""
domain = self.domain
bus = self.bus
Expand Down
Loading