Hey,
On Tue, Jan 28, 2014 at 05:49:29PM +0100, Michal Privoznik wrote:
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(a)redhat.com>
---
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);
+ }
NB: this has also been deprecated in libvirt-gconfig git :-/
I'd do the string->enum conversion using a helper similar to
gvir_config_genum_get_value() in libvirt-gconfig/libvirt-gconfig-helpers.c
Christophe