[PATCH 00/11] RFC: refactor internal driver architecture

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently we have a bit of a craz setup for activating
drivers for virConnectPtr. We iterate over the primary
hypervisor drivers until one matches and activates. This
bit is fine.

Then we do the same for the network, storage, interface,
etc secondary drivers. This is where the fun starts.

In the case of the stateless drivers that run outside
of libvirtd, they always want the secondary drivers to
match the primary driver. Unfortunately if they don't
register any dummy secondary driver they'll get given
the reomte driver instead. The probing of secondary
drivers is really unhelpful here.

In the case of stateful drivers that run inside of
libvirtd, there is (almost) always only one driver instance
that they want to work with. So at best the probing of
secondary drivers is a waste of time. With the increasing
feature set though we're getting tight dependancies from
the hypervisor driver to the secondary driver. eg QEMU
depends on the specific network driver we have because it
calls various internal APIs it exposes.

We also have circular dependancy problems during libvirtd
startup:

  https://www.redhat.com/archives/libvir-list/2014-January/msg01143.html

There the storage driver needs a virConnectPtr instance in
order to talk to the secret driver. At the same time the
storage driver must run before the hypervisor driver because
the hypervisor driver needs to use it for autostart of VMs.
This is a horrible mess.

The solution I think is to remove the concept of probing for
secondary drivers entirely.  Instead I suggest creating a

  struct virDriver {
     ...
  }

which contains a pointer to virHypervisorDriver,
virNetworkDriver, virInterfaceDriver, etc. now virConnectPtr
will only reference the single virDriverPtr and when we open
a hypervisor driver, we immediately get a full set of APIs
for everything. This way all the hypervisor drivers will
always know exactly what secondary driver they are working
with.

We'll be able to remove all the xxxPrivateData elements from
the virConnectPtr. The stateless drivers can just access the
main privateData. The stateful drivers can avoid any use of
privateData at all - just access their global static variable
with the driverState.

This won't quite solve the circular dependancy problem in that
mail thread above. By removing the directly reliance on the
virConnectPtr driver table though, we'll be able to update the
code more easily so it can fetch secrets directly and thus the
storage driver wont need to do virConnectOpen("qemu:///system").

The patches that follow illustrate the first part of cleaning
up use of the xxxPrivateData fields. This isn't complete but
I wanted to show the direction it would go before I spend the
time todo the full job.

Incidentally our code is buggy as hell when it comes to using
the xxxPrivateData fields. The PHyp driver actually abuses the
networkPrivateData field for all its APIs.  Alot of code wil
directly access the global state driver state already ignoring
the privateData fields already. So they are really more pain
than they are worth and leading to buggy code.

Daniel P. Berrange (11):
  Clean up remote driver connection open code
  Update remote driver to always use privateData
  Update ESX driver to always use privateData
  Update Hyper-V driver to always use privateData
  Move phyp internal info out of the header file
  Remove abuse of networkPrivateData in phyp driver
  Update Parallels driver to always use privateData
  Update Test driver to always use privateData
  Remove use of storagePrivateData from storage driver
  Remove use of networkPrivateData from network driver
  Remove use of networkPrivateData from netcf driver

 src/esx/esx_device_monitor.c            |   6 +-
 src/esx/esx_interface_driver.c          |  16 +-
 src/esx/esx_network_driver.c            |  20 +-
 src/esx/esx_nwfilter_driver.c           |   6 +-
 src/esx/esx_secret_driver.c             |   6 +-
 src/esx/esx_storage_backend_iscsi.c     |  26 +-
 src/esx/esx_storage_backend_vmfs.c      |  36 +--
 src/esx/esx_storage_driver.c            |  44 ++--
 src/hyperv/hyperv_device_monitor.c      |   6 +-
 src/hyperv/hyperv_interface_driver.c    |   6 +-
 src/hyperv/hyperv_network_driver.c      |   6 +-
 src/hyperv/hyperv_nwfilter_driver.c     |   6 +-
 src/hyperv/hyperv_secret_driver.c       |   6 +-
 src/hyperv/hyperv_storage_driver.c      |   6 +-
 src/interface/interface_backend_netcf.c |  71 ++----
 src/network/bridge_driver.c             | 435 ++++++++++++++------------------
 src/parallels/parallels_network.c       |   2 -
 src/parallels/parallels_storage.c       |  12 +-
 src/parallels/parallels_utils.h         |   1 +
 src/phyp/phyp_driver.c                  | 225 ++++++++---------
 src/phyp/phyp_driver.h                  |  53 ----
 src/remote/remote_driver.c              | 153 +++--------
 src/rpc/gendispatch.pl                  |  28 +-
 src/storage/storage_driver.c            | 194 +++++++-------
 src/test/test_driver.c                  |  24 +-
 25 files changed, 537 insertions(+), 857 deletions(-)

-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux