Skip to contentSkip to conversation

char: fix avail_connections init in qemu_chr_open_eventfd()

RFC PATCH In review David Marchand 4 participants 11 messages Feb 4, 2014 – Jun 12, 2014

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 char: fix avail_connections init in qemu_chr_open_eventfd()

Hello,

First of all, this is a pure RFC patch, I did not take too much time to dig into qemu source code to find the right solution, but since qemu_chr_open_eventfd() is only used by the code I was looking at, here is a patch.

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

I suppose this problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

---
 qemu-char.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qemu-char.c +6 -1
index 30c5a6a..c0adb04 100644
@@ -2492,7 +2492,12 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
 #ifndef _WIN32
 CharDriverState *qemu_chr_open_eventfd(int eventfd)
 {
-    return qemu_chr_open_fd(eventfd, eventfd);
+    CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
+
+    if (chr)
+        chr->avail_connections = 1;
+
+    return chr;
 }
 #endif
 
Signature · 1 line
David Marchand
#1 lore raw

Hello,

Can someone take a look at my previous email and tell me if my patch is just wrong ?

Thank you.

Signature · 1 line
David Marchand
Quoted 52 lines · David Marchand

Hello,

First of all, this is a pure RFC patch, I did not take too much time to dig into
qemu source code to find the right solution, but since qemu_chr_open_eventfd()
is only used by the code I was looking at, here is a patch.

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can
be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

I suppose this problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

---
 qemu-char.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qemu-char.c +6 -2
index 30c5a6a..c0adb04 100644
@@ -2492,7 +2492,12 @@ static gboolean tcp_chr_read(GIOChannel *chan,
 GIOCondition cond, void *opaque)
 #ifndef _WIN32
 CharDriverState *qemu_chr_open_eventfd(int eventfd)
 {
-    return qemu_chr_open_fd(eventfd, eventfd);
+    CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
+
+    if (chr)
+        chr->avail_connections = 1;
+
+    return chr;
 }
 #endif
 
--

David Marchand

#2 lore raw
In reply to David Marchand

Hi David,

I'm not sure which is the correct approach. You could either do what you did or you could simply remove the qemu_chr_fe_claim_no_fail() from ivshmem.c. I'm not sure how your change impacts other devices.

Sincerely,
Cam

Quoted 53 lines · David Marchand

Hello,

First of all, this is a pure RFC patch, I did not take too much time to dig into
qemu source code to find the right solution, but since qemu_chr_open_eventfd()
is only used by the code I was looking at, here is a patch.

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can
be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

I suppose this problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

---
 qemu-char.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qemu-char.c +6 -2
index 30c5a6a..c0adb04 100644
@@ -2492,7 +2492,12 @@ static gboolean tcp_chr_read(GIOChannel *chan,
 GIOCondition cond, void *opaque)
 #ifndef _WIN32
 CharDriverState *qemu_chr_open_eventfd(int eventfd)
 {
-    return qemu_chr_open_fd(eventfd, eventfd);
+    CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
+
+    if (chr)
+        chr->avail_connections = 1;
+
+    return chr;
 }
 #endif
 
--

David Marchand

#3 lore raw

Hello Cam,

Quoted 5 lines · Cam Macdonell

I'm not sure which is the correct approach. You could either do what you did or you could simply remove the qemu_chr_fe_claim_no_fail() from ivshmem.c. I'm not sure how your change impacts other devices.

Actually, the first thing I tried, when I encountered the problem, was to remove qemu_chr_fe_claim_no_fail(), and it worked.

In HEAD, ivshmem seems to be the only place where qemu_chr_open_eventfd() is used :

$ git grep qemu_chr_open_eventfd
hw/misc/ivshmem.c:    chr = qemu_chr_open_eventfd(eventfd);
include/sysemu/char.h:CharDriverState *qemu_chr_open_eventfd(int eventfd);
qemu-char.c:CharDriverState *qemu_chr_open_eventfd(int eventfd)

I suppose my change is not that impacting :-)

Regards,

Signature · 1 line
David Marchand
#4 lore raw

Hello all,

Quoted 10 lines · David Marchand

In HEAD, ivshmem seems to be the only place where qemu_chr_open_eventfd() is used :

$ git grep qemu_chr_open_eventfd
hw/misc/ivshmem.c:    chr = qemu_chr_open_eventfd(eventfd);
include/sysemu/char.h:CharDriverState *qemu_chr_open_eventfd(int eventfd);
qemu-char.c:CharDriverState *qemu_chr_open_eventfd(int eventfd)

I suppose my change is not that impacting :-)

Since this change has no impact, can it be pulled in current git tree ?

Thanks.

Signature · 1 line
David Marchand
#7 lore raw

PATCH 1/1 char: fix avail_connections init in qemu_chr_open_eventfd()

In reply to David Marchand

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

This problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

---
 qemu-char.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

No change since initial patch: http://patchwork.ozlabs.org/patch/316785/
I just rebased this patch on top of master branch and removed the [RFC] part.

Signature · 1 line
David Marchand
qemu-char.c +6 -1
index 17b476e..7640f17 100644
@@ -2493,7 +2493,12 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
 #ifndef _WIN32
 CharDriverState *qemu_chr_open_eventfd(int eventfd)
 {
-    return qemu_chr_open_fd(eventfd, eventfd);
+    CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
+
+    if (chr)
+        chr->avail_connections = 1;
+
+    return chr;
 }
 #endif
 
Signature · 1 line
1.7.10.4
#8 lore raw

Il 11/06/2014 15:39, David Marchand ha scritto:

Quoted 13 lines

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

This problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

Quoted 8 lines
---
 qemu-char.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

No change since initial patch: http://patchwork.ozlabs.org/patch/316785/
I just rebased this patch on top of master branch and removed the [RFC] part.

CCing Gerd who lately has been taking care of qemu-char.c ([email protected]).

The patch has a small coding style problem; it's missing braces around the "if" statement. Please send an updated version and include Gerd in the email.

Thanks,

Paolo

#9 lore raw

PATCH v2 1/1 char: fix avail_connections init in qemu_chr_open_eventfd()

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

This problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

---
 qemu-char.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Changes since v1
- fix coding style issue (missing braces)

Signature · 1 line
David Marchand
qemu-char.c +7 -1
index 17b476e..53eccc2 100644
@@ -2493,7 +2493,13 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
 #ifndef _WIN32
 CharDriverState *qemu_chr_open_eventfd(int eventfd)
 {
-    return qemu_chr_open_fd(eventfd, eventfd);
+    CharDriverState *chr = qemu_chr_open_fd(eventfd, eventfd);
+
+    if (chr) {
+        chr->avail_connections = 1;
+    }
+
+    return chr;
 }
 #endif
 
Signature · 1 line
1.7.10.4
#10 lore raw
Quoted 8 lines · David Marchand

When trying to use a ivshmem server with qemu, ivshmem init code tries to create a CharDriverState object for each eventfd retrieved from the server. To create this object, a call to qemu_chr_open_eventfd() is done. Right after this, before adding a frontend, qemu_chr_fe_claim_no_fail() is called.
qemu_chr_open_eventfd() does not set avail_connections to 1, so no frontend can be associated because qemu_chr_fe_claim_no_fail() makes qemu stop right away.

Quoted 6 lines

This problem comes from 456d60692310e7ac25cf822cc1e98192ad636ece "qemu-char: Call fe_claim / fe_release when not using qdev chr properties".

Fix this, by setting avail_connections to 1 in qemu_chr_open_eventfd().

Picked up.

cheers,
Gerd