After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 725520 - OvirtBroker is used if it is not available
OvirtBroker is used if it is not available
Status: RESOLVED OBSOLETE
Product: gnome-boxes
Classification: Applications
Component: ovirt
unspecified
Other All
: Normal enhancement
: 3.22
Assigned To: Lasse Schuirmann
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-03-02 20:52 UTC by Lasse Schuirmann
Modified: 2016-03-31 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
OvirtBroker isnt used if it is not available (1010 bytes, patch)
2014-03-02 20:52 UTC, Lasse Schuirmann
none Details | Review
Adds empty ovirt dummy to allow ovirt-free compilation (2.06 KB, patch)
2014-03-28 18:23 UTC, Lasse Schuirmann
none Details | Review
Add empty ovirt (2.19 KB, patch)
2014-04-01 11:20 UTC, Lasse Schuirmann
none Details | Review
Add empty ovirt (2.65 KB, patch)
2014-04-08 17:53 UTC, Lasse Schuirmann
none Details | Review
Add empty ovirt (2.83 KB, patch)
2014-04-25 14:26 UTC, Lasse Schuirmann
rejected Details | Review

Description Lasse Schuirmann 2014-03-02 20:52:21 UTC
If HAVE_OVIRT is not defined, ovirt-broker.vala is not included. (See
makefile.am, line 152.) Therefore compilation fails.
Comment 1 Lasse Schuirmann 2014-03-02 20:52:23 UTC
Created attachment 270720 [details] [review]
OvirtBroker isnt used if it is not available

If HAVE_OVIRT is not defined ovirt-broker.vala is not included for
compilation so the condition has to be a preprocessor directive.
Comment 2 Zeeshan Ali 2014-03-02 21:32:23 UTC
Review of attachment 270720 [details] [review]:

::: src/app.vala
@@ +140,2 @@
         brokers.insert ("libvirt", LibvirtBroker.get_default ());
+#if HAVE_OVIRT

I'd like Christophe to review this but there was a reason we didn't use '#if' on vala level. IIRC the reason was that we distribute generated C files in that tarball so people (typically distribute packagers) don't need vala compiler to build Boxes from tarball. This means that if person creating the tarball doesn't have ovirt, the tarball will distribute Boxes without ovirt support compiled in C files.
Comment 3 Lasse Schuirmann 2014-03-03 05:48:43 UTC
9(In reply to comment #2)
> Review of attachment 270720 [details] [review]:
> 
> ::: src/app.vala
> @@ +140,2 @@
>          brokers.insert ("libvirt", LibvirtBroker.get_default ());
> +#if HAVE_OVIRT
> 
> I'd like Christophe to review this but there was a reason we didn't use '#if'
> on vala level. IIRC the reason was that we distribute generated C files in that
> tarball so people (typically distribute packagers) don't need vala compiler to
> build Boxes from tarball. This means that if person creating the tarball
> doesn't have ovirt, the tarball will distribute Boxes without ovirt support
> compiled in C files.

Knowing this and with my limited vala capabilities I see the best possibility would be to create a c header and include it on vala level in a vapi file. We can then move the directive to that C file.

Do you agree?
Comment 4 Zeeshan Ali 2014-03-03 13:02:41 UTC
(In reply to comment #3)
> 9(In reply to comment #2)
> > Review of attachment 270720 [details] [review] [details]:
> > 
> > ::: src/app.vala
> > @@ +140,2 @@
> >          brokers.insert ("libvirt", LibvirtBroker.get_default ());
> > +#if HAVE_OVIRT
> > 
> > I'd like Christophe to review this but there was a reason we didn't use '#if'
> > on vala level. IIRC the reason was that we distribute generated C files in that
> > tarball so people (typically distribute packagers) don't need vala compiler to
> > build Boxes from tarball. This means that if person creating the tarball
> > doesn't have ovirt, the tarball will distribute Boxes without ovirt support
> > compiled in C files.
> 
> Knowing this and with my limited vala capabilities I see the best possibility
> would be to create a c header and include it on vala level in a vapi file.

That is the case already. Perhaps its not working as it should somehow.
Comment 5 Lasse Schuirmann 2014-03-03 16:00:05 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > 9(In reply to comment #2)
...
> > Knowing this and with my limited vala capabilities I see the best possibility
> > would be to create a c header and include it on vala level in a vapi file.
> 
> That is the case already. Perhaps its not working as it should somehow.

As I look at the file,
brokers.insert ("ovirt", OvirtBroker.get_default ());
will be parsed by valac independendly of the Config.HAVE_OVIRT. It will just not be evaluated at runtime but thats not enought if the ovirt-broker.vala is not included.
Comment 6 Christophe Fergeau 2014-03-03 16:38:20 UTC
(In reply to comment #2)
> Review of attachment 270720 [details] [review]:
> IIRC the reason was that we distribute generated C files in that
> tarball so people (typically distribute packagers) don't need vala compiler to
> build Boxes from tarball. This means that if person creating the tarball
> doesn't have ovirt, the tarball will distribute Boxes without ovirt support
> compiled in C files.

Yup

(In reply to comment #4)
> That is the case already. Perhaps its not working as it should somehow.

Currently, it's relying on gcc to not attempt to compile code in a if (0) block. This works with -O2 and -O0 with my f20 gcc, with RHEL6 gcc and worked with the compiler that was in latest stable fedora when I added ovirt support. Maybe this is what is causing issue on your system? A quick test-case should be:

int main(int argc, char **argv)
{

    if (0) {
        stub_function_totototot();
    }

    return 0;
}
Comment 7 Lasse Schuirmann 2014-03-03 18:41:56 UTC
(In reply to comment #6)
> (In reply to comment #2)
> > Review of attachment 270720 [details] [review] [details]:
> > IIRC the reason was that we distribute generated C files in that
> > tarball so people (typically distribute packagers) don't need vala compiler to
> > build Boxes from tarball. This means that if person creating the tarball
> > doesn't have ovirt, the tarball will distribute Boxes without ovirt support
> > compiled in C files.
> 
> Yup
> 
> (In reply to comment #4)
> > That is the case already. Perhaps its not working as it should somehow.
> 
> Currently, it's relying on gcc to not attempt to compile code in a if (0)
> block. This works with -O2 and -O0 with my f20 gcc, with RHEL6 gcc and worked
> with the compiler that was in latest stable fedora when I added ovirt support.
> Maybe this is what is causing issue on your system? A quick test-case should
> be:
> 
> int main(int argc, char **argv)
> {
> 
>     if (0) {
>         stub_function_totototot();
>     }
> 
>     return 0;
> }

lasse@lssteady ~/prog/gnome/exp % vim tst.c
lasse@lssteady ~/prog/gnome/exp % gcc -O0 tst.c 
lasse@lssteady ~/prog/gnome/exp % gcc -O2 tst.c 
lasse@lssteady ~/prog/gnome/exp % 

I just pasted your code to tst.c and it compiled fine.

I personally don't like code that relies on certain optimizations to function properly. At least some users have this issue. (gnome-boxes is known in the ArchLinux wiki not to compile. At least not using jhbuild [1]. Also see [2] if you want more info about the message and another case.)

I can probably post the patch there but is this really a good way of coding if it needs a patch for some persons to compile...?

[1] https://wiki.archlinux.org/index.php/JHBuild#Other_broken_modules
[2] https://mail.gnome.org/archives/gnome-boxes-list/2013-April/msg00018.html
Comment 8 Zeeshan Ali 2014-03-03 18:49:27 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #2)
> > > Review of attachment 270720 [details] [review] [details] [details]:
> > > IIRC the reason was that we distribute generated C files in that
> > > tarball so people (typically distribute packagers) don't need vala compiler to
> > > build Boxes from tarball. This means that if person creating the tarball
> > > doesn't have ovirt, the tarball will distribute Boxes without ovirt support
> > > compiled in C files.
> > 
> > Yup
> > 
> > (In reply to comment #4)
> > > That is the case already. Perhaps its not working as it should somehow.
> > 
> > Currently, it's relying on gcc to not attempt to compile code in a if (0)
> > block. This works with -O2 and -O0 with my f20 gcc, with RHEL6 gcc and worked
> > with the compiler that was in latest stable fedora when I added ovirt support.
> > Maybe this is what is causing issue on your system? A quick test-case should
> > be:
> > 
> > int main(int argc, char **argv)
> > {
> > 
> >     if (0) {
> >         stub_function_totototot();
> >     }
> > 
> >     return 0;
> > }
> 
> lasse@lssteady ~/prog/gnome/exp % vim tst.c
> lasse@lssteady ~/prog/gnome/exp % gcc -O0 tst.c 
> lasse@lssteady ~/prog/gnome/exp % gcc -O2 tst.c 
> lasse@lssteady ~/prog/gnome/exp % 
> 
> I just pasted your code to tst.c and it compiled fine.
> 
> I personally don't like code that relies on certain optimizations to function
> properly. At least some users have this issue. (gnome-boxes is known in the
> ArchLinux wiki not to compile. At least not using jhbuild [1].

Really nice that they never bothered to tell us about this. :(

> Also see [2] if
> you want more info about the message and another case.)
 
Since those guys never really followed up on this issue, it got completely forgotten. :(

> I can probably post the patch there but is this really a good way of coding if
> it needs a patch for some persons to compile...?

Yeah, you shouldn't need a downstream hack/patch to be able to build Boxes, unless the distro is doing something weird (which it doesn't seem to).
Comment 9 Zeeshan Ali 2014-03-03 18:59:31 UTC
(In reply to comment #6)
> (In reply to comment #2)
> > Review of attachment 270720 [details] [review] [details]:
> > IIRC the reason was that we distribute generated C files in that
> > tarball so people (typically distribute packagers) don't need vala compiler to
> > build Boxes from tarball. This means that if person creating the tarball
> > doesn't have ovirt, the tarball will distribute Boxes without ovirt support
> > compiled in C files.
> 
> Yup
> 
> (In reply to comment #4)
> > That is the case already. Perhaps its not working as it should somehow.
> 
> Currently, it's relying on gcc to not attempt to compile code in a if (0)
> block. This works with -O2 and -O0

Ouch. Thats sounds really hackish. How about we enclose all govirt-relying code in a specific module(s) and have the same API in dummy module(s) and then choose which one to compile against in Makefile.am depending on if ovirt is enabled or not?
Comment 10 Christophe Fergeau 2014-03-04 08:59:33 UTC
(In reply to comment #8)
> > Also see [2] if
> > you want more info about the message and another case.)
> 
> Since those guys never really followed up on this issue, it got completely
> forgotten. :(

Yup, fairly sure I've seen people with this build issue in the past, but I did not manage to reproduce when I tried, so I dropped the ball on it.

(In reply to comment #9)
> Ouch. Thats sounds really hackish. 

Well, this is not intentionally hackish as I only found out about this yesterday :) When writing this conditional code, I was happy with everything building with the right code generated, never realized this was relying on this if (0) thing. 

> How about we enclose all govirt-relying code
> in a specific module(s) and have the same API in dummy module(s) and then
> choose which one to compile against in Makefile.am depending on if ovirt is
> enabled or not?

Yup.
Comment 11 Lasse Schuirmann 2014-03-28 18:23:52 UTC
Created attachment 273191 [details] [review]
Adds empty ovirt dummy to allow ovirt-free compilation

It took my some time to learn automake besides my usual activities, but finally: here's the patch.

I tried it out, it compiles from vala with and without ovirt and the distributed thing also compiles without ovirt if the distributor compiled with ovirt.

The one thing I didn't figure out: it would be good to have at least a warning if one tries to distribute this without having ovirt installed because then no user can have ovirt. If you can name me any references about related automake commands (I didn't find them on my initial research) I will add this too.
Comment 12 Zeeshan Ali 2014-03-28 18:37:44 UTC
(In reply to comment #11)
> Created an attachment (id=273191) [details] [review]
> Adds empty ovirt dummy to allow ovirt-free compilation
> 
> It took my some time to learn automake besides my usual activities, but
> finally: here's the patch.
> 
> I tried it out, it compiles from vala with and without ovirt and the
> distributed thing also compiles without ovirt if the distributor compiled with
> ovirt.
> 
> The one thing I didn't figure out: it would be good to have at least a warning
> if one tries to distribute this without having ovirt installed because then no
> user can have ovirt. If you can name me any references about related automake
> commands (I didn't find them on my initial research) I will add this too.

I can find that out for you later (its pretty simple actually and doesn't exactly involve any auomake commands) and also review rest of the patch. However, I seriously doubt packagers give much attention to warnings from configure so I'd recommend we do this how Ryan Lortie suggests one should handle optional deps: Require the dep by default but provide any option to disable it. This is what will definitely get packagers attention and they can then decide what path to take.
Comment 13 Lasse Schuirmann 2014-04-01 11:20:13 UTC
Created attachment 273393 [details] [review]
Add empty ovirt

If you now compile, the ovirt-broker.vapi will be distributed among
the other files allowing users to compile it from C level without
ovirt.

Directly compiling from vala sources is also supported through this
changeset.
Comment 14 Lasse Schuirmann 2014-04-01 11:30:50 UTC
(In reply to comment #13)
> Created an attachment (id=273393) [details] [review]
> Add empty ovirt
> 
> If you now compile, the ovirt-broker.vapi will be distributed among
> the other files allowing users to compile it from C level without
> ovirt.
> 
> Directly compiling from vala sources is also supported through this
> changeset.

I think I uploaded a wrong patch. Testing this is a bit chaotic with several PCs (one having ovirt and one not having it.)
Comment 15 Lasse Schuirmann 2014-04-08 17:53:30 UTC
Created attachment 273824 [details] [review]
Add empty ovirt

If you now compile, the ovirt-broker.vapi will be distributed among
the other files allowing users to compile it from C level without
ovirt.

Directly compiling from vala sources is also supported through this
changeset.
Comment 16 Lasse Schuirmann 2014-04-08 18:02:40 UTC
Review of attachment 273824 [details] [review]:

Whenever compiling without ovirt one has to append --enable-ovirt=no after this patch and everything will work.

I tested the following cases with this patch:

* Compilation with ovirt installed (works)
* Package generation with ovirt installed (works)
   * Compilation of this generated package with ovirt installed (works)
   * Compilation of this generated package without ovirt installed and --enable-ovirt=no (works)
   * Compilation of this generated package without ovirt installed without additional flags (does not work: message: ovirt required)
* Compilation without ovirt installed and --enable-ovirt=no (works)
Comment 17 Lasse Schuirmann 2014-04-08 18:52:20 UTC
I'll have to do some retesting with all the different OSes and machines at home. Dont use the given patch (even though I think it is at least near to a working solution)
Comment 18 Lasse Schuirmann 2014-04-25 14:26:01 UTC
Created attachment 275135 [details] [review]
Add empty ovirt

This patch allows the following scenarios:
- Configure and compile Boxes with ovirt normally
- Configure and compile Boxes without ovirt with --enable-ovirt=no
- Distribute Boxes with ovirt (make distcheck)
- Configure and compile the distributed Boxes with ovirt
- Configure and compile the distributed Boxes without ovirt with --enable-ovirt=no

The following scenarios don't work and shouldn't work:
- Configure Boxes without ovirt normally (implicit --enable-ovirt=yes)
- Configure distributed Boxes without ovirt normally (implicit --enable-ovirt=yes)

The following scenarios don't work:
- Distribute Boxes without ovirt

All these scenarios were tested with a newly cleanly cloned environment so that older builds have no effect on this. (I think this was the case in my tests before since I got inconsistent results back then.)

As I see it now the only possibly non-intendet behaviour would be distributing Boxes without ovirt.

When I try distributing without ovirt, autotools generates the target ovirt-broker.vapi anyway. (HAVE_OVIRT should be false.) While I am not an expert in autotools (this is actually my first contact) so I hope I can maybe get some help or hints for this problem.
Comment 19 Zeeshan Ali 2014-04-26 13:02:45 UTC
(In reply to comment #18)
> Created an attachment (id=275135) [details] [review]
> Add empty ovirt
> 
> This patch allows the following scenarios:
> - Configure and compile Boxes with ovirt normally
> - Configure and compile Boxes without ovirt with --enable-ovirt=no
> - Distribute Boxes with ovirt (make distcheck)
> - Configure and compile the distributed Boxes with ovirt
> - Configure and compile the distributed Boxes without ovirt with
> --enable-ovirt=no
> 
> The following scenarios don't work and shouldn't work:
> - Configure Boxes without ovirt normally (implicit --enable-ovirt=yes)

I don't get this. Are you talking about running configure on dist tarball? If so, please make it clear in all these scenerios whether you are talking about tarball or git checkout. Right now it all sounds very mixed and therefore confusing.

> - Configure distributed Boxes without ovirt normally (implicit
> --enable-ovirt=yes)
> 
> The following scenarios don't work:
> - Distribute Boxes without ovirt
> 
> All these scenarios were tested with a newly cleanly cloned environment so that
> older builds have no effect on this. (I think this was the case in my tests
> before since I got inconsistent results back then.)
> 
> As I see it now the only possibly non-intendet behaviour would be distributing
> Boxes without ovirt.
> 
> When I try distributing without ovirt, autotools generates the target
> ovirt-broker.vapi anyway. (HAVE_OVIRT should be false.) While I am not an
> expert in autotools (this is actually my first contact) so I hope I can maybe
> get some help or hints for this problem.

Sure, I'll have a look but keep in mind nobody is an autotools expert, really. :)
Comment 20 Lasse Schuirmann 2014-04-26 13:11:43 UTC
What works:

Git:
 - Configure and compile Boxes from git with ovirt normally
 - Configure and compile Boxes from git without ovirt with --enable-ovirt=no

 - Distribute Boxes with ovirt (make distcheck)

Tarball:
 - Configure and compile Boxes tarball with ovirt
 - Configure and compile Boxes tarball without ovirt with --enable-ovirt=no

Is this clearer? (With distributed boxes i meant the tarball in the original post)
Comment 21 Zeeshan Ali 2014-04-26 13:41:32 UTC
Review of attachment 275135 [details] [review]:

Oh, the info I commented on previous seems not to be part of git log. I think the non-working schenerious you mention in your comment should also be mentioned in the commit log.

::: configure.ac
@@ +104,3 @@
               AS_HELP_STRING([--enable-ovirt=yes|no|auto], [Enable support for OVirt]),
               [enable_ovirt=$enableval],
+              [enable_ovirt=yes])

We shouldn't need to do this.

::: src/ovirt-broker-empty.vala
@@ +5,3 @@
+ * but the user can compile without it.
+ */
+#if HAVE_OVIRT

If you want to use the #if in source file, you wouldn't need a new dummy file. The gust of this solution was for Makefile.am to decide which C files to use depending on if ovirt support is enabled or not.

"well in that case you won't need a seperate C file, you can decide to use the appropriate (generated) C file in Makefile itself
you can put ovirt stuff in a separate static library
and list the ovirt vala files as sources for that naturally but get Makefile to compile them only to C level
actually you don't want to list them as sources
for the library
you want to list the generated C files as sources of the library
and have an intermediate target for building the vala files to C files
then add that target as dependency of the static library source(s)

<flo> zeenix: I moved the optional part out in a independend static library and only statically link it if necessary. Worked well enough.
seems its a tested solution :)"

If you want to see example of how this is done, you should ask flo on #vala IRC channel for links to the project he is doing it in.
Comment 22 Zeeshan Ali 2014-04-26 14:31:48 UTC
(In reply to comment #20)
> What works:
> 
> Git:
>  - Configure and compile Boxes from git with ovirt normally
>  - Configure and compile Boxes from git without ovirt with --enable-ovirt=no
> 
>  - Distribute Boxes with ovirt (make distcheck)
> 
> Tarball:
>  - Configure and compile Boxes tarball with ovirt
>  - Configure and compile Boxes tarball without ovirt with --enable-ovirt=no
> 
> Is this clearer?

Much :) If I understood correctly, with your current patch, tarball must be created with '--enable-ovirt=yes'? That is something we'd want to avoid if possible.

> (With distributed boxes i meant the tarball in the original
> post)

Yeah, I understood where you made it explicit.
Comment 23 Lasse Schuirmann 2014-04-26 14:37:49 UTC
(In reply to comment #22)
> (In reply to comment #20)
> Much :) If I understood correctly, with your current patch, tarball must be
> created with '--enable-ovirt=yes'? That is something we'd want to avoid if
> possible.

I thought we wanted exactly this to force the distributor to think about ovirt if he doesn't have it. (Although it doesn't make sense to do this if distributing without ovirt is not possible - but if I understood you right we wanted this to be possible with explicitly stating that ovirt should not be included.)
Comment 24 Zeeshan Ali 2014-06-16 17:17:36 UTC
(In reply to comment #23)
> (In reply to comment #22)
> > (In reply to comment #20)
> > Much :) If I understood correctly, with your current patch, tarball must be
> > created with '--enable-ovirt=yes'? That is something we'd want to avoid if
> > possible.
> 
> I thought we wanted exactly this to force the distributor to think about ovirt
> if he doesn't have it.

distributor doesn't create tarballs, they consume it. What we wanted was for '--enable-ovirt=yes' to be default so that ovirt support has to be always disabled explicitly and it doesn't happen by accident.
Comment 25 Lasse Schuirmann 2014-08-15 14:48:28 UTC
I cant recreate this issue anymore.

I'm marking this as enhancement since this is merely about this now:

> > Currently, it's relying on gcc to not attempt to compile code in a if (0)
> > block. This works with -O2 and -O0
>
> Ouch. Thats sounds really hackish.
Comment 26 Zeeshan Ali 2014-08-15 15:43:52 UTC
(In reply to comment #25)
> I cant recreate this issue anymore.

If you can't reproduce with optimizations options other than -O2 and -O0, then there is no hack involved and there is nothing to fix.
Comment 27 Lasse Schuirmann 2014-08-15 15:57:26 UTC
I tried to reproduce it and failed. THerefore closing this bug like you suggested.