mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
qemu_fd: Add return value handling for qemuFDPassTransfer* APIs
Add possibility to delay checks to the point when the FDs are to be passed to qemu. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7b0e2e4a55
commit
bcfd23b762
@ -1514,7 +1514,8 @@ qemuBuildChardevCommand(virCommand *cmd,
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd);
|
||||
if (qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd) < 0)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_NULL:
|
||||
@ -1538,7 +1539,8 @@ qemuBuildChardevCommand(virCommand *cmd,
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd);
|
||||
if (qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(charstr = qemuBuildChardevStr(dev, charAlias)))
|
||||
return -1;
|
||||
@ -8918,7 +8920,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
||||
vhostfd[i] = -1;
|
||||
}
|
||||
|
||||
qemuFDPassTransferCommand(vdpa, cmd);
|
||||
if (qemuFDPassTransferCommand(vdpa, cmd) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(hostnetprops = qemuBuildHostNetProps(net,
|
||||
tapfdName, tapfdSize,
|
||||
@ -9827,8 +9830,11 @@ qemuBuildTPMCommandLine(virCommand *cmd,
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemuFDPassTransferCommand(passtpm, cmd);
|
||||
qemuFDPassTransferCommand(passcancel, cmd);
|
||||
if (qemuFDPassTransferCommand(passtpm, cmd) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuFDPassTransferCommand(passcancel, cmd) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(tpmdevstr = qemuBuildTPMBackendStr(tpm, passtpm, passcancel)))
|
||||
return -1;
|
||||
|
@ -177,14 +177,14 @@ qemuFDPassAddFD(qemuFDPass *fdpass,
|
||||
* Pass the fds in @fdpass to a commandline object @cmd. @fdpass may be NULL
|
||||
* in which case this is a no-op.
|
||||
*/
|
||||
void
|
||||
int
|
||||
qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
||||
virCommand *cmd)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!fdpass)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < fdpass->nfds; i++) {
|
||||
virCommandPassFD(cmd, fdpass->fds[i].fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
||||
@ -206,6 +206,8 @@ qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
||||
|
||||
fdpass->fds[i].fd = -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -265,18 +267,20 @@ qemuFDPassTransferMonitor(qemuFDPass *fdpass,
|
||||
* Simulate as if @fdpass was passed via monitor for callers which don't
|
||||
* actually wish to test that code path.
|
||||
*/
|
||||
void
|
||||
int
|
||||
qemuFDPassTransferMonitorFake(qemuFDPass *fdpass)
|
||||
{
|
||||
|
||||
if (!fdpass)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
if (fdpass->useFDSet) {
|
||||
fdpass->path = g_strdup_printf("/dev/fdset/monitor-fake");
|
||||
} else {
|
||||
fdpass->path = g_strdup(fdpass->fds[0].opaque);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ qemuFDPassAddFD(qemuFDPass *fdpass,
|
||||
int *fd,
|
||||
const char *suffix);
|
||||
|
||||
void
|
||||
int
|
||||
qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
||||
virCommand *cmd);
|
||||
|
||||
@ -47,7 +47,7 @@ int
|
||||
qemuFDPassTransferMonitor(qemuFDPass *fdpass,
|
||||
qemuMonitor *mon);
|
||||
|
||||
void
|
||||
int
|
||||
qemuFDPassTransferMonitorFake(qemuFDPass *fdpass);
|
||||
|
||||
void
|
||||
|
@ -743,8 +743,12 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt,
|
||||
|
||||
chrdev.source = chr;
|
||||
ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL));
|
||||
qemuFDPassTransferMonitorFake(charpriv->sourcefd);
|
||||
qemuFDPassTransferMonitorFake(charpriv->logfd);
|
||||
if (qemuFDPassTransferMonitorFake(charpriv->sourcefd) < 0)
|
||||
ret = -1;
|
||||
|
||||
if (qemuFDPassTransferMonitorFake(charpriv->logfd) < 0)
|
||||
ret = -1;
|
||||
|
||||
CHECK("file", false,
|
||||
"{'id':'alias','backend':{'type':'file','data':{'out':'/dev/fdset/monitor-fake',"
|
||||
"'append':true,"
|
||||
|
Loading…
Reference in New Issue
Block a user