Let the user specify the format of the source disk image in host-image
mounts. This will allow us to mount other image types than raw ones.
---
.../libvirt-sandbox-builder-container.c| 10 +++
libvirt-sandbox/libvirt-sandbox-builder-machine.c | 9 +++
.../libvirt-sandbox-config-mount-host-image.c | 91 +-
.../libvirt-sandbox-config-mount-host-image.h | 5 +-
libvirt-sandbox/libvirt-sandbox-config.c | 68 +++-
libvirt-sandbox/libvirt-sandbox.sym| 5 ++
libvirt-sandbox/tests/test-config.c| 1 +
7 files changed, 181 insertions(+), 8 deletions(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-container.c
b/libvirt-sandbox/libvirt-sandbox-builder-container.c
index c3a58b2..59bfee1 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-container.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-container.c
@@ -273,6 +273,9 @@ static gboolean
gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
g_object_unref(fs);
} else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_IMAGE(mconfig)) {
GVirSandboxConfigMountFile *mfile =
GVIR_SANDBOX_CONFIG_MOUNT_FILE(mconfig);
+GVirSandboxConfigMountHostImage *mimage =
GVIR_SANDBOX_CONFIG_MOUNT_HOST_IMAGE(mconfig);
+GVirConfigDomainDiskFormat format;
+GVirConfigDomainFilesysDriverType type =
GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_LOOP;
fs = gvir_config_domain_filesys_new();
gvir_config_domain_filesys_set_type(fs,
GVIR_CONFIG_DOMAIN_FILESYS_FILE);
@@ -282,6 +285,13 @@ static gboolean
gvir_sandbox_builder_container_construct_devices(GVirSandboxBuil
gvir_config_domain_filesys_set_target(fs,
gvir_sandbox_config_mount_get_target(mconfig));
+format = gvir_sandbox_config_mount_host_image_get_format(mimage);
+if (format != GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW)
+type = GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_NBD;
+
+gvir_config_domain_filesys_set_driver_type(fs, type);
+gvir_config_domain_filesys_set_driver_format(fs, format);
+
gvir_config_domain_add_device(domain,
GVIR_CONFIG_DOMAIN_DEVICE(fs));
g_object_unref(fs);
diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
index e342ba1..5e6bf72 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -497,6 +497,7 @@ static gboolean
gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
{
GVirConfigDomainFilesys *fs;
GVirConfigDomainDisk *disk;
+GVirConfigDomainDiskDriver *diskDriver;
GVirConfigDomainInterface *iface;
GVirConfigDomainMemballoon *ball;
GVirConfigDomainConsole *con;
@@ -560,6 +561,8 @@ static gboolean
gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
} else if (GVIR_SANDBOX_IS_CONFIG_MOUNT_HOST_IMAGE(mconfig)) {
GVirSandboxConfigMountFile *mfile =
GVIR_SANDBOX_CONFIG_MOUNT_FILE(mconfig);
+GVirSandboxConfigMountHostImage *mimage =
GVIR_SANDBOX_CONFIG_MOUNT_HOST_IMAGE(mconfig);
+GVirConfigDomainDiskFormat format;
gchar *target = g_strdup_printf("vd%c", (char)('a' +
nHostImage++));
disk = gvir_config_domain_disk_new();
@@ -568,8 +571,14 @@ static gboolean
gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
gvir_sandbox_config_mount_file_get_source(mfile));
gvir_config_domain_disk_set_target_dev(disk, target);
+diskDriver = gvir_config_domain_disk_driver_new();
+format = gvir_sandbox_config_mount_host_image_get_format(mimage);
+gvir_config_domain_disk_driver_set_format(diskDriver, format);
+gvir_config_domain_disk_set_driver(disk, diskDriver);
+
gvir_config_domain_add_device(domain,
GVIR_CONFIG_DOMAIN_DEVICE(disk));
+g_object_unref(diskDriver);
g_object_unref(disk);
g_free(target);
}
diff --git a/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c
b/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c
index 61e8f42..37573ef 100644
--- a/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c
+++ b/libvirt-sandbox/libvirt-sandbox-config-mount-host-image.c
@@ -45,21 +45,90 @@
struct _GVirSandboxConfigMountHostImagePrivate
{
-gboolean unused;
+GVirConfigDomainDiskFormat format;
};
G_DEFINE_TYPE(GVirSandboxConfigMountHostImage,
gvir_sandbox_config_mount_host_image, GVIR_SANDBOX_TYPE_CONFIG_MOUNT_FILE);
+enum {
+PROP_0,
+PROP_FORMAT,
+};
+
+enum {
+LAST_SIGNAL
+};
+
+//static gint signals[LAST_SIGNAL];
+
+
+static