Address type can be set as spapr-vio for newtwork device on pseries guest.So address type configuration for network device should be added. Signed-off-by: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx> --- tests/xmlconfig-xml/boot-many-devices.xml | 6 ++++++ tests/xmlconfig.py | 5 +++++ virtinst/Guest.py | 3 ++- virtinst/VirtualNetworkInterface.py | 5 +++++ 4 files changed, 18 insertions(+), 1 deletions(-) diff --git a/tests/xmlconfig-xml/boot-many-devices.xml b/tests/xmlconfig-xml/boot-many-devices.xml index c9c5632..043e291 100644 --- a/tests/xmlconfig-xml/boot-many-devices.xml +++ b/tests/xmlconfig-xml/boot-many-devices.xml @@ -52,6 +52,12 @@ <interface type='user'> <mac address='11:11:11:11:11:11'/> </interface> + <interface type='network'> + <source network='default'/> + <mac address='22:22:22:22:22:22'/> + <model type='spapr-vlan'/> + <address type='spapr-vio'/> + </interface> <input type='mouse' bus='ps2'/> <graphics type='sdl' display=':3.4' xauth='/tmp/.Xauthority'/> <graphics type='vnc' port='-1' keymap='en-us'/> diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py index e6838c3..1dd447d 100644 --- a/tests/xmlconfig.py +++ b/tests/xmlconfig.py @@ -731,8 +731,13 @@ class TestXMLConfig(unittest.TestCase): net1.model = "e1000" net2 = VirtualNetworkInterface(type="user", macaddr="11:11:11:11:11:11") + net3 = VirtualNetworkInterface(type=virtinst.VirtualNetworkInterface.TYPE_VIRTUAL, + macaddr="22:22:22:22:22:22", network="default") + net3.model = "spapr-vlan" + net3.set_address("spapr-vio") g.nics.append(net1) g.nics.append(net2) + g.nics.append(net3) # Character devices cdev1 = VirtualCharDevice.get_dev_instance(g.conn, diff --git a/virtinst/Guest.py b/virtinst/Guest.py index 8e6496c..cd529aa 100644 --- a/virtinst/Guest.py +++ b/virtinst/Guest.py @@ -881,7 +881,8 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain): # Build XML for dev in devs: xml = _util.xml_append(xml, get_dev_xml(dev)) - if dev.address.type == "spapr-vio": + if (dev.address.type == "spapr-vio" and + dev.virtual_device_type == virtinst.VirtualDevice.VIRTUAL_DEV_DISK): xml = _util.xml_append(xml, get_vscsi_ctrl_xml()) return xml diff --git a/virtinst/VirtualNetworkInterface.py b/virtinst/VirtualNetworkInterface.py index 4b0761d..37a51e6 100644 --- a/virtinst/VirtualNetworkInterface.py +++ b/virtinst/VirtualNetworkInterface.py @@ -360,6 +360,7 @@ class VirtualNetworkInterface(VirtualDevice.VirtualDevice): src_xml = "" model_xml = "" target_xml = "" + addr_xml = "" if self.type == self.TYPE_BRIDGE: src_xml = " <source bridge='%s'/>\n" % self.bridge elif self.type == self.TYPE_VIRTUAL: @@ -372,6 +373,9 @@ class VirtualNetworkInterface(VirtualDevice.VirtualDevice): if self.model: model_xml = " <model type='%s'/>\n" % self.model + if self.address: + addr_xml = self.indent(self.address.get_xml_config(), 6) + if self.target_dev: target_xml = " <target dev='%s'/>\n" % self.target_dev @@ -380,6 +384,7 @@ class VirtualNetworkInterface(VirtualDevice.VirtualDevice): xml += " <mac address='%s'/>\n" % self.macaddr xml += target_xml xml += model_xml + xml += addr_xml xml += " </interface>" return xml -- 1.7.5.4