Skip to content

Commit

Permalink
Merge pull request #2042 from balamuruhans/macvtap_xml
Browse files Browse the repository at this point in the history
utils_test/libvirt: add API to create macvtap xml for VM
  • Loading branch information
Satheesh Rajendran committed May 30, 2019
2 parents 95ea694 + a8b9705 commit b1d8278
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
from virttest.libvirt_xml.devices import controller
from virttest.libvirt_xml.devices import seclabel
from virttest.libvirt_xml.devices import channel
from virttest.libvirt_xml.devices import interface

ping = utils_net.ping

Expand Down Expand Up @@ -160,6 +161,25 @@ def cleanup(self):
virsh.net_undefine(self.name)


def create_macvtap_vmxml(iface, params):
"""
Method to create Macvtap interface xml for VM
:param iface: macvtap interface name
:param params: Test dict params for macvtap config
:return: macvtap xml object
"""
mode = params.get('macvtap_mode', 'passthrough')
model = params.get('macvtap_model', 'virtio')
macvtap_type = params.get('macvtap_type', 'direct')
macvtap = interface.Interface(macvtap_type)
macvtap.mac_address = utils_net.generate_mac_address_simple()
macvtap.model = model
macvtap.source = {'dev': iface, 'mode': mode}
return macvtap


def get_machine_types(arch, virt_type, virsh_instance=base.virsh, ignore_status=True):
"""
Method to get all supported machine types
Expand Down

0 comments on commit b1d8278

Please sign in to comment.