qemu: log error output from nbdkit

log stderr and stdout from nbdkit into its own log so that
nbdkit-related issues can be debugged more easily.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jonathon Jongsma 2022-12-12 15:12:33 -06:00
parent e498941476
commit e04373794c

View File

@ -852,12 +852,23 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc,
virTimeBackOffVar timebackoff;
g_autoptr(virURI) uri = NULL;
g_autofree char *uristring = NULL;
g_autofree char *basename = g_strdup_printf("%s-nbdkit-%i", vm->def->name, proc->source->id);
int logfd = -1;
g_autoptr(qemuLogContext) logContext = NULL;
if (!(cmd = qemuNbdkitProcessBuildCommand(proc)))
return -1;
if (!(logContext = qemuLogContextNew(driver, vm, basename))) {
virLastErrorPrefixMessage("%s", _("can't connect to virtlogd"));
return -1;
}
logfd = qemuLogContextGetWriteFD(logContext);
VIR_DEBUG("starting nbdkit process for %s", proc->source->nodestorage);
virCommandSetErrorBuffer(cmd, &errbuf);
virCommandSetErrorFD(cmd, &logfd);
virCommandSetOutputFD(cmd, &logfd);
virCommandSetPidFile(cmd, proc->pidfile);
if (qemuExtDeviceLogCommand(driver, vm, cmd, "nbdkit") < 0)
@ -899,6 +910,9 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc,
if ((uri = qemuBlockStorageSourceGetURI(proc->source)))
uristring = virURIFormat(uri);
if (qemuLogContextReadFiltered(logContext, &errbuf, 1024) < 0)
VIR_WARN("Unable to read from nbdkit log");
virReportError(VIR_ERR_OPERATION_FAILED,
_("Failed to connect to nbdkit for '%1$s': %2$s"),
NULLSTR(uristring), NULLSTR(errbuf));