[libvirt-designer][PATCH 1/3] disk_add: Don't hardcode 'qemu' driver

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

 



but depend on domain virt type instead.
---
 libvirt-designer/libvirt-designer-domain.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
index ee1dd65..1127ce7 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -806,6 +806,8 @@ gvir_designer_domain_add_disk_full(GVirDesignerDomain *design,
     GVirConfigDomainDiskBus bus;
     gchar *target_gen = NULL;
     const gchar *bus_str = NULL;
+    const char *driver_name;
+    int virt_type;
     GList *bus_str_list = NULL, *item = NULL;
 
     /* Guess preferred disk bus */
@@ -828,10 +830,25 @@ gvir_designer_domain_add_disk_full(GVirDesignerDomain *design,
 
     g_clear_error(error);
 
+    virt_type = gvir_config_domain_get_virt_type(priv->config);
+    switch (virt_type) {
+    case GVIR_CONFIG_DOMAIN_VIRT_QEMU:
+    case GVIR_CONFIG_DOMAIN_VIRT_KQEMU:
+    case GVIR_CONFIG_DOMAIN_VIRT_KVM:
+        driver_name = "qemu";
+        break;
+        /* add new virt type here */
+    default:
+        g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0,
+                    "Unsupported virt type %d", virt_type);
+        goto error;
+        break;
+    }
+
     disk = gvir_config_domain_disk_new();
     gvir_config_domain_disk_set_type(disk, type);
     gvir_config_domain_disk_set_source(disk, path);
-    gvir_config_domain_disk_set_driver_name(disk, "qemu");
+    gvir_config_domain_disk_set_driver_name(disk, driver_name);
     if (format)
         gvir_config_domain_disk_set_driver_type(disk, format);
     if (g_str_equal(bus_str, "ide")) {
-- 
1.7.8.6

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