mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +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);
|
VIR_FREE(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
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)))
|
if (!(properties = virConfReadMem(config, 0, VIR_CONF_FLAG_LXC_FORMAT)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(vmdef) < 0)
|
if (!(vmdef = virDomainDefNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (virUUIDGenerate(vmdef->uuid) < 0) {
|
if (virUUIDGenerate(vmdef->uuid) < 0) {
|
||||||
|
@ -543,7 +543,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
|
|||||||
}
|
}
|
||||||
*line++ = '\0';
|
*line++ = '\0';
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
|
def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
|
||||||
|
@ -1186,7 +1186,7 @@ prlsdkLoadDomain(parallelsConnPtr privconn,
|
|||||||
virCheckNonNullArgGoto(privconn, error);
|
virCheckNonNullArgGoto(privconn, error);
|
||||||
virCheckNonNullArgGoto(sdkdom, error);
|
virCheckNonNullArgGoto(sdkdom, error);
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!olddom) {
|
if (!olddom) {
|
||||||
|
@ -1708,7 +1708,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
|
|||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *domain_name = NULL;
|
char *domain_name = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
domain_name = escape_specialcharacters(domain->name);
|
domain_name = escape_specialcharacters(domain->name);
|
||||||
|
@ -11870,7 +11870,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* allocate the cmdlinedef up-front; if it's unused, we'll free it later */
|
/* 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)
|
if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
gVBoxAPI.UIMachine.GetAccessible(machine, &accessible);
|
gVBoxAPI.UIMachine.GetAccessible(machine, &accessible);
|
||||||
@ -4114,7 +4114,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
VBOX_IID_INITIALIZE(&iid);
|
VBOX_IID_INITIALIZE(&iid);
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (VIR_STRDUP(def->os.type, "hvm") < 0)
|
if (VIR_STRDUP(def->os.type, "hvm") < 0)
|
||||||
@ -4246,7 +4246,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
VBOX_IID_INITIALIZE(&iid);
|
VBOX_IID_INITIALIZE(&iid);
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (VIR_STRDUP(def->os.type, "hvm") < 0)
|
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)))
|
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0 || VIR_ALLOC(def->dom) < 0)
|
if (VIR_ALLOC(def) < 0 || !(def->dom = virDomainDefNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (VIR_STRDUP(def->name, snapshot->name) < 0)
|
if (VIR_STRDUP(def->name, snapshot->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1298,7 +1298,7 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate domain def */
|
/* Allocate domain def */
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
def->virtType = VIR_DOMAIN_VIRT_VMWARE;
|
def->virtType = VIR_DOMAIN_VIRT_VMWARE;
|
||||||
|
@ -1093,7 +1093,7 @@ xenParseSxpr(const struct sexpr *root,
|
|||||||
virDomainDefPtr def;
|
virDomainDefPtr def;
|
||||||
int hvm = 0, vmlocaltime;
|
int hvm = 0, vmlocaltime;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
tmp = sexpr_node(root, "domain/domid");
|
tmp = sexpr_node(root, "domain/domid");
|
||||||
|
@ -295,7 +295,7 @@ xenParseXL(virConfPtr conf, virCapsPtr caps, int xendConfigVersion)
|
|||||||
{
|
{
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
def->virtType = VIR_DOMAIN_VIRT_XEN;
|
def->virtType = VIR_DOMAIN_VIRT_XEN;
|
||||||
|
@ -375,7 +375,7 @@ xenParseXM(virConfPtr conf,
|
|||||||
{
|
{
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
def->virtType = VIR_DOMAIN_VIRT_XEN;
|
def->virtType = VIR_DOMAIN_VIRT_XEN;
|
||||||
|
@ -102,7 +102,7 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
|
|||||||
" </devices>\n"
|
" </devices>\n"
|
||||||
"</domain>\n";
|
"</domain>\n";
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0 ||
|
if (!(def = virDomainDefNew()) ||
|
||||||
VIR_STRDUP(def->os.type, "exe") < 0 ||
|
VIR_STRDUP(def->os.type, "exe") < 0 ||
|
||||||
VIR_STRDUP(def->os.init, "/sbin/init") < 0)
|
VIR_STRDUP(def->os.init, "/sbin/init") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -70,7 +70,7 @@ testBuildDomainDef(bool dynamic,
|
|||||||
virDomainDefPtr def;
|
virDomainDefPtr def;
|
||||||
virSecurityLabelDefPtr secdef;
|
virSecurityLabelDefPtr secdef;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (!(def = virDomainDefNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->seclabels, 1) < 0)
|
if (VIR_ALLOC_N(def->seclabels, 1) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user