[libvirt] [sandbox 09/10] Don't add sandbox:root device if we have a mount targetting /

Cédric Bosdonnat cbosdonnat at suse.com
Thu Jun 25 16:49:46 UTC 2015


There is no need to expose the host file system if the user defined a
mount targetting /
---
 libvirt-sandbox/libvirt-sandbox-builder-machine.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
index 7a2af83..cd459ac 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -590,17 +590,19 @@ static gboolean gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
         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_SQUASH);
-    gvir_config_domain_filesys_set_source(fs,
-                                          gvir_sandbox_config_get_root(config));
-    gvir_config_domain_filesys_set_target(fs, "sandbox:root");
-    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_SQUASH);
+        gvir_config_domain_filesys_set_source(fs,
+                                              gvir_sandbox_config_get_root(config));
+        gvir_config_domain_filesys_set_target(fs, "sandbox:root");
+        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);
+    }
 
 
     fs = gvir_config_domain_filesys_new();
-- 
2.1.4




More information about the libvir-list mailing list