Skip to content

Commit

Permalink
vt_iothread: New class added
Browse files Browse the repository at this point in the history
Add new support to the parameter: iothread_scheme.

Signed-off-by: Houqi (Nick) Zuo <[email protected]>
  • Loading branch information
nickzhq committed Nov 14, 2023
1 parent 2827d0c commit 06c658d
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion virttest/vt_iothread.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,66 @@ def request_iothread(self, iothread):
self._iothread_finder[iothread.get_aid()] = iothread
return iothread
else:
raise ValueError("Not support request specific iothread")
raise ValueError("Not support request specific iothread")


class MultiImagesRoundRobinManager(IOThreadManagerBase):
"""
Dispatch iothread object in new round-robin way.
Each iothreads will be allocated in round-robin way to the images.
"""

def __init__(self, iothreads=None):
"""
Initialize iothread manager.
:param iothreads: list of iothread objects, its id must conform with
ID_PATTERN.
:type iothreads: List
"""
super().__init__(iothreads)
self.__length = len(iothreads)
self.__current_index = 0

def request_iothread(self, iothread):
"""Return iothread.
:param iothread: iothread.
:type iothread: QIOThread
:return: iothread.
:rtype: QIOThread
"""
if iothread == "AUTO" or iothread == "auto":
iothread_aid = self.ID_PATTERN % (
self.__current_index % self.__length)
iothread = self.find_iothread(iothread_aid)
self.__current_index += 1
return iothread
raise ValueError("Not support request specific iothread!")


class FullManager(IOThreadManagerBase):
"""Dispatch all iothread objects to an image device."""

def __init__(self, iothreads=None):
"""
Initialize iothread manager.
:param iothreads: list of iothread objects, its id must conform with
ID_PATTERN.
:type iothreads: List
"""
super().__init__(iothreads)
self.__iothreads_list = iothreads

def request_iothread(self, iothread):
"""Return iothreads.
:param iothread: iothread.
:type iothread: QIOThread
:return: the list of the iothreads.
:rtype: List
"""
if iothread == "AUTO" or iothread == "auto":
return self.__iothreads_list
raise ValueError("Not support request specific iothread!")

0 comments on commit 06c658d

Please sign in to comment.