]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Allocate domain definition with the new helper
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Feb 2015 15:30:11 +0000 (16:30 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Feb 2015 16:43:05 +0000 (17:43 +0100)
Use the virDomainDefNew() helper to allocate the definition instead of
doing it via VIR_ALLOC.

13 files changed:
src/conf/domain_conf.c
src/lxc/lxc_native.c
src/openvz/openvz_conf.c
src/parallels/parallels_sdk.c
src/phyp/phyp_driver.c
src/qemu/qemu_command.c
src/vbox/vbox_common.c
src/vmx/vmx.c
src/xenconfig/xen_sxpr.c
src/xenconfig/xen_xl.c
src/xenconfig/xen_xm.c
tests/openvzutilstest.c
tests/securityselinuxtest.c

index dc8cd3a9838d2e414e00d559da6d648e7bc19397..724221069d670942fb877d6c95ea0fa241c40035 100644 (file)
@@ -12910,7 +12910,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         VIR_FREE(schema);
     }
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         return NULL;
 
     if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
index cd3b86b03f88e260fd774343495e45f46442c1ce..99613afb90f62d35a9a28f52a25f7e894e1e5304 100644 (file)
@@ -1002,7 +1002,7 @@ lxcParseConfigString(const char *config)
     if (!(properties = virConfReadMem(config, 0, VIR_CONF_FLAG_LXC_FORMAT)))
         return NULL;
 
-    if (VIR_ALLOC(vmdef) < 0)
+    if (!(vmdef = virDomainDefNew()))
         goto error;
 
     if (virUUIDGenerate(vmdef->uuid) < 0) {
index f955ddaa0bc6463125cfc9dbb4398c3ec786de7d..848e230b6365eafc9b853f5f63f6a841ab48ad48 100644 (file)
@@ -543,7 +543,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
         }
         *line++ = '\0';
 
-        if (VIR_ALLOC(def) < 0)
+        if (!(def = virDomainDefNew()))
             goto cleanup;
 
         def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
index ef15c7de2fc36a2ebcb861d5134466d0643200b2..fb1f724ced1c271a4adff124bad2648d4e9437f3 100644 (file)
@@ -1186,7 +1186,7 @@ prlsdkLoadDomain(parallelsConnPtr privconn,
     virCheckNonNullArgGoto(privconn, error);
     virCheckNonNullArgGoto(sdkdom, error);
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto error;
 
     if (!olddom) {
index d05f897679c328027e1f42cc43bd3dfd636af12d..d69e29c20acc79bfc7aad068ca83264509ed8880 100644 (file)
@@ -1708,7 +1708,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *domain_name = NULL;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto cleanup;
 
     domain_name = escape_specialcharacters(domain->name);
index b6ef66d3b9d3dcf02cfb2936fab2564c8e6d2141..0e4cef94e5678071a872c33fd4a0d28e2396dda8 100644 (file)
@@ -11870,7 +11870,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
         return NULL;
     }
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto error;
 
     /* allocate the cmdlinedef up-front; if it's unused, we'll free it later */
index deca49084fd74f832effb86c736773b169a48da9..55d362455d57a7bc98dbfd6df9996a1f7da364b2 100644 (file)
@@ -3860,7 +3860,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
     if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
         goto cleanup;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto cleanup;
 
     gVBoxAPI.UIMachine.GetAccessible(machine, &accessible);
@@ -4114,7 +4114,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
         return ret;
 
     VBOX_IID_INITIALIZE(&iid);
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         return ret;
 
     if (VIR_STRDUP(def->os.type, "hvm") < 0)
@@ -4246,7 +4246,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml)
         return ret;
 
     VBOX_IID_INITIALIZE(&iid);
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         return ret;
 
     if (VIR_STRDUP(def->os.type, "hvm") < 0)
@@ -6032,7 +6032,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
     if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
         goto cleanup;
 
-    if (VIR_ALLOC(def) < 0 || VIR_ALLOC(def->dom) < 0)
+    if (VIR_ALLOC(def) < 0 || !(def->dom = virDomainDefNew()))
         goto cleanup;
     if (VIR_STRDUP(def->name, snapshot->name) < 0)
         goto cleanup;
index 2a794c7fe3ab49ab3cc7654d5e584584e43b25e1..ac2542ad7b1911b7e382d5341753400970216828 100644 (file)
@@ -1298,7 +1298,7 @@ virVMXParseConfig(virVMXContext *ctx,
     }
 
     /* Allocate domain def */
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto cleanup;
 
     def->virtType = VIR_DOMAIN_VIRT_VMWARE;
index 554d28fdb5b796b5576fc83d9c3fc464d5695729..3e18a7e0c2b88b5200c6082ef7dfb66d12ffd31b 100644 (file)
@@ -1093,7 +1093,7 @@ xenParseSxpr(const struct sexpr *root,
     virDomainDefPtr def;
     int hvm = 0, vmlocaltime;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto error;
 
     tmp = sexpr_node(root, "domain/domid");
index 7913118fa7307e069fc14b203c5f157dc29cfa9a..95ef5f45e84b6ad0502be83e9fffc20d8a2d6b74 100644 (file)
@@ -295,7 +295,7 @@ xenParseXL(virConfPtr conf, virCapsPtr caps, int xendConfigVersion)
 {
     virDomainDefPtr def = NULL;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         return NULL;
 
     def->virtType = VIR_DOMAIN_VIRT_XEN;
index 1e57e2488ee8ab336cd520a4cc275a72fa2aca6a..2f57cd265c1dd184b899e97725198999b6e6df2f 100644 (file)
@@ -375,7 +375,7 @@ xenParseXM(virConfPtr conf,
 {
     virDomainDefPtr def = NULL;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         return NULL;
 
     def->virtType = VIR_DOMAIN_VIRT_XEN;
index 5f8735956b9949c59ff121bbce084e3eed0322e1..f9d10020a55a4083798aa307f56226ae97eb7ff3 100644 (file)
@@ -102,7 +102,7 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
         "  </devices>\n"
         "</domain>\n";
 
-    if (VIR_ALLOC(def) < 0 ||
+    if (!(def = virDomainDefNew()) ||
         VIR_STRDUP(def->os.type, "exe") < 0 ||
         VIR_STRDUP(def->os.init, "/sbin/init") < 0)
         goto cleanup;
index 3b5c3e5547299deb72f7c4219fea8de88c4797d0..38ab70e6ac8e22868ca69d2b46118349c0d048be 100644 (file)
@@ -70,7 +70,7 @@ testBuildDomainDef(bool dynamic,
     virDomainDefPtr def;
     virSecurityLabelDefPtr secdef;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainDefNew()))
         goto error;
 
     if (VIR_ALLOC_N(def->seclabels, 1) < 0)