提交 575cf9a9 编写于 作者: J Jiri Denemark

Factor out def assignment to existing domain from virDomainAssignDef

We need to be able to assign new def to an existing virDomainObj which
is already locked. This patch factors out the relevant code from
virDomainAssignDef into virDomainObjAssignDef.
上级 de5a60e1
...@@ -808,6 +808,26 @@ static virDomainObjPtr virDomainObjNew(virCapsPtr caps) ...@@ -808,6 +808,26 @@ static virDomainObjPtr virDomainObjNew(virCapsPtr caps)
return domain; return domain;
} }
void virDomainObjAssignDef(virDomainObjPtr domain,
const virDomainDefPtr def,
bool live)
{
if (!virDomainObjIsActive(domain)) {
if (live) {
/* save current configuration to be restored on domain shutdown */
if (!domain->newDef)
domain->newDef = domain->def;
domain->def = def;
} else {
virDomainDefFree(domain->def);
domain->def = def;
}
} else {
virDomainDefFree(domain->newDef);
domain->newDef = def;
}
}
virDomainObjPtr virDomainAssignDef(virCapsPtr caps, virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virDomainObjListPtr doms, virDomainObjListPtr doms,
const virDomainDefPtr def, const virDomainDefPtr def,
...@@ -817,21 +837,7 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps, ...@@ -817,21 +837,7 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((domain = virDomainFindByUUID(doms, def->uuid))) { if ((domain = virDomainFindByUUID(doms, def->uuid))) {
if (!virDomainObjIsActive(domain)) { virDomainObjAssignDef(domain, def, live);
if (live) {
/* save current configuration to be restored on domain shutdown */
if (!domain->newDef)
domain->newDef = domain->def;
domain->def = def;
} else {
virDomainDefFree(domain->def);
domain->def = def;
}
} else {
virDomainDefFree(domain->newDef);
domain->newDef = def;
}
return domain; return domain;
} }
......
...@@ -954,6 +954,9 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps, ...@@ -954,6 +954,9 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
virDomainObjListPtr doms, virDomainObjListPtr doms,
const virDomainDefPtr def, const virDomainDefPtr def,
bool live); bool live);
void virDomainObjAssignDef(virDomainObjPtr domain,
const virDomainDefPtr def,
bool live);
void virDomainRemoveInactive(virDomainObjListPtr doms, void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainObjPtr dom); virDomainObjPtr dom);
......
...@@ -215,6 +215,7 @@ virDomainSnapshotObjUnref; ...@@ -215,6 +215,7 @@ virDomainSnapshotObjUnref;
virDomainSnapshotDefParseString; virDomainSnapshotDefParseString;
virDomainSnapshotDefFormat; virDomainSnapshotDefFormat;
virDomainSnapshotAssignDef; virDomainSnapshotAssignDef;
virDomainObjAssignDef;
# domain_event.h # domain_event.h
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册