On Fri, Sep 22, 2017 at 07:39:09PM +0800, Lin Ma wrote: > Signed-off-by: Lin Ma <lma@xxxxxxxx> > --- Hi, thanks for the patches. The $subject starts with "tests:" which would suggest that this is mainly a test change, but it actually adds a support to format/parse addresses of virtual functions, so I would rather change the it to "network". > tests/xmlparse-xml/network-vf-pool-in.xml | 2 ++ > tests/xmlparse-xml/network-vf-pool-out.xml | 1 + > tests/xmlparse.py | 11 ++++++++--- > virtinst/network.py | 10 ++++++++++ > 4 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/tests/xmlparse-xml/network-vf-pool-in.xml b/tests/xmlparse-xml/network-vf-pool-in.xml > index 821aa07..542757d 100644 > --- a/tests/xmlparse-xml/network-vf-pool-in.xml > +++ b/tests/xmlparse-xml/network-vf-pool-in.xml > @@ -1,5 +1,7 @@ > <network> > <name>passthrough</name> > <forward mode="hostdev" managed="yes"> > + <pf dev="eth3"/> > + <address type="pci" domain="0x0000" bus="0x03" slot="0x10" function="0x0"/> > </forward> > </network> > diff --git a/tests/xmlparse-xml/network-vf-pool-out.xml b/tests/xmlparse-xml/network-vf-pool-out.xml > index 62a7305..8364411 100644 > --- a/tests/xmlparse-xml/network-vf-pool-out.xml > +++ b/tests/xmlparse-xml/network-vf-pool-out.xml > @@ -2,5 +2,6 @@ > <name>new-foo</name> > <forward mode="hostdev" managed="yes"> > <pf dev="eth3"/> > + <address type="pci" domain="0x0000" bus="0x03" slot="0x10" function="0x0"/> > </forward> > </network> > diff --git a/tests/xmlparse.py b/tests/xmlparse.py > index cc29ead..f31188b 100644 > --- a/tests/xmlparse.py > +++ b/tests/xmlparse.py > @@ -1332,11 +1332,16 @@ class XMLParseTest(unittest.TestCase): > check("mode", "hostdev") > check("managed", "yes") > > - r = net.forward.add_pf() > - r.dev = "eth3" > - check = self._make_checker(r) > + check = self._make_checker(net.forward.pf[0]) > check("dev", "eth3") > > + check = self._make_checker(net.forward.addresses[0]) > + check("type", "pci") > + check("domain", "0x0000") > + check("bus", "0x03") > + check("slot", "0x10") > + check("function", "0x0") > + > utils.diff_compare(net.get_xml_config(), outfile) > utils.test_create(conn, net.get_xml_config(), "networkDefineXML") > > diff --git a/virtinst/network.py b/virtinst/network.py > index 183b0e3..745db7c 100644 > --- a/virtinst/network.py > +++ b/virtinst/network.py > @@ -77,6 +77,15 @@ class _NetworkForwardPf(XMLBuilder): > dev = XMLProperty("./@dev") > > > +class _NetworkForwardAddress(XMLBuilder): > + _XML_ROOT_NAME = "address" > + type = XMLProperty("./@type") > + domain = XMLProperty("./@domain") > + bus = XMLProperty("./@bus") > + slot = XMLProperty("./@slot") > + function = XMLProperty("./@function") All of domain, bus, slot and function should be modeled as numbers, like we do for device addresses: domain = XMLProperty("./@domain", is_int=True) ... > + > + > class _NetworkForward(XMLBuilder): > _XML_ROOT_NAME = "forward" > > @@ -84,6 +93,7 @@ class _NetworkForward(XMLBuilder): > dev = XMLProperty("./@dev") > managed = XMLProperty("./@managed") > pf = XMLChildProperty(_NetworkForwardPf) > + addresses = XMLChildProperty(_NetworkForwardAddress) Even though it's a list of pci addresses it's also a list of virtual functions. How about naming it "vfs"? Otherwise this patch looks good. Pavel > > def add_pf(self): > r = _NetworkForwardPf(self.conn) > -- > 2.9.2 > > _______________________________________________ > virt-tools-list mailing list > virt-tools-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/virt-tools-list
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list