Add possibility to delay checks to the point when the FDs are to be
passed to qemu.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 16 +++++++++++-----
src/qemu/qemu_fd.c | 12 ++++++++----
src/qemu/qemu_fd.h | 4 ++--
tests/qemumonitorjsontest.c | 8 ++++++--
4 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3746f02ff0..30671df4f2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1494,7 +1494,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:
@@ -1517,7 +1518,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;
@@ -8896,7 +8898,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
vhostfd[i] = -1;
}
- qemuFDPassTransferCommand(vdpa, cmd);
+ if (qemuFDPassTransferCommand(vdpa, cmd) < 0)
+ return -1;
if (!(hostnetprops = qemuBuildHostNetProps(net,
tapfdName, tapfdSize,
@@ -9805,8 +9808,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;
diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c
index 29370a4bb6..1af8932bdd 100644
--- a/src/qemu/qemu_fd.c
+++ b/src/qemu/qemu_fd.c
@@ -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;
}
diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h
index 6d090392db..db16d77ecc 100644
--- a/src/qemu/qemu_fd.h
+++ b/src/qemu/qemu_fd.h
@@ -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
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 278d7ba765..e15c8533f6 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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,"
--
2.35.1