]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virpcimock: Create devices/ and drivers/ under /sys/bus/pci upfront
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Aug 2019 08:51:05 +0000 (10:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Sat, 17 Aug 2019 09:48:09 +0000 (11:48 +0200)
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 exist.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
tests/virpcimock.c

index 93275648dc8cb48c1f8d113c1c8ebbc6ac84e9c6..bc34c0f181840f71fdbc4a25ec3c88466972aa98 100644 (file)
@@ -188,6 +188,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,
@@ -848,6 +861,8 @@ init_env(void)
     if (virFileMakePath(tmp) < 0)
         ABORT("Unable to create: %s", tmp);
 
+    make_dir(tmp, "devices");
+    make_dir(tmp, "drivers");
     make_file(tmp, "drivers_probe", NULL, -1);
 
 # define MAKE_PCI_DRIVER(name, ...) \