Use the new disk configuration in the container builder to provide disks in
lxc containers sandboxes.
---
.../libvirt-sandbox-builder-container.c | 33 +++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c
b/libvirt-sandbox/libvirt-sandbox-builder-container.c
index 59bfee1..900acf2 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-container.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c
@@ -218,14 +218,45 @@ 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;
+ size_t nVirtioDev = 0;
if (!GVIR_SANDBOX_BUILDER_CLASS(gvir_sandbox_builder_container_parent_class)->
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)){
+ gchar *device = g_strdup_printf("sd%c", (char)('a' +
nVirtioDev++));
+ 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_set_source(disk,
+
gvir_sandbox_config_disk_get_source(dconfig));
+ gvir_config_domain_disk_set_target_dev(disk,device);
+ 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