[PATCH] qemu: Provide non-linux stub for qemuDomainAttachDeviceMknodRecursive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The way we create devices under /dev is highly linux specific.
For instance we do mknod(), mount(), umount(), etc. Some
platforms are even missing some of these functions. Then again,
as declared in qemuDomainNamespaceAvailable(): namespaces are
linux only. Therefore, to avoid obfuscating the code by trying to
make it compile on weird platforms, just provide a non-linux stub
for qemuDomainAttachDeviceMknodRecursive(). At the same time,
qemuDomainAttachDeviceMknodHelper() which actually calls the
non-existent functions is moved under ifdef __linux__ block since
its only caller is in that block too.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 080ff336e..eb1a9794b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8541,6 +8541,8 @@ struct qemuDomainAttachDeviceMknodData {
 };
 
 
+/* Our way of creating devices is highly linux specific */
+#if defined(__linux__)
 static int
 qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
                                   void *opaque)
@@ -8638,7 +8640,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
     if (data->tcon &&
         lsetfilecon_raw(data->file, (VIR_SELINUX_CTX_CONST char *) data->tcon) < 0) {
         VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
@@ -8650,7 +8652,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
             goto cleanup;
         }
     }
-#endif
+# endif
 
     /* Finish mount process started earlier. */
     if (isReg &&
@@ -8661,9 +8663,9 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
  cleanup:
     if (ret < 0 && delDevice)
         unlink(data->file);
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
     freecon(data->tcon);
-#endif
+# endif
     virFileFreeACLs(&data->acl);
     return ret;
 }
@@ -8754,14 +8756,14 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
     if (lgetfilecon_raw(file, &data.tcon) < 0 &&
         (errno != ENOTSUP && errno != ENODATA)) {
         virReportSystemError(errno,
                              _("Unable to get SELinux label from %s"), file);
         goto cleanup;
     }
-#endif
+# endif
 
     if (STRPREFIX(file, DEVPREFIX)) {
         size_t i;
@@ -8798,9 +8800,9 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
 
     ret = 0;
  cleanup:
-#ifdef WITH_SELINUX
+# ifdef WITH_SELINUX
     freecon(data.tcon);
-#endif
+# endif
     virFileFreeACLs(&data.acl);
     if (isReg && target)
         umount(target);
@@ -8810,6 +8812,26 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
 }
 
 
+#else /* !defined(__linux__) */
+
+
+static int
+qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+                                     virDomainObjPtr vm ATTRIBUTE_UNUSED,
+                                     const char *file ATTRIBUTE_UNUSED,
+                                     char * const *devMountsPath ATTRIBUTE_UNUSED,
+                                     size_t ndevMountsPath ATTRIBUTE_UNUSED,
+                                     unsigned int ttl ATTRIBUTE_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("Namespaces are not supported on this platform."));
+    return -1;
+}
+
+
+#endif /* !defined(__linux__) */
+
+
 static int
 qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
                             virDomainObjPtr vm,
-- 
2.13.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux