mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Fix uses of virFileMakePath
* src/lxc/lxc_container.c src/lxc/lxc_controller.c src/lxc/lxc_driver.c src/network/bridge_driver.c src/qemu/qemu_driver.c src/uml/uml_driver.c: virFileMakePath returns 0 for success, or the value of errno on failure, so error checking should be to test if non-zero, not if lower than 0
This commit is contained in:
parent
62927dd8f0
commit
623bc48ad8
@ -317,7 +317,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = virFileMakePath(oldroot)) < 0) {
|
if ((rc = virFileMakePath(oldroot)) != 0) {
|
||||||
virReportSystemError(NULL, rc,
|
virReportSystemError(NULL, rc,
|
||||||
_("Failed to create %s"),
|
_("Failed to create %s"),
|
||||||
oldroot);
|
oldroot);
|
||||||
@ -339,7 +339,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = virFileMakePath(newroot)) < 0) {
|
if ((rc = virFileMakePath(newroot)) != 0) {
|
||||||
virReportSystemError(NULL, rc,
|
virReportSystemError(NULL, rc,
|
||||||
_("Failed to create %s"),
|
_("Failed to create %s"),
|
||||||
newroot);
|
newroot);
|
||||||
@ -407,7 +407,7 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0 ; i < ARRAY_CARDINALITY(mnts) ; i++) {
|
for (i = 0 ; i < ARRAY_CARDINALITY(mnts) ; i++) {
|
||||||
if (virFileMakePath(mnts[i].dst) < 0) {
|
if (virFileMakePath(mnts[i].dst) != 0) {
|
||||||
virReportSystemError(NULL, errno,
|
virReportSystemError(NULL, errno,
|
||||||
_("Failed to mkdir %s"),
|
_("Failed to mkdir %s"),
|
||||||
mnts[i].src);
|
mnts[i].src);
|
||||||
@ -421,7 +421,7 @@ static int lxcContainerMountBasicFS(virDomainFSDefPtr root)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = virFileMakePath("/dev/pts") < 0)) {
|
if ((rc = virFileMakePath("/dev/pts") != 0)) {
|
||||||
virReportSystemError(NULL, rc, "%s",
|
virReportSystemError(NULL, rc, "%s",
|
||||||
_("Cannot create /dev/pts"));
|
_("Cannot create /dev/pts"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -510,7 +510,7 @@ static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileMakePath(vmDef->fss[i]->dst) < 0) {
|
if (virFileMakePath(vmDef->fss[i]->dst) != 0) {
|
||||||
virReportSystemError(NULL, errno,
|
virReportSystemError(NULL, errno,
|
||||||
_("Failed to create %s"),
|
_("Failed to create %s"),
|
||||||
vmDef->fss[i]->dst);
|
vmDef->fss[i]->dst);
|
||||||
|
@ -556,7 +556,7 @@ lxcControllerRun(virDomainDefPtr def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileMakePath(devpts) < 0) {
|
if (virFileMakePath(devpts) != 0) {
|
||||||
virReportSystemError(NULL, errno,
|
virReportSystemError(NULL, errno,
|
||||||
_("Failed to make path %s"),
|
_("Failed to make path %s"),
|
||||||
devpts);
|
devpts);
|
||||||
|
@ -1193,7 +1193,7 @@ static int lxcVmStart(virConnectPtr conn,
|
|||||||
char **veths = NULL;
|
char **veths = NULL;
|
||||||
lxcDomainObjPrivatePtr priv = vm->privateData;
|
lxcDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
if ((r = virFileMakePath(driver->logDir)) < 0) {
|
if ((r = virFileMakePath(driver->logDir)) != 0) {
|
||||||
virReportSystemError(conn, r,
|
virReportSystemError(conn, r,
|
||||||
_("Cannot create log directory '%s'"),
|
_("Cannot create log directory '%s'"),
|
||||||
driver->logDir);
|
driver->logDir);
|
||||||
|
@ -539,13 +539,13 @@ dhcpStartDhcpDaemon(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = virFileMakePath(NETWORK_PID_DIR)) < 0) {
|
if ((err = virFileMakePath(NETWORK_PID_DIR)) != 0) {
|
||||||
virReportSystemError(conn, err,
|
virReportSystemError(conn, err,
|
||||||
_("cannot create directory %s"),
|
_("cannot create directory %s"),
|
||||||
NETWORK_PID_DIR);
|
NETWORK_PID_DIR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((err = virFileMakePath(NETWORK_STATE_DIR)) < 0) {
|
if ((err = virFileMakePath(NETWORK_STATE_DIR)) != 0) {
|
||||||
virReportSystemError(conn, err,
|
virReportSystemError(conn, err,
|
||||||
_("cannot create directory %s"),
|
_("cannot create directory %s"),
|
||||||
NETWORK_STATE_DIR);
|
NETWORK_STATE_DIR);
|
||||||
|
@ -1042,19 +1042,19 @@ qemudStartup(int privileged) {
|
|||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileMakePath(qemu_driver->stateDir) < 0) {
|
if (virFileMakePath(qemu_driver->stateDir) != 0) {
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
VIR_ERROR(_("Failed to create state dir '%s': %s"),
|
VIR_ERROR(_("Failed to create state dir '%s': %s"),
|
||||||
qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
|
qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virFileMakePath(qemu_driver->libDir) < 0) {
|
if (virFileMakePath(qemu_driver->libDir) != 0) {
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
VIR_ERROR(_("Failed to create lib dir '%s': %s"),
|
VIR_ERROR(_("Failed to create lib dir '%s': %s"),
|
||||||
qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
|
qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virFileMakePath(qemu_driver->cacheDir) < 0) {
|
if (virFileMakePath(qemu_driver->cacheDir) != 0) {
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
VIR_ERROR(_("Failed to create cache dir '%s': %s"),
|
VIR_ERROR(_("Failed to create cache dir '%s': %s"),
|
||||||
qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf));
|
qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf));
|
||||||
@ -2786,7 +2786,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
|||||||
vm->def->graphics[0]->data.vnc.port = port;
|
vm->def->graphics[0]->data.vnc.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileMakePath(driver->logDir) < 0) {
|
if (virFileMakePath(driver->logDir) != 0) {
|
||||||
virReportSystemError(conn, errno,
|
virReportSystemError(conn, errno,
|
||||||
_("cannot create log directory %s"),
|
_("cannot create log directory %s"),
|
||||||
driver->logDir);
|
driver->logDir);
|
||||||
|
@ -419,7 +419,7 @@ umlStartup(int privileged) {
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileMakePath(uml_driver->monitorDir) < 0) {
|
if (virFileMakePath(uml_driver->monitorDir) != 0) {
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
VIR_ERROR(_("Failed to create monitor directory %s: %s"),
|
VIR_ERROR(_("Failed to create monitor directory %s: %s"),
|
||||||
uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof ebuf));
|
uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof ebuf));
|
||||||
@ -840,7 +840,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFileMakePath(driver->logDir) < 0) {
|
if (virFileMakePath(driver->logDir) != 0) {
|
||||||
virReportSystemError(conn, errno,
|
virReportSystemError(conn, errno,
|
||||||
_("cannot create log directory %s"),
|
_("cannot create log directory %s"),
|
||||||
driver->logDir);
|
driver->logDir);
|
||||||
|
Loading…
Reference in New Issue
Block a user