mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
conf: Allocate domain definition with the new helper
Use the virDomainDefNew() helper to allocate the definition instead of doing it via VIR_ALLOC.
This commit is contained in:
parent
61e43ce9df
commit
c03411199e
@ -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))
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user