conf: refresh network ports missing from network driver on restart
Before the refactoring that properly separated the network driver from the hypervisor driver and forced all interaction to go through public APIs, all network usage counters were zeroed when the network driver was initialized, and the network driver's now-deprecated "semi-private" API networkNotifyActualDevice() was called for every interface of every domain as each hypervisor "reconnected" its domains during a libvirtd restart, and this would refresh the usage count for each network. Post-driver-split, during libvirtd restart/reconnection of the running domains, the function virDomainNetNotifyActualDevice() is called by each hypervisor driver for every interface of every domain restart, and this function has code to re-register interfaces, but it only calls into the network driver to re-register those ports that don't already have a valid portid (ie. one that is not simply all 0), assuming that those with valid portids are already known (and counted) by the network driver. commit 7ab9bdd4 recently modified the network driver so that, in most cases, it properly resyncs each network's connection count during libvirtd (or maybe virtnetworkd) restart by iterating through the network's port list. This doesn't account for the case where a network is destroyed and restarted while there are running domains that have active ports on the network. In that case, the entire port list and connection count for that network is lost, and now even a restart of libvirtd/virtnetworkd/virtqemud, which in the past would resync the connection count, doesn't help (the network driver thinks there are no active ports, while the hypervisor driver knows about all the active ports, but mistakenly believes that the network driver also knows). The solution to this is to not just bypass valid portids during the call to virDomainNetworkNotifyActualDevice(). Instead, we query the network driver about the portid that was preserved in the domain status, and if it is not registered, we register it. (NB: while it would technically be correct to just generate a new portid for these cases, it makes for less churn in portids (and thus may make troubleshooting simpler) if we make the small fix to virDomainNetDefActualToNetworkPort() that preserves existing valid portids rather than unconditionally generating a new one.) Signed-off-by: NLaine Stump <laine@redhat.com> Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Showing
想要评论请 注册 或 登录