mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: convert process stop/attach to use qemuDomainLogContextPtr
When the qemuProcessAttach/Stop methods write a marker into the log file, they can use qemuDomainLogContextWrite to write a formatted message. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
@@ -77,9 +77,6 @@
|
|||||||
|
|
||||||
VIR_LOG_INIT("qemu.qemu_process");
|
VIR_LOG_INIT("qemu.qemu_process");
|
||||||
|
|
||||||
#define ATTACH_POSTFIX ": attaching\n"
|
|
||||||
#define SHUTDOWN_POSTFIX ": shutting down\n"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuProcessRemoveDomainStatus
|
* qemuProcessRemoveDomainStatus
|
||||||
*
|
*
|
||||||
@@ -5184,7 +5181,6 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
|||||||
size_t i;
|
size_t i;
|
||||||
char *timestamp;
|
char *timestamp;
|
||||||
char *tmppath = NULL;
|
char *tmppath = NULL;
|
||||||
char ebuf[1024];
|
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
qemuDomainLogContextPtr logCtxt = NULL;
|
qemuDomainLogContextPtr logCtxt = NULL;
|
||||||
|
|
||||||
@@ -5217,15 +5213,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if ((logCtxt = qemuDomainLogContextNew(driver, vm,
|
if ((logCtxt = qemuDomainLogContextNew(driver, vm,
|
||||||
QEMU_DOMAIN_LOG_CONTEXT_MODE_STOP))) {
|
QEMU_DOMAIN_LOG_CONTEXT_MODE_STOP))) {
|
||||||
int logfile = qemuDomainLogContextGetWriteFD(logCtxt);
|
|
||||||
if ((timestamp = virTimeStringNow()) != NULL) {
|
if ((timestamp = virTimeStringNow()) != NULL) {
|
||||||
if (safewrite(logfile, timestamp, strlen(timestamp)) < 0 ||
|
qemuDomainLogContextWrite(logCtxt, "%s: shutting down\n", timestamp);
|
||||||
safewrite(logfile, SHUTDOWN_POSTFIX,
|
|
||||||
strlen(SHUTDOWN_POSTFIX)) < 0) {
|
|
||||||
VIR_WARN("Unable to write timestamp to logfile: %s",
|
|
||||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(timestamp);
|
VIR_FREE(timestamp);
|
||||||
}
|
}
|
||||||
qemuDomainLogContextFree(logCtxt);
|
qemuDomainLogContextFree(logCtxt);
|
||||||
@@ -5487,8 +5476,6 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
bool monJSON)
|
bool monJSON)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char ebuf[1024];
|
|
||||||
int logfile = -1;
|
|
||||||
qemuDomainLogContextPtr logCtxt = NULL;
|
qemuDomainLogContextPtr logCtxt = NULL;
|
||||||
char *timestamp;
|
char *timestamp;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
@@ -5587,7 +5574,6 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (!(logCtxt = qemuDomainLogContextNew(driver, vm,
|
if (!(logCtxt = qemuDomainLogContextNew(driver, vm,
|
||||||
QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH)))
|
QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH)))
|
||||||
goto error;
|
goto error;
|
||||||
logfile = qemuDomainLogContextGetWriteFD(logCtxt);
|
|
||||||
|
|
||||||
VIR_DEBUG("Determining emulator version");
|
VIR_DEBUG("Determining emulator version");
|
||||||
virObjectUnref(priv->qemuCaps);
|
virObjectUnref(priv->qemuCaps);
|
||||||
@@ -5619,11 +5605,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if ((timestamp = virTimeStringNow()) == NULL)
|
if ((timestamp = virTimeStringNow()) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (safewrite(logfile, timestamp, strlen(timestamp)) < 0 ||
|
qemuDomainLogContextWrite(logCtxt, "%s: attaching\n", timestamp);
|
||||||
safewrite(logfile, ATTACH_POSTFIX, strlen(ATTACH_POSTFIX)) < 0) {
|
|
||||||
VIR_WARN("Unable to write timestamp to logfile: %s",
|
|
||||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
||||||
}
|
|
||||||
VIR_FREE(timestamp);
|
VIR_FREE(timestamp);
|
||||||
|
|
||||||
qemuDomainObjTaint(driver, vm, VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH, logCtxt);
|
qemuDomainObjTaint(driver, vm, VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH, logCtxt);
|
||||||
|
|||||||
Reference in New Issue
Block a user