]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Separate helper for creating domain objects
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Feb 2015 14:58:13 +0000 (15:58 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Feb 2015 16:43:05 +0000 (17:43 +0100)
Move the existing virDomainDefNew to virDomainDefNewFull as it's setting
a few things in the conf and re-introduce virDomainDefNew as a function
without parameters for common use.

src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms
src/xen/xen_hypervisor.c
src/xen/xend_internal.c
src/xen/xm_internal.c

index e399a3301aa96c784bbfe25ed7e6cbc2635788ef..dc8cd3a9838d2e414e00d559da6d648e7bc19397 100644 (file)
@@ -2314,13 +2314,25 @@ virDomainObjNew(virDomainXMLOptionPtr xmlopt)
 }
 
 
-virDomainDefPtr virDomainDefNew(const char *name,
-                                const unsigned char *uuid,
-                                int id)
+virDomainDefPtr
+virDomainDefNew(void)
+{
+    virDomainDefPtr ret;
+
+    ignore_value(VIR_ALLOC(ret));
+
+    return ret;
+}
+
+
+virDomainDefPtr
+virDomainDefNewFull(const char *name,
+                    const unsigned char *uuid,
+                    int id)
 {
     virDomainDefPtr def;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         return NULL;
 
     if (VIR_STRDUP(def->name, name) < 0) {
index 1e048869352c5f9fe2f2e759a35a29e16a5f0f33..86db2ab9df3c817e8b8a425e365b6fe71335192c 100644 (file)
@@ -2414,9 +2414,10 @@ void virDomainDefFree(virDomainDefPtr vm);
 
 virDomainChrDefPtr virDomainChrDefNew(void);
 
-virDomainDefPtr virDomainDefNew(const char *name,
-                                const unsigned char *uuid,
-                                int id);
+virDomainDefPtr virDomainDefNew(void);
+virDomainDefPtr virDomainDefNewFull(const char *name,
+                                    const unsigned char *uuid,
+                                    int id);
 
 enum {
     VIR_DOMAIN_OBJ_LIST_ADD_LIVE = (1 << 0),
index a7465ce610e59ae25bf17831bc55ef8d5b5b7471..b145c8b921efb22dc2130df950fdce719d4b5ec0 100644 (file)
@@ -204,6 +204,7 @@ virDomainDefMaybeAddController;
 virDomainDefMaybeAddInput;
 virDomainDefNeedsPlacementAdvice;
 virDomainDefNew;
+virDomainDefNewFull;
 virDomainDefParseFile;
 virDomainDefParseNode;
 virDomainDefParseString;
index 31a2a1b6ad71ad4ac5fea52cc44a2bc534de18ca..bc498ff91f5255f133d3d2a02ba3d43ab2ba01a7 100644 (file)
@@ -2634,9 +2634,9 @@ xenHypervisorLookupDomainByID(virConnectPtr conn, int id)
     if (!name)
         return NULL;
 
-    ret = virDomainDefNew(name,
-                          XEN_GETDOMAININFO_UUID(dominfo),
-                          id);
+    ret = virDomainDefNewFull(name,
+                              XEN_GETDOMAININFO_UUID(dominfo),
+                              id);
     VIR_FREE(name);
     return ret;
 }
@@ -2699,7 +2699,7 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (!name)
         return NULL;
 
-    ret = virDomainDefNew(name, uuid, id);
+    ret = virDomainDefNewFull(name, uuid, id);
     if (ret)
         ret->id = id;
     VIR_FREE(name);
index c2b90981e98b8270932192488ed5329071b24666..ab03c1c158243ac9a85b1591ee2bfd5c7ad6ff38 100644 (file)
@@ -1152,7 +1152,7 @@ sexpr_to_domain(virConnectPtr conn, const struct sexpr *root)
     if (tmp)
         id = sexpr_int(root, "domain/domid");
 
-    return virDomainDefNew(name, uuid, id);
+    return virDomainDefNewFull(name, uuid, id);
 
  error:
     virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2117,7 +2117,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (name == NULL)
         return NULL;
 
-    ret = virDomainDefNew(name, uuid, id);
+    ret = virDomainDefNewFull(name, uuid, id);
 
     VIR_FREE(name);
     return ret;
index dc6f88a94dd90420ca3d01f60c054110b2983046..354ab3f9de28a0bdfdcccbfd38cb71c7d582e641 100644 (file)
@@ -844,7 +844,7 @@ xenXMDomainLookupByName(virConnectPtr conn, const char *domname)
     if (!(entry = virHashLookup(priv->configCache, filename)))
         goto cleanup;
 
-    ret = virDomainDefNew(domname, entry->def->uuid, -1);
+    ret = virDomainDefNewFull(domname, entry->def->uuid, -1);
 
  cleanup:
     xenUnifiedUnlock(priv);
@@ -887,7 +887,7 @@ xenXMDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (!(entry = virHashSearch(priv->configCache, xenXMDomainSearchForUUID, (const void *)uuid)))
         goto cleanup;
 
-    ret = virDomainDefNew(entry->def->name, uuid, -1);
+    ret = virDomainDefNewFull(entry->def->name, uuid, -1);
 
  cleanup:
     xenUnifiedUnlock(priv);