]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lib: Replace virFileMakePath() with g_mkdir_with_parents()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 26 Feb 2021 08:37:10 +0000 (09:37 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Mar 2021 19:52:23 +0000 (20:52 +0100)
Generated using the following spatch:

  @@
  expression path;
  @@
  - virFileMakePath(path)
  + g_mkdir_with_parents(path, 0777)

However, 14 occurrences were not replaced, e.g. in
virHostdevManagerNew(). I don't really understand why.
Fixed by hand afterwards.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
40 files changed:
src/bhyve/bhyve_driver.c
src/conf/domain_conf.c
src/conf/network_conf.c
src/conf/virnetworkportdef.c
src/conf/virnwfilterbindingobj.c
src/conf/virstorageobj.c
src/hypervisor/virhostdev.c
src/libxl/libxl_conf.c
src/libxl/libxl_driver.c
src/locking/lock_daemon.c
src/logging/log_daemon.c
src/lxc/lxc_container.c
src/lxc/lxc_controller.c
src/lxc/lxc_driver.c
src/lxc/lxc_fuse.c
src/lxc/lxc_process.c
src/network/bridge_driver.c
src/qemu/qemu_checkpoint.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
src/qemu/qemu_namespace.c
src/qemu/qemu_process.c
src/remote/remote_daemon.c
src/storage/storage_driver.c
src/storage/storage_util.c
src/util/vircgroupv1.c
src/util/vircgroupv2.c
src/util/virdaemon.c
src/util/virdnsmasq.c
src/util/virfile.c
src/util/virfilecache.c
src/util/virlog.c
src/util/virpidfile.c
src/util/virresctrl.c
tests/securityselinuxlabeltest.c
tests/vboxsnapshotxmltest.c
tests/vircgroupmock.c
tests/virhostdevtest.c
tests/virpcimock.c
tests/virstoragetest.c

index d02dc65a9de7536c7fa77f61ebddbd03392d424e..8363259d4c7c19305c590c7e6a536bc6794aafe3 100644 (file)
@@ -385,7 +385,7 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autostart)
             goto cleanup;
 
         if (autostart) {
-            if (virFileMakePath(BHYVE_AUTOSTART_DIR) < 0) {
+            if (g_mkdir_with_parents(BHYVE_AUTOSTART_DIR, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("cannot create autostart directory %s"),
                                      BHYVE_AUTOSTART_DIR);
@@ -1265,14 +1265,14 @@ bhyveStateInitialize(bool privileged,
     if (virBhyveLoadDriverConfig(bhyve_driver->config, SYSCONFDIR "/libvirt/bhyve.conf") < 0)
         goto cleanup;
 
-    if (virFileMakePath(BHYVE_LOG_DIR) < 0) {
+    if (g_mkdir_with_parents(BHYVE_LOG_DIR, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to mkdir %s"),
                              BHYVE_LOG_DIR);
         goto cleanup;
     }
 
-    if (virFileMakePath(BHYVE_STATE_DIR) < 0) {
+    if (g_mkdir_with_parents(BHYVE_STATE_DIR, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to mkdir %s"),
                              BHYVE_STATE_DIR);
index 05b6cb300063fea38b369694bce253dab1505a35..55c4c1a55b1e6ccd87d002ccc60f74047f4aa5b9 100644 (file)
@@ -29339,7 +29339,7 @@ virDomainDefSaveXML(virDomainDefPtr def,
     if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL)
         return -1;
 
-    if (virFileMakePath(configDir) < 0) {
+    if (g_mkdir_with_parents(configDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create config directory '%s'"),
                              configDir);
index 69d99a60e0ffdeeee3bc1987683bccaf548f76e9..4cf4aa484021a5ed8b5592dece568426efa53c83 100644 (file)
@@ -2759,7 +2759,7 @@ virNetworkSaveXML(const char *configDir,
     if ((configFile = virNetworkConfigFile(configDir, def->name)) == NULL)
         return -1;
 
-    if (virFileMakePath(configDir) < 0) {
+    if (g_mkdir_with_parents(configDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create config directory '%s'"),
                              configDir);
index 21ebbdb054a1b9454e029b0d8604af7058af5608..3923d2aa37b7a73f4653ddb56ff70cc2bee966ba 100644 (file)
@@ -443,7 +443,7 @@ virNetworkPortDefSaveStatus(virNetworkPortDef *def,
 
     virUUIDFormat(def->uuid, uuidstr);
 
-    if (virFileMakePath(dir) < 0)
+    if (g_mkdir_with_parents(dir, 0777) < 0)
         return -1;
 
     if (!(path = virNetworkPortDefConfigFile(dir, uuidstr)))
index 584721f8b63d7854c6baf595b70bb8a5ea1e51bb..2f29670f9f79d6be9c736bfe914e2f0014367d9c 100644 (file)
@@ -160,7 +160,7 @@ virNWFilterBindingObjSave(const virNWFilterBindingObj *obj,
     if (!(xml = virNWFilterBindingObjFormat(obj)))
         goto cleanup;
 
-    if (virFileMakePath(statusDir) < 0) {
+    if (g_mkdir_with_parents(statusDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create config directory '%s'"),
                              statusDir);
index 6a8874b1fb4aae9bb5fe3e05d57d9bac66d80218..69c2c2da36693587e6caa5c47ec6dcc81cc5a589 100644 (file)
@@ -1777,7 +1777,7 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
                          virStoragePoolDefPtr def)
 {
     if (!obj->configFile) {
-        if (virFileMakePath(driver->configDir) < 0) {
+        if (g_mkdir_with_parents(driver->configDir, 0777) < 0) {
             virReportSystemError(errno,
                                  _("cannot create config directory %s"),
                                  driver->configDir);
index 5686f0fe42b033bd9fde3fa6e24b831035bc6558..01c56f51bc69eaf6657635b4cab8c0f9bd6f521e 100644 (file)
@@ -171,7 +171,7 @@ virHostdevManagerNew(void)
     if (privileged) {
         hostdevMgr->stateDir = g_strdup(HOSTDEV_STATE_DIR);
 
-        if (virFileMakePath(hostdevMgr->stateDir) < 0) {
+        if (g_mkdir_with_parents(hostdevMgr->stateDir, 0777) < 0) {
             virReportError(VIR_ERR_OPERATION_FAILED,
                            _("Failed to create state dir '%s'"),
                            hostdevMgr->stateDir);
@@ -187,7 +187,7 @@ virHostdevManagerNew(void)
 
         old_umask = umask(077);
 
-        if (virFileMakePath(hostdevMgr->stateDir) < 0) {
+        if (g_mkdir_with_parents(hostdevMgr->stateDir, 0777) < 0) {
             umask(old_umask);
             virReportError(VIR_ERR_OPERATION_FAILED,
                            _("Failed to create state dir '%s'"),
index f2bcd77a29d62808c6e98e24b5e432214405d11a..4b6a7e60962aa6a6991453ee08eceed5d01e93a4 100644 (file)
@@ -1787,7 +1787,7 @@ libxlDriverConfigInit(libxlDriverConfigPtr cfg)
 {
     unsigned int free_mem;
 
-    if (virFileMakePath(cfg->logDir) < 0) {
+    if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create log dir '%s': %s"),
                        cfg->logDir,
index 6657e69acb39eeb6236259a3632ff79625470048..c93dbeeabfe1ee8faf3fe9f36800af86e8abf682 100644 (file)
@@ -721,35 +721,35 @@ libxlStateInitialize(bool privileged,
     libxl_event_register_callbacks(cfg->ctx, &ev_hooks, libxl_driver);
 
     libxl_driver->config = cfg;
-    if (virFileMakePath(cfg->stateDir) < 0) {
+    if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create state dir '%s': %s"),
                        cfg->stateDir,
                        g_strerror(errno));
         goto error;
     }
-    if (virFileMakePath(cfg->libDir) < 0) {
+    if (g_mkdir_with_parents(cfg->libDir, 0777) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create lib dir '%s': %s"),
                        cfg->libDir,
                        g_strerror(errno));
         goto error;
     }
-    if (virFileMakePath(cfg->saveDir) < 0) {
+    if (g_mkdir_with_parents(cfg->saveDir, 0777) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create save dir '%s': %s"),
                        cfg->saveDir,
                        g_strerror(errno));
         goto error;
     }
-    if (virFileMakePath(cfg->autoDumpDir) < 0) {
+    if (g_mkdir_with_parents(cfg->autoDumpDir, 0777) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create dump dir '%s': %s"),
                        cfg->autoDumpDir,
                        g_strerror(errno));
         goto error;
     }
-    if (virFileMakePath(cfg->channelDir) < 0) {
+    if (g_mkdir_with_parents(cfg->channelDir, 0777) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create channel dir '%s': %s"),
                        cfg->channelDir,
@@ -4543,7 +4543,7 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
             goto endjob;
 
         if (autostart) {
-            if (virFileMakePath(cfg->autostartDir) < 0) {
+            if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("cannot create autostart directory %s"),
                                      cfg->autostartDir);
index d68c61b099c4a3e3f4c6eb46a951dd22cacbc5d1..04038d266871ec429a011dda10a201b81161ef59 100644 (file)
@@ -602,7 +602,7 @@ virLockDaemonExecRestartStatePath(bool privileged,
         rundir = virGetUserRuntimeDirectory();
 
         old_umask = umask(077);
-        if (virFileMakePath(rundir) < 0) {
+        if (g_mkdir_with_parents(rundir, 0777) < 0) {
             umask(old_umask);
             return -1;
         }
@@ -993,7 +993,7 @@ int main(int argc, char **argv) {
     else
         old_umask = umask(077);
     VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
-    if (virFileMakePath(run_dir) < 0) {
+    if (g_mkdir_with_parents(run_dir, 0777) < 0) {
         VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
                   g_strerror(errno));
         ret = VIR_DAEMON_ERR_RUNDIR;
index cc0b96ea0512925d9b0ebbaf41d682b2e060a39f..aa76dcd329c44d01bb4761de4462c9d278fb9418 100644 (file)
@@ -407,7 +407,7 @@ virLogDaemonExecRestartStatePath(bool privileged,
         rundir = virGetUserRuntimeDirectory();
 
         old_umask = umask(077);
-        if (virFileMakePath(rundir) < 0) {
+        if (g_mkdir_with_parents(rundir, 0777) < 0) {
             umask(old_umask);
             return -1;
         }
@@ -780,7 +780,7 @@ int main(int argc, char **argv) {
     else
         old_umask = umask(077);
     VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
-    if (virFileMakePath(run_dir) < 0) {
+    if (g_mkdir_with_parents(run_dir, 0777) < 0) {
         VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
                   g_strerror(errno));
         ret = VIR_DAEMON_ERR_RUNDIR;
index 2a5f8711c4714c0c27b8b37b282312826e0e4a26..70b776e17296a30cb98444b962abffad09175f40 100644 (file)
@@ -665,7 +665,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
 
     oldroot = g_strdup_printf("%s/.oldroot", root->src->path);
 
-    if (virFileMakePath(oldroot) < 0) {
+    if (g_mkdir_with_parents(oldroot, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to create %s"),
                              oldroot);
@@ -684,7 +684,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
     /* Create a directory called 'new' in tmpfs */
     newroot = g_strdup_printf("%s/new", oldroot);
 
-    if (virFileMakePath(newroot) < 0) {
+    if (g_mkdir_with_parents(newroot, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to create %s"),
                              newroot);
@@ -889,7 +889,7 @@ static int lxcContainerMountBasicFS(bool userns_enabled,
             continue;
         }
 
-        if (virFileMakePath(mnt->dst) < 0) {
+        if (g_mkdir_with_parents(mnt->dst, 0777) < 0) {
             virReportSystemError(errno,
                                  _("Failed to mkdir %s"),
                                  mnt->dst);
@@ -969,7 +969,7 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
 
     path = g_strdup_printf("/.oldroot/%s/%s.dev", stateDir, def->name);
 
-    if (virFileMakePath("/dev") < 0) {
+    if (g_mkdir_with_parents("/dev", 0777) < 0) {
         virReportSystemError(errno, "%s",
                              _("Cannot create /dev"));
         return -1;
@@ -998,7 +998,7 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
 
     path = g_strdup_printf("/.oldroot/%s/%s.devpts", stateDir, def->name);
 
-    if (virFileMakePath("/dev/pts") < 0) {
+    if (g_mkdir_with_parents("/dev/pts", 0777) < 0) {
         virReportSystemError(errno, "%s",
                              _("Cannot create /dev/pts"));
         return -1;
@@ -1080,7 +1080,7 @@ static int lxcContainerMountFSBind(virDomainFSDefPtr fs,
             return -1;
         }
         if (S_ISDIR(st.st_mode)) {
-            if (virFileMakePath(fs->dst) < 0) {
+            if (g_mkdir_with_parents(fs->dst, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("Failed to create %s"),
                                      fs->dst);
@@ -1349,7 +1349,7 @@ static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs,
     if (fs->readonly)
         fsflags |= MS_RDONLY;
 
-    if (virFileMakePath(fs->dst) < 0) {
+    if (g_mkdir_with_parents(fs->dst, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to create %s"),
                              fs->dst);
@@ -1403,7 +1403,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
 
     data = g_strdup_printf("size=%lld%s", fs->usage, sec_mount_options);
 
-    if (virFileMakePath(fs->dst) < 0) {
+    if (g_mkdir_with_parents(fs->dst, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to create %s"),
                              fs->dst);
@@ -1508,7 +1508,7 @@ int lxcContainerSetupHostdevCapsMakePath(const char *dev)
 
     if ((tmp = strrchr(dir, '/'))) {
         *tmp = '\0';
-        if (virFileMakePath(dir) < 0) {
+        if (g_mkdir_with_parents(dir, 0777) < 0) {
             virReportSystemError(errno,
                                  _("Failed to create directory for '%s' dev '%s'"),
                                  dir, dev);
index 8f166a436af4c64943b532e4b051ceceba49bd89..f633a24b16178df955f566ca30245cde4a38bf0c 100644 (file)
@@ -1608,7 +1608,7 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
 
     mode = 0700 | S_IFCHR;
 
-    if (virFileMakePath(dstdir) < 0) {
+    if (g_mkdir_with_parents(dstdir, 0777) < 0) {
         virReportSystemError(errno,
                              _("Unable to create %s"), dstdir);
         return -1;
@@ -2128,7 +2128,7 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
     devpts = g_strdup_printf("%s/%s.devpts", LXC_STATE_DIR, ctrl->def->name);
     ctrl->devptmx = g_strdup_printf("%s/%s.devpts/ptmx", LXC_STATE_DIR, ctrl->def->name);
 
-    if (virFileMakePath(devpts) < 0) {
+    if (g_mkdir_with_parents(devpts, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to make path %s"),
                              devpts);
index 61faceb2de423634ff9c04e30ea14f273cd39134..51a1d01ec907c6b219f4c18114ba3f6199b33563 100644 (file)
@@ -1535,7 +1535,7 @@ static int lxcStateInitialize(bool privileged,
     if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
         goto cleanup;
 
-    if (virFileMakePath(cfg->stateDir) < 0) {
+    if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to mkdir %s"),
                              cfg->stateDir);
@@ -2513,7 +2513,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
         goto endjob;
 
     if (autostart) {
-        if (virFileMakePath(cfg->autostartDir) < 0) {
+        if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
             virReportSystemError(errno,
                                  _("Cannot create autostart directory %s"),
                                  cfg->autostartDir);
index 6e23361617d67d450647e180d9e86117dc4ca8f7..10ddd59a99cff95b6977a4a944b7354fbb7b6be6 100644 (file)
@@ -291,7 +291,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
 
     fuse->mountpoint = g_strdup_printf("%s/%s.fuse/", LXC_STATE_DIR, def->name);
 
-    if (virFileMakePath(fuse->mountpoint) < 0) {
+    if (g_mkdir_with_parents(fuse->mountpoint, 0777) < 0) {
         virReportSystemError(errno, _("Cannot create %s"),
                              fuse->mountpoint);
         goto cleanup1;
index 679709605ec842de8c0cce973432e0ebac958618..d0b1d80523b9e02ce9cc7366c775c3a422b39834 100644 (file)
@@ -1250,7 +1250,7 @@ int virLXCProcessStart(virConnectPtr conn,
         }
     }
 
-    if (virFileMakePath(cfg->logDir) < 0) {
+    if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("Cannot create log directory '%s'"),
                              cfg->logDir);
index b29c37ef4c510b1b8f13b42db7c2567376f5ee1a..32872d7ec144c37f4b67064cd866816f54cf669a 100644 (file)
@@ -737,7 +737,7 @@ networkStateInitialize(bool privileged,
         network_driver->radvdStateDir = g_strdup_printf("%s/radvd/lib", rundir);
     }
 
-    if (virFileMakePath(network_driver->stateDir) < 0) {
+    if (g_mkdir_with_parents(network_driver->stateDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create directory %s"),
                              network_driver->stateDir);
@@ -1618,7 +1618,7 @@ networkStartDhcpDaemon(virNetworkDriverStatePtr driver,
     if (!needDnsmasq && def->dns.enable == VIR_TRISTATE_BOOL_NO)
         return 0;
 
-    if (virFileMakePath(driver->pidDir) < 0) {
+    if (g_mkdir_with_parents(driver->pidDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create directory %s"),
                              driver->pidDir);
@@ -1628,7 +1628,7 @@ networkStartDhcpDaemon(virNetworkDriverStatePtr driver,
     if (!(pidfile = virPidFileBuildPath(driver->pidDir, def->name)))
         return -1;
 
-    if (virFileMakePath(driver->dnsmasqStateDir) < 0) {
+    if (g_mkdir_with_parents(driver->dnsmasqStateDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create directory %s"),
                              driver->dnsmasqStateDir);
@@ -1901,14 +1901,14 @@ networkStartRadvd(virNetworkDriverStatePtr driver,
         return -1;
     }
 
-    if (virFileMakePath(driver->pidDir) < 0) {
+    if (g_mkdir_with_parents(driver->pidDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create directory %s"),
                              driver->pidDir);
         return -1;
     }
 
-    if (virFileMakePath(driver->radvdStateDir) < 0) {
+    if (g_mkdir_with_parents(driver->radvdStateDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create directory %s"),
                              driver->radvdStateDir);
@@ -4003,7 +4003,7 @@ networkSetAutostart(virNetworkPtr net,
             goto cleanup;
 
         if (new_autostart) {
-            if (virFileMakePath(driver->networkAutostartDir) < 0) {
+            if (g_mkdir_with_parents(driver->networkAutostartDir, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("cannot create autostart directory '%s'"),
                                      driver->networkAutostartDir);
index 1740cadabf9dccb005f394e867dbe44120b41f99..689a556959f76b267a6321d809346c0d08fc5c92 100644 (file)
@@ -123,7 +123,7 @@ qemuCheckpointWriteMetadata(virDomainObjPtr vm,
         return -1;
 
     chkDir = g_strdup_printf("%s/%s", checkpointDir, vm->def->name);
-    if (virFileMakePath(chkDir) < 0) {
+    if (g_mkdir_with_parents(chkDir, 0777) < 0) {
         virReportSystemError(errno, _("cannot create checkpoint directory '%s'"),
                              chkDir);
         return -1;
index bb14fe2e33b69756189b879fde9a4c7a5dc50303..17fa71c21b7dc71fc2791e558ec209457d136296 100644 (file)
@@ -6786,7 +6786,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
         return -1;
 
     snapDir = g_strdup_printf("%s/%s", snapshotDir, vm->def->name);
-    if (virFileMakePath(snapDir) < 0) {
+    if (g_mkdir_with_parents(snapDir, 0777) < 0) {
         virReportSystemError(errno, _("cannot create snapshot directory '%s'"),
                              snapDir);
         return -1;
index 75076bfa642f4b36d946eb44e574b2bc2f9753d4..185fe903b2eca6b93d2da49c10da27ba56cfec4b 100644 (file)
@@ -654,57 +654,57 @@ qemuStateInitialize(bool privileged,
     if (virQEMUDriverConfigSetDefaults(cfg) < 0)
         goto error;
 
-    if (virFileMakePath(cfg->stateDir) < 0) {
+    if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create state dir %s"),
                              cfg->stateDir);
         goto error;
     }
-    if (virFileMakePath(cfg->libDir) < 0) {
+    if (g_mkdir_with_parents(cfg->libDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create lib dir %s"),
                              cfg->libDir);
         goto error;
     }
-    if (virFileMakePath(cfg->cacheDir) < 0) {
+    if (g_mkdir_with_parents(cfg->cacheDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create cache dir %s"),
                              cfg->cacheDir);
         goto error;
     }
-    if (virFileMakePath(cfg->saveDir) < 0) {
+    if (g_mkdir_with_parents(cfg->saveDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create save dir %s"),
                              cfg->saveDir);
         goto error;
     }
-    if (virFileMakePath(cfg->snapshotDir) < 0) {
+    if (g_mkdir_with_parents(cfg->snapshotDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create snapshot dir %s"),
                              cfg->snapshotDir);
         goto error;
     }
-    if (virFileMakePath(cfg->checkpointDir) < 0) {
+    if (g_mkdir_with_parents(cfg->checkpointDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create checkpoint dir %s"),
                              cfg->checkpointDir);
         goto error;
     }
-    if (virFileMakePath(cfg->autoDumpPath) < 0) {
+    if (g_mkdir_with_parents(cfg->autoDumpPath, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create dump dir %s"),
                              cfg->autoDumpPath);
         goto error;
     }
-    if (virFileMakePath(cfg->channelTargetDir) < 0) {
+    if (g_mkdir_with_parents(cfg->channelTargetDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create channel target dir %s"),
                              cfg->channelTargetDir);
         goto error;
     }
-    if (virFileMakePath(cfg->nvramDir) < 0) {
+    if (g_mkdir_with_parents(cfg->nvramDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create nvram dir %s"),
                              cfg->nvramDir);
         goto error;
     }
-    if (virFileMakePath(cfg->memoryBackingDir) < 0) {
+    if (g_mkdir_with_parents(cfg->memoryBackingDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create memory backing dir %s"),
                              cfg->memoryBackingDir);
         goto error;
     }
-    if (virFileMakePath(cfg->slirpStateDir) < 0) {
+    if (g_mkdir_with_parents(cfg->slirpStateDir, 0777) < 0) {
         virReportSystemError(errno, _("Failed to create slirp state dir %s"),
                              cfg->slirpStateDir);
         goto error;
@@ -891,7 +891,7 @@ qemuStateInitialize(bool privileged,
         if (!hugepagePath)
             goto error;
 
-        if (virFileMakePath(hugepagePath) < 0) {
+        if (g_mkdir_with_parents(hugepagePath, 0777) < 0) {
             virReportSystemError(errno,
                                  _("unable to create hugepage path %s"),
                                  hugepagePath);
@@ -8265,7 +8265,7 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
             goto endjob;
 
         if (autostart) {
-            if (virFileMakePath(cfg->autostartDir) < 0) {
+            if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("cannot create autostart directory %s"),
                                      cfg->autostartDir);
index f4b4d4d9ec4b39c7b7a343ac463681b9ca59c069..cc08aa8c362074481c8bef541abe34771a7c2b52 100644 (file)
@@ -720,7 +720,7 @@ qemuDomainUnshareNamespace(virQEMUDriverConfigPtr cfg,
         /* At this point, devMountsPath is either:
          * a file (regular or special), or
          * a directory. */
-        if ((S_ISDIR(sb.st_mode) && virFileMakePath(devMountsSavePath[i]) < 0) ||
+        if ((S_ISDIR(sb.st_mode) && g_mkdir_with_parents(devMountsSavePath[i], 0777) < 0) ||
             (!S_ISDIR(sb.st_mode) && virFileTouch(devMountsSavePath[i], sb.st_mode) < 0)) {
             virReportSystemError(errno,
                                  _("Failed to create %s"),
@@ -749,7 +749,7 @@ qemuDomainUnshareNamespace(virQEMUDriverConfigPtr cfg,
         }
 
         if (S_ISDIR(sb.st_mode)) {
-            if (virFileMakePath(devMountsPath[i]) < 0) {
+            if (g_mkdir_with_parents(devMountsPath[i], 0777) < 0) {
                 virReportSystemError(errno, _("Cannot create %s"),
                                      devMountsPath[i]);
                 goto cleanup;
index 944664ca28e0376b046e822d1318de20e511eca6..d3208e520328a4575a534e93d9e35c89ea6cfd26 100644 (file)
@@ -6713,7 +6713,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
     VIR_DEBUG("Ensuring no historical cgroup is lying around");
     qemuRemoveCgroup(vm);
 
-    if (virFileMakePath(cfg->logDir) < 0) {
+    if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) {
         virReportSystemError(errno,
                              _("cannot create log directory %s"),
                              cfg->logDir);
index 635e1deec884b49410ea16748dd9e816b46e07de..c5563a0e80d2581964cfec3d9c07a411e4e6cecf 100644 (file)
@@ -999,7 +999,7 @@ int main(int argc, char **argv) {
     else
         old_umask = umask(077);
     VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
-    if (virFileMakePath(run_dir) < 0) {
+    if (g_mkdir_with_parents(run_dir, 0777) < 0) {
         VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
                   g_strerror(errno));
         ret = VIR_DAEMON_ERR_RUNDIR;
index 9c5be071df1cebf0697ff61c9c547ab3654ba938..ecb5b86b4fa5c05b546a7f598ef7c2e2ed2f42d9 100644 (file)
@@ -291,7 +291,7 @@ storageStateInitialize(bool privileged,
     }
     driver->privileged = privileged;
 
-    if (virFileMakePath(driver->stateDir) < 0) {
+    if (g_mkdir_with_parents(driver->stateDir, 0777) < 0) {
         virReportError(errno,
                        _("cannot create directory %s"),
                        driver->stateDir);
@@ -1398,7 +1398,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
     cur_autostart = virStoragePoolObjIsAutostart(obj);
     if (cur_autostart != new_autostart) {
         if (new_autostart) {
-            if (virFileMakePath(driver->autostartDir) < 0) {
+            if (g_mkdir_with_parents(driver->autostartDir, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("cannot create autostart directory %s"),
                                      driver->autostartDir);
index db2c7a18bf27a099e167e560b29bc7abede54e58..687bc645ee7c9a44aec5c748a332fddd99a95b4f 100644 (file)
@@ -2811,7 +2811,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
         /* assure all directories in the path prior to the final dir
          * exist, with default uid/gid/mode. */
         *p = '\0';
-        if (virFileMakePath(parent) < 0) {
+        if (g_mkdir_with_parents(parent, 0777) < 0) {
             virReportSystemError(errno, _("cannot create path '%s'"),
                                  parent);
             return -1;
index f8bdca4e78983e2f3546dbd272fc3baf684b88e6..0e7ab98a0100200e8daf67f6bc2fb839f37513ad 100644 (file)
@@ -864,7 +864,7 @@ virCgroupV1BindMount(virCgroupPtr group,
 
     VIR_DEBUG("Mounting cgroups at '%s'", root);
 
-    if (virFileMakePath(root) < 0) {
+    if (g_mkdir_with_parents(root, 0777) < 0) {
         virReportSystemError(errno,
                              _("Unable to create directory %s"),
                              root);
@@ -890,7 +890,7 @@ virCgroupV1BindMount(virCgroupPtr group,
 
             VIR_DEBUG("Create mount point '%s'",
                       group->legacy[i].mountPoint);
-            if (virFileMakePath(group->legacy[i].mountPoint) < 0) {
+            if (g_mkdir_with_parents(group->legacy[i].mountPoint, 0777) < 0) {
                 virReportSystemError(errno,
                                      _("Unable to create directory %s"),
                                      group->legacy[i].mountPoint);
index 669bf1b52e377978f18f94bfe2a23019b15908c9..248d4047e5ddae7ffedd9db18bc0380f08903046 100644 (file)
@@ -595,7 +595,7 @@ virCgroupV2BindMount(virCgroupPtr group,
 
     VIR_DEBUG("Mounting cgroups at '%s'", group->unified.mountPoint);
 
-    if (virFileMakePath(group->unified.mountPoint) < 0) {
+    if (g_mkdir_with_parents(group->unified.mountPoint, 0777) < 0) {
         virReportSystemError(errno, _("Unable to create directory %s"),
                              group->unified.mountPoint);
         return -1;
index a02665dce839942a473cb04e5ee73987fb0914ba..bb2df2eb2cab12f3f61d29e5dca1ea9d5ffed4a4 100644 (file)
@@ -238,7 +238,7 @@ virDaemonUnixSocketPaths(const char *sock_prefix,
             rundir = virGetUserRuntimeDirectory();
 
             old_umask = umask(077);
-            if (virFileMakePath(rundir) < 0) {
+            if (g_mkdir_with_parents(rundir, 0777) < 0) {
                 umask(old_umask);
                 goto cleanup;
             }
index 3eee4a5a840e804a1c4d7418121640ba976a1490..3913114eca610dfc079000f34099cd2b812ccf48 100644 (file)
@@ -524,7 +524,7 @@ dnsmasqSave(const dnsmasqContext *ctx)
 {
     int ret = 0;
 
-    if (virFileMakePath(ctx->config_dir) < 0) {
+    if (g_mkdir_with_parents(ctx->config_dir, 0777) < 0) {
         virReportSystemError(errno, _("cannot create config directory '%s'"),
                              ctx->config_dir);
         return -1;
index afa3f015f549304a909431f0ecea47fe092b46a3..7b907de588c0018954a60e0852ac2f172d1c9561 100644 (file)
@@ -3733,7 +3733,7 @@ virFileSetupDev(const char *path,
     const unsigned long mount_flags = MS_NOSUID;
     const char *mount_fs = "tmpfs";
 
-    if (virFileMakePath(path) < 0) {
+    if (g_mkdir_with_parents(path, 0777) < 0) {
         virReportSystemError(errno,
                              _("Failed to make path %s"), path);
         return -1;
@@ -3758,7 +3758,7 @@ virFileBindMountDevice(const char *src,
 {
     if (!virFileExists(dst)) {
         if (virFileIsDir(src)) {
-            if (virFileMakePath(dst) < 0) {
+            if (g_mkdir_with_parents(dst, 0777) < 0) {
                 virReportSystemError(errno, _("Unable to make dir %s"), dst);
                 return -1;
             }
index 14b28855053cb020e4f89a41d591c53b0ae0f99f..f2324b2cf216c75a008497a12ddd28310bea9d28 100644 (file)
@@ -106,7 +106,7 @@ virFileCacheGetFileName(virFileCachePtr cache,
     if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &namehash) < 0)
         return NULL;
 
-    if (virFileMakePath(cache->dir) < 0) {
+    if (g_mkdir_with_parents(cache->dir, 0777) < 0) {
         virReportSystemError(errno,
                              _("Unable to create directory '%s'"),
                              cache->dir);
index 00c0fcc45702c2488bcd355beb82a8dbbada9709..934c96915ba22b09d43749dae5038533067463b1 100644 (file)
@@ -176,7 +176,7 @@ virLogSetDefaultOutputToFile(const char *binary, bool privileged)
         logdir = virGetUserCacheDirectory();
 
         old_umask = umask(077);
-        if (virFileMakePath(logdir) < 0) {
+        if (g_mkdir_with_parents(logdir, 0777) < 0) {
             umask(old_umask);
             return -1;
         }
index 4c38ebe50028da5db61511ce7c1c4ab9c2921827..c6389c1869c492f1dd539642acf848cab2f79968 100644 (file)
@@ -93,7 +93,7 @@ int virPidFileWrite(const char *dir,
     if (name == NULL || dir == NULL)
         return -EINVAL;
 
-    if (virFileMakePath(dir) < 0)
+    if (g_mkdir_with_parents(dir, 0777) < 0)
         return -errno;
 
     if (!(pidfile = virPidFileBuildPath(dir, name)))
index ab35bccfc5815faa58d1ca47c1375041aaea244d..0460be8d3a84c8b82e2d1e43dc4e7c553126c7a6 100644 (file)
@@ -2337,7 +2337,7 @@ virResctrlCreateGroupPath(const char *path)
     if (virFileExists(path))
         return 0;
 
-    if (virFileMakePath(path) < 0) {
+    if (g_mkdir_with_parents(path, 0777) < 0) {
         virReportSystemError(errno,
                              _("Cannot create resctrl directory '%s'"),
                              path);
index 168acc2bdfa373cc03e5122ed7552021fdf18e59..b1bf6e0f9548a57a247403df4d2a3fbe8617b11a 100644 (file)
@@ -62,7 +62,7 @@ testUserXattrEnabled(void)
     char *path = NULL;
     path = g_strdup_printf("%s/securityselinuxlabeldata/testxattr", abs_builddir);
 
-    if (virFileMakePath(abs_builddir "/securityselinuxlabeldata") < 0 ||
+    if (g_mkdir_with_parents(abs_builddir "/securityselinuxlabeldata", 0777) < 0 ||
         virFileTouch(path, 0600) < 0)
         goto cleanup;
 
@@ -221,7 +221,7 @@ testSELinuxCreateDisks(testSELinuxFile *files, size_t nfiles)
 {
     size_t i;
 
-    if (virFileMakePath(abs_builddir "/securityselinuxlabeldata/nfs") < 0)
+    if (g_mkdir_with_parents(abs_builddir "/securityselinuxlabeldata/nfs", 0777) < 0)
         return -1;
 
     for (i = 0; i < nfiles; i++) {
index 9298bcb837a451f13f8831590c432ebb0c416a70..e44ca7fc98db4bcb53d71899088d813261962624 100644 (file)
@@ -54,7 +54,7 @@ testCompareXMLtoXMLFiles(const char *xml)
 
     pathResult = g_strdup(abs_builddir "/vboxsnapshotxmldata/testResult.vbox");
 
-    if (virFileMakePath(abs_builddir "/vboxsnapshotxmldata") < 0)
+    if (g_mkdir_with_parents(abs_builddir "/vboxsnapshotxmldata", 0777) < 0)
         goto cleanup;
 
     if (virTestLoadFile(xml, &xmlData) < 0)
index dac6b6b99134355dab34f0f75a096f6ea8d52d81..5d7badc44aefb603cac6cbc047650bdb9e7d5ff0 100644 (file)
@@ -371,7 +371,7 @@ static void init_sysfs(void)
     fakesysfscgroupdir = g_strdup_printf("%s%s",
                                          fakerootdir, SYSFS_CGROUP_PREFIX);
 
-    if (virFileMakePath(fakesysfscgroupdir) < 0) {
+    if (g_mkdir_with_parents(fakesysfscgroupdir, 0777) < 0) {
         fprintf(stderr, "Cannot create %s\n", fakesysfscgroupdir);
         abort();
     }
index 91f9112e8bc744eb1145c99d3b1e312a56c87dbb..d3c0bca1c030870b6c180bee888b0ed5cea67191 100644 (file)
@@ -162,7 +162,7 @@ myInit(void)
     if ((mgr->activeNVMeHostdevs = virNVMeDeviceListNew()) == NULL)
         goto cleanup;
     mgr->stateDir = g_strdup(TEST_STATE_DIR);
-    if (virFileMakePath(mgr->stateDir) < 0)
+    if (g_mkdir_with_parents(mgr->stateDir, 0777) < 0)
         goto cleanup;
 
     return 0;
index d1c6220c5751e47be8b2aa371674828a8adfd954..be513ad91842df6c129289b88e1f5b401ca13eca 100644 (file)
@@ -201,7 +201,7 @@ make_dir(const char *path,
 
     dirpath = g_strdup_printf("%s/%s", path, name);
 
-    if (virFileMakePath(dirpath) < 0)
+    if (g_mkdir_with_parents(dirpath, 0777) < 0)
         ABORT("Unable to create: %s", dirpath);
 }
 
@@ -405,7 +405,7 @@ pci_device_create_iommu(const struct pciDevice *dev,
     iommuPath = g_strdup_printf("%s/sys/kernel/iommu_groups/%d/devices/",
                                 fakerootdir, dev->iommuGroup);
 
-    if (virFileMakePath(iommuPath) < 0)
+    if (g_mkdir_with_parents(iommuPath, 0777) < 0)
         ABORT("Unable to create: %s", iommuPath);
 
     if (g_snprintf(tmp, sizeof(tmp),
@@ -473,7 +473,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
     if (!(devpath = pci_device_get_path(dev, NULL, true)))
         ABORT_OOM();
 
-    if (virFileMakePath(devpath) < 0)
+    if (g_mkdir_with_parents(devpath, 0777) < 0)
         ABORT("Unable to create: %s", devpath);
 
     if (stat(configSrc, &sb) == 0)
@@ -693,7 +693,7 @@ pci_driver_new(const char *name, ...)
     if (!(driverpath = pci_driver_get_path(driver, NULL, true)))
         ABORT_OOM();
 
-    if (virFileMakePath(driverpath) < 0)
+    if (g_mkdir_with_parents(driverpath, 0777) < 0)
         ABORT("Unable to create: %s", driverpath);
 
     va_start(args, name);
@@ -954,7 +954,7 @@ init_env(void)
 
     tmp = g_strdup_printf("%s%s", fakerootdir, SYSFS_PCI_PREFIX);
 
-    if (virFileMakePath(tmp) < 0)
+    if (g_mkdir_with_parents(tmp, 0777) < 0)
         ABORT("Unable to create: %s", tmp);
 
     make_dir(tmp, "devices");
@@ -965,7 +965,7 @@ init_env(void)
     VIR_FREE(tmp);
     tmp = g_strdup_printf("%s/dev/vfio", fakerootdir);
 
-    if (virFileMakePath(tmp) < 0)
+    if (g_mkdir_with_parents(tmp, 0777) < 0)
         ABORT("Unable to create: %s", tmp);
 
     make_file(tmp, "vfio", NULL, -1);
index 762328df9a3a0c580341fd580039b11b24d0da79..84dd813b8046a8c8e5af685da2c2f265b790c3ff 100644 (file)
@@ -141,11 +141,11 @@ testPrepImages(void)
     absdir = g_strdup_printf("%s/dir", datadir);
     abslink2 = g_strdup_printf("%s/sub/link2", datadir);
 
-    if (virFileMakePath(datadir "/sub") < 0) {
+    if (g_mkdir_with_parents(datadir "/sub", 0777) < 0) {
         fprintf(stderr, "unable to create directory %s\n", datadir "/sub");
         goto cleanup;
     }
-    if (virFileMakePath(datadir "/dir") < 0) {
+    if (g_mkdir_with_parents(datadir "/dir", 0777) < 0) {
         fprintf(stderr, "unable to create directory %s\n", datadir "/dir");
         goto cleanup;
     }