[sandbox 10/10] container builder: don't expose host rootfs if unneeded

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

 



If the user defined a mount targeting / don't add the host / as mount
to /.
---
 .../libvirt-sandbox-builder-container.c            | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c b/libvirt-sandbox/libvirt-sandbox-builder-container.c
index bd29c87..8315ab5 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-container.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c
@@ -225,17 +225,19 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
         construct_devices(builder, config, statedir, domain, error))
         goto cleanup;
 
-    fs = gvir_config_domain_filesys_new();
-    gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_MOUNT);
-    gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH);
-    gvir_config_domain_filesys_set_source(fs,
-                                          gvir_sandbox_config_get_root(config));
-    gvir_config_domain_filesys_set_target(fs, "/");
-    gvir_config_domain_filesys_set_readonly(fs, TRUE);
+    if (!gvir_sandbox_config_has_root_mount(config)) {
+        fs = gvir_config_domain_filesys_new();
+        gvir_config_domain_filesys_set_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_MOUNT);
+        gvir_config_domain_filesys_set_access_type(fs, GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH);
+        gvir_config_domain_filesys_set_source(fs,
+                                              gvir_sandbox_config_get_root(config));
+        gvir_config_domain_filesys_set_target(fs, "/");
+        gvir_config_domain_filesys_set_readonly(fs, TRUE);
 
-    gvir_config_domain_add_device(domain,
-                                  GVIR_CONFIG_DOMAIN_DEVICE(fs));
-    g_object_unref(fs);
+        gvir_config_domain_add_device(domain,
+                                      GVIR_CONFIG_DOMAIN_DEVICE(fs));
+        g_object_unref(fs);
+    }
 
 
 
-- 
2.1.4

--
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]