Skip to contentSkip to conversation

libxl: Fix build with recent Xen that introduces new disk backend type

PATCH In review Oleksandr Tyshchenko 7 participants 13 messages Jul 29, 2022 – Aug 22, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: Fix build with recent Xen that introduces new disk backend type

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support enabled, reported by the osstest today [2]:

CC libxl/libvirt_driver_libxl_impl_la-xen_xl.lo
../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'
not handled in switch [-Werror=switch-enum]

                 switch (libxldisk->backend) {
                 ^~~~~~

cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default label.

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced after fixing the first one, but it that case the corresponding switch doesn't have a default branch.

Fix both issues by inserting required enumeration item to make the compiler happy and adding ifdef guard to be able to build against old Xen libraries as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest. Also it worth mentioning that current patch won't solve the possible additions in the future.

[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Please note, the patch is tested on:
https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master
but should work on the master as well (as the same code is present here).

---
 src/libxl/libxl_conf.c | 4 ++++
 src/libxl/xen_xl.c     | 3 +++
 2 files changed, 7 insertions(+)
src/libxl/libxl_conf.c +4 -0
index aa3d7925ec..526f0b2b08 100644
@@ -1240,6 +1240,10 @@ libxlUpdateDiskDef(virDomainDiskDef *l_disk, libxl_device_disk *x_disk)
         driver = "phy";
         break;
     case LIBXL_DISK_BACKEND_UNKNOWN:
+#ifdef LIBXL_HAVE_DEVICE_DISK_SPECIFICATION
+    case LIBXL_DISK_BACKEND_STANDALONE:
+#endif
+    default:
         break;
     }
     if (driver)
src/libxl/xen_xl.c +3 -0
index 4de4e3140f..6919325623 100644
@@ -715,6 +715,9 @@ xenParseXLDisk(virConf *conf, virDomainDef *def)
                     virDomainDiskSetDriver(disk, "phy");
                     virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
                     break;
+#ifdef LIBXL_HAVE_DEVICE_DISK_SPECIFICATION
+                case LIBXL_DISK_BACKEND_STANDALONE:
+#endif
                 default:
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                    _("disk backend not supported: %s"),
Signature · 1 line
2.25.1
#1 lore raw
Quoted 13 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support enabled, reported by the osstest today [2]:

CC libxl/libvirt_driver_libxl_impl_la-xen_xl.lo
../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'
not handled in switch [-Werror=switch-enum]

Quoted 8 lines
                 switch (libxldisk->backend) {
                 ^~~~~~

cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default label.

This is expected and in fact working correctly. We want compiler to warn us about enum members that are not handled in a switch() statement. The 'default' case exists in some places because we suspect the value might not have been validated before. For instance:

libxl_disk_backend x = atoi(argv[1]); /* or parse something from XML */

switch(x) {
case LIBXL_DISK_BACKEND_UNKNOWN:
case LIBXL_DISK_BACKEND_PHY:
case LIBXL_DISK_BACKEND_TAP:
case LIBXL_DISK_BACKEND_QDISK:
// Neither of these might be exectuted ..
default:
// .. in which case this will.
}

But we are not very consistent in putting 'default' case, sadly.

Quoted 24 lines

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced after fixing the first one, but it that case the corresponding switch doesn't have a default branch.

Fix both issues by inserting required enumeration item to make the compiler happy and adding ifdef guard to be able to build against old Xen libraries as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest. Also it worth mentioning that current patch won't solve the possible additions in the future.

[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Quoted 7 lines

Please note, the patch is tested on:
https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master
but should work on the master as well (as the same code is present here).

---
 src/libxl/libxl_conf.c | 4 ++++
 src/libxl/xen_xl.c     | 3 +++
 2 files changed, 7 insertions(+)

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

Michal

#2 lore raw

Hi Michal,

Quoted 18 lines · Michal Prívozník
Quoted 17 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support enabled, reported by the osstest today [2]:

CC libxl/libvirt_driver_libxl_impl_la-xen_xl.lo
../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'

    not handled in switch [-Werror=switch-enum]
                  switch (libxldisk->backend) {
                  ^~~~~~

cc1: all warnings being treated as errors

Quoted 7 lines
Quoted 4 lines

The interesting fact is that switch already has a default branch (which ought to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default label.

This is expected and in fact working correctly. We want compiler to warn us about enum members that are not handled in a switch() statement.

For us this is treated as an error. Is it intended?

If it is, then I think this will be a problem for Xen because it means we will always need to fix libvirt before accepting a patch in Xen (see more below).

Quoted 51 lines

The
'default' case exists in some places because we suspect the value might not have been validated before. For instance:

libxl_disk_backend x = atoi(argv[1]); /* or parse something from XML */

switch(x) {
case LIBXL_DISK_BACKEND_UNKNOWN:
case LIBXL_DISK_BACKEND_PHY:
case LIBXL_DISK_BACKEND_TAP:
case LIBXL_DISK_BACKEND_QDISK:

   // Neither of these might be exectuted ..
default:
   // .. in which case this will.
}

But we are not very consistent in putting 'default' case, sadly.

Quoted 24 lines

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced after fixing the first one, but it that case the corresponding switch doesn't have a default branch.

Fix both issues by inserting required enumeration item to make the compiler happy and adding ifdef guard to be able to build against old Xen libraries as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest. Also it worth mentioning that current patch won't solve the possible additions in the future.

[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Quoted 7 lines

Please note, the patch is tested on:
https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master
but should work on the master as well (as the same code is present here).

---
  src/libxl/libxl_conf.c | 4 ++++
  src/libxl/xen_xl.c     | 3 +++
  2 files changed, 7 insertions(+)
Quoted 8 lines

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

The patches usually land in master after our test suite has completed. One of the test is to confirm that libvirt is still working. Therefore, the Xen patch will not be part of master until the patch in libvirt is added.

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw
Quoted 26 lines · Julien Grall

Hi Michal,

Quoted 23 lines · Michal Prívozník
Quoted 21 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support enabled, reported by the osstest today [2]:

CC libxl/libvirt_driver_libxl_impl_la-xen_xl.lo
../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'

    not handled in switch [-Werror=switch-enum]
                  switch (libxldisk->backend) {
                  ^~~~~~

cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default label.

Quoted 4 lines
Quoted 2 lines

This is expected and in fact working correctly. We want compiler to warn us about enum members that are not handled in a switch() statement.

For us this is treated as an error. Is it intended?

Yes & no, but mostly yes.

You can choose to build with -Werror or not. If building from .git then it defaults to enabled, but can be disabled if desired.

Generally we want to see errors triggered from new enums arriving, as it can be a sign that libvirt code needs a semantic change in order to continue operating correctly. It isn't always correct to assume that the 'default' case gives the correct behaviour.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
Quoted 4 lines · Daniel P. Berrangé

Generally we want to see errors triggered from new enums arriving, as it can be a sign that libvirt code needs a semantic change in order to continue operating correctly. It isn't always correct to assume that the 'default' case gives the correct behaviour.

Isn't that the exact purpose of 'default' label? If use of 'default' means "any of the other 5 specific values, but lets save some characters to not name them explicitly", then IMHO better to name them explicitly...

I can see a value of -Werror=switch-enum when adding new (internal) enum value, to find all the cases where code needs to be adjusted, but even then a grep is probably sufficient enough. On the other hand, if there are cases where indeed all the values of (internal API) enum needs to be handled explicitly, maybe simply omit 'default' label and use -Werror=switch?

Anyway, if tracking all the enums values of all the used 3rd-party APIs is desirable (like, noticing when libxl adds new disk type), then it probably should be a separate CI job, not the default devel build. Otherwise breakages like this will happen from time to time, and will be annoyed for people on involved in specific code part at all.

As a short term fix, maybe Xen's CI can build libvirt with -Wno-error=switch-enum?

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#5 lore raw
Quoted 18 lines · Marek Marczykowski-Górecki
Quoted 4 lines · Daniel P. Berrangé

Generally we want to see errors triggered from new enums arriving, as it can be a sign that libvirt code needs a semantic change in order to continue operating correctly. It isn't always correct to assume that the 'default' case gives the correct behaviour.

Isn't that the exact purpose of 'default' label? If use of 'default' means "any of the other 5 specific values, but lets save some characters to not name them explicitly", then IMHO better to name them explicitly...

I can see a value of -Werror=switch-enum when adding new (internal) enum value, to find all the cases where code needs to be adjusted, but even then a grep is probably sufficient enough. On the other hand, if there are cases where indeed all the values of (internal API) enum needs to be handled explicitly, maybe simply omit 'default' label and use -Werror=switch?

Quoted 8 lines

Anyway, if tracking all the enums values of all the used 3rd-party APIs is desirable (like, noticing when libxl adds new disk type), then it probably should be a separate CI job, not the default devel build. Otherwise breakages like this will happen from time to time, and will be annoyed for people on involved in specific code part at all.

As a short term fix, maybe Xen's CI can build libvirt with -Wno-error=switch-enum?

I think makes sense for a 3rd party CI todo that, since these warnings are primarily targetted at libvirt upstream maintainers, so that we catch problems before code is committed.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw
In reply to Julien Grall
Quoted 30 lines · Julien Grall

Hi Michal,

Quoted 27 lines · Michal Prívozník
Quoted 25 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support
enabled, reported by the osstest today [2]:

CC       libxl/libvirt_driver_libxl_impl_la-xen_xl.lo ../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'
    not handled in switch [-Werror=switch-enum] switch (libxldisk->backend) { ^~~~~~
cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought
to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default
label.

Quoted 4 lines
Quoted 2 lines

This is expected and in fact working correctly. We want compiler to warn us about enum members that are not handled in a switch() statement.

For us this is treated as an error. Is it intended?

-Werror shouldn't be enabled when building a package, exactly for this reason. Header files change and we might get a warning or two when building a RPM. However, we definitely want to treat warnings as errors when developing libvirt, i.e. building libvirt from a git repo. That's why we get -Werror enabled in our CI too.

Quoted 4 lines

If it is, then I think this will be a problem for Xen because it means we will always need to fix libvirt before accepting a patch in Xen (see more below).

So we have a chicken egg problem. Xen needs libvirt to compile without any warning to merge a patch and libvirt wants hypervisors to have the patch merged first. Well, I think in this case we can make an "exception". Our demand comes from quite a few cases where we burned ourselves by merging our portion of a feature before it was merged into QEMU. And according to Murphy's law, QEMU interface was changed rendering our patches (now commits) useless. But I believe this is not the case with xen staging, is it?

BTW: every other package that does switch() over libxl_disk_backend enum will need this fix.

Quoted 70 lines
Quoted 70 lines

 The
'default' case exists in some places because we suspect the value might not have been validated before. For instance:

libxl_disk_backend x = atoi(argv[1]); /* or parse something from XML */

switch(x) {
case LIBXL_DISK_BACKEND_UNKNOWN:
case LIBXL_DISK_BACKEND_PHY:
case LIBXL_DISK_BACKEND_TAP:
case LIBXL_DISK_BACKEND_QDISK:
   // Neither of these might be exectuted ..
default:
   // .. in which case this will.
}

But we are not very consistent in putting 'default' case, sadly.

Quoted 37 lines

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced
after fixing the first one, but it that case the corresponding switch doesn't
have a default branch.

Fix both issues by inserting required enumeration item to make the compiler
happy and adding ifdef guard to be able to build against old Xen libraries
as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default
branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest.  Also it worth mentioning
that current patch won't solve the possible additions in the future.

[1]
https://lore.kernel.org/xen-devel/[email protected]/

[2]
https://lore.kernel.org/xen-devel/[email protected]/

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Please note, the patch is tested on:
https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master

Quoted 6 lines

but should work on the master as well (as the same code is present here).
---
  src/libxl/libxl_conf.c | 4 ++++
  src/libxl/xen_xl.c     | 3 +++

  2 files changed, 7 insertions(+)

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

Quoted 8 lines
Quoted 3 lines

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

The patches usually land in master after our test suite has completed. One of the test is to confirm that libvirt is still working. Therefore, the Xen patch will not be part of master until the patch in libvirt is added.

I understand that but what can we do here is to disable -Werror so that the commit can land in master. And then merge this libvirt fix. Does that work for you?

Michal

#7 lore raw

On 01.08.22 13:08, Michal Prívozník wrote:

Hello Michal, Julien

Quoted 42 lines · Julien Grall
Quoted 29 lines

Hi Michal,

Quoted 26 lines · Michal Prívozník
Quoted 25 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support
enabled, reported by the osstest today [2]:

CC       libxl/libvirt_driver_libxl_impl_la-xen_xl.lo ../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'
    not handled in switch [-Werror=switch-enum] switch (libxldisk->backend) { ^~~~~~
cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought
to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default
label.

Quoted 3 lines
Quoted 2 lines

This is expected and in fact working correctly. We want compiler to warn us about enum members that are not handled in a switch() statement.

For us this is treated as an error. Is it intended?

-Werror shouldn't be enabled when building a package, exactly for this reason. Header files change and we might get a warning or two when building a RPM. However, we definitely want to treat warnings as errors when developing libvirt, i.e. building libvirt from a git repo. That's why we get -Werror enabled in our CI too.

Quoted 3 lines

If it is, then I think this will be a problem for Xen because it means we will always need to fix libvirt before accepting a patch in Xen (see more below).

Quoted 8 lines

So we have a chicken egg problem. Xen needs libvirt to compile without any warning to merge a patch and libvirt wants hypervisors to have the patch merged first. Well, I think in this case we can make an "exception". Our demand comes from quite a few cases where we burned ourselves by merging our portion of a feature before it was merged into QEMU. And according to Murphy's law, QEMU interface was changed rendering our patches (now commits) useless. But I believe this is not the case with xen staging, is it?

I also believe so.

Quoted 74 lines

BTW: every other package that does switch() over libxl_disk_backend enum will need this fix.

Quoted 70 lines
Quoted 70 lines

 The
'default' case exists in some places because we suspect the value might not have been validated before. For instance:

libxl_disk_backend x = atoi(argv[1]); /* or parse something from XML */

switch(x) {
case LIBXL_DISK_BACKEND_UNKNOWN:
case LIBXL_DISK_BACKEND_PHY:
case LIBXL_DISK_BACKEND_TAP:
case LIBXL_DISK_BACKEND_QDISK:
   // Neither of these might be exectuted ..
default:
   // .. in which case this will.
}

But we are not very consistent in putting 'default' case, sadly.

Quoted 34 lines

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced
after fixing the first one, but it that case the corresponding switch doesn't
have a default branch.

Fix both issues by inserting required enumeration item to make the compiler
happy and adding ifdef guard to be able to build against old Xen libraries
as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default
branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest.  Also it worth mentioning
that current patch won't solve the possible additions in the future.

[1]

https://urldefense.com/v3/__https://lore.kernel.org/xen-devel/[email protected]/__;!!GF_29dbcQIUBPA!2GtOGVnLefUlZqkD4BAl9lVy82Avr_zPfztssIJ0qIBO8m8GTnSS2n2U6MpS0I2MhBxaE0EA9-GqbnlB-bQ9SdxTbA$ [lore[.]kernel[.]org]

[2]

https://urldefense.com/v3/__https://lore.kernel.org/xen-devel/[email protected]/__;!!GF_29dbcQIUBPA!2GtOGVnLefUlZqkD4BAl9lVy82Avr_zPfztssIJ0qIBO8m8GTnSS2n2U6MpS0I2MhBxaE0EA9-GqbnlB-bTJQY0vsw$ [lore[.]kernel[.]org]

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Please note, the patch is tested on:

Quoted 8 lines
https://urldefense.com/v3/__https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs*heads*xen-tested-master__;Ly8!!GF_29dbcQIUBPA!2GtOGVnLefUlZqkD4BAl9lVy82Avr_zPfztssIJ0qIBO8m8GTnSS2n2U6MpS0I2MhBxaE0EA9-GqbnlB-bTeUkf24g$ [xenbits[.]xen[.]org]

but should work on the master as well (as the same code is present here).

---
   src/libxl/libxl_conf.c | 4 ++++
   src/libxl/xen_xl.c     | 3 +++
   2 files changed, 7 insertions(+)

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://urldefense.com/v3/__https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools*libs*light*libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f__;Ly8v!!GF_29dbcQIUBPA!2GtOGVnLefUlZqkD4BAl9lVy82Avr_zPfztssIJ0qIBO8m8GTnSS2n2U6MpS0I2MhBxaE0EA9-GqbnlB-bR-mL3uGQ$ [xenbits[.]xen[.]org]

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

Quoted 7 lines
Quoted 4 lines

The patches usually land in master after our test suite has completed. One of the test is to confirm that libvirt is still working. Therefore, the Xen patch will not be part of master until the patch in libvirt is added.

I understand that but what can we do here is to disable -Werror so that the commit can land in master. And then merge this libvirt fix. Does that work for you?

Michal,
thank you for the review and attempts to find a compromise. As I understand the things are bit more complicated, what they look like at the first glance (Julien, please correct me if I am wrong). I think, the proposed solution perfectly worked for us if Osstest would use actual libvirt's master to test against. But Osstest still uses old master located at (because it hasn't been adapted yet to new build system using Meson):

https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master

So, I am afraid, any actions in libvirt's master won't immediately solve the current situation at the our side. Besides getting the current (or alternative) patch merged into the libvirt we will need to fix Osstest (update the libvirt build script).

The discussion how to resolve the current situation is in progress now [2]:

[1]
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f
[2]
https://lore.kernel.org/xen-devel/[email protected]/

Quoted 3 lines

Michal

Signature · 3 lines
Regards,

Oleksandr Tyshchenko
#8 lore raw
In reply to Michal Prívozník

Hi Michal,

Quoted 45 lines · Michal Prívozník
Quoted 28 lines · Julien Grall
Quoted 27 lines · Michal Prívozník
Quoted 25 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support
enabled, reported by the osstest today [2]:

CC       libxl/libvirt_driver_libxl_impl_la-xen_xl.lo ../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'
    not handled in switch [-Werror=switch-enum] switch (libxldisk->backend) { ^~~~~~
cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought
to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default
label.

Quoted 4 lines
Quoted 2 lines

This is expected and in fact working correctly. We want compiler to warn us about enum members that are not handled in a switch() statement.

For us this is treated as an error. Is it intended?

-Werror shouldn't be enabled when building a package, exactly for this reason. Header files change and we might get a warning or two when building a RPM. However, we definitely want to treat warnings as errors when developing libvirt, i.e. building libvirt from a git repo. That's why we get -Werror enabled in our CI too.

Quoted 4 lines

If it is, then I think this will be a problem for Xen because it means we will always need to fix libvirt before accepting a patch in Xen (see more below).

Quoted 8 lines

So we have a chicken egg problem. Xen needs libvirt to compile without any warning to merge a patch and libvirt wants hypervisors to have the patch merged first. Well, I think in this case we can make an "exception". Our demand comes from quite a few cases where we burned ourselves by merging our portion of a feature before it was merged into QEMU. And according to Murphy's law, QEMU interface was changed rendering our patches (now commits) useless. But I believe this is not the case with xen staging, is it?

That's correct. Once a patch is merged in staging, we would only revert it if there is a breakage that can't be easily solved.

Quoted 3 lines

BTW: every other package that does switch() over libxl_disk_backend enum will need this fix.

Indeed. From my understanding, there is an expectation that tools built on top of libxl may need some update to work on the latest Xen. I will let Anthony (one of the tools maintainers to confirm).

Quoted 74 lines
Quoted 74 lines
Quoted 73 lines

 The
'default' case exists in some places because we suspect the value might not have been validated before. For instance:

libxl_disk_backend x = atoi(argv[1]); /* or parse something from XML */

switch(x) {
case LIBXL_DISK_BACKEND_UNKNOWN:
case LIBXL_DISK_BACKEND_PHY:
case LIBXL_DISK_BACKEND_TAP:
case LIBXL_DISK_BACKEND_QDISK:
   // Neither of these might be exectuted ..
default:
   // .. in which case this will.
}

But we are not very consistent in putting 'default' case, sadly.

Quoted 37 lines

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced
after fixing the first one, but it that case the corresponding switch doesn't
have a default branch.

Fix both issues by inserting required enumeration item to make the compiler
happy and adding ifdef guard to be able to build against old Xen libraries
as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default
branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest.  Also it worth mentioning
that current patch won't solve the possible additions in the future.

[1]
https://lore.kernel.org/xen-devel/[email protected]/

[2]
https://lore.kernel.org/xen-devel/[email protected]/

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Please note, the patch is tested on:
https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master

Quoted 6 lines

but should work on the master as well (as the same code is present here).

---
   src/libxl/libxl_conf.c | 4 ++++
   src/libxl/xen_xl.c     | 3 +++
   2 files changed, 7 insertions(+)

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

Quoted 8 lines
Quoted 4 lines

The patches usually land in master after our test suite has completed. One of the test is to confirm that libvirt is still working. Therefore, the Xen patch will not be part of master until the patch in libvirt is added.

I understand that but what can we do here is to disable -Werror so that the commit can land in master. And then merge this libvirt fix. Does that work for you?

This sounds a sensible plan. Anyone from Xen community has an objection this with approach?

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw
Quoted 7 lines · Julien Grall
Quoted 2 lines · Michal Prívozník

BTW: every other package that does switch() over libxl_disk_backend enum will need this fix.

Indeed. From my understanding, there is an expectation that tools built on top of libxl may need some update to work on the latest Xen. I will let Anthony (one of the tools maintainers to confirm).

Actually, if an application defines LIBXL_API_VERSION, like libvirt does, we expect the application to still build against the latest version of libxl. But I don't think that should prevent us from adding new enum values.

Cheers,

Signature · 1 line
Anthony PERARD
#10 lore raw
In reply to Michal Prívozník
Quoted 8 lines · Michal Prívozník

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

Hi Michal,

Now that the commit is "master", do you think this libvirt patch could be committed?

Thanks,

Signature · 1 line
Anthony PERARD
#11 lore raw
Quoted 6 lines · Anthony PERARD
Quoted 5 lines · Michal Prívozník

Ah, I couldn't find the commit in master, and it's simply because it's not there yet. It's in staging:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;f=tools/libs/light/libxl_types.idl;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

Quoted 8 lines
Quoted 3 lines

The patch looks correct. Do you have any estimate when it can be merged into master? I'm not sure what our, libvirt, rules about xen staging are, but for qemu we require master (even unreleased yet).

Hi Michal,

Now that the commit is "master", do you think this libvirt patch could be committed?

Indeed. Let me do that right now.

Michal

Reviewed-by on v1 1/1
#12 lore raw
In reply to Oleksandr Tyshchenko
Quoted 45 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Xen toolstack has gained basic Virtio support recently which becides adding various virtio related stuff introduces new disk backend type LIBXL_DISK_BACKEND_STANDALONE [1].

Unfortunately, this caused a regression in libvirt build with Xen support enabled, reported by the osstest today [2]:

CC libxl/libvirt_driver_libxl_impl_la-xen_xl.lo
../../src/libxl/xen_xl.c: In function 'xenParseXLDisk':
../../src/libxl/xen_xl.c:779:17: error: enumeration value 'LIBXL_DISK_BACKEND_STANDALONE'
not handled in switch [-Werror=switch-enum]

                 switch (libxldisk->backend) {
                 ^~~~~~

cc1: all warnings being treated as errors

The interesting fact is that switch already has a default branch (which ought to cover such new addition), but the error is triggered as -Wswitch-enum gives a warning about an omitted enumeration code even if there is a default label.

Also there is a similar issue in libxlUpdateDiskDef() which I have reproduced after fixing the first one, but it that case the corresponding switch doesn't have a default branch.

Fix both issues by inserting required enumeration item to make the compiler happy and adding ifdef guard to be able to build against old Xen libraries as well (without LIBXL_HAVE_DEVICE_DISK_SPECIFICATION). Also add a default branch to switch in libxlUpdateDiskDef().

Please note, that current patch doesn't implement the proper handling of LIBXL_DISK_BACKEND_STANDALONE and friends, it is just intended to fix the regression immediately to unblock the osstest. Also it worth mentioning that current patch won't solve the possible additions in the future.

[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/

---
Cc: Julien Grall <[email protected]>
Cc: Anthony PERARD <[email protected]>
Cc: Michal Privoznik <[email protected]>

Quoted 7 lines

Please note, the patch is tested on:
https://xenbits.xen.org/gitweb/?p=libvirt.git;a=shortlog;h=refs/heads/xen-tested-master
but should work on the master as well (as the same code is present here).

---
 src/libxl/libxl_conf.c | 4 ++++
 src/libxl/xen_xl.c     | 3 +++
 2 files changed, 7 insertions(+)

Now that the libxl patch is merged into the master:

https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=66dd1c62b2a3c707bd5c55750d10a8223fbd577f

I can merge this.

Michal