qemu: Don't track quiesced state of FSs

https://bugzilla.redhat.com/show_bug.cgi?id=1160084

As of b6d4dad11b (1.2.5) we are trying to keep the status of FSFreeze
in the guest. Even though I've tried to fixed couple of corner cases
(6ea54769ba), it occurred to me just recently, that the approach is
broken by design. Firstly, there are many other ways to talk to
qemu-ga (even through libvirt) that filesystems can be thawed (e.g.
qemu-agent-command) without libvirt noticing. Moreover, there are
plenty of ways to thaw filesystems without even qemu-ga noticing (yes,
qemu-ga keeps internal track of FSFreeze status). So, instead of
keeping the track ourselves, or asking qemu-ga for stale state, it's
the best to let qemu-ga deal with that (and possibly let guest kernel
propagate an error).

Moreover, there's one bug with the following approach, if fsfreeze
command failed, we've executed fsthaw subsequently. So issuing
domfsfreeze in virsh gave the following result:

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2014-11-27 11:43:56 +01:00
parent 9340528a7f
commit 6085d917d5
4 changed files with 2 additions and 54 deletions

View File

@ -563,9 +563,6 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
virBufferAddLit(buf, "</devices>\n");
}
if (priv->quiesced)
virBufferAddLit(buf, "<quiesced/>\n");
return 0;
}
@ -750,8 +747,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
}
VIR_FREE(nodes);
priv->quiesced = virXPathBoolean("boolean(./quiesced)", ctxt) == 1;
return 0;
error:

View File

@ -187,8 +187,6 @@ struct _qemuDomainObjPrivate {
char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
bool hookRun; /* true if there was a hook run over this domain */
bool quiesced; /* true if filesystems are quiesced */
};
typedef enum {

View File

@ -12704,34 +12704,17 @@ qemuDomainPrepareDiskChainElement(virQEMUDriverPtr driver,
* is sent but failed, and number of frozen filesystems on success. If -2 is
* returned, FSThaw should be called revert the quiesced status. */
static int
qemuDomainSnapshotFSFreeze(virQEMUDriverPtr driver,
qemuDomainSnapshotFSFreeze(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
const char **mountpoints,
unsigned int nmountpoints)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUDriverConfigPtr cfg;
int frozen;
if (priv->quiesced) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is already quiesced"));
return -1;
}
if (!qemuDomainAgentAvailable(priv, true))
return -1;
priv->quiesced = true;
cfg = virQEMUDriverGetConfig(driver);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
priv->quiesced = false;
virObjectUnref(cfg);
return -1;
}
virObjectUnref(cfg);
qemuDomainObjEnterAgent(vm);
frozen = qemuAgentFSFreeze(priv->agent, mountpoints, nmountpoints);
qemuDomainObjExitAgent(vm);
@ -12741,24 +12724,17 @@ qemuDomainSnapshotFSFreeze(virQEMUDriverPtr driver,
/* Return -1 on error, otherwise number of thawed filesystems. */
static int
qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver,
qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
bool report)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUDriverConfigPtr cfg;
int thawed;
virErrorPtr err = NULL;
if (!qemuDomainAgentAvailable(priv, report))
return -1;
if (!priv->quiesced && report) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not quiesced"));
return -1;
}
qemuDomainObjEnterAgent(vm);
if (!report)
err = virSaveLastError();
@ -12769,18 +12745,6 @@ qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver,
virFreeError(err);
if (!report || thawed >= 0) {
priv->quiesced = false;
cfg = virQEMUDriverGetConfig(driver);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
/* Revert the statuses when we failed to save them. */
priv->quiesced = true;
thawed = -1;
}
virObjectUnref(cfg);
}
return thawed;
}
@ -18033,10 +17997,6 @@ qemuDomainFSFreeze(virDomainPtr dom,
}
ret = qemuDomainSnapshotFSFreeze(driver, vm, mountpoints, nmountpoints);
if (ret == -2) {
qemuDomainSnapshotFSThaw(driver, vm, false);
ret = -1;
}
endjob:
if (!qemuDomainObjEndJob(driver, vm))

View File

@ -539,10 +539,6 @@ qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
priv = vm->privateData;
if (priv->agent)
qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_RESET);
/* Clear some domain runtime information. For instance,
* fsfreeze won't survive domain reset. This, however,
* required the domain status file to be rewritten onto disk. */
priv->quiesced = false;
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
VIR_WARN("Failed to save status on vm %s", vm->def->name);
@ -4985,7 +4981,6 @@ void qemuProcessStop(virQEMUDriverPtr driver,
virPortAllocatorRelease(driver->migrationPorts, priv->nbdPort);
priv->nbdPort = 0;
priv->quiesced = false;
if (priv->agent) {
qemuAgentClose(priv->agent);