qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	Eduardo Otubo <otubo@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] seccomp: Fix build
Date: Mon, 18 Sep 2017 20:30:12 +0800	[thread overview]
Message-ID: <20170918123012.GN15551@lemon.lan> (raw)
In-Reply-To: <CAFEAcA_bpija3nfB2URJbsqyGZfkziszFf16Q2U9TkC9HbnAJQ@mail.gmail.com>

On Mon, 09/18 09:31, Peter Maydell wrote:
> On 18 September 2017 at 08:46, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> > From: Jan Kiszka <jan.kiszka@siemens.com>
> >
> > vl.c includes seccomp.h, thus requires the related CFLAGS as well.
> >
> > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> > ---
> >  Makefile.objs | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/Makefile.objs b/Makefile.objs
> > index d9cf7ad791..4f1488d65d 100644
> > --- a/Makefile.objs
> > +++ b/Makefile.objs
> > @@ -61,7 +61,7 @@ bt-host.o-cflags := $(BLUEZ_CFLAGS)
> >
> >  common-obj-y += dma-helpers.o
> >  common-obj-y += vl.o
> > -vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
> > +vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS) $(SECCOMP_CFLAGS)
> >  common-obj-y += tpm.o
> >
> >  common-obj-$(CONFIG_SLIRP) += slirp/
> 
> ...I get the feeling we're going to get a whole bunch of these
> compile errors and fixups as we switch over to trying to specify
> package-dependent cflags only on certain source files. Is
> there anything we can do to make this changeover more reliable?

I think we should spot those risky headers and clean them up. See below.

> 
> In particular I think that just adding a new #include line
> to a source file shouldn't suddenly require us to change
> the makefile to add a FOO_CFLAGS if we can avoid it. If
> it is necessary, then we need to make sure that's a compile
> error on all platforms and configurations (including those
> where pkg-config happens to set FOO_CFLAGS to the empty string.)

My apologies in advance that I'm not directly answering your question, because I
don't know. Anyway..  IMHO being prudent on which library headers to pull in
from a source file is a good thing, so I feel the conversion a worthwhile
effort.  It also forces developers to fully hide the implementation details
behind an internal API:

> qemu-foo.h:
  void qemu_foo_do_a(void);
  void qemu_foo_do_b(void);
> qemu-foo-internal.h:
  /* A header that includes the library header, if necessary */
  #include <libfoo.h>
  #include "qemu-foo.h"
> qemu-foo-a.c:
  #include "qemu-foo.h"
  #include "qemu-foo-internal.h"
  void qemu_foo_do_a(void)
  {
      ...
  }
> qemu-foo-b.c:
  #include "qemu-foo.h"
  #include "qemu-foo-internal.h"
  void qemu_foo_do_b(void)
  {
      ...
  }

So in general we could clean up non-internal headers (as in the above example
the qemu-foo.h versus qemu-foo-internal.h) so that the library headers are not
included there, whenever possible.

If a library header is indeed wanted by different .c files, it probably should
goto QEMU_CFLAGS, like the glib headers.

But if a .c file does need to include a library header, it probably also wants
the libs flag as well. So, commonly -cflags and -libs still go together.

In the case of this patch, I think we should do this:

diff --git a/include/sysemu/seccomp.h b/include/sysemu/seccomp.h
index e67c2dc840..9b092aa23f 100644
--- a/include/sysemu/seccomp.h
+++ b/include/sysemu/seccomp.h
@@ -21,7 +21,5 @@
 #define QEMU_SECCOMP_SET_SPAWN       (1 << 3)
 #define QEMU_SECCOMP_SET_RESOURCECTL (1 << 4)

-#include <seccomp.h>
-
 int seccomp_start(uint32_t seccomp_opts);
 #endif

      reply	other threads:[~2017-09-18 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  7:46 [Qemu-devel] [PATCH] seccomp: Fix build Jan Kiszka
2017-09-18  8:31 ` Peter Maydell
2017-09-18 12:30   ` Fam Zheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170918123012.GN15551@lemon.lan \
    --to=famz@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=otubo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).