[libvirt] [PATCH 08/18] virpcimock: Create devices/ and drivers/ under /sys/bus/pci upfront
Daniel Henrique Barboza
danielhb413 at gmail.com
Fri Aug 16 20:41:04 UTC 2019
On 8/14/19 8:57 AM, Michal Privoznik wrote:
> In near future, we will be creating devices under different
> location and just symlink them under devices/. Just like real
> kernel does. But for that we need the directories to exists.
nit: s/exists/exist
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> tests/virpcimock.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tests/virpcimock.c b/tests/virpcimock.c
> index e97dbd81f8..213f906500 100644
> --- a/tests/virpcimock.c
> +++ b/tests/virpcimock.c
> @@ -187,6 +187,19 @@ make_file(const char *path,
> VIR_FORCE_CLOSE(fd);
> }
>
> +static void
> +make_dir(const char *path,
> + const char *name)
> +{
> + VIR_AUTOFREE(char *) dirpath = NULL;
> +
> + if (virAsprintfQuiet(&dirpath, "%s/%s", path, name) < 0)
> + ABORT_OOM();
> +
> + if (virFileMakePath(dirpath) < 0)
> + ABORT("Unable to create: %s", dirpath);
> +}
> +
> static void
> make_symlink(const char *path,
> const char *name,
> @@ -846,6 +859,8 @@ init_env(void)
> if (virFileMakePath(tmp) < 0)
> ABORT("Unable to create: %s", tmp);
>
> + make_dir(tmp, "devices");
> + make_dir(tmp, "drivers");
make_dir could also be used to create the tmp directory as well, like
make_dir(fakerootdir, SYSFS_PCI_PREFIX), getting rid of all the
virFileMakePath() calls inside init_env(). Not worth rerolling the patch
just because of that though.
Reviewed-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> make_file(tmp, "drivers_probe", NULL, -1);
>
> # define MAKE_PCI_DRIVER(name, ...) \
More information about the libvir-list
mailing list