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

Support address and rom for hostdev #3362

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions virttest/libvirt_xml/devices/hostdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

http://libvirt.org/formatdomain.html#elementsHostDev
"""
from virttest.libvirt_xml.devices import base
from virttest.libvirt_xml import accessors
from virttest.libvirt_xml.devices import base
from virttest.libvirt_xml.devices import librarian


class Hostdev(base.TypedDeviceBase):

__slots__ = ('type', 'mode', 'managed', 'sgio', 'rawio',
'source', 'boot_order', 'readonly', 'shareable',
'alias', 'model', 'teaming')
'alias', 'model', 'teaming', 'rom', 'address')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps add simple hostdev xml under class Hostdev(base.TypedDeviceBase):
to make people understand what one typical hostdev looks like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A reference link has been added to the top of the code, I don't think we need to 'copy' them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently already there are some devices xml following up that practice. But it doesn't block approve


def __init__(self, type_name="hostdev", virsh_instance=base.base.virsh):
accessors.XMLAttribute('type', self, parent_xpath='/',
Expand All @@ -38,12 +39,20 @@ def __init__(self, type_name="hostdev", virsh_instance=base.base.virsh):
tag_name='shareable')
accessors.XMLElementDict('alias', self, parent_xpath='/',
tag_name='alias')
accessors.XMLElementDict('rom', self, parent_xpath='/',
tag_name='rom')
accessors.XMLElementNest('address', self, parent_xpath='/',
tag_name='address', subclass=self.Address,
subclass_dargs={'type_name': 'drive',
'virsh_instance': virsh_instance})
accessors.XMLElementDict("teaming", self, parent_xpath='/',
tag_name='teaming')
super(self.__class__, self).__init__(device_tag='hostdev',
type_name=type_name,
virsh_instance=virsh_instance)

Address = librarian.get('address')

def new_source(self, **dargs):
new_one = self.Source(virsh_instance=self.virsh)
if self.type == 'pci':
Expand Down