mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +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_FILE:
|
||||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||||
qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd);
|
if (qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd) < 0)
|
||||||
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_NULL:
|
case VIR_DOMAIN_CHR_TYPE_NULL:
|
||||||
@ -1538,7 +1539,8 @@ qemuBuildChardevCommand(virCommand *cmd,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd);
|
if (qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!(charstr = qemuBuildChardevStr(dev, charAlias)))
|
if (!(charstr = qemuBuildChardevStr(dev, charAlias)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -8918,7 +8920,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
|
|||||||
vhostfd[i] = -1;
|
vhostfd[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuFDPassTransferCommand(vdpa, cmd);
|
if (qemuFDPassTransferCommand(vdpa, cmd) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!(hostnetprops = qemuBuildHostNetProps(net,
|
if (!(hostnetprops = qemuBuildHostNetProps(net,
|
||||||
tapfdName, tapfdSize,
|
tapfdName, tapfdSize,
|
||||||
@ -9827,8 +9830,11 @@ qemuBuildTPMCommandLine(virCommand *cmd,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuFDPassTransferCommand(passtpm, cmd);
|
if (qemuFDPassTransferCommand(passtpm, cmd) < 0)
|
||||||
qemuFDPassTransferCommand(passcancel, cmd);
|
return -1;
|
||||||
|
|
||||||
|
if (qemuFDPassTransferCommand(passcancel, cmd) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!(tpmdevstr = qemuBuildTPMBackendStr(tpm, passtpm, passcancel)))
|
if (!(tpmdevstr = qemuBuildTPMBackendStr(tpm, passtpm, passcancel)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -177,14 +177,14 @@ qemuFDPassAddFD(qemuFDPass *fdpass,
|
|||||||
* Pass the fds in @fdpass to a commandline object @cmd. @fdpass may be NULL
|
* Pass the fds in @fdpass to a commandline object @cmd. @fdpass may be NULL
|
||||||
* in which case this is a no-op.
|
* in which case this is a no-op.
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
||||||
virCommand *cmd)
|
virCommand *cmd)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!fdpass)
|
if (!fdpass)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < fdpass->nfds; i++) {
|
for (i = 0; i < fdpass->nfds; i++) {
|
||||||
virCommandPassFD(cmd, fdpass->fds[i].fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
virCommandPassFD(cmd, fdpass->fds[i].fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
||||||
@ -206,6 +206,8 @@ qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
|||||||
|
|
||||||
fdpass->fds[i].fd = -1;
|
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
|
* Simulate as if @fdpass was passed via monitor for callers which don't
|
||||||
* actually wish to test that code path.
|
* actually wish to test that code path.
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
qemuFDPassTransferMonitorFake(qemuFDPass *fdpass)
|
qemuFDPassTransferMonitorFake(qemuFDPass *fdpass)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fdpass)
|
if (!fdpass)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
if (fdpass->useFDSet) {
|
if (fdpass->useFDSet) {
|
||||||
fdpass->path = g_strdup_printf("/dev/fdset/monitor-fake");
|
fdpass->path = g_strdup_printf("/dev/fdset/monitor-fake");
|
||||||
} else {
|
} else {
|
||||||
fdpass->path = g_strdup(fdpass->fds[0].opaque);
|
fdpass->path = g_strdup(fdpass->fds[0].opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ qemuFDPassAddFD(qemuFDPass *fdpass,
|
|||||||
int *fd,
|
int *fd,
|
||||||
const char *suffix);
|
const char *suffix);
|
||||||
|
|
||||||
void
|
int
|
||||||
qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
qemuFDPassTransferCommand(qemuFDPass *fdpass,
|
||||||
virCommand *cmd);
|
virCommand *cmd);
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ int
|
|||||||
qemuFDPassTransferMonitor(qemuFDPass *fdpass,
|
qemuFDPassTransferMonitor(qemuFDPass *fdpass,
|
||||||
qemuMonitor *mon);
|
qemuMonitor *mon);
|
||||||
|
|
||||||
void
|
int
|
||||||
qemuFDPassTransferMonitorFake(qemuFDPass *fdpass);
|
qemuFDPassTransferMonitorFake(qemuFDPass *fdpass);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -743,8 +743,12 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
chrdev.source = chr;
|
chrdev.source = chr;
|
||||||
ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL));
|
ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL));
|
||||||
qemuFDPassTransferMonitorFake(charpriv->sourcefd);
|
if (qemuFDPassTransferMonitorFake(charpriv->sourcefd) < 0)
|
||||||
qemuFDPassTransferMonitorFake(charpriv->logfd);
|
ret = -1;
|
||||||
|
|
||||||
|
if (qemuFDPassTransferMonitorFake(charpriv->logfd) < 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
CHECK("file", false,
|
CHECK("file", false,
|
||||||
"{'id':'alias','backend':{'type':'file','data':{'out':'/dev/fdset/monitor-fake',"
|
"{'id':'alias','backend':{'type':'file','data':{'out':'/dev/fdset/monitor-fake',"
|
||||||
"'append':true,"
|
"'append':true,"
|
||||||
|
Loading…
Reference in New Issue
Block a user