[PATCH] Removed function virDomainDefNewFull.

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

 



The function virDomainDefNewFull() in src/conf/domain_conf.c was a thin
wrapper around virDomainDefNew() that was only used in a few places in
the code. The function was removed and the callers were re-implemented.
---
 src/conf/domain_conf.c   | 22 ----------------------
 src/conf/domain_conf.h   |  3 ---
 src/libvirt_private.syms |  1 -
 src/vz/vz_utils.c        |  8 +++++++-
 src/xen/xen_hypervisor.c | 26 ++++++++++++++++++--------
 src/xen/xend_internal.c  | 23 +++++++++++++++++++----
 src/xen/xm_internal.c    | 24 ++++++++++++++++++++++--
 7 files changed, 66 insertions(+), 41 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fb05bf7..5721800 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2754,28 +2754,6 @@ virDomainDefNew(void)
 }
 
 
-virDomainDefPtr
-virDomainDefNewFull(const char *name,
-                    const unsigned char *uuid,
-                    int id)
-{
-    virDomainDefPtr def;
-
-    if (!(def = virDomainDefNew()))
-        return NULL;
-
-    if (VIR_STRDUP(def->name, name) < 0) {
-        VIR_FREE(def);
-        return NULL;
-    }
-
-    memcpy(def->uuid, uuid, VIR_UUID_BUFLEN);
-    def->id = id;
-
-    return def;
-}
-
-
 void virDomainObjAssignDef(virDomainObjPtr domain,
                            virDomainDefPtr def,
                            bool live,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 82e581b..afb722c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2507,9 +2507,6 @@ void virDomainDefFree(virDomainDefPtr vm);
 virDomainChrDefPtr virDomainChrDefNew(void);
 
 virDomainDefPtr virDomainDefNew(void);
-virDomainDefPtr virDomainDefNewFull(const char *name,
-                                    const unsigned char *uuid,
-                                    int id);
 
 void virDomainObjAssignDef(virDomainObjPtr domain,
                            virDomainDefPtr def,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fb5b419..1a09a95 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -234,7 +234,6 @@ virDomainDefMaybeAddController;
 virDomainDefMaybeAddInput;
 virDomainDefNeedsPlacementAdvice;
 virDomainDefNew;
-virDomainDefNewFull;
 virDomainDefParseFile;
 virDomainDefParseNode;
 virDomainDefParseString;
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 5427314..0e98a39 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -166,9 +166,15 @@ vzNewDomain(vzDriverPtr driver, const char *name, const unsigned char *uuid)
     virDomainObjPtr dom = NULL;
     vzDomObjPtr pdom = NULL;
 
-    if (!(def = virDomainDefNewFull(name, uuid, -1)))
+    if (!(def = virDomainDefNew()))
         goto error;
 
+    if (VIR_STRDUP(def->name, name) < 0)
+        goto error;
+
+    memcpy(def->uuid, uuid, VIR_UUID_BUFLEN);
+    def->id = -1;
+
     if (VIR_ALLOC(pdom) < 0)
         goto error;
 
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index fc9e1c6..1b9d2e1 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2634,10 +2634,15 @@ xenHypervisorLookupDomainByID(virConnectPtr conn, int id)
     if (!name)
         return NULL;
 
-    ret = virDomainDefNewFull(name,
-                              XEN_GETDOMAININFO_UUID(dominfo),
-                              id);
-    VIR_FREE(name);
+    if (!(ret = virDomainDefNew())) {
+        VIR_FREE(name);
+        return NULL;
+    }
+
+    ret->name = name;
+    memcpy(ret->uuid, XEN_GETDOMAININFO_UUID(dominfo), VIR_UUID_BUFLEN);
+    ret->id = id;
+
     return ret;
 }
 
@@ -2699,10 +2704,15 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (!name)
         return NULL;
 
-    ret = virDomainDefNewFull(name, uuid, id);
-    if (ret)
-        ret->id = id;
-    VIR_FREE(name);
+    if (!(ret = virDomainDefNew())) {
+        VIR_FREE(name);
+        return NULL;
+    }
+
+    ret->name = name;
+    memcpy(ret->uuid, uuid, VIR_UUID_BUFLEN);
+    ret->id = id;
+
     return ret;
 }
 
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 4dd6b41..2ba5459 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1111,12 +1111,21 @@ sexpr_to_domain(virConnectPtr conn ATTRIBUTE_UNUSED, const struct sexpr *root)
     if (sexpr_node(root, "domain/domid"))
         id = sexpr_int(root, "domain/domid");
 
-    return virDomainDefNewFull(name, uuid, id);
+    if (!(ret = virDomainDefNew()))
+        goto error;
+
+    if (VIR_STRDUP(ret->name, name) < 0)
+        goto error;
+
+    memcpy(def->uuid, uuid, VIR_UUID_BUFLEN);
+    def->id = id;
+
+    return ret;
 
  error:
     virReportError(VIR_ERR_INTERNAL_ERROR,
                    "%s", _("failed to parse Xend domain information"));
-    virObjectUnref(ret);
+    virDomainDevFree(ret);
     return NULL;
 }
 
@@ -2003,9 +2012,15 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (name == NULL)
         return NULL;
 
-    ret = virDomainDefNewFull(name, uuid, id);
+    if (!(ret = virDomainDefNew())) {
+        VIR_FREE(name);
+        return NULL;
+    }
+
+    ret->name = name;
+    memcpy(ret->uuid, uuid, VIR_UUID_BUFLEN);
+    ret->id = id;
 
-    VIR_FREE(name);
     return ret;
 }
 
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index ef1a460..ca4577f 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -848,7 +848,17 @@ xenXMDomainLookupByName(virConnectPtr conn, const char *domname)
     if (!(entry = virHashLookup(priv->configCache, filename)))
         goto cleanup;
 
-    ret = virDomainDefNewFull(domname, entry->def->uuid, -1);
+    if (!(ret = virDomainDefNew()))
+        goto cleanup;
+
+    if (VIR_STRDUP(ret->name, domname) < 0) {
+        virDomainDevFree(ret);
+        ret = NULL;
+        goto cleanup;
+    }
+
+    memcpy(def->uuid, entry->def->uuid, VIR_UUID_BUFLEN);
+    def->id = -1;
 
  cleanup:
     xenUnifiedUnlock(priv);
@@ -891,7 +901,17 @@ xenXMDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (!(entry = virHashSearch(priv->configCache, xenXMDomainSearchForUUID, (const void *)uuid)))
         goto cleanup;
 
-    ret = virDomainDefNewFull(entry->def->name, uuid, -1);
+    if (!(ret = virDomainDefNew()))
+        goto cleanup;
+
+    if (VIR_STRDUP(ret->name, entry->def->name) < 0) {
+        virDomainDevFree(ret);
+        ret = NULL;
+        goto cleanup;
+    }
+
+    memcpy(def->uuid, uuid, VIR_UUID_BUFLEN);
+    def->id = -1;
 
  cleanup:
     xenUnifiedUnlock(priv);
-- 
2.5.5

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