[PATCH 13/36] virclosecallbacks: Remove old close callbacks code

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

 



Now that all code was refactored to use the new version we can remove
the old code.

For now the new close callbacks code has no error messages so
syntax-check forced me to remove the POTFILES entry for
virclosecallbacks.c

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 po/POTFILES                        |   1 -
 src/hypervisor/virclosecallbacks.c | 282 -----------------------------
 src/hypervisor/virclosecallbacks.h |  27 ---
 src/libvirt_private.syms           |   5 -
 4 files changed, 315 deletions(-)

diff --git a/po/POTFILES b/po/POTFILES
index 169e2a41dc..b2297be84e 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -91,7 +91,6 @@ src/hyperv/hyperv_util.c
 src/hyperv/hyperv_wmi.c
 src/hypervisor/domain_cgroup.c
 src/hypervisor/domain_driver.c
-src/hypervisor/virclosecallbacks.c
 src/hypervisor/virhostdev.c
 src/interface/interface_backend_netcf.c
 src/interface/interface_backend_udev.c
diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/virclosecallbacks.c
index 21b97cce12..4fad4c8288 100644
--- a/src/hypervisor/virclosecallbacks.c
+++ b/src/hypervisor/virclosecallbacks.c
@@ -29,288 +29,6 @@

 VIR_LOG_INIT("util.closecallbacks");

-typedef struct _virDriverCloseDef virDriverCloseDef;
-struct _virDriverCloseDef {
-    virConnectPtr conn;
-    virCloseCallback cb;
-};
-
-struct _virCloseCallbacks {
-    virObjectLockable parent;
-
-    /* UUID string to qemuDriverCloseDef mapping */
-    GHashTable *list;
-};
-
-
-static virClass *virCloseCallbacksClass;
-static void virCloseCallbacksDispose(void *obj);
-
-static int virCloseCallbacksOnceInit(void)
-{
-    if (!VIR_CLASS_NEW(virCloseCallbacks, virClassForObjectLockable()))
-        return -1;
-
-    return 0;
-}
-
-VIR_ONCE_GLOBAL_INIT(virCloseCallbacks);
-
-
-virCloseCallbacks *
-virCloseCallbacksNew(void)
-{
-    virCloseCallbacks *closeCallbacks;
-
-    if (virCloseCallbacksInitialize() < 0)
-        return NULL;
-
-    if (!(closeCallbacks = virObjectLockableNew(virCloseCallbacksClass)))
-        return NULL;
-
-    closeCallbacks->list = virHashNew(g_free);
-
-    return closeCallbacks;
-}
-
-static void
-virCloseCallbacksDispose(void *obj)
-{
-    virCloseCallbacks *closeCallbacks = obj;
-
-    g_clear_pointer(&closeCallbacks->list, g_hash_table_unref);
-}
-
-int
-virCloseCallbacksSet(virCloseCallbacks *closeCallbacks,
-                     virDomainObj *vm,
-                     virConnectPtr conn,
-                     virCloseCallback cb)
-{
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virDriverCloseDef *closeDef;
-    int ret = -1;
-
-    virUUIDFormat(vm->def->uuid, uuidstr);
-    VIR_DEBUG("vm=%s, uuid=%s, conn=%p, cb=%p",
-              vm->def->name, uuidstr, conn, cb);
-
-    virObjectLock(closeCallbacks);
-
-    closeDef = virHashLookup(closeCallbacks->list, uuidstr);
-    if (closeDef) {
-        if (closeDef->conn != conn) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Close callback for domain %s already registered"
-                             " with another connection %p"),
-                           vm->def->name, closeDef->conn);
-            goto cleanup;
-        }
-        if (closeDef->cb && closeDef->cb != cb) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Another close callback is already defined for"
-                             " domain %s"), vm->def->name);
-            goto cleanup;
-        }
-
-        closeDef->cb = cb;
-    } else {
-        closeDef = g_new0(virDriverCloseDef, 1);
-        closeDef->conn = conn;
-        closeDef->cb = cb;
-        if (virHashAddEntry(closeCallbacks->list, uuidstr, closeDef) < 0) {
-            VIR_FREE(closeDef);
-            goto cleanup;
-        }
-        virObjectRef(vm);
-    }
-
-    virObjectRef(closeCallbacks);
-    ret = 0;
- cleanup:
-    virObjectUnlock(closeCallbacks);
-    return ret;
-}
-
-int
-virCloseCallbacksUnset(virCloseCallbacks *closeCallbacks,
-                       virDomainObj *vm,
-                       virCloseCallback cb)
-{
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virDriverCloseDef *closeDef;
-    int ret = -1;
-
-    virUUIDFormat(vm->def->uuid, uuidstr);
-    VIR_DEBUG("vm=%s, uuid=%s, cb=%p",
-              vm->def->name, uuidstr, cb);
-
-    virObjectLock(closeCallbacks);
-
-    closeDef = virHashLookup(closeCallbacks->list, uuidstr);
-    if (!closeDef)
-        goto cleanup;
-
-    if (closeDef->cb && closeDef->cb != cb) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Trying to remove mismatching close callback for"
-                         " domain %s"), vm->def->name);
-        goto cleanup;
-    }
-
-    if (virHashRemoveEntry(closeCallbacks->list, uuidstr) < 0)
-        goto cleanup;
-
-    virObjectUnref(vm);
-    ret = 0;
- cleanup:
-    virObjectUnlock(closeCallbacks);
-    if (!ret)
-        virObjectUnref(closeCallbacks);
-    return ret;
-}
-
-virCloseCallback
-virCloseCallbacksGet(virCloseCallbacks *closeCallbacks,
-                     virDomainObj *vm,
-                     virConnectPtr conn)
-{
-    char uuidstr[VIR_UUID_STRING_BUFLEN];
-    virDriverCloseDef *closeDef;
-    virCloseCallback cb = NULL;
-
-    virUUIDFormat(vm->def->uuid, uuidstr);
-    VIR_DEBUG("vm=%s, uuid=%s, conn=%p",
-              vm->def->name, uuidstr, conn);
-
-    virObjectLock(closeCallbacks);
-
-    closeDef = virHashLookup(closeCallbacks->list, uuidstr);
-    if (closeDef && (!conn || closeDef->conn == conn))
-        cb = closeDef->cb;
-
-    virObjectUnlock(closeCallbacks);
-
-    VIR_DEBUG("cb=%p", cb);
-    return cb;
-}
-
-typedef struct _virCloseCallbacksListEntry virCloseCallbacksListEntry;
-struct _virCloseCallbacksListEntry {
-    unsigned char uuid[VIR_UUID_BUFLEN];
-    virCloseCallback callback;
-};
-
-typedef struct _virCloseCallbacksList virCloseCallbacksList;
-struct _virCloseCallbacksList {
-    size_t nentries;
-    virCloseCallbacksListEntry *entries;
-};
-
-struct virCloseCallbacksData {
-    virConnectPtr conn;
-    virCloseCallbacksList *list;
-};
-
-static int
-virCloseCallbacksGetOne(void *payload,
-                        const char *key,
-                        void *opaque)
-{
-    struct virCloseCallbacksData *data = opaque;
-    virDriverCloseDef *closeDef = payload;
-    const char *uuidstr = key;
-    unsigned char uuid[VIR_UUID_BUFLEN];
-
-    if (virUUIDParse(uuidstr, uuid) < 0)
-        return 0;
-
-    VIR_DEBUG("conn=%p, thisconn=%p, uuid=%s, cb=%p",
-              closeDef->conn, data->conn, uuidstr, closeDef->cb);
-
-    if (data->conn != closeDef->conn || !closeDef->cb)
-        return 0;
-
-    VIR_EXPAND_N(data->list->entries, data->list->nentries, 1);
-
-    memcpy(data->list->entries[data->list->nentries - 1].uuid,
-           uuid, VIR_UUID_BUFLEN);
-    data->list->entries[data->list->nentries - 1].callback = closeDef->cb;
-    return 0;
-}
-
-static virCloseCallbacksList *
-virCloseCallbacksGetForConn(virCloseCallbacks *closeCallbacks,
-                            virConnectPtr conn)
-{
-    virCloseCallbacksList *list = NULL;
-    struct virCloseCallbacksData data;
-
-    list = g_new0(virCloseCallbacksList, 1);
-
-    data.conn = conn;
-    data.list = list;
-
-    virHashForEach(closeCallbacks->list, virCloseCallbacksGetOne, &data);
-
-    return list;
-}
-
-
-void
-virCloseCallbacksRun(virCloseCallbacks *closeCallbacks,
-                     virConnectPtr conn,
-                     virDomainObjList *domains)
-{
-    virCloseCallbacksList *list;
-    size_t i;
-
-    VIR_DEBUG("conn=%p", conn);
-
-    /* We must not hold the lock while running the callbacks,
-     * so first we obtain the list of callbacks, then remove
-     * them all from the hash. At that point we can release
-     * the lock and run the callbacks safely. */
-
-    virObjectLock(closeCallbacks);
-    list = virCloseCallbacksGetForConn(closeCallbacks, conn);
-    if (!list) {
-        virObjectUnlock(closeCallbacks);
-        return;
-    }
-
-    for (i = 0; i < list->nentries; i++) {
-        char uuidstr[VIR_UUID_STRING_BUFLEN];
-        virUUIDFormat(list->entries[i].uuid, uuidstr);
-        virHashRemoveEntry(closeCallbacks->list, uuidstr);
-    }
-    virObjectUnlock(closeCallbacks);
-
-    for (i = 0; i < list->nentries; i++) {
-        virDomainObj *vm;
-
-        /* Grab a ref and lock to the vm */
-        if (!(vm = virDomainObjListFindByUUID(domains,
-                                              list->entries[i].uuid))) {
-            char uuidstr[VIR_UUID_STRING_BUFLEN];
-            virUUIDFormat(list->entries[i].uuid, uuidstr);
-            VIR_DEBUG("No domain object with UUID %s", uuidstr);
-            continue;
-        }
-
-        /* Remove the ref taken out during virCloseCallbacksSet since
-         * we're about to call the callback function and we have another
-         * ref anyway (so it cannot be deleted).
-         *
-         * Call the callback function and end the API usage. */
-        virObjectUnref(vm);
-        list->entries[i].callback(vm, conn);
-        virDomainObjEndAPI(&vm);
-    }
-    VIR_FREE(list->entries);
-    VIR_FREE(list);
-}
-

 struct _virCloseCallbacksDomainData {
     virConnectPtr conn;
diff --git a/src/hypervisor/virclosecallbacks.h b/src/hypervisor/virclosecallbacks.h
index b471f6b160..893292763f 100644
--- a/src/hypervisor/virclosecallbacks.h
+++ b/src/hypervisor/virclosecallbacks.h
@@ -22,36 +22,9 @@

 #include "conf/virdomainobjlist.h"

-typedef struct _virCloseCallbacks virCloseCallbacks;
-
 typedef void (*virCloseCallback)(virDomainObj *vm,
                                  virConnectPtr conn);

-virCloseCallbacks *
-virCloseCallbacksNew(void);
-
-int
-virCloseCallbacksSet(virCloseCallbacks *closeCallbacks,
-                     virDomainObj *vm,
-                     virConnectPtr conn,
-                     virCloseCallback cb);
-int
-virCloseCallbacksUnset(virCloseCallbacks *closeCallbacks,
-                       virDomainObj *vm,
-                       virCloseCallback cb);
-
-virCloseCallback
-virCloseCallbacksGet(virCloseCallbacks *closeCallbacks,
-                     virDomainObj *vm,
-                     virConnectPtr conn);
-
-void
-virCloseCallbacksRun(virCloseCallbacks *closeCallbacks,
-                     virConnectPtr conn,
-                     virDomainObjList *domains);
-
-/* ---- */
-
 virObject *
 virCloseCallbacksDomainAlloc(void);

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b1fa23729a..b81c2cc7da 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1612,11 +1612,6 @@ virCloseCallbacksDomainAlloc;
 virCloseCallbacksDomainIsRegistered;
 virCloseCallbacksDomainRemove;
 virCloseCallbacksDomainRunForConn;
-virCloseCallbacksGet;
-virCloseCallbacksNew;
-virCloseCallbacksRun;
-virCloseCallbacksSet;
-virCloseCallbacksUnset;


 # hypervisor/virhostdev.h
-- 
2.38.1




[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