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");
|
VIR_LOG_INIT("qemu.qemu_extdevice");
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt,
|
qemuExtDeviceLogCommand(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
virCommandPtr cmd,
|
virCommandPtr cmd,
|
||||||
const char *info)
|
const char *info)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
VIR_AUTOFREE(char *) timestamp = virTimeStringNow();
|
||||||
char *timestamp = NULL;
|
VIR_AUTOFREE(char *) cmds = virCommandToString(cmd, false);
|
||||||
char *logline = NULL;
|
|
||||||
int logFD;
|
|
||||||
|
|
||||||
logFD = qemuDomainLogContextGetWriteFD(logCtxt);
|
if (!timestamp || !cmds)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if ((timestamp = virTimeStringNow()) == NULL)
|
return qemuDomainLogAppendMessage(driver, vm,
|
||||||
goto cleanup;
|
_("%s: Starting external device: %s\n%s\n"),
|
||||||
|
timestamp, info, cmds);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* qemuExtDevicesInitPaths:
|
* qemuExtDevicesInitPaths:
|
||||||
*
|
*
|
||||||
@ -128,7 +113,6 @@ qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
|
|||||||
int
|
int
|
||||||
qemuExtDevicesStart(virQEMUDriverPtr driver,
|
qemuExtDevicesStart(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainLogContextPtr logCtxt,
|
|
||||||
bool incomingMigration)
|
bool incomingMigration)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -137,7 +121,7 @@ qemuExtDevicesStart(virQEMUDriverPtr driver,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (vm->def->tpm)
|
if (vm->def->tpm)
|
||||||
ret = qemuExtTPMStart(driver, vm, logCtxt, incomingMigration);
|
ret = qemuExtTPMStart(driver, vm, incomingMigration);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,11 @@
|
|||||||
#include "qemu_conf.h"
|
#include "qemu_conf.h"
|
||||||
#include "qemu_domain.h"
|
#include "qemu_domain.h"
|
||||||
|
|
||||||
int qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt,
|
int qemuExtDeviceLogCommand(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
virCommandPtr cmd,
|
virCommandPtr cmd,
|
||||||
const char *info)
|
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;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver,
|
int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver,
|
||||||
@ -40,9 +41,8 @@ void qemuExtDevicesCleanupHost(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
int qemuExtDevicesStart(virQEMUDriverPtr driver,
|
int qemuExtDevicesStart(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainLogContextPtr logCtxt,
|
|
||||||
bool incomingMigration)
|
bool incomingMigration)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
void qemuExtDevicesStop(virQEMUDriverPtr driver,
|
void qemuExtDevicesStop(virQEMUDriverPtr driver,
|
||||||
|
@ -6794,7 +6794,7 @@ qemuProcessLaunch(virConnectPtr conn,
|
|||||||
if (qemuProcessGenID(vm, flags) < 0)
|
if (qemuProcessGenID(vm, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuExtDevicesStart(driver, vm, logCtxt, incoming != NULL) < 0)
|
if (qemuExtDevicesStart(driver, vm, incoming != NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Building emulator command line");
|
VIR_DEBUG("Building emulator command line");
|
||||||
|
@ -824,7 +824,6 @@ qemuExtTPMCleanupHost(virDomainDefPtr def)
|
|||||||
*
|
*
|
||||||
* @driver: QEMU driver
|
* @driver: QEMU driver
|
||||||
* @vm: the domain object
|
* @vm: the domain object
|
||||||
* @logCtxt: log context
|
|
||||||
* @incomingMigration: whether we have an incoming migration
|
* @incomingMigration: whether we have an incoming migration
|
||||||
*
|
*
|
||||||
* Start the external TPM Emulator:
|
* Start the external TPM Emulator:
|
||||||
@ -834,7 +833,6 @@ qemuExtTPMCleanupHost(virDomainDefPtr def)
|
|||||||
static int
|
static int
|
||||||
qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainLogContextPtr logCtxt,
|
|
||||||
bool incomingMigration)
|
bool incomingMigration)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -863,7 +861,7 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
|||||||
incomingMigration)))
|
incomingMigration)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuExtDeviceLogCommand(logCtxt, cmd, "TPM Emulator") < 0)
|
if (qemuExtDeviceLogCommand(driver, vm, cmd, "TPM Emulator") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virCommandSetErrorBuffer(cmd, &errbuf);
|
virCommandSetErrorBuffer(cmd, &errbuf);
|
||||||
@ -917,7 +915,6 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
|
|||||||
int
|
int
|
||||||
qemuExtTPMStart(virQEMUDriverPtr driver,
|
qemuExtTPMStart(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainLogContextPtr logCtxt,
|
|
||||||
bool incomingMigration)
|
bool incomingMigration)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -925,7 +922,7 @@ qemuExtTPMStart(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
switch (tpm->type) {
|
switch (tpm->type) {
|
||||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
||||||
ret = qemuExtTPMStartEmulator(driver, vm, logCtxt, incomingMigration);
|
ret = qemuExtTPMStartEmulator(driver, vm, incomingMigration);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||||
case VIR_DOMAIN_TPM_TYPE_LAST:
|
case VIR_DOMAIN_TPM_TYPE_LAST:
|
||||||
|
@ -37,9 +37,8 @@ void qemuExtTPMCleanupHost(virDomainDefPtr def)
|
|||||||
|
|
||||||
int qemuExtTPMStart(virQEMUDriverPtr driver,
|
int qemuExtTPMStart(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainLogContextPtr logCtxt,
|
|
||||||
bool incomingMigration)
|
bool incomingMigration)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
void qemuExtTPMStop(virQEMUDriverPtr driver,
|
void qemuExtTPMStop(virQEMUDriverPtr driver,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user