mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-05 00:13:48 +00:00
qemu: driver: Use 'qemuDomainSaveStatus' for saving status XML
We've got multiple random open-coded versions. Switch to the helper function which doesn't report errors as they'd be mostly wrong as the operation was indeed successful. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a640237b53
commit
effeee5c2f
@ -1869,8 +1869,7 @@ static int qemuDomainSuspend(virDomainPtr dom)
|
|||||||
if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0)
|
if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
@ -1927,8 +1926,7 @@ static int qemuDomainResume(virDomainPtr dom)
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
@ -2522,8 +2520,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
|
|||||||
}
|
}
|
||||||
|
|
||||||
def->memballoon->period = period;
|
def->memballoon->period = period;
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
@ -3621,7 +3618,6 @@ processGuestPanicEvent(virQEMUDriver *driver,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
virObjectEvent *event = NULL;
|
virObjectEvent *event = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
bool removeInactive = false;
|
bool removeInactive = false;
|
||||||
unsigned long flags = VIR_DUMP_MEMORY_ONLY;
|
unsigned long flags = VIR_DUMP_MEMORY_ONLY;
|
||||||
|
|
||||||
@ -3646,10 +3642,7 @@ processGuestPanicEvent(virQEMUDriver *driver,
|
|||||||
|
|
||||||
virObjectEventStateQueue(driver->domainEventState, event);
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) {
|
qemuDomainSaveStatus(vm);
|
||||||
VIR_WARN("Unable to save status on vm %s after state change",
|
|
||||||
vm->def->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState) < 0)
|
||||||
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
||||||
@ -3702,7 +3695,6 @@ processDeviceDeletedEvent(virQEMUDriver *driver,
|
|||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
const char *devAlias)
|
const char *devAlias)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
virDomainDeviceDef dev;
|
virDomainDeviceDef dev;
|
||||||
|
|
||||||
VIR_DEBUG("Removing device %s from domain %p %s",
|
VIR_DEBUG("Removing device %s from domain %p %s",
|
||||||
@ -3726,9 +3718,7 @@ processDeviceDeletedEvent(virQEMUDriver *driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
VIR_WARN("unable to save domain status after removing device %s",
|
|
||||||
devAlias);
|
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
@ -4043,7 +4033,6 @@ processSerialChangedEvent(virQEMUDriver *driver,
|
|||||||
const char *devAlias,
|
const char *devAlias,
|
||||||
bool connected)
|
bool connected)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
virDomainChrDeviceState newstate;
|
virDomainChrDeviceState newstate;
|
||||||
virObjectEvent *event = NULL;
|
virObjectEvent *event = NULL;
|
||||||
virDomainDeviceDef dev;
|
virDomainDeviceDef dev;
|
||||||
@ -4094,9 +4083,7 @@ processSerialChangedEvent(virQEMUDriver *driver,
|
|||||||
|
|
||||||
dev.data.chr->state = newstate;
|
dev.data.chr->state = newstate;
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
VIR_WARN("unable to save status of domain %s after updating state of "
|
|
||||||
"channel %s", vm->def->name, devAlias);
|
|
||||||
|
|
||||||
if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0")) {
|
if (STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agent.0")) {
|
||||||
if (newstate == VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
|
if (newstate == VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED) {
|
||||||
@ -4518,7 +4505,6 @@ qemuDomainPinVcpuLive(virDomainObj *vm,
|
|||||||
virDomainDef *def,
|
virDomainDef *def,
|
||||||
int vcpu,
|
int vcpu,
|
||||||
virQEMUDriver *driver,
|
virQEMUDriver *driver,
|
||||||
virQEMUDriverConfig *cfg,
|
|
||||||
virBitmap *cpumap)
|
virBitmap *cpumap)
|
||||||
{
|
{
|
||||||
virBitmap *tmpmap = NULL;
|
virBitmap *tmpmap = NULL;
|
||||||
@ -4570,8 +4556,7 @@ qemuDomainPinVcpuLive(virDomainObj *vm,
|
|||||||
vcpuinfo->cpumask = tmpmap;
|
vcpuinfo->cpumask = tmpmap;
|
||||||
tmpmap = NULL;
|
tmpmap = NULL;
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
|
VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
|
||||||
@ -4644,7 +4629,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (def &&
|
if (def &&
|
||||||
qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap) < 0)
|
qemuDomainPinVcpuLive(vm, def, vcpu, driver, pcpumap) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
@ -4785,8 +4770,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
|||||||
virBitmapFree(def->cputune.emulatorpin);
|
virBitmapFree(def->cputune.emulatorpin);
|
||||||
def->cputune.emulatorpin = virBitmapNewCopy(pcpumap);
|
def->cputune.emulatorpin = virBitmapNewCopy(pcpumap);
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
str = virBitmapFormat(pcpumap);
|
str = virBitmapFormat(pcpumap);
|
||||||
if (virTypedParamsAddString(&eventParams, &eventNparams,
|
if (virTypedParamsAddString(&eventParams, &eventNparams,
|
||||||
@ -5245,8 +5229,7 @@ qemuDomainPinIOThread(virDomainPtr dom,
|
|||||||
if (virProcessSetAffinity(iothrid->thread_id, pcpumap, false) < 0)
|
if (virProcessSetAffinity(iothrid->thread_id, pcpumap, false) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, iothread_id) < 0) {
|
VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, iothread_id) < 0) {
|
||||||
@ -5692,8 +5675,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
@ -7823,8 +7805,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObj *vm,
|
|||||||
* changed even if we failed to attach the device. For example,
|
* changed even if we failed to attach the device. For example,
|
||||||
* a new controller may be created.
|
* a new controller may be created.
|
||||||
*/
|
*/
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, if no error until here, we can save config. */
|
/* Finally, if no error until here, we can save config. */
|
||||||
@ -7962,15 +7943,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
* device we're going to update. */
|
* device we're going to update. */
|
||||||
if ((ret = qemuDomainUpdateDeviceLive(vm, dev_copy, dom, force)) < 0)
|
if ((ret = qemuDomainUpdateDeviceLive(vm, dev_copy, dom, force)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
/*
|
|
||||||
* update domain status forcibly because the domain status may be
|
qemuDomainSaveStatus(vm);
|
||||||
* changed even if we failed to attach the device. For example,
|
|
||||||
* a new controller may be created.
|
|
||||||
*/
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) {
|
|
||||||
ret = -1;
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, if no error until here, we can save config. */
|
/* Finally, if no error until here, we can save config. */
|
||||||
@ -8055,13 +8029,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *driver,
|
|||||||
if (rc == 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
if (rc == 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/*
|
qemuDomainSaveStatus(vm);
|
||||||
* update domain status forcibly because the domain status may be
|
|
||||||
* changed even if we failed to attach the device. For example,
|
|
||||||
* a new controller may be created.
|
|
||||||
*/
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, if no error until here, we can save config. */
|
/* Finally, if no error until here, we can save config. */
|
||||||
@ -8434,9 +8402,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
if (def) {
|
if (def) {
|
||||||
ret = virDomainCgroupSetupDomainBlkioParameters(priv->cgroup, def,
|
ret = virDomainCgroupSetupDomainBlkioParameters(priv->cgroup, def,
|
||||||
params, nparams);
|
params, nparams);
|
||||||
|
qemuDomainSaveStatus(vm);
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -8611,9 +8577,8 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
|
|||||||
params, nparams) < 0)
|
params, nparams) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (def &&
|
if (def)
|
||||||
virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (persistentDef &&
|
if (persistentDef &&
|
||||||
virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0)
|
virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir) < 0)
|
||||||
@ -8874,8 +8839,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
|
|||||||
-1, mode, nodeset) < 0)
|
-1, mode, nodeset) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
@ -9066,8 +9030,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
|
|||||||
VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
|
VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
@ -9518,8 +9481,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (eventNparams) {
|
if (eventNparams) {
|
||||||
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
||||||
@ -10416,8 +10378,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentNet) {
|
if (persistentNet) {
|
||||||
@ -14442,7 +14403,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
{
|
{
|
||||||
virQEMUDriver *driver = dom->conn->privateData;
|
virQEMUDriver *driver = dom->conn->privateData;
|
||||||
virDomainDiskDef *disk = NULL;
|
virDomainDiskDef *disk = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
bool pivot = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT);
|
bool pivot = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT);
|
||||||
bool async = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC);
|
bool async = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC);
|
||||||
g_autoptr(qemuBlockJobData) job = NULL;
|
g_autoptr(qemuBlockJobData) job = NULL;
|
||||||
@ -14506,7 +14466,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
job->state = QEMU_BLOCKJOB_STATE_ABORTING;
|
job->state = QEMU_BLOCKJOB_STATE_ABORTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_value(virDomainObjSave(vm, driver->xmlopt, cfg->stateDir));
|
qemuDomainSaveStatus(vm);
|
||||||
|
|
||||||
if (!async) {
|
if (!async) {
|
||||||
qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
|
qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
|
||||||
@ -16189,8 +16149,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
|
|||||||
|
|
||||||
qemuDomainSetGroupBlockIoTune(def, &info);
|
qemuDomainSetGroupBlockIoTune(def, &info);
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (eventNparams) {
|
if (eventNparams) {
|
||||||
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
|
||||||
@ -19684,8 +19643,7 @@ qemuDomainSetLifecycleAction(virDomainPtr dom,
|
|||||||
|
|
||||||
qemuDomainModifyLifecycleAction(def, type, action);
|
qemuDomainModifyLifecycleAction(def, type, action);
|
||||||
|
|
||||||
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
qemuDomainSaveStatus(vm);
|
||||||
goto endjob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
@ -20223,9 +20181,7 @@ qemuDomainAgentSetResponseTimeout(virDomainPtr dom,
|
|||||||
|
|
||||||
QEMU_DOMAIN_PRIVATE(vm)->agentTimeout = timeout;
|
QEMU_DOMAIN_PRIVATE(vm)->agentTimeout = timeout;
|
||||||
|
|
||||||
if (virDomainObjIsActive(vm) &&
|
qemuDomainSaveStatus(vm);
|
||||||
virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user