[PATCH 1/9] tests: Fix virQEMUDriverConfigNew() calling with respect to @root

Michal Privoznik posted 9 patches 5 years, 10 months ago
There is a newer version of this series
[PATCH 1/9] tests: Fix virQEMUDriverConfigNew() calling with respect to @root
Posted by Michal Privoznik 5 years, 10 months ago
The virQEMUDriverConfigNew() accepts path to root directory for
embed mode as an argument. If the argument is not NULL it uses
the passed value as prefix for some internal paths (e.g.
cfg->libDir). If it is NULL though, it looks if the other
argument, @privileged is true or false and generates internal
paths accordingly. But when calling the function from the test
suite, instead of passing NULL for @root, an empty string is
passed. Fortunately, this doesn't create a problem because in
both problematic cases the generated paths are "fixed" to point
somewhere into build dir or the code which is tested doesn't
access them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/domaincapstest.c | 2 +-
 tests/testutilsqemu.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index fb803eaa47..c3a9f4ef91 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -369,7 +369,7 @@ mymain(void)
 #endif
 
 #if WITH_QEMU
-    virQEMUDriverConfigPtr cfg = virQEMUDriverConfigNew(false, "");
+    virQEMUDriverConfigPtr cfg = virQEMUDriverConfigNew(false, NULL);
 
     if (!cfg)
         return EXIT_FAILURE;
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index f3b4e2b3b2..cb68ac0488 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -390,7 +390,7 @@ int qemuTestDriverInit(virQEMUDriver *driver)
         return -1;
 
     driver->hostarch = virArchFromHost();
-    driver->config = virQEMUDriverConfigNew(false, "");
+    driver->config = virQEMUDriverConfigNew(false, NULL);
     if (!driver->config)
         goto error;
 
-- 
2.24.1

Re: [PATCH 1/9] tests: Fix virQEMUDriverConfigNew() calling with respect to @root
Posted by Andrea Bolognani 5 years, 10 months ago
On Wed, 2020-03-25 at 11:18 +0100, Michal Privoznik wrote:
> The virQEMUDriverConfigNew() accepts path to root directory for
> embed mode as an argument. If the argument is not NULL it uses
> the passed value as prefix for some internal paths (e.g.
> cfg->libDir). If it is NULL though, it looks if the other
> argument, @privileged is true or false and generates internal
> paths accordingly. But when calling the function from the test
> suite, instead of passing NULL for @root, an empty string is
> passed. Fortunately, this doesn't create a problem because in
> both problematic cases the generated paths are "fixed" to point
> somewhere into build dir or the code which is tested doesn't
> access them.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tests/domaincapstest.c | 2 +-
>  tests/testutilsqemu.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization