[libvirt-designer][PATCH] virtxml: Adapt to latest libvirt-glib

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

 



With libvirt-glib update, I've noticed a deprecation warning:

libvirt-designer-domain.c: In function 'gvir_designer_domain_add_disk_full':
libvirt-designer-domain.c:1610:9: error: 'gvir_config_domain_disk_set_driver_type' is deprecated (declared at /usr/include/libvirt-gconfig-1.0/libvirt-gconfig/libvirt-gconfig-domain-disk.h:145): Use 'gvir_config_domain_disk_set_driver_format' instead [-Werror=deprecated-declarations]
         gvir_config_domain_disk_set_driver_type(disk, format);
         ^
cc1: all warnings being treated as errors

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 configure.ac                                 |  4 +++
 libvirt-designer/libvirt-designer-domain.c   | 41 ++++++++++++++++++++++++++--
 libvirt-designer/libvirt-designer-internal.h | 18 ++++++++++++
 3 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index bad199b..f74e3f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,10 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_CHECK_FUNCS([strchr])
 AC_CHECK_FUNCS([strrchr])
+AC_CHECK_FUNCS([strcmp])
+AC_CHECK_FUNCS([strcasecmp])
+AC_CHECK_FUNCS([strncmp])
+AC_CHECK_FUNCS([strncasecmp])
 AC_CHECK_FUNCS([uname])
 AC_PROG_CXX
 AC_TYPE_SIZE_T
diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c
index 848dfea..8a11894 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -1606,8 +1606,45 @@ gvir_designer_domain_add_disk_full(GVirDesignerDomain *design,
     gvir_config_domain_disk_set_type(disk, type);
     gvir_config_domain_disk_set_source(disk, path);
     gvir_config_domain_disk_set_driver_name(disk, driver_name);
-    if (format)
-        gvir_config_domain_disk_set_driver_type(disk, format);
+    if (format) {
+        GVirConfigDomainDiskFormat fmt;
+
+        if (STRCASEEQ(format, "raw"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW;
+        else if (STRCASEEQ(format, "dir"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_DIR;
+        else if (STRCASEEQ(format, "bochs"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_BOCHS;
+        else if (STRCASEEQ(format, "cloop"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_CLOOP;
+        else if (STRCASEEQ(format, "cow"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_COW;
+        else if (STRCASEEQ(format, "dmg"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_DMG;
+        else if (STRCASEEQ(format, "iso"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_ISO;
+        else if (STRCASEEQ(format, "qcow"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW;
+        else if (STRCASEEQ(format, "qcow2"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_QCOW2;
+        else if (STRCASEEQ(format, "qed"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_QED;
+        else if (STRCASEEQ(format, "vmdk"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_VMDK;
+        else if (STRCASEEQ(format, "vpc"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_VPC;
+        else if (STRCASEEQ(format, "fat"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_FAT;
+        else if (STRCASEEQ(format, "vhd"))
+            fmt = GVIR_CONFIG_DOMAIN_DISK_FORMAT_VHD;
+        else {
+            g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0,
+                        "unknown disk format %s", format);
+            goto error;
+        }
+
+        gvir_config_domain_disk_set_driver_format(disk, fmt);
+    }
 
     controller = gvir_designer_domain_get_preferred_disk_controller(design, NULL);
     if (controller == NULL)
diff --git a/libvirt-designer/libvirt-designer-internal.h b/libvirt-designer/libvirt-designer-internal.h
index e95edfc..05dcf1d 100644
--- a/libvirt-designer/libvirt-designer-internal.h
+++ b/libvirt-designer/libvirt-designer-internal.h
@@ -24,4 +24,22 @@
 #ifndef __LIBVIRT_DESIGNER_INTERNAL_H__
 #define __LIBVIRT_DESIGNER_INTERNAL_H__
 
+# include <strings.h>
+
+# define STREQ(a,b) (strcmp(a,b) == 0)
+# define STRCASEEQ(a,b) (strcasecmp(a,b) == 0)
+# define STRNEQ(a,b) (strcmp(a,b) != 0)
+# define STRCASENEQ(a,b) (strcasecmp(a,b) != 0)
+# define STREQLEN(a,b,n) (strncmp(a,b,n) == 0)
+# define STRCASEEQLEN(a,b,n) (strncasecmp(a,b,n) == 0)
+# define STRNEQLEN(a,b,n) (strncmp(a,b,n) != 0)
+# define STRCASENEQLEN(a,b,n) (strncasecmp(a,b,n) != 0)
+# define STRPREFIX(a,b) (strncmp(a,b,strlen(b)) == 0)
+# define STRSKIP(a,b) (STRPREFIX(a,b) ? (a) + strlen(b) : NULL)
+
+# define STREQ_NULLABLE(a, b)                           \
+    ((a) ? (b) && STREQ((a) ? (a) : "", (b) ? (b) : "") : !(b))
+# define STRNEQ_NULLABLE(a, b)                          \
+    ((a) ? !(b) || STRNEQ((a) ? (a) : "", (b) ? (b) : "") : !!(b))
+
 #endif /* __LIBVIRT_DESIGNER_INTERNAL_H__ */
-- 
1.8.5.2

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