[sandbox PATCH 04/10] Add disk support to the container builder

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

 



Use the new disk configuration in the container builder to provide disks in
lxc containers sandboxes.
---
 .../libvirt-sandbox-builder-container.c            | 36 +++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c b/libvirt-sandbox/libvirt-sandbox-builder-container.c
index 59bfee1..2a6c273 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-container.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c
@@ -218,7 +218,9 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
     GVirConfigDomainInterfaceNetwork *iface;
     GVirConfigDomainConsole *con;
     GVirConfigDomainChardevSourcePty *src;
-    GList *tmp = NULL, *mounts = NULL, *networks = NULL;
+    GVirConfigDomainDisk *disk;
+    GVirConfigDomainDiskDriver *diskDriver;
+    GList *tmp = NULL, *mounts = NULL, *networks = NULL, *disks = NULL;
     gchar *configdir = g_strdup_printf("%s/config", statedir);
     gboolean ret = FALSE;
 
@@ -226,6 +228,38 @@ static gboolean gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
         construct_devices(builder, config, statedir, domain, error))
         goto cleanup;
 
+
+    tmp = disks = gvir_sandbox_config_get_disks(config);
+    while(tmp){
+        GVirSandboxConfigDisk *dconfig = GVIR_SANDBOX_CONFIG_DISK(tmp->data);
+
+        if (GVIR_SANDBOX_IS_CONFIG_DISK(dconfig)){
+
+            disk = gvir_config_domain_disk_new();
+            diskDriver = gvir_config_domain_disk_driver_new();
+            gvir_config_domain_disk_set_type(disk,
+                                             gvir_sandbox_config_disk_get_disk_type(dconfig));
+            gvir_config_domain_disk_driver_set_format(diskDriver,
+                                                      gvir_sandbox_config_disk_get_format(dconfig));
+            gvir_config_domain_disk_driver_set_name(diskDriver, "nbd");
+            gvir_config_domain_disk_set_source(disk,
+                                               gvir_sandbox_config_disk_get_source(dconfig));
+            gvir_config_domain_disk_set_target_bus(disk,
+                                                   GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
+            gvir_config_domain_disk_set_target_dev(disk,
+                                                   gvir_sandbox_config_disk_get_target(dconfig));
+            gvir_config_domain_disk_set_driver(disk, diskDriver);
+            gvir_config_domain_add_device(domain,
+                                          GVIR_CONFIG_DOMAIN_DEVICE(disk));
+            g_object_unref(disk);
+        }
+    tmp = tmp->next;
+    }
+
+    g_list_foreach(disks, (GFunc)g_object_unref, NULL);
+    g_list_free(disks);
+
+
     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);
-- 
2.1.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]