Re: [RFC][PATCH 6/7] interface: Implement the driver methods

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

 



On 05/09/2011 03:28 PM, Michal Privoznik wrote:
---
  configure.ac                 |    5 +++++
  src/interface/netcf_driver.c |   36 ++++++++++++++++++++++++++++++++++++
  2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index dcec371..041d738 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1483,6 +1483,11 @@ if test "$with_netcf" = "yes" || test "$with_netcf" = "check"; then
    if test "$with_netcf" = "yes" ; then
      AC_DEFINE_UNQUOTED([WITH_NETCF], 1,
        [whether libnetcf is available to configure physical host network interfaces])
+    AC_CHECK_LIB([netcf], [ncf_change_start], [new_netcf=1], [new_netcf=0])

I've changed the name, as danpb suggested, to "ncf_change_begin".

Also, it might be more future-proof to use something more specific than "new_netcf". Maybe netcf_transactions, or something like that.

+    if test "$new_netcf" = "1" ; then
+        AC_DEFINE_UNQUOTED([HAVE_NCF_CHANGE_START], ["1"],
+          [we have sufficiently new version of netcf for transaction network API])
+    fi
    fi
  fi
  AM_CONDITIONAL([WITH_NETCF], [test "$with_netcf" = "yes"])
diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c
index fc7979c..082c4eb 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/netcf_driver.c
@@ -30,6 +30,7 @@
  #include "netcf_driver.h"
  #include "interface_conf.h"
  #include "memory.h"
+#include "logging.h"

  #define VIR_FROM_THIS VIR_FROM_INTERFACE

@@ -540,6 +541,35 @@ cleanup:
      return ret;
  }

+#ifdef HAVE_NCF_CHANGE_START
+static int interfaceChangeStart(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                unsigned int flags ATTRIBUTE_UNUSED)
+{
+    VIR_DEBUG0("A long time ago in a galaxy far, far away....");
+    /* Nothing here yet */

Actually, you can put the function call in here even before you have a version of netcf that has it. This one will look something like this:

static int interfaceChangeStart(virConnectPtr conn, unsigned int flags)
{
  struct interface_driver *driver = conn->interfacePrivateData;
  int ret;


    virCheckFlags(0, -1); /* currently flags must be 0 */

    interfaceDriverLock(driver);

    ret = ncf_change_begin(driver->netcf, 0);
    if (ret < 0) {
        const char *errmsg, *details;
        int errcode = ncf_error(driver->netcf, &errmsg, &details);
        interfaceReportError(netcf_to_vir_err(errcode),
_("failed to begin transaction (netcf: %s - %s)"),
                            errmsg, details ? details : "");
    }

    interfaceDriverUnlock(driver);
    return ret;
    }

The others are identical except for function name.

+
+    return 0;
+}
+
+static int interfaceChangeCommit(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                 unsigned int flags ATTRIBUTE_UNUSED)
+{
+    VIR_DEBUG0("I am fish");
+    /* Nothing here yet */
+
+    return 0;
+}
+
+static int interfaceChangeRollback(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                   unsigned int flags ATTRIBUTE_UNUSED)
+{
+    VIR_DEBUG0("Hello, IT. Have you tried turning it off and on again?");
+    /* Nothing here yet */
+
+    return 0;
+}
+#endif /* HAVE_NCF_CHANGE_START */
+
  static virInterfaceDriver interfaceDriver = {
      "Interface",
      interfaceOpenInterface,          /* open */
@@ -556,9 +586,15 @@ static virInterfaceDriver interfaceDriver = {
      interfaceCreate,                 /* interfaceCreate */
      interfaceDestroy,                /* interfaceDestroy */
      interfaceIsActive,               /* interfaceIsActive */
+#ifdef HAVE_NCF_CHANGE_START
+    interfaceChangeStart,            /* interfaceChangeStart */
+    interfaceChangeCommit,           /* interfaceChangeCommit */
+    interfaceChangeRollback,         /* interfaceChangeRollback */
+#else
      NULL,                            /* interfaceChangeStart */
      NULL,                            /* interfaceChangeCommit */
      NULL,                            /* interfaceChangeRollback */
+#endif /* HAVE_NCF_CHANGE_START */
  };

  int interfaceRegister(void) {

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