All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c
@ 2022-03-31 18:26 Will Cohen
  2022-03-31 20:00 ` Peter Maydell
  0 siblings, 1 reply; 5+ messages in thread
From: Will Cohen @ 2022-03-31 18:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, thuth, fabianfranz.oss, Christian Schoenebeck,
	Greg Kurz, keno, reactorcontrol, philippe.mathieu.daude,
	Will Cohen, hi

The patch set adding 9p functionality to darwin introduced an issue
where limits.h, which defines XATTR_SIZE_MAX, is included in 9p.c,
though the referenced constant is needed in 9p.h. This commit fixes that
issue by moving the definition of P9_XATTR_SIZE_MAX, which uses
XATTR_SIZE_MAX, to also be in 9p.c.

Additionally, this commit moves the location of the system headers
include in 9p.c to occur before the project headers.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/950
Fixes: 38d7fd68b0 ("9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX")

Signed-off-by: Will Cohen <wwcohen@gmail.com>
---
 hw/9pfs/9p.c | 28 +++++++++++++++++++++++-----
 hw/9pfs/9p.h | 18 ------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index dcaa602d4c..b9152c7882 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -16,6 +16,11 @@
  * https://wiki.qemu.org/Documentation/9p
  */
 
+#ifdef CONFIG_LINUX
+#include <linux/limits.h>
+#else
+#include <limits.h>
+#endif
 #include "qemu/osdep.h"
 #include <glib/gprintf.h>
 #include "hw/virtio/virtio.h"
@@ -33,11 +38,6 @@
 #include "migration/blocker.h"
 #include "qemu/xxhash.h"
 #include <math.h>
-#ifdef CONFIG_LINUX
-#include <linux/limits.h>
-#else
-#include <limits.h>
-#endif
 
 int open_fd_hw;
 int total_open_fd;
@@ -3925,6 +3925,24 @@ out_nofid:
     v9fs_string_free(&name);
 }
 
+#if defined(CONFIG_LINUX)
+/* Currently, only Linux has XATTR_SIZE_MAX */
+#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX
+#elif defined(CONFIG_DARWIN)
+/*
+ * Darwin doesn't seem to define a maximum xattr size in its user
+ * space header, so manually configure it across platforms as 64k.
+ *
+ * Having no limit at all can lead to QEMU crashing during large g_malloc()
+ * calls. Because QEMU does not currently support macOS guests, the below
+ * preliminary solution only works due to its being a reflection of the limit of
+ * Linux guests.
+ */
+#define P9_XATTR_SIZE_MAX 65536
+#else
+#error Missing definition for P9_XATTR_SIZE_MAX for this host system
+#endif
+
 static void coroutine_fn v9fs_xattrcreate(void *opaque)
 {
     int flags, rflags = 0;
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index af2635fae9..994f952600 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -479,22 +479,4 @@ struct V9fsTransport {
     void        (*push_and_notify)(V9fsPDU *pdu);
 };
 
-#if defined(XATTR_SIZE_MAX)
-/* Linux */
-#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX
-#elif defined(CONFIG_DARWIN)
-/*
- * Darwin doesn't seem to define a maximum xattr size in its user
- * space header, so manually configure it across platforms as 64k.
- *
- * Having no limit at all can lead to QEMU crashing during large g_malloc()
- * calls. Because QEMU does not currently support macOS guests, the below
- * preliminary solution only works due to its being a reflection of the limit of
- * Linux guests.
- */
-#define P9_XATTR_SIZE_MAX 65536
-#else
-#error Missing definition for P9_XATTR_SIZE_MAX for this host system
-#endif
-
 #endif
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c
  2022-03-31 18:26 [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c Will Cohen
@ 2022-03-31 20:00 ` Peter Maydell
  2022-03-31 20:06   ` Will Cohen
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2022-03-31 20:00 UTC (permalink / raw)
  To: Will Cohen
  Cc: thuth, fabianfranz.oss, Christian Schoenebeck, qemu-devel,
	Greg Kurz, keno, reactorcontrol, philippe.mathieu.daude, hi

On Thu, 31 Mar 2022 at 19:27, Will Cohen <wwcohen@gmail.com> wrote:
>
> The patch set adding 9p functionality to darwin introduced an issue
> where limits.h, which defines XATTR_SIZE_MAX, is included in 9p.c,
> though the referenced constant is needed in 9p.h. This commit fixes that
> issue by moving the definition of P9_XATTR_SIZE_MAX, which uses
> XATTR_SIZE_MAX, to also be in 9p.c.
>
> Additionally, this commit moves the location of the system headers
> include in 9p.c to occur before the project headers.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/950
> Fixes: 38d7fd68b0 ("9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX")
>
> Signed-off-by: Will Cohen <wwcohen@gmail.com>
> ---
>  hw/9pfs/9p.c | 28 +++++++++++++++++++++++-----
>  hw/9pfs/9p.h | 18 ------------------
>  2 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index dcaa602d4c..b9152c7882 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -16,6 +16,11 @@
>   * https://wiki.qemu.org/Documentation/9p
>   */
>
> +#ifdef CONFIG_LINUX
> +#include <linux/limits.h>
> +#else
> +#include <limits.h>
> +#endif
>  #include "qemu/osdep.h"

osdep.h must always be the first include line in any .c file.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c
  2022-03-31 20:00 ` Peter Maydell
@ 2022-03-31 20:06   ` Will Cohen
  2022-04-01 11:01     ` Thomas Huth
  0 siblings, 1 reply; 5+ messages in thread
From: Will Cohen @ 2022-03-31 20:06 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Thomas Huth, Fabian Franz, Christian Schoenebeck,
	qemu Developers, Greg Kurz, Keno Fischer, Michael Roitzsch,
	Philippe Mathieu-Daudé,
	hi

[-- Attachment #1: Type: text/plain, Size: 1675 bytes --]

On Thu, Mar 31, 2022 at 4:00 PM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Thu, 31 Mar 2022 at 19:27, Will Cohen <wwcohen@gmail.com> wrote:
> >
> > The patch set adding 9p functionality to darwin introduced an issue
> > where limits.h, which defines XATTR_SIZE_MAX, is included in 9p.c,
> > though the referenced constant is needed in 9p.h. This commit fixes that
> > issue by moving the definition of P9_XATTR_SIZE_MAX, which uses
> > XATTR_SIZE_MAX, to also be in 9p.c.
> >
> > Additionally, this commit moves the location of the system headers
> > include in 9p.c to occur before the project headers.
> >
> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/950
> > Fixes: 38d7fd68b0 ("9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX")
> >
> > Signed-off-by: Will Cohen <wwcohen@gmail.com>
> > ---
> >  hw/9pfs/9p.c | 28 +++++++++++++++++++++++-----
> >  hw/9pfs/9p.h | 18 ------------------
> >  2 files changed, 23 insertions(+), 23 deletions(-)
> >
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index dcaa602d4c..b9152c7882 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -16,6 +16,11 @@
> >   * https://wiki.qemu.org/Documentation/9p
> >   */
> >
> > +#ifdef CONFIG_LINUX
> > +#include <linux/limits.h>
> > +#else
> > +#include <limits.h>
> > +#endif
> >  #include "qemu/osdep.h"
>
> osdep.h must always be the first include line in any .c file.
>

Understood, apologies -- if there's other changes for a v3 I can resubmit
accordingly, but if this otherwise looks okay then I would be fine with a
QEMU maintainer adjusting the header placement as needed when preparing for
submission to the main tree.

Will


>
> thanks
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 2699 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c
  2022-03-31 20:06   ` Will Cohen
@ 2022-04-01 11:01     ` Thomas Huth
  2022-04-01 11:24       ` Christian Schoenebeck
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2022-04-01 11:01 UTC (permalink / raw)
  To: Will Cohen, Peter Maydell
  Cc: Fabian Franz, Christian Schoenebeck, qemu Developers, Greg Kurz,
	Keno Fischer, Michael Roitzsch, Philippe Mathieu-Daudé,
	hi

On 31/03/2022 22.06, Will Cohen wrote:
> On Thu, Mar 31, 2022 at 4:00 PM Peter Maydell <peter.maydell@linaro.org 
> <mailto:peter.maydell@linaro.org>> wrote:
> 
>     On Thu, 31 Mar 2022 at 19:27, Will Cohen <wwcohen@gmail.com
>     <mailto:wwcohen@gmail.com>> wrote:
>      >
>      > The patch set adding 9p functionality to darwin introduced an issue
>      > where limits.h, which defines XATTR_SIZE_MAX, is included in 9p.c,
>      > though the referenced constant is needed in 9p.h. This commit fixes that
>      > issue by moving the definition of P9_XATTR_SIZE_MAX, which uses
>      > XATTR_SIZE_MAX, to also be in 9p.c.
>      >
>      > Additionally, this commit moves the location of the system headers
>      > include in 9p.c to occur before the project headers.
>      >
>      > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/950
>     <https://gitlab.com/qemu-project/qemu/-/issues/950>
>      > Fixes: 38d7fd68b0 ("9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX")
>      >
>      > Signed-off-by: Will Cohen <wwcohen@gmail.com <mailto:wwcohen@gmail.com>>
>      > ---
>      >  hw/9pfs/9p.c | 28 +++++++++++++++++++++++-----
>      >  hw/9pfs/9p.h | 18 ------------------
>      >  2 files changed, 23 insertions(+), 23 deletions(-)
>      >
>      > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
>      > index dcaa602d4c..b9152c7882 100644
>      > --- a/hw/9pfs/9p.c
>      > +++ b/hw/9pfs/9p.c
>      > @@ -16,6 +16,11 @@
>      >   * https://wiki.qemu.org/Documentation/9p
>     <https://wiki.qemu.org/Documentation/9p>
>      >   */
>      >
>      > +#ifdef CONFIG_LINUX
>      > +#include <linux/limits.h>
>      > +#else
>      > +#include <limits.h>
>      > +#endif
>      >  #include "qemu/osdep.h"
> 
>     osdep.h must always be the first include line in any .c file.
> 
> Understood, apologies -- if there's other changes for a v3 I can resubmit 
> accordingly, but if this otherwise looks okay then I would be fine with a 
> QEMU maintainer adjusting the header placement as needed when preparing for 
> submission to the main tree.

Makes sense. I'm currently assembling a pull req with some misc fixes for 
7.0 ... if Christian & Greg do not have any other patches pending right now, 
I could throw this in, with the osdep.h location fixed.

  Thomas



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c
  2022-04-01 11:01     ` Thomas Huth
@ 2022-04-01 11:24       ` Christian Schoenebeck
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Schoenebeck @ 2022-04-01 11:24 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Will Cohen, Peter Maydell, qemu Developers, Keno Fischer,
	Philippe Mathieu-Daudé,
	Fabian Franz, Michael Roitzsch, Greg Kurz, hi

On Freitag, 1. April 2022 13:01:31 CEST Thomas Huth wrote:
> On 31/03/2022 22.06, Will Cohen wrote:
> > On Thu, Mar 31, 2022 at 4:00 PM Peter Maydell <peter.maydell@linaro.org
> > 
> > <mailto:peter.maydell@linaro.org>> wrote:
> >     On Thu, 31 Mar 2022 at 19:27, Will Cohen <wwcohen@gmail.com
> >     
> >     <mailto:wwcohen@gmail.com>> wrote:
> >      > The patch set adding 9p functionality to darwin introduced an issue
> >      > where limits.h, which defines XATTR_SIZE_MAX, is included in 9p.c,
> >      > though the referenced constant is needed in 9p.h. This commit fixes
> >      > that
> >      > issue by moving the definition of P9_XATTR_SIZE_MAX, which uses
> >      > XATTR_SIZE_MAX, to also be in 9p.c.
> >      > 
> >      > Additionally, this commit moves the location of the system headers
> >      > include in 9p.c to occur before the project headers.
> >      > 
> >      > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/950
> >     
> >     <https://gitlab.com/qemu-project/qemu/-/issues/950>
> >     
> >      > Fixes: 38d7fd68b0 ("9p: darwin: Move
> >      > XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX")
> >      > 
> >      > Signed-off-by: Will Cohen <wwcohen@gmail.com
> >      > <mailto:wwcohen@gmail.com>>
> >      > ---
> >      >
> >      >  hw/9pfs/9p.c | 28 +++++++++++++++++++++++-----
> >      >  hw/9pfs/9p.h | 18 ------------------
> >      >  2 files changed, 23 insertions(+), 23 deletions(-)
> >      >
> >      > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> >      > index dcaa602d4c..b9152c7882 100644
> >      > --- a/hw/9pfs/9p.c
> >      > +++ b/hw/9pfs/9p.c
> >      > @@ -16,6 +16,11 @@
> >      >
> >      >   * https://wiki.qemu.org/Documentation/9p
> >     
> >     <https://wiki.qemu.org/Documentation/9p>
> >     
> >      >   */
> >      >
> >      > +#ifdef CONFIG_LINUX
> >      > +#include <linux/limits.h>
> >      > +#else
> >      > +#include <limits.h>
> >      > +#endif
> >      >
> >      >  #include "qemu/osdep.h"
> >     
> >     osdep.h must always be the first include line in any .c file.
> > 
> > Understood, apologies -- if there's other changes for a v3 I can resubmit
> > accordingly, but if this otherwise looks okay then I would be fine with a
> > QEMU maintainer adjusting the header placement as needed when preparing
> > for
> > submission to the main tree.
> 
> Makes sense. I'm currently assembling a pull req with some misc fixes for
> 7.0 ... if Christian & Greg do not have any other patches pending right now,
> I could throw this in, with the osdep.h location fixed.
> 
>   Thomas

That would be appreciated, nothing else for 7.0 at this point. Thanks Thomas!

Best regards,
Christian Schoenebeck




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-01 11:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 18:26 [PATCH v2] 9p: move P9_XATTR_SIZE_MAX from 9p.h to 9p.c Will Cohen
2022-03-31 20:00 ` Peter Maydell
2022-03-31 20:06   ` Will Cohen
2022-04-01 11:01     ` Thomas Huth
2022-04-01 11:24       ` Christian Schoenebeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.