mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
conf: Separate helper for creating domain objects
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.
This commit is contained in:
parent
121cde4726
commit
61e43ce9df
@ -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) {
|
||||
|
@ -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),
|
||||
|
@ -204,6 +204,7 @@ virDomainDefMaybeAddController;
|
||||
virDomainDefMaybeAddInput;
|
||||
virDomainDefNeedsPlacementAdvice;
|
||||
virDomainDefNew;
|
||||
virDomainDefNewFull;
|
||||
virDomainDefParseFile;
|
||||
virDomainDefParseNode;
|
||||
virDomainDefParseString;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user