2013-07-10 11:00:44

by Ramkumar Ramachandra

[permalink] [raw]
Subject: [PATCH 0/2] virtio tools: build failure

Hi,

This is actually a bug report. As you can see, I tried fixing the
build but failed. The problem is that the vringh_test target was
added by:

1515c5c (tools/virtio: add vring_test, 2013-03-20)

but then

f558a84 (Add missing module license tag to vring helpers, 2013-05-03)

broke the build by adding a MODULE_LICENSE that is undefined for the
purposes of virtio tools. I tried moving the definition of
MODULE_LICENSE from virtio.h to module.h, but then the build failed
with multiple __MODULE_LICENSE_name declarations. After trying
several things, I decided to revert f558a84: that builds vringh
successfully. Unfortunately, vhost_test doesn't build with tons of
errors:

make -C `pwd`/../.. M=`pwd`/vhost_test
make[1]: Entering directory `/home/artagnon/src/linux'
CC [M] /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.o
In file included from /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.c:1:0:
drivers/vhost/test.c: In function ‘handle_vq’:
drivers/vhost/test.c:41:31: warning: initialization from incompatible pointer type [enabled by default]
struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ];
^
drivers/vhost/test.c: In function ‘vhost_test_open’:
drivers/vhost/test.c:112:2: warning: passing argument 2 of ‘vhost_dev_init’ from incompatible pointer type [enabled by default]
r = vhost_dev_init(dev, n->vqs, VHOST_TEST_VQ_MAX);
^
In file included from drivers/vhost/test.c:21:0,
from /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.c:1:
drivers/vhost/vhost.c:283:6: note: expected ‘struct vhost_virtqueue **’ but argument is of type ‘struct vhost_virtqueue *’
long vhost_dev_init(struct vhost_dev *dev,
^
In file included from /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.c:1:0:
drivers/vhost/test.c: In function ‘vhost_test_flush_vq’:
drivers/vhost/test.c:143:37: error: request for member ‘poll’ in something not a structure or union
vhost_poll_flush(&n->dev.vqs[index].poll);
^
drivers/vhost/test.c: In function ‘vhost_test_ioctl’:
drivers/vhost/test.c:271:14: error: ‘VHOST_NET_FEATURES’ undeclared (first use in this function)
features = VHOST_NET_FEATURES;
^
drivers/vhost/test.c:271:14: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [/home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.o] Error 1
make[1]: *** [_module_/home/artagnon/src/linux/tools/virtio/vhost_test] Error 2
make[1]: Leaving directory `/home/artagnon/src/linux'
make: *** [mod] Error 2

I just gave up trying to fix the build, and thought I should atleast
submit a bug report. Maybe I'm missing something?

Thanks.

Ramkumar Ramachandra (2):
virtio tools: strip bad include-path from Makefile
virtio tools: add .gitignore

tools/virtio/.gitignore | 3 +++
tools/virtio/Makefile | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 tools/virtio/.gitignore

--
1.8.3.2.736.g869de25


2013-07-10 11:00:50

by Ramkumar Ramachandra

[permalink] [raw]
Subject: [PATCH] virtio tools: add .gitignore

Signed-off-by: Ramkumar Ramachandra <[email protected]>
---
tools/virtio/.gitignore | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 tools/virtio/.gitignore

diff --git a/tools/virtio/.gitignore b/tools/virtio/.gitignore
new file mode 100644
index 0000000..1cfbb01
--- /dev/null
+++ b/tools/virtio/.gitignore
@@ -0,0 +1,3 @@
+*.d
+virtio_test
+vringh_test
--
1.8.3.2.736.g869de25

2013-07-10 11:00:48

by Ramkumar Ramachandra

[permalink] [raw]
Subject: [PATCH 1/2] virtio tools: strip bad include-path from Makefile

CFLAGS contains a mysterious "-I ../../usr/include", but no such path
exists in the linux tree. The line was originally introduced in
4e53f78e (tools/virtio: virtio_test tool, 2010-11-29), but no such path
existed in the tree even then.

Cc: Michael S. Tsirkin <[email protected]>
Cc: Rusty Russell <[email protected]>
Signed-off-by: Ramkumar Ramachandra <[email protected]>
---
tools/virtio/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index 3187c62..53623c6 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -3,7 +3,7 @@ test: virtio_test vringh_test
virtio_test: virtio_ring.o virtio_test.o
vringh_test: vringh_test.o vringh.o virtio_ring.o

-CFLAGS += -g -O2 -Wall -I. -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
+CFLAGS += -g -O2 -Wall -I. -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
vpath %.c ../../drivers/virtio ../../drivers/vhost
mod:
${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test
--
1.8.3.2.736.g869de25

2013-07-10 12:14:14

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH 1/2] virtio tools: strip bad include-path from Makefile

On Wed, Jul 10, 2013 at 04:26:59PM +0530, Ramkumar Ramachandra wrote:
> CFLAGS contains a mysterious "-I ../../usr/include", but no such path
> exists in the linux tree. The line was originally introduced in
> 4e53f78e (tools/virtio: virtio_test tool, 2010-11-29), but no such path
> existed in the tree even then.
>
> Cc: Michael S. Tsirkin <[email protected]>
> Cc: Rusty Russell <[email protected]>
> Signed-off-by: Ramkumar Ramachandra <[email protected]>

NACK

It exists if you do make headers_install.
So it's handy for old distos where userspace headers don't
exist or are out of date.

> ---
> tools/virtio/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
> index 3187c62..53623c6 100644
> --- a/tools/virtio/Makefile
> +++ b/tools/virtio/Makefile
> @@ -3,7 +3,7 @@ test: virtio_test vringh_test
> virtio_test: virtio_ring.o virtio_test.o
> vringh_test: vringh_test.o vringh.o virtio_ring.o
>
> -CFLAGS += -g -O2 -Wall -I. -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
> +CFLAGS += -g -O2 -Wall -I. -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE
> vpath %.c ../../drivers/virtio ../../drivers/vhost
> mod:
> ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test
> --
> 1.8.3.2.736.g869de25

2013-07-10 12:15:00

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH] virtio tools: add .gitignore

On Wed, Jul 10, 2013 at 04:27:00PM +0530, Ramkumar Ramachandra wrote:
> Signed-off-by: Ramkumar Ramachandra <[email protected]>
> ---

Why not.

Acked-by: Michael S. Tsirkin <[email protected]>

> tools/virtio/.gitignore | 3 +++
> 1 file changed, 3 insertions(+)
> create mode 100644 tools/virtio/.gitignore
>
> diff --git a/tools/virtio/.gitignore b/tools/virtio/.gitignore
> new file mode 100644
> index 0000000..1cfbb01
> --- /dev/null
> +++ b/tools/virtio/.gitignore
> @@ -0,0 +1,3 @@
> +*.d
> +virtio_test
> +vringh_test
> --
> 1.8.3.2.736.g869de25

2013-07-10 12:17:05

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH 0/2] virtio tools: build failure

On Wed, Jul 10, 2013 at 04:26:58PM +0530, Ramkumar Ramachandra wrote:
> Hi,
>
> This is actually a bug report. As you can see, I tried fixing the
> build but failed. The problem is that the vringh_test target was
> added by:
>
> 1515c5c (tools/virtio: add vring_test, 2013-03-20)
>
> but then
>
> f558a84 (Add missing module license tag to vring helpers, 2013-05-03)
>
> broke the build by adding a MODULE_LICENSE that is undefined for the
> purposes of virtio tools. I tried moving the definition of
> MODULE_LICENSE from virtio.h to module.h, but then the build failed
> with multiple __MODULE_LICENSE_name declarations. After trying
> several things, I decided to revert f558a84: that builds vringh
> successfully. Unfortunately, vhost_test doesn't build with tons of
> errors:
>
> make -C `pwd`/../.. M=`pwd`/vhost_test
> make[1]: Entering directory `/home/artagnon/src/linux'
> CC [M] /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.o
> In file included from /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.c:1:0:
> drivers/vhost/test.c: In function ‘handle_vq’:
> drivers/vhost/test.c:41:31: warning: initialization from incompatible pointer type [enabled by default]
> struct vhost_virtqueue *vq = &n->dev.vqs[VHOST_TEST_VQ];
> ^
> drivers/vhost/test.c: In function ‘vhost_test_open’:
> drivers/vhost/test.c:112:2: warning: passing argument 2 of ‘vhost_dev_init’ from incompatible pointer type [enabled by default]
> r = vhost_dev_init(dev, n->vqs, VHOST_TEST_VQ_MAX);
> ^
> In file included from drivers/vhost/test.c:21:0,
> from /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.c:1:
> drivers/vhost/vhost.c:283:6: note: expected ‘struct vhost_virtqueue **’ but argument is of type ‘struct vhost_virtqueue *’
> long vhost_dev_init(struct vhost_dev *dev,
> ^
> In file included from /home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.c:1:0:
> drivers/vhost/test.c: In function ‘vhost_test_flush_vq’:
> drivers/vhost/test.c:143:37: error: request for member ‘poll’ in something not a structure or union
> vhost_poll_flush(&n->dev.vqs[index].poll);
> ^
> drivers/vhost/test.c: In function ‘vhost_test_ioctl’:
> drivers/vhost/test.c:271:14: error: ‘VHOST_NET_FEATURES’ undeclared (first use in this function)
> features = VHOST_NET_FEATURES;
> ^
> drivers/vhost/test.c:271:14: note: each undeclared identifier is reported only once for each function it appears in
> make[2]: *** [/home/artagnon/src/linux/tools/virtio/vhost_test/vhost_test.o] Error 1
> make[1]: *** [_module_/home/artagnon/src/linux/tools/virtio/vhost_test] Error 2
> make[1]: Leaving directory `/home/artagnon/src/linux'
> make: *** [mod] Error 2
>
> I just gave up trying to fix the build, and thought I should atleast
> submit a bug report. Maybe I'm missing something?
>
> Thanks.
>
> Ramkumar Ramachandra (2):
> virtio tools: strip bad include-path from Makefile
> virtio tools: add .gitignore
>
> tools/virtio/.gitignore | 3 +++
> tools/virtio/Makefile | 2 +-
> 2 files changed, 4 insertions(+), 1 deletion(-)
> create mode 100644 tools/virtio/.gitignore

Right. I sent a pull request to Linus which fixes some of these errors,
and Rusty queued fixes for the rest.
So you'll be able to build it again once 3.11-rc1 is out.


> --
> 1.8.3.2.736.g869de25

2013-07-10 12:20:46

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [PATCH 1/2] virtio tools: strip bad include-path from Makefile

Michael S. Tsirkin wrote:
>> CFLAGS contains a mysterious "-I ../../usr/include", but no such path
>> exists in the linux tree. The line was originally introduced in
>> 4e53f78e (tools/virtio: virtio_test tool, 2010-11-29), but no such path
>> existed in the tree even then.
>
> It exists if you do make headers_install.

I see. Why do we need these (or userspace headers) when /include
exists in the linux tree though?

> So it's handy for old distos where userspace headers don't
> exist or are out of date.

I thought userspace headers (linux-kernel-headers package in my
distribution) are used for building kernel modules that exist as
independent projects outside the linux tree (?).

2013-07-10 12:41:46

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH 1/2] virtio tools: strip bad include-path from Makefile

On Wed, Jul 10, 2013 at 05:50:04PM +0530, Ramkumar Ramachandra wrote:
> Michael S. Tsirkin wrote:
> >> CFLAGS contains a mysterious "-I ../../usr/include", but no such path
> >> exists in the linux tree. The line was originally introduced in
> >> 4e53f78e (tools/virtio: virtio_test tool, 2010-11-29), but no such path
> >> existed in the tree even then.
> >
> > It exists if you do make headers_install.
>
> I see. Why do we need these (or userspace headers) when /include
> exists in the linux tree though?

This is usespace code so it needs the cleaned-up version from
usr/include, not the internal kernel one.

> > So it's handy for old distos where userspace headers don't
> > exist or are out of date.
>
> I thought userspace headers (linux-kernel-headers package in my
> distribution) are used for building kernel modules that exist as
> independent projects outside the linux tree (?).

userspace headers are for userspace, not for external modules.
I don't know what does your distro puts in a linux-kernel-headers
package.

--
MST

2013-07-10 13:22:50

by Ramkumar Ramachandra

[permalink] [raw]
Subject: Re: [PATCH 1/2] virtio tools: strip bad include-path from Makefile

Michael S. Tsirkin wrote:
> This is usespace code so it needs the cleaned-up version from
> usr/include, not the internal kernel one.

Right, thanks for clearing that up. However, it does seem to depend
on some code in /include in the linux tree. From
tools/virtio/linux/virtio_ring.h:

#include "../../../include/linux/virtio_ring.h"

2013-07-10 13:25:40

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH 1/2] virtio tools: strip bad include-path from Makefile

On Wed, Jul 10, 2013 at 06:52:09PM +0530, Ramkumar Ramachandra wrote:
> Michael S. Tsirkin wrote:
> > This is usespace code so it needs the cleaned-up version from
> > usr/include, not the internal kernel one.
>
> Right, thanks for clearing that up. However, it does seem to depend
> on some code in /include in the linux tree. From
> tools/virtio/linux/virtio_ring.h:
>
> #include "../../../include/linux/virtio_ring.h"

Yes, this is because we take some kernel bits
and compile as userspace. But it's fragile and it only works
for specific headers.

--
MST

2013-07-11 03:24:42

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] virtio tools: add .gitignore

"Michael S. Tsirkin" <[email protected]> writes:
> On Wed, Jul 10, 2013 at 04:27:00PM +0530, Ramkumar Ramachandra wrote:
>> Signed-off-by: Ramkumar Ramachandra <[email protected]>
>> ---
>
> Why not.
>
> Acked-by: Michael S. Tsirkin <[email protected]>

Applied.

Thanks,
Rusty.