]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_namespace: Properly report new files
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 15 Oct 2024 12:51:00 +0000 (14:51 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 16 Oct 2024 13:07:10 +0000 (15:07 +0200)
Function qemuNamespaceMknodOne() is supposed to return 0 if the file did
not exist before this function.  If, however, the file existed, but was
removed and recreated by this function the @existed flag should be reset
to its proper state (false) because the function then behaves the same
way as if the file did not exist as it needed to be recreated.

So reset the @existed flag to properly reflect what happened.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_namespace.c

index 71e29b4ba4f68a9d2058af44fc177c856ad62d95..33a773917373fa9254ccb07a8dd50214d3c2f945 100644 (file)
@@ -1022,6 +1022,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data)
                       data->file, data->target);
         } else {
             VIR_DEBUG("Creating symlink %s -> %s", data->file, data->target);
+            existed = false;
 
             /* First, unlink the symlink target. Symlinks change and
              * therefore we have no guarantees that pre-existing
@@ -1053,6 +1054,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data)
         } else {
             VIR_DEBUG("Creating dev %s (%d,%d)",
                       data->file, major(data->sb.st_rdev), minor(data->sb.st_rdev));
+            existed = false;
             unlink(data->file);
             if (mknod(data->file, data->sb.st_mode, data->sb.st_rdev) < 0) {
                 virReportSystemError(errno,