Re: [PATCH v2] add func to set shared drivers after libvirtd init

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

 




On 07.04.2016 19:28, Maxim Nestratov wrote:
19.11.2015 15:22, Mikhail Feoktistov пишет:
Diff from v1:
Remove vz prefix from the title of this letter. Because this is the common case
for all drivers in libvirt.

Description:
Built-in drivers in libvirt are initialized before libvirtd initialization.
Libvirt loads shared drivers on libvirtd initialization step.
For built-in drivers we can't set shared drivers, because they are not initialized yet.
This patch adds function to set shared drivers after libvirtd init.
---
  daemon/libvirtd.c        |  4 ++++
src/libvirt.c | 41 +++++++++++++++++++++++++++++++++++++++++
  src/libvirt_internal.h   |  1 +
  src/libvirt_private.syms |  1 +
  4 files changed, 47 insertions(+)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 250094b..aac1826 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -431,6 +431,10 @@ static void daemonInitialize(void)
      bhyveRegister();
  # endif
  #endif
+# ifdef WITH_VZ
+    virAssignSharedDrivers("vz");
+    virAssignSharedDrivers("Parallels");
+# endif
  }
    diff --git a/src/libvirt.c b/src/libvirt.c
index 25a0040..1763be7 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1433,3 +1433,44 @@ virTypedParameterValidateSet(virConnectPtr conn,
      }
      return 0;
  }
+
+/**
+ * virAssignSharedDrivers:
+ * @name: name of connection driver
+ *
+ * This function fills in any empty pointers for shared drivers
+ * in connect driver structure
+ *
+ * Returns 0 in case of success, -1 in case of error
+*/
+int
+virAssignSharedDrivers(const char *name)
+{
+    size_t i;
+
+    if (name == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Driver name must be specified"));
+        return -1;
+    }
+
+    for (i = 0; i < virConnectDriverTabCount; i++) {
+ if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, name)) {
+            if (virConnectDriverTab[i]->interfaceDriver == NULL)
+ virConnectDriverTab[i]->interfaceDriver = virSharedInterfaceDriver;
+            if (virConnectDriverTab[i]->networkDriver == NULL)
+ virConnectDriverTab[i]->networkDriver = virSharedNetworkDriver;
+            if (virConnectDriverTab[i]->nodeDeviceDriver == NULL)
+ virConnectDriverTab[i]->nodeDeviceDriver = virSharedNodeDeviceDriver;
+            if (virConnectDriverTab[i]->nwfilterDriver == NULL)
+ virConnectDriverTab[i]->nwfilterDriver = virSharedNWFilterDriver;
+            if (virConnectDriverTab[i]->secretDriver == NULL)
+ virConnectDriverTab[i]->secretDriver = virSharedSecretDriver;
+            if (virConnectDriverTab[i]->storageDriver == NULL)
+ virConnectDriverTab[i]->storageDriver = virSharedStorageDriver;
+            break;
+       }
+    }
+
+    return 0;
+}
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 1313b58..2a7227b 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -289,4 +289,5 @@ virTypedParameterValidateSet(virConnectPtr conn,
                               virTypedParameterPtr params,
                               int nparams);
  +int virAssignSharedDrivers(const char *name);
  #endif
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a835f18..a0fcdf5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -943,6 +943,7 @@ virFDStreamSetInternalCloseCb;
      # libvirt_internal.h
+virAssignSharedDrivers;
  virConnectSupportsFeature;
  virDomainMigrateBegin3;
  virDomainMigrateBegin3Params;

It looks like this patch is not necessary anymore as far as changes proposed in the series [1] seem to be the better way to use shared drivers.

Maxim

[1] https://www.redhat.com/archives/libvir-list/2016-March/msg01357.html
I agree. Please, do not push this patch.

--
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]