virDomainObjPtr vm)
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- const unsigned long mount_flags = MS_MOVE;
char *devPath = NULL;
char **devMountsPath = NULL, **devMountsSavePath = NULL;
size_t ndevMountsPath = 0, i;
goto cleanup;
}
- if (mount(devMountsPath[i], devMountsSavePath[i],
- NULL, mount_flags, NULL) < 0) {
- virReportSystemError(errno,
- _("Unable to move %s mount"),
- devMountsPath[i]);
+ if (virFileMoveMount(devMountsPath[i], devMountsSavePath[i]) < 0)
goto cleanup;
- }
}
if (qemuDomainSetupAllDisks(driver, vm, devPath) < 0)
if (qemuDomainSetupAllRNGs(driver, vm, devPath) < 0)
goto cleanup;
- if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
- virReportSystemError(errno,
- _("Failed to mount %s on /dev"),
- devPath);
+ if (virFileMoveMount(devPath, "/dev") < 0)
goto cleanup;
- }
for (i = 0; i < ndevMountsPath; i++) {
if (devMountsSavePath[i] == devPath)
goto cleanup;
}
- if (mount(devMountsSavePath[i], devMountsPath[i],
- NULL, mount_flags, NULL) < 0) {
- virReportSystemError(errno,
- _("Failed to mount %s on %s"),
- devMountsSavePath[i],
- devMountsPath[i]);
+ if (virFileMoveMount(devMountsSavePath[i], devMountsPath[i]) < 0)
goto cleanup;
- }
}
ret = 0;
return 0;
}
+
+int
+virFileMoveMount(const char *src,
+ const char *dst)
+{
+ const unsigned long mount_flags = MS_MOVE;
+
+ if (mount(src, dst, NULL, mount_flags, NULL) < 0) {
+ virReportSystemError(errno,
+ _("Unable to move %s mount to %s"),
+ src, dst);
+ return -1;
+ }
+
+ return 0;
+}
+
+
#else /* !defined(__linux__) || !defined(HAVE_SYS_MOUNT_H) */
int
_("mount is not supported on this platform."));
return -1;
}
+
+
+int
+virFileMoveMount(const char *src ATTRIBUTE_UNUSED,
+ const char *dst ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("mount move is not supported on this platform."));
+ return -1;
+}
#endif /* !defined(__linux__) || !defined(HAVE_SYS_MOUNT_H) */