mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 22:03:49 +03:00
qemu: Check for existing file in namespace
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
3c18bc304e
commit
b0ef407c65
@ -929,6 +929,10 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data)
|
|||||||
bool isDev = S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode);
|
bool isDev = S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode);
|
||||||
bool isReg = S_ISREG(data->sb.st_mode) || S_ISFIFO(data->sb.st_mode) || S_ISSOCK(data->sb.st_mode);
|
bool isReg = S_ISREG(data->sb.st_mode) || S_ISFIFO(data->sb.st_mode) || S_ISSOCK(data->sb.st_mode);
|
||||||
bool isDir = S_ISDIR(data->sb.st_mode);
|
bool isDir = S_ISDIR(data->sb.st_mode);
|
||||||
|
bool exists = false;
|
||||||
|
|
||||||
|
if (virFileExists(data->file))
|
||||||
|
exists = true;
|
||||||
|
|
||||||
if (virFileMakeParentPath(data->file) < 0) {
|
if (virFileMakeParentPath(data->file) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
@ -1039,7 +1043,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data)
|
|||||||
virFileMoveMount(data->target, data->file) < 0)
|
virFileMoveMount(data->target, data->file) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = exists;
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0 && delDevice) {
|
if (ret < 0 && delDevice) {
|
||||||
if (isDir)
|
if (isDir)
|
||||||
@ -1069,15 +1073,21 @@ qemuNamespaceMknodHelper(pid_t pid G_GNUC_UNUSED,
|
|||||||
qemuNamespaceMknodData *data = opaque;
|
qemuNamespaceMknodData *data = opaque;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
bool exists = false;
|
||||||
|
|
||||||
qemuSecurityPostFork(data->driver->securityManager);
|
qemuSecurityPostFork(data->driver->securityManager);
|
||||||
|
|
||||||
for (i = 0; i < data->nitems; i++) {
|
for (i = 0; i < data->nitems; i++) {
|
||||||
if (qemuNamespaceMknodOne(&data->items[i]) < 0)
|
int rc = 0;
|
||||||
|
|
||||||
|
if ((rc = qemuNamespaceMknodOne(&data->items[i])) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (rc > 0)
|
||||||
|
exists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = exists;
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuNamespaceMknodDataClear(data);
|
qemuNamespaceMknodDataClear(data);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user