On 12/14/2016 09:15 AM, Cédric Bosdonnat wrote:
Without a default: case in the switches in xenParseXLDisk(), build
would fail with every new disk backend or image format added in libxl,
as this is the case in this error:

One upshot of the error is we learn about the new feature :-). But yeah, build errors are not the best way to learn of new features in external projects.


http://logs.test-lab.xenproject.org/osstest/logs/103325/build-amd64-libvirt/5.ts-libvirt-build.log
---
 src/xenconfig/xen_xl.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index bcdd35527..f197267bb 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -393,6 +393,11 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)

                 case LIBXL_DISK_FORMAT_EMPTY:
                     break;
+
+                default:
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("disk image format not supported: %s"),
+                                   
libxl_disk_format_to_string(libxldisk->format));
                 }

                 switch (libxldisk->backend) {
@@ -415,6 +420,10 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
                         goto fail;
                     virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
                     break;
+                default:
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("disk backend not supported: %s"),
+                                   
libxl_disk_backend_to_string(libxldisk->backend));
                 }
             }

You need to goto 'fail' after reporting the error. ACK with the below diff squashed in.

Regards,
Jim

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index f197267..ffdf798 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -398,6 +398,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                    _("disk image format not supported: %s"),

libxl_disk_format_to_string(libxldisk->format));
+                    goto fail;
                 }

                 switch (libxldisk->backend) {
@@ -424,6 +425,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                    _("disk backend not supported: %s"),

libxl_disk_backend_to_string(libxldisk->backend));
+                    goto fail;
                 }
             }


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to