mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: Set domain def transient at beginning of startup process
This will allow us to record transient runtime state in vm->def, like default VNC parameters. Accomplish this by adding an extra 'live' parameter to SetDefTransient, with similar semantics to the 'live' flag for AssignDef.
This commit is contained in:
parent
125978fe3b
commit
cb4c2694f1
@ -1016,17 +1016,22 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
|
||||
*
|
||||
* @param caps pointer to capabilities info
|
||||
* @param domain domain object pointer
|
||||
* @param live if true, run this operation even for an inactive domain.
|
||||
* this allows freely updated domain->def with runtime defaults before
|
||||
* starting the VM, which will be discarded on VM shutdown. Any cleanup
|
||||
* paths need to be sure to handle newDef if the domain is never started.
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
int
|
||||
virDomainObjSetDefTransient(virCapsPtr caps,
|
||||
virDomainObjPtr domain)
|
||||
virDomainObjPtr domain,
|
||||
bool live)
|
||||
{
|
||||
int ret = -1;
|
||||
char *xml = NULL;
|
||||
virDomainDefPtr newDef = NULL;
|
||||
|
||||
if (!virDomainObjIsActive(domain))
|
||||
if (!virDomainObjIsActive(domain) && !live)
|
||||
return 0;
|
||||
|
||||
if (!domain->persistent)
|
||||
@ -1061,7 +1066,7 @@ virDomainDefPtr
|
||||
virDomainObjGetPersistentDef(virCapsPtr caps,
|
||||
virDomainObjPtr domain)
|
||||
{
|
||||
if (virDomainObjSetDefTransient(caps, domain) < 0)
|
||||
if (virDomainObjSetDefTransient(caps, domain, false) < 0)
|
||||
return NULL;
|
||||
|
||||
if (domain->newDef)
|
||||
|
@ -1139,7 +1139,8 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
|
||||
const virDomainDefPtr def,
|
||||
bool live);
|
||||
int virDomainObjSetDefTransient(virCapsPtr caps,
|
||||
virDomainObjPtr domain);
|
||||
virDomainObjPtr domain,
|
||||
bool live);
|
||||
virDomainDefPtr
|
||||
virDomainObjGetPersistentDef(virCapsPtr caps,
|
||||
virDomainObjPtr domain);
|
||||
|
@ -1555,7 +1555,7 @@ static int lxcVmStart(virConnectPtr conn,
|
||||
if (virDomainSaveConfig(driver->stateDir, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm) < 0)
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
rc = 0;
|
||||
|
@ -2633,6 +2633,14 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Do this upfront, so any part of the startup process can add
|
||||
* runtime state to vm->def that won't be persisted. This let's us
|
||||
* report implicit runtime defaults in the XML, like vnc listen/socket
|
||||
*/
|
||||
DEBUG0("Setting current domain def as transient");
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm, true) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Must be run before security labelling */
|
||||
DEBUG0("Preparing host devices");
|
||||
if (qemuPrepareHostDevices(driver, vm->def) < 0)
|
||||
@ -2923,11 +2931,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Do this last, since it depends on domain being active */
|
||||
DEBUG0("Setting running domain def as transient");
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
virCommandFree(cmd);
|
||||
VIR_FORCE_CLOSE(logfile);
|
||||
|
||||
|
@ -487,7 +487,7 @@ testDomainStartState(virConnectPtr conn,
|
||||
dom->state = VIR_DOMAIN_RUNNING;
|
||||
dom->def->id = privconn->nextDomID++;
|
||||
|
||||
if (virDomainObjSetDefTransient(privconn->caps, dom) < 0) {
|
||||
if (virDomainObjSetDefTransient(privconn->caps, dom, false) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -887,7 +887,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virDomainObjSetDefTransient(driver->caps, vm);
|
||||
ret = virDomainObjSetDefTransient(driver->caps, vm, false);
|
||||
cleanup:
|
||||
virCommandFree(cmd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user