mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuBuildTPMOpenBackendFDs: Construct 'cancel_path' internally
Since 'cancel_path' is constructed from the 'tpmdev' argument, we can push it down into the function opening the FDs. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d42be77208
commit
4225de7c73
@ -9737,10 +9737,14 @@ qemuBuildTPMDevCmd(virCommand *cmd,
|
|||||||
/* this function is exported so that tests can mock the FDs */
|
/* this function is exported so that tests can mock the FDs */
|
||||||
int
|
int
|
||||||
qemuBuildTPMOpenBackendFDs(const char *tpmdev,
|
qemuBuildTPMOpenBackendFDs(const char *tpmdev,
|
||||||
const char *cancel_path,
|
|
||||||
int *tpmfd,
|
int *tpmfd,
|
||||||
int *cancelfd)
|
int *cancelfd)
|
||||||
{
|
{
|
||||||
|
g_autofree char *cancel_path = NULL;
|
||||||
|
|
||||||
|
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if ((*tpmfd = open(tpmdev, O_RDWR)) < 0) {
|
if ((*tpmfd = open(tpmdev, O_RDWR)) < 0) {
|
||||||
virReportSystemError(errno, _("Could not open TPM device %s"),
|
virReportSystemError(errno, _("Could not open TPM device %s"),
|
||||||
tpmdev);
|
tpmdev);
|
||||||
@ -9766,10 +9770,8 @@ qemuBuildTPMBackendStr(virCommand *cmd,
|
|||||||
int *cancelfd)
|
int *cancelfd)
|
||||||
{
|
{
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
g_autofree char *cancel_path = NULL;
|
|
||||||
g_autofree char *devset = NULL;
|
g_autofree char *devset = NULL;
|
||||||
g_autofree char *cancelset = NULL;
|
g_autofree char *cancelset = NULL;
|
||||||
const char *tpmdev;
|
|
||||||
|
|
||||||
*tpmfd = -1;
|
*tpmfd = -1;
|
||||||
*cancelfd = -1;
|
*cancelfd = -1;
|
||||||
@ -9779,11 +9781,8 @@ qemuBuildTPMBackendStr(virCommand *cmd,
|
|||||||
|
|
||||||
switch (tpm->type) {
|
switch (tpm->type) {
|
||||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||||
tpmdev = tpm->data.passthrough.source->data.file.path;
|
if (qemuBuildTPMOpenBackendFDs(tpm->data.passthrough.source->data.file.path,
|
||||||
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
|
tpmfd, cancelfd) < 0)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (qemuBuildTPMOpenBackendFDs(tpmdev, cancel_path, tpmfd, cancelfd) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
virCommandPassFD(cmd, *tpmfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
virCommandPassFD(cmd, *tpmfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
|
||||||
|
@ -251,11 +251,9 @@ qemuBuildVsockDevProps(virDomainDef *def,
|
|||||||
/* this function is exported so that tests can mock the FDs */
|
/* this function is exported so that tests can mock the FDs */
|
||||||
int
|
int
|
||||||
qemuBuildTPMOpenBackendFDs(const char *tpmdev,
|
qemuBuildTPMOpenBackendFDs(const char *tpmdev,
|
||||||
const char *cancel_path,
|
|
||||||
int *tpmfd,
|
int *tpmfd,
|
||||||
int *cancelfd)
|
int *cancelfd)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_GNUC_NO_INLINE;
|
||||||
ATTRIBUTE_NONNULL(4) G_GNUC_NO_INLINE;
|
|
||||||
|
|
||||||
const char * qemuAudioDriverTypeToString(virDomainAudioType type);
|
const char * qemuAudioDriverTypeToString(virDomainAudioType type);
|
||||||
virDomainAudioType qemuAudioDriverTypeFromString(const char *str);
|
virDomainAudioType qemuAudioDriverTypeFromString(const char *str);
|
||||||
|
@ -263,7 +263,6 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev G_GNUC_UNUSED)
|
|||||||
|
|
||||||
int
|
int
|
||||||
qemuBuildTPMOpenBackendFDs(const char *tpmdev G_GNUC_UNUSED,
|
qemuBuildTPMOpenBackendFDs(const char *tpmdev G_GNUC_UNUSED,
|
||||||
const char *cancel_path G_GNUC_UNUSED,
|
|
||||||
int *tpmfd,
|
int *tpmfd,
|
||||||
int *cancelfd)
|
int *cancelfd)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user