mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: replace logCtxt with qemuDomainLogAppendMessage()
Once QEMU is started, the qemuDomainLogContext is owned by it, and can no longer be used from libvirt. Instead, use qemuDomainLogAppendMessage() which will redirect the log. This is not strictly necessary for swtpm, but the following patches are going to reuse qemuExtDeviceLogCommand(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
39dded7bb6
commit
861882d314
@ -36,39 +36,24 @@
|
||||
VIR_LOG_INIT("qemu.qemu_extdevice");
|
||||
|
||||
int
|
||||
qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt,
|
||||
qemuExtDeviceLogCommand(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virCommandPtr cmd,
|
||||
const char *info)
|
||||
{
|
||||
int ret = -1;
|
||||
char *timestamp = NULL;
|
||||
char *logline = NULL;
|
||||
int logFD;
|
||||
VIR_AUTOFREE(char *) timestamp = virTimeStringNow();
|
||||
VIR_AUTOFREE(char *) cmds = virCommandToString(cmd, false);
|
||||
|
||||
logFD = qemuDomainLogContextGetWriteFD(logCtxt);
|
||||
if (!timestamp || !cmds)
|
||||
return -1;
|
||||
|
||||
if ((timestamp = virTimeStringNow()) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (virAsprintf(&logline, "%s: Starting external device: %s\n",
|
||||
timestamp, info) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (safewrite(logFD, logline, strlen(logline)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
virCommandWriteArgLog(cmd, logFD);
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(timestamp);
|
||||
VIR_FREE(logline);
|
||||
|
||||
return ret;
|
||||
return qemuDomainLogAppendMessage(driver, vm,
|
||||
_("%s: Starting external device: %s\n%s\n"),
|
||||
timestamp, info, cmds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* qemuExtDevicesInitPaths:
|
||||
*
|
||||
@ -128,7 +113,6 @@ qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
|
||||
int
|
||||
qemuExtDevicesStart(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainLogContextPtr logCtxt,
|
||||
bool incomingMigration)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -137,7 +121,7 @@ qemuExtDevicesStart(virQEMUDriverPtr driver,
|
||||
return -1;
|
||||
|
||||
if (vm->def->tpm)
|
||||
ret = qemuExtTPMStart(driver, vm, logCtxt, incomingMigration);
|
||||
ret = qemuExtTPMStart(driver, vm, incomingMigration);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -23,10 +23,11 @@
|
||||
#include "qemu_conf.h"
|
||||
#include "qemu_domain.h"
|
||||
|
||||
int qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt,
|
||||
int qemuExtDeviceLogCommand(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virCommandPtr cmd,
|
||||
const char *info)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
|
||||
ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver,
|
||||
@ -40,9 +41,8 @@ void qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
|
||||
|
||||
int qemuExtDevicesStart(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainLogContextPtr logCtxt,
|
||||
bool incomingMigration)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||
ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
void qemuExtDevicesStop(virQEMUDriverPtr driver,
|
||||
|
@ -6794,7 +6794,7 @@ qemuProcessLaunch(virConnectPtr conn,
|
||||
if (qemuProcessGenID(vm, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuExtDevicesStart(driver, vm, logCtxt, incoming != NULL) < 0)
|
||||
if (qemuExtDevicesStart(driver, vm, incoming != NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Building emulator command line");
|
||||
|
@ -824,7 +824,6 @@ qemuExtTPMCleanupHost(virDomainDefPtr def)
|
||||
*
|
||||
* @driver: QEMU driver
|
||||
* @vm: the domain object
|
||||
* @logCtxt: log context
|
||||
* @incomingMigration: whether we have an incoming migration
|
||||
*
|
||||
* Start the external TPM Emulator:
|
||||
@ -834,7 +833,6 @@ qemuExtTPMCleanupHost(virDomainDefPtr def)
|
||||
static int
|
||||
qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainLogContextPtr logCtxt,
|
||||
bool incomingMigration)
|
||||
{
|
||||
int ret = -1;
|
||||
@ -863,7 +861,7 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
||||
incomingMigration)))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuExtDeviceLogCommand(logCtxt, cmd, "TPM Emulator") < 0)
|
||||
if (qemuExtDeviceLogCommand(driver, vm, cmd, "TPM Emulator") < 0)
|
||||
goto cleanup;
|
||||
|
||||
virCommandSetErrorBuffer(cmd, &errbuf);
|
||||
@ -917,7 +915,6 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
||||
int
|
||||
qemuExtTPMStart(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainLogContextPtr logCtxt,
|
||||
bool incomingMigration)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -925,7 +922,7 @@ qemuExtTPMStart(virQEMUDriverPtr driver,
|
||||
|
||||
switch (tpm->type) {
|
||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
||||
ret = qemuExtTPMStartEmulator(driver, vm, logCtxt, incomingMigration);
|
||||
ret = qemuExtTPMStartEmulator(driver, vm, incomingMigration);
|
||||
break;
|
||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||
case VIR_DOMAIN_TPM_TYPE_LAST:
|
||||
|
@ -37,9 +37,8 @@ void qemuExtTPMCleanupHost(virDomainDefPtr def)
|
||||
|
||||
int qemuExtTPMStart(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainLogContextPtr logCtxt,
|
||||
bool incomingMigration)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||
ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
void qemuExtTPMStop(virQEMUDriverPtr driver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user