[PATCH 16/16] qemuxml2argvtest: Fix type for faked chardev backing a TPM

Peter Krempa posted 16 patches 4 years, 2 months ago
There is a newer version of this series
[PATCH 16/16] qemuxml2argvtest: Fix type for faked chardev backing a TPM
Posted by Peter Krempa 4 years, 2 months ago
The test filled the chardev type to VIR_DOMAIN_CHR_TYPE_FILE and thus
set the 'data.emulator.source->data.file.path' pointer, but the
commandline formatter is unconditionally expecting VIR_DOMAIN_CHR_TYPE_UNIX
and thus reading 'data.emulator.source->data.nix.path'. Since it's an
union it happened to land in the correct place. Fix the faked data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/qemuxml2argvtest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 1d0d6e14ba..a5d162958e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -450,9 +450,9 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv,
         if (vm->def->tpms[i]->type != VIR_DOMAIN_TPM_TYPE_EMULATOR)
             continue;

-        VIR_FREE(vm->def->tpms[i]->data.emulator.source->data.file.path);
-        vm->def->tpms[i]->data.emulator.source->data.file.path = g_strdup("/dev/test");
-        vm->def->tpms[i]->data.emulator.source->type = VIR_DOMAIN_CHR_TYPE_FILE;
+        VIR_FREE(vm->def->tpms[i]->data.emulator.source->data.nix.path);
+        vm->def->tpms[i]->data.emulator.source->type = VIR_DOMAIN_CHR_TYPE_UNIX;
+        vm->def->tpms[i]->data.emulator.source->data.nix.path = g_strdup("/dev/test");
     }

     for (i = 0; i < vm->def->nvideos; i++) {
-- 
2.31.1

Re: [PATCH 16/16] qemuxml2argvtest: Fix type for faked chardev backing a TPM
Posted by Ján Tomko 4 years, 2 months ago
On a Thursday in 2021, Peter Krempa wrote:
>The test filled the chardev type to VIR_DOMAIN_CHR_TYPE_FILE and thus
>set the 'data.emulator.source->data.file.path' pointer, but the
>commandline formatter is unconditionally expecting VIR_DOMAIN_CHR_TYPE_UNIX
>and thus reading 'data.emulator.source->data.nix.path'. Since it's an
>union it happened to land in the correct place. Fix the faked data.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> tests/qemuxml2argvtest.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano