[virt-tools-list] [virt-manager PATCH 2/2] host: Show details about the network of SR-IOV VF pool

Pavel Hrdina phrdina at redhat.com
Tue Oct 3 08:00:32 UTC 2017


On Fri, Sep 22, 2017 at 07:39:10PM +0800, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>  ui/host.ui             | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  virtManager/host.py    | 54 ++++++++++++++++++++++++++++
>  virtManager/network.py | 12 +++++++
>  3 files changed, 164 insertions(+)
> 
> diff --git a/ui/host.ui b/ui/host.ui
> index 2e5ea49..66435ff 100644
> --- a/ui/host.ui
> +++ b/ui/host.ui
> @@ -1117,6 +1117,104 @@
>                                      <property name="position">3</property>
>                                    </packing>
>                                  </child>
> +                                <child>
> +                                  <object class="GtkExpander" id="net-sriov-vf-pool-expander">

How about "net-sriov-expander"?

> +                                    <property name="visible">True</property>
> +                                    <property name="can_focus">True</property>
> +                                    <child>
> +                                      <object class="GtkBox" id="vbox19">

I personally don't like this generic "ids".  I'm OK with keeping it like
this but I would prefer better "ids", for example this one could be
"net-sriov-box".

> +                                        <property name="visible">True</property>
> +                                        <property name="can_focus">False</property>
> +                                        <property name="orientation">vertical</property>
> +                                        <property name="spacing">3</property>
> +                                        <child>
> +                                          <object class="GtkGrid" id="table21">

There is no need to use GtkGird, it can be simple GtkBox.

> +                                            <property name="visible">True</property>
> +                                            <property name="can_focus">False</property>
> +                                            <property name="row_spacing">5</property>
> +                                            <property name="column_spacing">6</property>
> +                                            <child>
> +                                              <object class="GtkLabel" id="pf_name">
> +                                                <property name="visible">True</property>
> +                                                <property name="can_focus">False</property>
> +                                                <property name="halign">start</property>
> +                                                <property name="label">label</property>
> +                                                <property name="selectable">True</property>
> +                                              </object>
> +                                              <packing>
> +                                                <property name="left_attach">1</property>
> +                                                <property name="top_attach">0</property>
> +                                              </packing>
> +                                            </child>
> +                                            <child>
> +                                              <object class="GtkLabel" id="label80">
> +                                                <property name="visible">True</property>
> +                                                <property name="can_focus">False</property>
> +                                                <property name="halign">start</property>
> +                                                <property name="label" translatable="yes">Physical Function:</property>
> +                                              </object>
> +                                              <packing>
> +                                                <property name="left_attach">0</property>
> +                                                <property name="top_attach">0</property>
> +                                              </packing>
> +                                            </child>
> +                                          </object>
> +                                          <packing>
> +                                            <property name="position">0</property>
> +                                          </packing>
> +                                        </child>
> +                                        <child>
> +                                          <object class="GtkLabel" id="label83">
> +                                            <property name="visible">True</property>
> +                                            <property name="can_focus">False</property>
> +                                            <property name="halign">start</property>
> +                                            <property name="label" translatable="yes">Virtual Functions:</property>
> +                                            <property name="use_markup">True</property>
> +                                          </object>
> +                                          <packing>
> +                                            <property name="position">1</property>
> +                                          </packing>
> +                                        </child>
> +                                        <child>
> +                                          <object class="GtkScrolledWindow" id="vf-scroll">
> +                                            <property name="visible">True</property>
> +                                            <property name="can_focus">True</property>
> +                                            <property name="shadow_type">in</property>
> +                                            <property name="height_request">144</property>
> +                                            <child>
> +                                              <object class="GtkTreeView" id="vf-list">
> +                                                <property name="visible">True</property>
> +                                                <property name="can_focus">True</property>
> +                                                <child internal-child="selection">
> +                                                  <object class="GtkTreeSelection" id="treeview-selection"/>
> +                                                </child>
> +                                              </object>
> +                                            </child>
> +                                          </object>
> +                                          <packing>
> +                                            <property name="expand">True</property>
> +                                            <property name="fill">True</property>
> +                                            <property name="position">2</property>
> +                                          </packing>
> +                                        </child>
> +                                      </object>
> +                                    </child>
> +                                    <child type="label">
> +                                      <object class="GtkLabel" id="label67">
> +                                        <property name="visible">True</property>
> +                                        <property name="can_focus">False</property>
> +                                        <property name="label" translatable="yes"><b>_VF pool information</b></property>

How about "SR-IOV information"?

> +                                        <property name="use_markup">True</property>
> +                                        <property name="use_underline">True</property>
> +                                      </object>
> +                                    </child>
> +                                  </object>
> +                                  <packing>
> +                                    <property name="expand">True</property>
> +                                    <property name="fill">True</property>
> +                                    <property name="position">4</property>
> +                                  </packing>
> +                                </child>
>                                </object>
>                              </child>
>                            </object>
> diff --git a/virtManager/host.py b/virtManager/host.py
> index 84e8865..eceae51 100644
> --- a/virtManager/host.py
> +++ b/virtManager/host.py
> @@ -167,6 +167,42 @@ class vmmHost(vmmGObjectUI):
>          self.widget("net-list").append_column(netCol)
>          netListModel.set_sort_column_id(1, Gtk.SortType.ASCENDING)
>  
> +        # Virtual Function list
> +        # [type, domain, bus, slot, function]
> +        vf_list = self.widget("vf-list")
> +        vf_list_model = Gtk.ListStore(str, str, str, str, str)
> +        vf_list.set_model(vf_list_model)
> +
> +        vfTypeCol = Gtk.TreeViewColumn(_("Type"))
> +        vf_txt1 = Gtk.CellRendererText()
> +        vfTypeCol.pack_start(vf_txt1, True)
> +        vfTypeCol.add_attribute(vf_txt1, 'text', 0)
> +        vf_list.append_column(vfTypeCol)
> +
> +        vfDomainCol = Gtk.TreeViewColumn(_("Domain"))
> +        vf_txt2 = Gtk.CellRendererText()
> +        vfDomainCol.pack_start(vf_txt2, False)
> +        vfDomainCol.add_attribute(vf_txt2, 'text', 1)
> +        vf_list.append_column(vfDomainCol)
> +
> +        vfBusCol = Gtk.TreeViewColumn(_("Bus"))
> +        vf_txt3 = Gtk.CellRendererText()
> +        vfBusCol.pack_start(vf_txt3, False)
> +        vfBusCol.add_attribute(vf_txt3, 'text', 2)
> +        vf_list.append_column(vfBusCol)
> +
> +        vfSlotCol = Gtk.TreeViewColumn(_("Slot"))
> +        vf_txt4 = Gtk.CellRendererText()
> +        vfSlotCol.pack_start(vf_txt4, False)
> +        vfSlotCol.add_attribute(vf_txt4, 'text', 3)
> +        vf_list.append_column(vfSlotCol)
> +
> +        vfFunctionCol = Gtk.TreeViewColumn(_("Function"))
> +        vf_txt5 = Gtk.CellRendererText()
> +        vfFunctionCol.pack_start(vf_txt5, False)
> +        vfFunctionCol.add_attribute(vf_txt5, 'text', 4)
> +        vf_list.append_column(vfFunctionCol)

I wouldn't model the TreeView as [Type, Domain, Bus, Slot, Function].
The address will always be a PCI address since SR-IOV is a PCI specific
feature.

Since the Physical function is described only with interface name, for
example "eth0" we should model the Virtual functions the same way, so
it should be "eth0_0", "eth0_1", ... .

Libvirt gives us back only PCI address of the Virtual function, so we
need to dig through the information about node devices like we do 
for PCI host devices in _populate_host_device_model().

The resulting list would be without any header line so the code above
can be dropped and [1] ...

> +
>      def init_storage_state(self):
>          self.storagelist = vmmStorageList(self.conn, self.builder, self.topwin)
>          self.widget("storage-align").add(self.storagelist.top_box)
> @@ -398,6 +434,7 @@ class vmmHost(vmmGObjectUI):
>              return
>  
>          logging.debug("Stopping network '%s'", net.get_name())
> +        self.widget("vf-list").get_model().clear()
>          vmmAsyncJob.simple_async_noshow(net.stop, [], self,
>                              _("Error stopping network '%s'") % net.get_name())
>  
> @@ -613,6 +650,22 @@ class vmmHost(vmmGObjectUI):
>          self.widget("qos-outbound-peak").set_text(qos.outbound_peak or "")
>          self.widget("qos-outbound-burst").set_text(qos.outbound_burst or "")
>  
> +    def _populate_sriov_vf_pool_state(self, net):
> +        (is_vf_pool, pf_name, addresses) = net.get_sriov_vf_pool_network()
> +
> +        self.widget("net-sriov-vf-pool-expander").set_visible(is_vf_pool)
> +        if not pf_name:
> +            self.widget("pf_name").set_text("N/A")
> +            return
> +
> +        self.widget("pf_name").set_text(pf_name)
> +
> +        self.widget("vf-list").get_model().clear()
> +        vf_list_model = self.widget("vf-list").get_model()
> +        for addr in addresses:
> +            vf_list_model.append([addr.type, addr.domain, addr.bus, addr.slot,
> +                                  addr.function])

... [1] in this function we get the list of PCI addresses and based on
the address we can get the interface name.  I'll update the patch
and send it to the list so you can try it out whether you agree with
the changes.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20171003/08788b1c/attachment.sig>


More information about the virt-tools-list mailing list