virtManager: Remove virInterface polling

There are no more users of interface objects in the code. Remove
all the polling support, and all the remaining references to
interface objects throughout the code base

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-01-25 20:28:43 -05:00
parent 212c5f813d
commit d410773af8
20 changed files with 8 additions and 401 deletions

View File

@ -1,20 +0,0 @@
<interface type="bond" name="test-bond-arp">
<bond>
<interface type="ethernet" name="eth0">
<start mode="none"/>
<mac address="00:FF:EE:FF:EE:FF"/>
</interface>
<interface type="ethernet" name="eth1">
<mac address="00:FF:EE:FF:EE:AB"/>
</interface>
<interface type="ethernet" name="eth2">
<start mode="hotplug"/>
<mac address="00:FF:EE:FF:EE:CD"/>
</interface>
<arpmon interval="100" target="192.168.100.200" validate="backup"/>
</bond>
<start mode="onboot"/>
<mac address="AA:AA:AA:AA:AA:AA"/>
<mtu size="1501"/>
<protocol family="ipv4"/>
</interface>

View File

@ -1,20 +0,0 @@
<interface type="bond" name="test-bond-mii">
<bond>
<interface type="ethernet" name="eth0">
<start mode="none"/>
<mac address="00:FF:EE:FF:EE:FF"/>
</interface>
<interface type="ethernet" name="eth1">
<mac address="00:FF:EE:FF:EE:AB"/>
</interface>
<interface type="ethernet" name="eth2">
<start mode="hotplug"/>
<mac address="00:FF:EE:FF:EE:CD"/>
</interface>
<miimon freq="123" downdelay="34" updelay="12" carrier="netif"/>
</bond>
<start mode="onboot"/>
<mac address="AA:AA:AA:AA:AA:AA"/>
<mtu size="1501"/>
<protocol family="ipv4"/>
</interface>

View File

@ -1,19 +0,0 @@
<interface type="bond" name="test-bond">
<bond>
<interface type="ethernet" name="eth0">
<start mode="none"/>
<mac address="00:FF:EE:FF:EE:FF"/>
</interface>
<interface type="ethernet" name="eth1">
<mac address="00:FF:EE:FF:EE:AB"/>
</interface>
<interface type="ethernet" name="eth2">
<start mode="hotplug"/>
<mac address="00:FF:EE:FF:EE:CD"/>
</interface>
</bond>
<start mode="onboot"/>
<mac address="AA:AA:AA:AA:AA:AA"/>
<mtu size="1501"/>
<protocol family="ipv4"/>
</interface>

View File

@ -1,38 +0,0 @@
<interface type="bridge" name="test-bridge-ip">
<bridge>
<interface type="ethernet" name="vlaneth1">
</interface>
<interface type="bond" name="bond-brbond">
<start mode="none"/>
<protocol family="ipv6">
<ip address="3ffe:ffff:0:5::1" prefix="128"/>
<ip address="3ffe:ffff:0:5::3" prefix="128"/>
<ip address="3ffe:ffff:0:5::5" prefix="128"/>
</protocol>
<bond mode="active-backup">
<miimon freq="100" updelay="10" carrier="ioctl"/>
<interface type="ethernet" name="brbond-eth0">
</interface>
<interface type="ethernet" name="brbond-eth1">
</interface>
</bond>
</interface>
<interface type="ethernet" name="eth0">
<start mode="none"/>
<mac address="00:FF:EE:FF:EE:FF"/>
</interface>
</bridge>
<protocol family="ipv4">
<dhcp peerdns="yes"/>
<ip address="129.63.1.2"/>
<ip address="255.255.255.0"/>
<route gateway="1.2.3.4"/>
</protocol>
<protocol family="ipv6">
<autoconf/>
<dhcp peerdns="yes"/>
<ip address="fe99::215:58ff:fe6e:5" prefix="32"/>
<ip address="fe80::215:58ff:fe6e:5" prefix="64"/>
<route gateway="1.2.3.4"/>
</protocol>
</interface>

View File

@ -1,25 +0,0 @@
<interface type="bridge" name="test-bridge">
<bridge stp="off" delay="7">
<interface type="ethernet" name="vlaneth1">
</interface>
<interface type="bond" name="bond-brbond">
<start mode="none"/>
<protocol family="ipv6">
<ip address="3ffe:ffff:0:5::1" prefix="128"/>
<ip address="3ffe:ffff:0:5::3" prefix="128"/>
<ip address="3ffe:ffff:0:5::5" prefix="128"/>
</protocol>
<bond mode="active-backup">
<miimon freq="100" updelay="10" carrier="ioctl"/>
<interface type="ethernet" name="brbond-eth0">
</interface>
<interface type="ethernet" name="brbond-eth1">
</interface>
</bond>
</interface>
<interface type="ethernet" name="eth0">
<start mode="none"/>
<mac address="00:FF:EE:FF:EE:FF"/>
</interface>
</bridge>
</interface>

View File

@ -1,5 +0,0 @@
<interface type="ethernet" name="test-ethernet-copy-proto">
<protocol family="ipv6">
<dhcp/>
</protocol>
</interface>

View File

@ -1,4 +0,0 @@
<interface type="ethernet" name="test-ethernet-params">
<start mode="hotplug"/>
<mtu size="1234"/>
</interface>

View File

@ -1 +0,0 @@
<interface type="ethernet" name="test-ethernet"/>

View File

@ -1,5 +0,0 @@
<interface type="vlan" name="test-vlan">
<vlan tag="123">
<interface name="eth2"/>
</vlan>
</interface>

View File

@ -1,32 +0,0 @@
# Copyright (C) 2013 Red Hat, Inc.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
import unittest
from virtinst import Interface
from tests import utils
datadir = "tests/interface-xml"
class TestInterfaces(unittest.TestCase):
def testInterfaceBridgeIP(self):
conn = utils.URIs.open_testdriver_cached()
def _check_iface(name, typ, child_names):
libvirtobj = conn.interfaceLookupByName(name)
xmlobj = Interface(conn, parsexml=libvirtobj.XMLDesc(0))
self.assertEqual(xmlobj.name, name)
self.assertEqual(xmlobj.type, typ)
self.assertEqual(
{i.name for i in xmlobj.interfaces},
set(child_names))
_check_iface("eth0", "ethernet", [])
_check_iface("bond0", "bond", ["eth-bond0-1", "eth-bond0-2"])
_check_iface("brplain", "bridge", ["eth-brplain0", "eth-brplain1"])
_check_iface("brempty", "bridge", [])
_check_iface("vlaneth1.3", "vlan", ["vlaneth1"])

View File

@ -3610,77 +3610,4 @@ ba</description>
</device>
<!-- ########## -->
<!-- Interfaces -->
<!-- ########## -->
<interface type='ethernet' name='eth0'>
<start mode='none'/>
<mac address='00:FF:EE:FF:EE:FF'/>
</interface>
<interface type='ethernet' name='eth1'>
<mac address='00:FF:EE:FF:EE:AB'/>
</interface>
<interface type='ethernet' name='wlan0'>
<start mode='none'/>
<mac address='00:AA:CC:BB:AA:BB'/>
</interface>
<!-- bond example -->
<interface type="ethernet" name="eth-bond0-1"/>
<interface type="ethernet" name="eth-bond0-2"/>
<interface type="bond" name="bond0">
<start mode="none"/>
<protocol family="ipv4">
<ip address="192.168.50.7" prefix="24"/>
<route gateway="192.168.50.1"/>
</protocol>
<bond mode="active-backup">
<miimon freq="100" updelay="10" carrier="ioctl"/>
<interface type="ethernet" name="eth-bond0-1"/>
<interface type="ethernet" name="eth-bond0-2"/>
</bond>
</interface>
<!-- Plain bridge -->
<interface type="ethernet" name="eth-brplain0"/>
<interface type="ethernet" name="eth-brplain1"/>
<interface type="bridge" name="brplain">
<start mode="onboot"/>
<mtu size="1500"/>
<bridge stp="off">
<interface type="ethernet" name="eth-brplain0"/>
<interface type="ethernet" name="eth-brplain1"/>
</bridge>
</interface>
<!-- Empty bridge -->
<interface type="bridge" name="brempty">
<start mode="onboot"/>
<mtu size="1500"/>
<bridge stp="off"/>
<protocol family='ipv4'>
<dhcp/>
</protocol>
<protocol family='ipv6'>
<autoconf/>
<dhcp/>
</protocol>
</interface>
<!-- vlan example -->
<interface type="ethernet" name="vlaneth1"/>
<interface type="vlan" name="vlaneth1.3">
<start mode="onboot"/>
<vlan tag="43">
<interface name="vlaneth1"/>
</vlan>
</interface>
</node>

View File

@ -131,7 +131,7 @@ class vmmAddHardware(vmmGObjectUI):
self.topwin.set_transient_for(parent)
self.topwin.present()
self.conn.schedule_priority_tick(pollnet=True,
pollpool=True, polliface=True,
pollpool=True,
pollnodedev=True)
def close(self, ignore1=None, ignore2=None):

View File

@ -19,7 +19,6 @@ from .lib import connectauth
from .baseclass import vmmGObject
from .lib.libvirtenummap import LibvirtEnumMap
from .object.domain import vmmDomain
from .object.interface import vmmInterface
from .object.network import vmmNetwork
from .object.nodedev import vmmNodeDevice
from .object.storagepool import vmmStoragePool
@ -148,8 +147,6 @@ class vmmConnection(vmmGObject):
"net-removed": (vmmGObject.RUN_FIRST, None, [str]),
"pool-added": (vmmGObject.RUN_FIRST, None, [str]),
"pool-removed": (vmmGObject.RUN_FIRST, None, [str]),
"interface-added": (vmmGObject.RUN_FIRST, None, [str]),
"interface-removed": (vmmGObject.RUN_FIRST, None, [str]),
"nodedev-added": (vmmGObject.RUN_FIRST, None, [str]),
"nodedev-removed": (vmmGObject.RUN_FIRST, None, [str]),
"resources-sampled": (vmmGObject.RUN_FIRST, None, []),
@ -533,11 +530,6 @@ class vmmConnection(vmmGObject):
def list_pools(self):
return self._objects.get_objects_for_class(vmmStoragePool)
def get_interface(self, connkey):
return self._objects.lookup_object(vmmInterface, connkey)
def list_interfaces(self):
return self._objects.get_objects_for_class(vmmInterface)
def get_nodedev(self, connkey):
return self._objects.lookup_object(vmmNodeDevice, connkey)
def list_nodedevs(self):
@ -958,8 +950,6 @@ class vmmConnection(vmmGObject):
log.debug("Connection doesn't seem to support storage APIs.")
if not self.support.conn_network():
log.debug("Connection doesn't seem to support network APIs.")
if not self.support.conn_interface():
log.debug("Connection doesn't seem to support interface APIs.")
if not self.support.conn_nodedev():
log.debug("Connection doesn't seem to support nodedev APIs.")
@ -983,8 +973,8 @@ class vmmConnection(vmmGObject):
self.schedule_priority_tick(stats_update=True,
pollvm=True, pollnet=True,
pollpool=True, polliface=True,
pollnodedev=True, force=True, initial_poll=True)
pollpool=True, pollnodedev=True,
force=True, initial_poll=True)
self._init_object_event.wait()
self._init_object_event = None
@ -1027,8 +1017,6 @@ class vmmConnection(vmmGObject):
self.emit("net-removed", obj.get_connkey())
elif obj.is_pool():
self.emit("pool-removed", obj.get_connkey())
elif obj.is_interface():
self.emit("interface-removed", obj.get_connkey())
elif obj.is_nodedev():
self.emit("nodedev-removed", obj.get_connkey())
@ -1090,8 +1078,6 @@ class vmmConnection(vmmGObject):
self.emit("net-added", obj.get_connkey())
elif obj.is_pool():
self.emit("pool-added", obj.get_connkey())
elif obj.is_interface():
self.emit("interface-added", obj.get_connkey())
elif obj.is_nodedev():
self.emit("nodedev-added", obj.get_connkey())
finally:
@ -1112,12 +1098,6 @@ class vmmConnection(vmmGObject):
return vmmStoragePool(self, obj, key)
return pollhelpers.fetch_pools(self._backend, keymap, cb)
def _update_interfaces(self):
keymap = dict((o.get_connkey(), o) for o in self.list_interfaces())
def cb(obj, key):
return vmmInterface(self, obj, key)
return pollhelpers.fetch_interfaces(self._backend, keymap, cb)
def _update_nodedevs(self):
keymap = dict((o.get_connkey(), o) for o in self.list_nodedevs())
def cb(obj, key):
@ -1131,7 +1111,7 @@ class vmmConnection(vmmGObject):
return pollhelpers.fetch_vms(self._backend, keymap, cb)
def _poll(self, initial_poll,
pollvm, pollnet, pollpool, polliface, pollnodedev):
pollvm, pollnet, pollpool, pollnodedev):
"""
Helper called from tick() to do necessary polling and return
the relevant object lists
@ -1156,7 +1136,6 @@ class vmmConnection(vmmGObject):
new_vms = _process_objects(self._update_vms, pollvm)
new_nets = _process_objects(self._update_nets, pollnet)
new_pools = _process_objects(self._update_pools, pollpool)
new_ifaces = _process_objects(self._update_interfaces, polliface)
new_nodedevs = _process_objects(self._update_nodedevs, pollnodedev)
# Kick off one thread per object type to handle the initial
@ -1172,8 +1151,7 @@ class vmmConnection(vmmGObject):
# is never called and the event is never set, so let's do it here
self._init_object_event.set()
for newlist in [new_vms, new_nets, new_pools,
new_ifaces, new_nodedevs]:
for newlist in [new_vms, new_nets, new_pools, new_nodedevs]:
if not newlist:
continue
@ -1190,8 +1168,7 @@ class vmmConnection(vmmGObject):
def _tick(self, stats_update=False,
pollvm=False, pollnet=False,
pollpool=False, polliface=False,
pollnodedev=False,
pollpool=False, pollnodedev=False,
force=False, initial_poll=False):
"""
main update function: polls for new objects, updates stats, ...
@ -1225,7 +1202,7 @@ class vmmConnection(vmmGObject):
self.statsmanager.cache_all_stats(self)
gone_objects, preexisting_objects = self._poll(
initial_poll, pollvm, pollnet, pollpool, polliface, pollnodedev)
initial_poll, pollvm, pollnet, pollpool, pollnodedev)
self.idle_add(self._gone_object_signals, gone_objects)
# Only tick() pre-existing objects, since new objects will be
@ -1240,8 +1217,6 @@ class vmmConnection(vmmGObject):
continue
elif obj.is_pool() and not pollpool:
continue
elif obj.is_interface() and not polliface:
continue
elif obj.is_nodedev() and not pollnodedev:
continue

View File

@ -514,7 +514,7 @@ class vmmCreateVM(vmmGObjectUI):
Update all state that has some dependency on the current connection
"""
self.conn.schedule_priority_tick(pollnet=True,
pollpool=True, polliface=True,
pollpool=True,
pollnodedev=True)
self.widget("install-box").show()

View File

@ -1,50 +0,0 @@
# Copyright (C) 2009, 2013 Red Hat, Inc.
# Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
from virtinst import Interface
from .libvirtobject import vmmLibvirtObject
class vmmInterface(vmmLibvirtObject):
def __init__(self, conn, backend, key):
vmmLibvirtObject.__init__(self, conn, backend, key, Interface)
##########################
# Required class methods #
##########################
# Routines from vmmLibvirtObject
def _conn_tick_poll_param(self):
return "polliface"
def class_name(self):
return "interface"
def _XMLDesc(self, flags):
return self._backend.XMLDesc(flags)
def _get_backend_status(self):
# The libvirt object can be active or inactive, but our code
# doesn't care.
return True
def tick(self, stats_update=True):
ignore = stats_update
self._refresh_status()
def _init_libvirt_state(self):
self.tick()
################
# XML routines #
################
def is_bridge(self):
return self.get_xmlobj().type == "bridge"
def get_interface_names(self):
return [obj.name for obj in self.get_xmlobj().interfaces]

View File

@ -105,8 +105,6 @@ class vmmLibvirtObject(vmmGObject):
return self.class_name() == "pool"
def is_nodedev(self):
return self.class_name() == "nodedev"
def is_interface(self):
return self.class_name() == "interface"
def change_name_backend(self, newbackend):
# Used for changing the backing object after a rename

View File

@ -50,7 +50,6 @@ from virtinst.domain import * # pylint: disable=wildcard-import
from virtinst.capabilities import Capabilities
from virtinst.domcapabilities import DomainCapabilities
from virtinst.interface import Interface
from virtinst.network import Network
from virtinst.nodedev import NodeDevice
from virtinst.storage import StoragePool, StorageVolume

View File

@ -1,64 +0,0 @@
#
# Copyright 2009, 2013 Red Hat, Inc.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
"""
Classes for building and installing libvirt interface xml
"""
from .xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
class _BondConfig(XMLBuilder):
XML_NAME = "bond"
class _BridgeConfig(XMLBuilder):
XML_NAME = "bridge"
class _VLANConfig(XMLBuilder):
XML_NAME = "vlan"
class Interface(XMLBuilder):
"""
Base class for parsing any libvirt virInterface object XML
"""
XML_NAME = "interface"
_XML_PROP_ORDER = ["type", "name", "_bond", "_bridge", "_vlan"]
######################
# Interface handling #
######################
# The recursive nature of nested interfaces complicates things here,
# which is why this is strange. See bottom of the file for more
# weirdness
_bond = XMLChildProperty(_BondConfig, is_single=True)
_bridge = XMLChildProperty(_BridgeConfig, is_single=True)
_vlan = XMLChildProperty(_VLANConfig, is_single=True)
@property
def interfaces(self):
if self.type != "ethernet":
return getattr(self, "_" + self.type).interfaces
return []
##################
# General params #
##################
type = XMLProperty("./@type")
name = XMLProperty("./@name")
# Interface can recursively have child interfaces which we can't define
# inline in the class config, hence this hackery
_BondConfig.interfaces = XMLChildProperty(Interface)
_BridgeConfig.interfaces = XMLChildProperty(Interface)
_VLANConfig.interfaces = XMLChildProperty(Interface)

View File

@ -58,13 +58,6 @@ def fetch_volumes(backend, pool, origmap, build_cb):
return _new_poll_helper(origmap, name, list_cb, build_cb, support_cb)
def fetch_interfaces(backend, origmap, build_cb):
name = "interface"
list_cb = backend.listAllInterfaces
support_cb = backend.support.conn_interface
return _new_poll_helper(origmap, name, list_cb, build_cb, support_cb)
def fetch_nodedevs(backend, origmap, build_cb):
name = "nodedev"
list_cb = backend.listAllDevices

View File

@ -235,8 +235,6 @@ class SupportCache:
function="virConnect.listDevices", run_args=(None, 0))
conn_network = _make(
function="virConnect.listNetworks", run_args=())
conn_interface = _make(
function="virConnect.listInterfaces", run_args=())
conn_stream = _make(function="virConnect.newStream", run_args=(0,))
conn_working_xen_events = _make(hv_version={"xen": "4.0.0", "all": 0})