It's effectively replaced by checks in qemuFDPassTransfer. This will simplify cleanup paths on constructing the qemuFDPass object when FDs are being handled. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 13 ++++--------- src/qemu/qemu_fd.c | 20 +------------------- src/qemu/qemu_fd.h | 2 +- src/qemu/qemu_process.c | 9 +++------ tests/testutilsqemu.c | 6 ++---- 5 files changed, 11 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 30671df4f2..3032cbc623 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4927,10 +4927,7 @@ qemuBuildVideoCommandLine(virCommand *cmd, chrsrc->type = VIR_DOMAIN_CHR_TYPE_UNIX; chrsrcpriv->sourcefd = qemuFDPassNewDirect(video->info.alias, priv); - if (qemuFDPassAddFD(chrsrcpriv->sourcefd, - &videopriv->vhost_user_fd, - "-vhost-user") < 0) - return -1; + qemuFDPassAddFD(chrsrcpriv->sourcefd, &videopriv->vhost_user_fd, "-vhost-user"); if (qemuBuildChardevCommand(cmd, chrsrc, chrAlias, priv->qemuCaps) < 0) return -1; @@ -8763,8 +8760,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, vdpa = qemuFDPassNew(net->info.alias, priv); - if (qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa") < 0) - return -1; + qemuFDPassAddFD(vdpa, &vdpafd, "-vdpa"); } break; @@ -9792,9 +9788,8 @@ qemuBuildTPMCommandLine(virCommand *cmd, passtpm = qemuFDPassNew(tpm->info.alias, priv); passcancel = qemuFDPassNew(tpm->info.alias, priv); - if (qemuFDPassAddFD(passtpm, &fdtpm, "-tpm") < 0 || - qemuFDPassAddFD(passcancel, &fdcancel, "-cancel") < 0) - return -1; + qemuFDPassAddFD(passtpm, &fdtpm, "-tpm"); + qemuFDPassAddFD(passcancel, &fdcancel, "-cancel"); } break; diff --git a/src/qemu/qemu_fd.c b/src/qemu/qemu_fd.c index 284e77ba2b..84e9d2bfdf 100644 --- a/src/qemu/qemu_fd.c +++ b/src/qemu/qemu_fd.c @@ -159,37 +159,19 @@ qemuFDPassNewDirect(const char *prefix, * @suffix is used to build the name of the file descriptor by concatenating * it with @prefix passed to qemuFDPassNew. @suffix may be NULL, in which case * it's considered to be an empty string. - * - * Returns 0 on success, -1 on error (when attempting to pass multiple FDs) using - * the 'direct' method. */ -int +void qemuFDPassAddFD(qemuFDPass *fdpass, int *fd, const char *suffix) { struct qemuFDPassFD newfd = { .fd = *fd }; - if (newfd.fd < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid file descriptor")); - return -1; - } - - if (!fdpass->useFDSet && - fdpass->nfds >= 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("direct FD passing supports only 1 file descriptor")); - return -1; - } - *fd = -1; newfd.opaque = g_strdup_printf("%s%s", fdpass->prefix, NULLSTR_EMPTY(suffix)); VIR_APPEND_ELEMENT(fdpass->fds, fdpass->nfds, newfd); - - return 0; } diff --git a/src/qemu/qemu_fd.h b/src/qemu/qemu_fd.h index db16d77ecc..ef35daba8c 100644 --- a/src/qemu/qemu_fd.h +++ b/src/qemu/qemu_fd.h @@ -34,7 +34,7 @@ qemuFDPass * qemuFDPassNewDirect(const char *prefix, void *dompriv); -int +void qemuFDPassAddFD(qemuFDPass *fdpass, int *fd, const char *suffix); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b0b00eb0a2..39ed10ee41 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6842,8 +6842,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev, charpriv->sourcefd = qemuFDPassNew(devalias, data->priv); - if (qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source") < 0) - return -1; + qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source"); } break; @@ -6862,8 +6861,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev, charpriv->sourcefd = qemuFDPassNewDirect(devalias, data->priv); - if (qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source") < 0) - return -1; + qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source"); } break; @@ -6890,8 +6888,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev, charpriv->logfd = qemuFDPassNew(devalias, data->priv); - if (qemuFDPassAddFD(charpriv->logfd, &logfd, "-log") < 0) - return -1; + qemuFDPassAddFD(charpriv->logfd, &logfd, "-log"); } return 0; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index d57f982c37..44443d8585 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -1083,8 +1083,7 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev, else charpriv->sourcefd = qemuFDPassNewDirect(devalias, priv); - if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") < 0) - return -1; + qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source"); } if (chardev->logfile) { @@ -1095,8 +1094,7 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev, charpriv->logfd = qemuFDPassNew(devalias, priv); - if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) - return -1; + qemuFDPassAddFD(charpriv->logfd, &fd, "-log"); } return 0; -- 2.35.1