There is no functional change in this patch.
It only moves virLXCControllerAppendNBDPids above
virLXCControllerSetupNBDDeviceFS.
---
src/lxc/lxc_controller.c | 96 ++++++++++++++++++++++++------------------------
1 file changed, 49 insertions(+), 47 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 507bffda0..61d9ed07b 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -481,6 +481,55 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr
disk)
}
+static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl,
+ const char *dev)
+{
+ char *pidpath = NULL;
+ pid_t *pids = NULL;
+ size_t npids = 0;
+ size_t i;
+ int ret = -1;
+ size_t loops = 0;
+ pid_t pid;
+
+ if (!STRPREFIX(dev, "/dev/") ||
+ virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5)
< 0)
+ goto cleanup;
+
+ /* Wait for the pid file to appear */
+ while (!virFileExists(pidpath)) {
+ /* wait for 100ms before checking again, but don't do it for ever */
+ if (errno == ENOENT && loops < 10) {
+ usleep(100 * 1000);
+ loops++;
+ } else {
+ virReportSystemError(errno,
+ _("Cannot check NBD device %s pid"),
+ dev + 5);
+ goto cleanup;
+ }
+ }
+
+ if (virPidFileReadPath(pidpath, &pid) < 0)
+ goto cleanup;
+
+ if (virProcessGetPids(pid, &npids, &pids) < 0)
+ goto cleanup;
+
+ for (i = 0; i < npids; i++) {
+ if (VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]) < 0)
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(pids);
+ VIR_FREE(pidpath);
+ return ret;
+}
+
+
static int virLXCControllerSetupNBDDeviceFS(virDomainFSDefPtr fs)
{
char *dev;
@@ -545,53 +594,6 @@ static int virLXCControllerSetupNBDDeviceDisk(virDomainDiskDefPtr
disk)
return 0;
}
-static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl,
- const char *dev)
-{
- char *pidpath = NULL;
- pid_t *pids = NULL;
- size_t npids = 0;
- size_t i;
- int ret = -1;
- size_t loops = 0;
- pid_t pid;
-
- if (!STRPREFIX(dev, "/dev/") ||
- virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5)
< 0)
- goto cleanup;
-
- /* Wait for the pid file to appear */
- while (!virFileExists(pidpath)) {
- /* wait for 100ms before checking again, but don't do it for ever */
- if (errno == ENOENT && loops < 10) {
- usleep(100 * 1000);
- loops++;
- } else {
- virReportSystemError(errno,
- _("Cannot check NBD device %s pid"),
- dev + 5);
- goto cleanup;
- }
- }
-
- if (virPidFileReadPath(pidpath, &pid) < 0)
- goto cleanup;
-
- if (virProcessGetPids(pid, &npids, &pids) < 0)
- goto cleanup;
-
- for (i = 0; i < npids; i++) {
- if (VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]) < 0)
- goto cleanup;
- }
-
- ret = 0;
-
- cleanup:
- VIR_FREE(pids);
- VIR_FREE(pidpath);
- return ret;
-}
static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
{
--
2.14.3