Skip to content

Commit

Permalink
Merge pull request #3791 from dzhengfy/add_subelement_VMIothreadidsXML
Browse files Browse the repository at this point in the history
vm_xml: update VMIothreadXML
  • Loading branch information
dzhengfy authored Nov 20, 2023
2 parents 3f724ed + 3c06a71 commit 9cf841c
Showing 1 changed file with 53 additions and 12 deletions.
65 changes: 53 additions & 12 deletions virttest/libvirt_xml/vm_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3756,31 +3756,72 @@ class VMIothreadidsXML(base.LibvirtXMLBase):
__slots__ = ('iothread',)

def __init__(self, virsh_instance=base.virsh):
accessors.XMLElementList('iothread', self, parent_xpath='/',
accessors.XMLElementList('iothread',
self,
forbidden=[],
parent_xpath='/',
marshal_from=self.marshal_from_iothreads,
marshal_to=self.marshal_to_iothreads)
marshal_to=self.marshal_to_iothreads,
has_subclass=True)
super(VMIothreadidsXML, self).__init__(virsh_instance=virsh_instance)
self.xml = '<iothreadids/>'

class VMIothreadXML(base.LibvirtXMLBase):
"""
Class of vm iothread tag
"""

__slots__ = ('id', 'thread_pool_min', 'thread_pool_max', 'poll')

def __init__(self, virsh_instance=base.virsh):
accessors.XMLAttribute(property_name="id",
libvirtxml=self,
forbidden=[],
parent_xpath='/',
tag_name='iothread',
attribute='id')
accessors.XMLAttribute(property_name="thread_pool_min",
libvirtxml=self,
forbidden=[],
parent_xpath='/',
tag_name='iothread',
attribute='thread_pool_min')
accessors.XMLAttribute(property_name="thread_pool_max",
libvirtxml=self,
forbidden=[],
parent_xpath='/',
tag_name='iothread',
attribute='thread_pool_max')
accessors.XMLElementDict('poll', self, parent_xpath='/',
tag_name='poll')
super(VMIothreadidsXML.VMIothreadXML, self).__init__(virsh_instance=virsh_instance)
self.xml = '<iothread/>'

@staticmethod
def marshal_from_iothreads(item, index, libvirtxml):
"""
Convert a string to iothread tag and attributes.
Convert an xml object to iothread tag and xml element.
"""
if not isinstance(item, dict):
raise xcepts.LibvirtXMLError("Expected a dictionary of iothread "
"attributes, not a %s"
% str(item))
return ('iothread', dict(item))
if isinstance(item, VMIothreadidsXML.VMIothreadXML):
return 'iothread', item
elif isinstance(item, dict):
iothread = VMIothreadidsXML.VMIothreadXML()
iothread.setup_attrs(**item)
return 'iothread', iothread
else:
raise xcepts.LibvirtXMLError("Expected a list of iothread "
"instances, not a %s" % str(item))

@staticmethod
def marshal_to_iothreads(tag, attr_dict, index, libvirtxml):
def marshal_to_iothreads(tag, new_treefile, index, libvirtxml):
"""
Convert a iothread tag and attributes to a string.
Convert an iothread tag xml element to an object of VMIothreadXML.
"""
if tag != 'iothread':
return None
return dict(attr_dict)
return None # Don't convert this item
newone = VMIothreadidsXML.VMIothreadXML(virsh_instance=libvirtxml.virsh)
newone.xmltreefile = new_treefile
return newone


class VMFeaturesHypervXML(base.LibvirtXMLBase):
Expand Down

0 comments on commit 9cf841c

Please sign in to comment.