* [Qemu-devel] [PATCH 2/8] xen: introduce the header file for the Xen 9pfs transport protocol
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend Stefano Stabellini
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross
It uses the new ring.h macros to declare rings and interfaces.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
---
hw/9pfs/xen_9pfs.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 hw/9pfs/xen_9pfs.h
diff --git a/hw/9pfs/xen_9pfs.h b/hw/9pfs/xen_9pfs.h
new file mode 100644
index 0000000..c4e8901
--- /dev/null
+++ b/hw/9pfs/xen_9pfs.h
@@ -0,0 +1,20 @@
+#ifndef XEN_9PFS_H
+#define XEN_9PFS_H
+
+#include "hw/xen/io/ring.h"
+#include <xen/io/protocols.h>
+
+struct xen_9pfs_header {
+ uint32_t size;
+ uint8_t id;
+ uint16_t tag;
+
+ /* uint8_t sdata[]; */
+} __attribute__((packed));
+
+#define PAGE_SHIFT XC_PAGE_SHIFT
+#define XEN_9PFS_RING_ORDER 6
+#define XEN_9PFS_RING_SIZE XEN_FLEX_RING_SIZE(XEN_9PFS_RING_ORDER)
+DEFINE_XEN_FLEX_RING_AND_INTF(xen_9pfs);
+
+#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 2/8] xen: introduce the header file for the Xen 9pfs transport protocol Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-09 17:54 ` Greg Kurz
2017-03-07 2:12 ` [Qemu-devel] [PATCH 4/8] xen/9pfs: connect to the frontend Stefano Stabellini
` (4 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross, Aneesh Kumar K.V, Greg Kurz
Introduce the Xen 9pfs backend: add struct XenDevOps to register as a
Xen backend and add struct V9fsTransport to register as v9fs transport.
All functions are empty stubs for now.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
hw/9pfs/xen-9p-backend.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
create mode 100644 hw/9pfs/xen-9p-backend.c
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
new file mode 100644
index 0000000..924fb64
--- /dev/null
+++ b/hw/9pfs/xen-9p-backend.c
@@ -0,0 +1,96 @@
+/*
+ * Xen 9p backend
+ *
+ * Copyright Aporeto 2017
+ *
+ * Authors:
+ * Stefano Stabellini <stefano@aporeto.com>
+ *
+ */
+
+#include "qemu/osdep.h"
+
+#include "hw/hw.h"
+#include "hw/9pfs/9p.h"
+#include "hw/xen/xen_backend.h"
+#include "xen_9pfs.h"
+#include "qemu/config-file.h"
+#include "fsdev/qemu-fsdev.h"
+
+struct Xen9pfsDev {
+ struct XenDevice xendev; /* must be first */
+};
+
+static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
+ size_t offset,
+ const char *fmt,
+ va_list ap)
+{
+ return 0;
+}
+
+static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
+ size_t offset,
+ const char *fmt,
+ va_list ap)
+{
+ return 0;
+}
+
+static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
+ struct iovec **piov,
+ unsigned int *pniov)
+{
+}
+
+static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
+ struct iovec **piov,
+ unsigned int *pniov,
+ size_t size)
+{
+}
+
+static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
+{
+}
+
+static const struct V9fsTransport xen_9p_transport = {
+ .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
+ .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
+ .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
+ .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
+ .push_and_notify = xen_9pfs_push_and_notify,
+};
+
+static int xen_9pfs_init(struct XenDevice *xendev)
+{
+ return 0;
+}
+
+static int xen_9pfs_free(struct XenDevice *xendev)
+{
+ return -1;
+}
+
+static int xen_9pfs_connect(struct XenDevice *xendev)
+{
+ return 0;
+}
+
+static void xen_9pfs_alloc(struct XenDevice *xendev)
+{
+}
+
+static void xen_9pfs_disconnect(struct XenDevice *xendev)
+{
+}
+
+struct XenDevOps xen_9pfs_ops = {
+ .size = sizeof(struct Xen9pfsDev),
+ .flags = DEVOPS_FLAG_NEED_GNTDEV,
+ .alloc = xen_9pfs_alloc,
+ .init = xen_9pfs_init,
+ .initialise = xen_9pfs_connect,
+ .disconnect = xen_9pfs_disconnect,
+ .free = xen_9pfs_free,
+};
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend Stefano Stabellini
@ 2017-03-09 17:54 ` Greg Kurz
2017-03-10 9:48 ` Greg Kurz
0 siblings, 1 reply; 13+ messages in thread
From: Greg Kurz @ 2017-03-09 17:54 UTC (permalink / raw)
To: Stefano Stabellini
Cc: qemu-devel, xen-devel, Stefano Stabellini, anthony.perard, jgross,
Aneesh Kumar K.V
[-- Attachment #1: Type: text/plain, Size: 3776 bytes --]
On Mon, 6 Mar 2017 18:12:43 -0800
Stefano Stabellini <sstabellini@kernel.org> wrote:
> Introduce the Xen 9pfs backend: add struct XenDevOps to register as a
> Xen backend and add struct V9fsTransport to register as v9fs transport.
>
> All functions are empty stubs for now.
>
> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> CC: anthony.perard@citrix.com
> CC: jgross@suse.com
> CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> CC: Greg Kurz <groug@kaod.org>
> ---
> hw/9pfs/xen-9p-backend.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 96 insertions(+)
> create mode 100644 hw/9pfs/xen-9p-backend.c
>
> diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> new file mode 100644
> index 0000000..924fb64
> --- /dev/null
> +++ b/hw/9pfs/xen-9p-backend.c
> @@ -0,0 +1,96 @@
> +/*
> + * Xen 9p backend
> + *
> + * Copyright Aporeto 2017
> + *
> + * Authors:
> + * Stefano Stabellini <stefano@aporeto.com>
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +
> +#include "hw/hw.h"
> +#include "hw/9pfs/9p.h"
> +#include "hw/xen/xen_backend.h"
> +#include "xen_9pfs.h"
> +#include "qemu/config-file.h"
> +#include "fsdev/qemu-fsdev.h"
> +
> +struct Xen9pfsDev {
> + struct XenDevice xendev; /* must be first */
> +};
According to HACKING, this should be:
typedef struct Xen9pfsDev {
struct XenDevice xendev; /* must be first */
} Xen9pfsDev;
and...
> +
> +static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
> + size_t offset,
> + const char *fmt,
> + va_list ap)
> +{
> + return 0;
> +}
> +
> +static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
> + size_t offset,
> + const char *fmt,
> + va_list ap)
> +{
> + return 0;
> +}
> +
> +static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
> + struct iovec **piov,
> + unsigned int *pniov)
> +{
> +}
> +
> +static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
> + struct iovec **piov,
> + unsigned int *pniov,
> + size_t size)
> +{
> +}
> +
> +static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
> +{
> +}
> +
> +static const struct V9fsTransport xen_9p_transport = {
> + .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
> + .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
> + .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
> + .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
> + .push_and_notify = xen_9pfs_push_and_notify,
> +};
> +
> +static int xen_9pfs_init(struct XenDevice *xendev)
> +{
> + return 0;
> +}
> +
> +static int xen_9pfs_free(struct XenDevice *xendev)
> +{
> + return -1;
> +}
> +
> +static int xen_9pfs_connect(struct XenDevice *xendev)
> +{
> + return 0;
> +}
> +
> +static void xen_9pfs_alloc(struct XenDevice *xendev)
> +{
> +}
> +
> +static void xen_9pfs_disconnect(struct XenDevice *xendev)
> +{
> +}
> +
> +struct XenDevOps xen_9pfs_ops = {
> + .size = sizeof(struct Xen9pfsDev),
... s/struct //
> + .flags = DEVOPS_FLAG_NEED_GNTDEV,
> + .alloc = xen_9pfs_alloc,
> + .init = xen_9pfs_init,
> + .initialise = xen_9pfs_connect,
> + .disconnect = xen_9pfs_disconnect,
> + .free = xen_9pfs_free,
> +};
With the above comments addressed:
Reviewed-by: Greg Kurz <groug@kaod.org>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend
2017-03-09 17:54 ` Greg Kurz
@ 2017-03-10 9:48 ` Greg Kurz
2017-03-13 23:26 ` Stefano Stabellini
0 siblings, 1 reply; 13+ messages in thread
From: Greg Kurz @ 2017-03-10 9:48 UTC (permalink / raw)
To: Stefano Stabellini
Cc: qemu-devel, xen-devel, Stefano Stabellini, anthony.perard, jgross,
Aneesh Kumar K.V
[-- Attachment #1: Type: text/plain, Size: 5239 bytes --]
On Thu, 9 Mar 2017 18:54:26 +0100
Greg Kurz <groug@kaod.org> wrote:
> On Mon, 6 Mar 2017 18:12:43 -0800
> Stefano Stabellini <sstabellini@kernel.org> wrote:
>
> > Introduce the Xen 9pfs backend: add struct XenDevOps to register as a
> > Xen backend and add struct V9fsTransport to register as v9fs transport.
> >
> > All functions are empty stubs for now.
> >
> > Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> > CC: anthony.perard@citrix.com
> > CC: jgross@suse.com
> > CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> > CC: Greg Kurz <groug@kaod.org>
> > ---
> > hw/9pfs/xen-9p-backend.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 96 insertions(+)
> > create mode 100644 hw/9pfs/xen-9p-backend.c
> >
> > diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> > new file mode 100644
> > index 0000000..924fb64
> > --- /dev/null
> > +++ b/hw/9pfs/xen-9p-backend.c
> > @@ -0,0 +1,96 @@
> > +/*
> > + * Xen 9p backend
> > + *
> > + * Copyright Aporeto 2017
> > + *
> > + * Authors:
> > + * Stefano Stabellini <stefano@aporeto.com>
> > + *
> > + */
> > +
> > +#include "qemu/osdep.h"
> > +
> > +#include "hw/hw.h"
> > +#include "hw/9pfs/9p.h"
> > +#include "hw/xen/xen_backend.h"
> > +#include "xen_9pfs.h"
> > +#include "qemu/config-file.h"
> > +#include "fsdev/qemu-fsdev.h"
> > +
> > +struct Xen9pfsDev {
> > + struct XenDevice xendev; /* must be first */
> > +};
>
> According to HACKING, this should be:
>
> typedef struct Xen9pfsDev {
> struct XenDevice xendev; /* must be first */
> } Xen9pfsDev;
>
> and...
>
> > +
> > +static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
> > + size_t offset,
> > + const char *fmt,
> > + va_list ap)
> > +{
> > + return 0;
> > +}
> > +
> > +static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
> > + size_t offset,
> > + const char *fmt,
> > + va_list ap)
> > +{
> > + return 0;
> > +}
> > +
> > +static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
> > + struct iovec **piov,
> > + unsigned int *pniov)
> > +{
> > +}
> > +
> > +static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
> > + struct iovec **piov,
> > + unsigned int *pniov,
> > + size_t size)
> > +{
> > +}
> > +
> > +static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
> > +{
> > +}
> > +
> > +static const struct V9fsTransport xen_9p_transport = {
> > + .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
> > + .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
> > + .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
> > + .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
> > + .push_and_notify = xen_9pfs_push_and_notify,
> > +};
> > +
> > +static int xen_9pfs_init(struct XenDevice *xendev)
> > +{
> > + return 0;
> > +}
> > +
> > +static int xen_9pfs_free(struct XenDevice *xendev)
> > +{
> > + return -1;
> > +}
> > +
> > +static int xen_9pfs_connect(struct XenDevice *xendev)
> > +{
> > + return 0;
> > +}
> > +
> > +static void xen_9pfs_alloc(struct XenDevice *xendev)
> > +{
> > +}
> > +
> > +static void xen_9pfs_disconnect(struct XenDevice *xendev)
> > +{
> > +}
> > +
> > +struct XenDevOps xen_9pfs_ops = {
> > + .size = sizeof(struct Xen9pfsDev),
>
> ... s/struct //
>
> > + .flags = DEVOPS_FLAG_NEED_GNTDEV,
> > + .alloc = xen_9pfs_alloc,
> > + .init = xen_9pfs_init,
> > + .initialise = xen_9pfs_connect,
> > + .disconnect = xen_9pfs_disconnect,
> > + .free = xen_9pfs_free,
> > +};
>
> With the above comments addressed:
>
> Reviewed-by: Greg Kurz <groug@kaod.org>
Hmm... there's still a problem actually. This patch breaks build for some
targets with '--enable-xen --enable-virtfs':
LINK cris-softmmu/qemu-system-cris
../hw/xen/xen_backend.o: In function `xen_be_register_common':
/home/greg/Work/qemu/qemu-9p/hw/xen/xen_backend.c:588: undefined reference to `xen_9pfs_ops'
This happens because only targets that support virtio and PCI pull the
9pfs/fsdev object files. This is an effort to have smaller QEMU binaries,
based on the historical dependency of 9pfs on virtio. This patch breaks
this assumption if CONFIG_XEN_BACKEND is defined but the target doesn't
define CONFIG_VIRTIO and CONFIG_PCI.
Since 9pfs can now be used with another transport, I guess that the
dependency on virtio and PCI isn't right anymore. The new condition
for targets to support 9pfs should rather be something like:
CONFIG_VIRTFS == y && CONFIG_SOFTMMU == y && (CONFIG_VIRTIO == y || CONFIG_XEN_BACKEND == y)
This would cause all targets to pull the 9pfs/fsdev object files though.
So I have a question: do all targets need to support the Xen backend, really ?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend
2017-03-10 9:48 ` Greg Kurz
@ 2017-03-13 23:26 ` Stefano Stabellini
0 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-13 23:26 UTC (permalink / raw)
To: Greg Kurz
Cc: Stefano Stabellini, jgross, qemu-devel, Stefano Stabellini,
Aneesh Kumar K.V, anthony.perard, xen-devel
On Fri, 10 Mar 2017, Greg Kurz wrote:
> On Thu, 9 Mar 2017 18:54:26 +0100
> Greg Kurz <groug@kaod.org> wrote:
>
> > On Mon, 6 Mar 2017 18:12:43 -0800
> > Stefano Stabellini <sstabellini@kernel.org> wrote:
> >
> > > Introduce the Xen 9pfs backend: add struct XenDevOps to register as a
> > > Xen backend and add struct V9fsTransport to register as v9fs transport.
> > >
> > > All functions are empty stubs for now.
> > >
> > > Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> > > CC: anthony.perard@citrix.com
> > > CC: jgross@suse.com
> > > CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> > > CC: Greg Kurz <groug@kaod.org>
> > > ---
> > > hw/9pfs/xen-9p-backend.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 96 insertions(+)
> > > create mode 100644 hw/9pfs/xen-9p-backend.c
> > >
> > > diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> > > new file mode 100644
> > > index 0000000..924fb64
> > > --- /dev/null
> > > +++ b/hw/9pfs/xen-9p-backend.c
> > > @@ -0,0 +1,96 @@
> > > +/*
> > > + * Xen 9p backend
> > > + *
> > > + * Copyright Aporeto 2017
> > > + *
> > > + * Authors:
> > > + * Stefano Stabellini <stefano@aporeto.com>
> > > + *
> > > + */
> > > +
> > > +#include "qemu/osdep.h"
> > > +
> > > +#include "hw/hw.h"
> > > +#include "hw/9pfs/9p.h"
> > > +#include "hw/xen/xen_backend.h"
> > > +#include "xen_9pfs.h"
> > > +#include "qemu/config-file.h"
> > > +#include "fsdev/qemu-fsdev.h"
> > > +
> > > +struct Xen9pfsDev {
> > > + struct XenDevice xendev; /* must be first */
> > > +};
> >
> > According to HACKING, this should be:
> >
> > typedef struct Xen9pfsDev {
> > struct XenDevice xendev; /* must be first */
> > } Xen9pfsDev;
> >
> > and...
> >
> > > +
> > > +static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
> > > + size_t offset,
> > > + const char *fmt,
> > > + va_list ap)
> > > +{
> > > + return 0;
> > > +}
> > > +
> > > +static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
> > > + size_t offset,
> > > + const char *fmt,
> > > + va_list ap)
> > > +{
> > > + return 0;
> > > +}
> > > +
> > > +static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
> > > + struct iovec **piov,
> > > + unsigned int *pniov)
> > > +{
> > > +}
> > > +
> > > +static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
> > > + struct iovec **piov,
> > > + unsigned int *pniov,
> > > + size_t size)
> > > +{
> > > +}
> > > +
> > > +static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
> > > +{
> > > +}
> > > +
> > > +static const struct V9fsTransport xen_9p_transport = {
> > > + .pdu_vmarshal = xen_9pfs_pdu_vmarshal,
> > > + .pdu_vunmarshal = xen_9pfs_pdu_vunmarshal,
> > > + .init_in_iov_from_pdu = xen_9pfs_init_in_iov_from_pdu,
> > > + .init_out_iov_from_pdu = xen_9pfs_init_out_iov_from_pdu,
> > > + .push_and_notify = xen_9pfs_push_and_notify,
> > > +};
> > > +
> > > +static int xen_9pfs_init(struct XenDevice *xendev)
> > > +{
> > > + return 0;
> > > +}
> > > +
> > > +static int xen_9pfs_free(struct XenDevice *xendev)
> > > +{
> > > + return -1;
> > > +}
> > > +
> > > +static int xen_9pfs_connect(struct XenDevice *xendev)
> > > +{
> > > + return 0;
> > > +}
> > > +
> > > +static void xen_9pfs_alloc(struct XenDevice *xendev)
> > > +{
> > > +}
> > > +
> > > +static void xen_9pfs_disconnect(struct XenDevice *xendev)
> > > +{
> > > +}
> > > +
> > > +struct XenDevOps xen_9pfs_ops = {
> > > + .size = sizeof(struct Xen9pfsDev),
> >
> > ... s/struct //
> >
> > > + .flags = DEVOPS_FLAG_NEED_GNTDEV,
> > > + .alloc = xen_9pfs_alloc,
> > > + .init = xen_9pfs_init,
> > > + .initialise = xen_9pfs_connect,
> > > + .disconnect = xen_9pfs_disconnect,
> > > + .free = xen_9pfs_free,
> > > +};
> >
> > With the above comments addressed:
> >
> > Reviewed-by: Greg Kurz <groug@kaod.org>
Thank you for the quick review and useful comments. I'll address them in
the next version of the series.
> Hmm... there's still a problem actually. This patch breaks build for some
> targets with '--enable-xen --enable-virtfs':
>
> LINK cris-softmmu/qemu-system-cris
> ../hw/xen/xen_backend.o: In function `xen_be_register_common':
> /home/greg/Work/qemu/qemu-9p/hw/xen/xen_backend.c:588: undefined reference to `xen_9pfs_ops'
I could reproduce the problem
> This happens because only targets that support virtio and PCI pull the
> 9pfs/fsdev object files. This is an effort to have smaller QEMU binaries,
> based on the historical dependency of 9pfs on virtio. This patch breaks
> this assumption if CONFIG_XEN_BACKEND is defined but the target doesn't
> define CONFIG_VIRTIO and CONFIG_PCI.
>
> Since 9pfs can now be used with another transport, I guess that the
> dependency on virtio and PCI isn't right anymore. The new condition
> for targets to support 9pfs should rather be something like:
>
> CONFIG_VIRTFS == y && CONFIG_SOFTMMU == y && (CONFIG_VIRTIO == y || CONFIG_XEN_BACKEND == y)
>
> This would cause all targets to pull the 9pfs/fsdev object files though.
>
> So I have a question: do all targets need to support the Xen backend, really ?
Not really: Xen is only supported on x86 and ARM platforms today.
Typically, Xen is only enabled in QEMU for i386 or x86_64 softmmu
targets, even when used in an ARM context (long story short: the Xen PV
machine is arch-agnostic, but the QEMU build doesn't support that, so we
tied it to x86 just because we had to pick one).
In fact, I think the issue is that CONFIG_XEN_BACKEND is set wrongly by
the configure script. It's not an host property, but a target property
like CONFIG_XEN. We need:
diff --git a/configure b/configure
index 6c21975..6d8f752 100755
--- a/configure
+++ b/configure
@@ -5442,7 +5442,6 @@ if test "$virglrenderer" = "yes" ; then
echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
fi
if test "$xen" = "yes" ; then
- echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
if test "$xen_pv_domain_build" = "yes" ; then
echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
@@ -6028,6 +6027,7 @@ case "$target_name" in
i386|x86_64)
if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
echo "CONFIG_XEN=y" >> $config_target_mak
+ echo "CONFIG_XEN_BACKEND=y" >> $config_target_mak
if test "$xen_pci_passthrough" = yes; then
echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
fi
With this change, and the other change you suggested:
common-obj-$(CONFIG_XEN_BACKEND) += xen-9p-backend.o
I couldn't see any build issues.
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 4/8] xen/9pfs: connect to the frontend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 2/8] xen: introduce the header file for the Xen 9pfs transport protocol Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 3/8] xen/9pfs: introduce Xen 9pfs backend Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 5/8] xen/9pfs: receive requests from " Stefano Stabellini
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross, Aneesh Kumar K.V, Greg Kurz
Write the limits of the backend to xenstore. Connect to the frontend.
Upon connection, allocate the rings according to the protocol
specification.
Initialize a QEMUBH to schedule work upon receiving an event channel
notification from the frontend.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
hw/9pfs/xen-9p-backend.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 158 insertions(+), 1 deletion(-)
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index 924fb64..59e89fd 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -17,8 +17,35 @@
#include "qemu/config-file.h"
#include "fsdev/qemu-fsdev.h"
+#define VERSIONS "1"
+#define MAX_RINGS 8
+#define MAX_RING_ORDER 8
+
+struct Xen9pfsRing {
+ struct Xen9pfsDev *priv;
+
+ int ref;
+ xenevtchn_handle *evtchndev;
+ int evtchn;
+ int local_port;
+ struct xen_9pfs_data_intf *intf;
+ unsigned char *data;
+ struct xen_9pfs_data ring;
+
+ QEMUBH *bh;
+
+ /* local copies, so that we can read/write PDU data directly from
+ * the ring */
+ RING_IDX out_cons, out_size, in_cons;
+ bool inprogress;
+};
+
struct Xen9pfsDev {
struct XenDevice xendev; /* must be first */
+ V9fsState state;
+
+ int num_rings;
+ struct Xen9pfsRing *rings;
};
static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
@@ -67,22 +94,152 @@ static int xen_9pfs_init(struct XenDevice *xendev)
return 0;
}
+static void xen_9pfs_bh(void *opaque)
+{
+}
+
+static void xen_9pfs_evtchn_event(void *opaque)
+{
+}
+
static int xen_9pfs_free(struct XenDevice *xendev)
{
- return -1;
+ int i;
+ struct Xen9pfsDev *xen_9pdev = container_of(xendev, struct Xen9pfsDev, xendev);
+
+ for (i = 0; i < xen_9pdev->num_rings; i++) {
+ if (xen_9pdev->rings[i].data != NULL) {
+ xengnttab_unmap(xen_9pdev->xendev.gnttabdev,
+ xen_9pdev->rings[i].data,
+ (1 << XEN_9PFS_RING_ORDER));
+ }
+ if (xen_9pdev->rings[i].intf != NULL) {
+ xengnttab_unmap(xen_9pdev->xendev.gnttabdev,
+ xen_9pdev->rings[i].intf,
+ 1);
+ }
+ if (xen_9pdev->rings[i].evtchndev > 0) {
+ qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
+ NULL, NULL, NULL);
+ xenevtchn_unbind(xen_9pdev->rings[i].evtchndev, xen_9pdev->rings[i].local_port);
+ }
+ if (xen_9pdev->rings[i].bh != NULL) {
+ qemu_bh_delete(xen_9pdev->rings[i].bh);
+ }
+ }
+ g_free(xen_9pdev->rings);
+ return 0;
}
static int xen_9pfs_connect(struct XenDevice *xendev)
{
+ int i;
+ struct Xen9pfsDev *xen_9pdev = container_of(xendev, struct Xen9pfsDev, xendev);
+ V9fsState *s = &xen_9pdev->state;
+ QemuOpts *fsdev;
+ char *security_model, *path;
+
+ if (xenstore_read_fe_int(&xen_9pdev->xendev, "num-rings",
+ &xen_9pdev->num_rings) == -1 ||
+ xen_9pdev->num_rings > MAX_RINGS) {
+ return -1;
+ }
+
+ xen_9pdev->rings = g_malloc0(xen_9pdev->num_rings * sizeof(struct Xen9pfsRing));
+ for (i = 0; i < xen_9pdev->num_rings; i++) {
+ char str[16];
+
+ xen_9pdev->rings[i].priv = xen_9pdev;
+ xen_9pdev->rings[i].evtchn = -1;
+ xen_9pdev->rings[i].local_port = -1;
+
+ sprintf(str, "ring-ref%u", i);
+ if (xenstore_read_fe_int(&xen_9pdev->xendev, str,
+ &xen_9pdev->rings[i].ref) == -1) {
+ goto out;
+ }
+ sprintf(str, "event-channel-%u", i);
+ if (xenstore_read_fe_int(&xen_9pdev->xendev, str,
+ &xen_9pdev->rings[i].evtchn) == -1) {
+ goto out;
+ }
+
+ xen_9pdev->rings[i].intf = xengnttab_map_grant_ref(
+ xen_9pdev->xendev.gnttabdev,
+ xen_9pdev->xendev.dom,
+ xen_9pdev->rings[i].ref,
+ PROT_READ | PROT_WRITE);
+ if (!xen_9pdev->rings[i].intf) {
+ goto out;
+ }
+ xen_9pdev->rings[i].data = xengnttab_map_domain_grant_refs(
+ xen_9pdev->xendev.gnttabdev,
+ (1 << XEN_9PFS_RING_ORDER),
+ xen_9pdev->xendev.dom,
+ xen_9pdev->rings[i].intf->ref,
+ PROT_READ | PROT_WRITE);
+ if (!xen_9pdev->rings[i].data) {
+ goto out;
+ }
+ xen_9pdev->rings[i].ring.in = xen_9pdev->rings[i].data;
+ xen_9pdev->rings[i].ring.out = xen_9pdev->rings[i].data + XEN_9PFS_RING_SIZE;
+
+ xen_9pdev->rings[i].bh = qemu_bh_new(xen_9pfs_bh, &xen_9pdev->rings[i]);
+ xen_9pdev->rings[i].out_cons = 0;
+ xen_9pdev->rings[i].out_size = 0;
+ xen_9pdev->rings[i].inprogress = false;
+
+
+ xen_9pdev->rings[i].evtchndev = xenevtchn_open(NULL, 0);
+ if (xen_9pdev->rings[i].evtchndev == NULL) {
+ goto out;
+ }
+ fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev), F_SETFD, FD_CLOEXEC);
+ xen_9pdev->rings[i].local_port = xenevtchn_bind_interdomain
+ (xen_9pdev->rings[i].evtchndev, xendev->dom, xen_9pdev->rings[i].evtchn);
+ if (xen_9pdev->rings[i].local_port == -1) {
+ xen_pv_printf(xendev, 0, "xenevtchn_bind_interdomain failed port=%d\n",
+ xen_9pdev->rings[i].evtchn);
+ goto out;
+ }
+ xen_pv_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
+ qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
+ xen_9pfs_evtchn_event, NULL, &xen_9pdev->rings[i]);
+ }
+
+ security_model = xenstore_read_be_str(xendev, "security_model");
+ path = xenstore_read_be_str(xendev, "path");
+ s->fsconf.fsdev_id = g_malloc(strlen("xen9p") + 6);
+ sprintf(s->fsconf.fsdev_id, "xen9p%d", xendev->dev);
+ s->fsconf.tag = xenstore_read_fe_str(xendev, "tag");
+ v9fs_register_transport(s, &xen_9p_transport);
+ fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
+ s->fsconf.tag,
+ 1, NULL);
+ qemu_opt_set(fsdev, "fsdriver", "local", NULL);
+ qemu_opt_set(fsdev, "path", path, NULL);
+ qemu_opt_set(fsdev, "security_model", security_model, NULL);
+ qemu_opts_set_id(fsdev, s->fsconf.fsdev_id);
+ qemu_fsdev_add(fsdev);
+ v9fs_device_realize_common(s, NULL);
+
return 0;
+
+out:
+ xen_9pfs_free(xendev);
+ return -1;
}
static void xen_9pfs_alloc(struct XenDevice *xendev)
{
+ xenstore_write_be_str(xendev, "versions", VERSIONS);
+ xenstore_write_be_int(xendev, "max-rings", MAX_RINGS);
+ xenstore_write_be_int(xendev, "max-ring-page-order", MAX_RING_ORDER);
}
static void xen_9pfs_disconnect(struct XenDevice *xendev)
{
+ /* Dynamic hotplug of PV filesystems at runtime is not supported. */
}
struct XenDevOps xen_9pfs_ops = {
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 5/8] xen/9pfs: receive requests from the frontend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
` (2 preceding siblings ...)
2017-03-07 2:12 ` [Qemu-devel] [PATCH 4/8] xen/9pfs: connect to the frontend Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 6/8] xen/9pfs: implement in/out_iov_from_pdu and vmarshal/vunmarshal Stefano Stabellini
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross, Aneesh Kumar K.V, Greg Kurz
Upon receiving an event channel notification from the frontend, schedule
the bottom half. From the bottom half, read one request from the ring,
create a pdu and call pdu_submit to handle it.
For now, only handle one request per ring at a time.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
hw/9pfs/xen-9p-backend.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index 59e89fd..d4c3d36 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -94,12 +94,59 @@ static int xen_9pfs_init(struct XenDevice *xendev)
return 0;
}
+static int xen_9pfs_receive(struct Xen9pfsRing *ring)
+{
+ struct xen_9pfs_header h;
+ RING_IDX cons, prod, masked_prod, masked_cons;
+ V9fsPDU *pdu;
+
+ if (ring->inprogress) {
+ return 0;
+ }
+
+ cons = ring->intf->out_cons;
+ prod = ring->intf->out_prod;
+ xen_rmb();
+
+ if (xen_9pfs_queued(prod, cons, XEN_9PFS_RING_SIZE) < sizeof(h)) {
+ return 0;
+ }
+ ring->inprogress = true;
+
+ masked_prod = xen_9pfs_mask(prod, XEN_9PFS_RING_SIZE);
+ masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE);
+
+ xen_9pfs_read_packet(ring->ring.out, masked_prod, &masked_cons,
+ XEN_9PFS_RING_SIZE, (uint8_t*) &h, sizeof(h));
+
+ pdu = pdu_alloc(&ring->priv->state);
+ pdu->size = h.size;
+ pdu->id = h.id;
+ pdu->tag = h.tag;
+ ring->out_size = h.size;
+ ring->out_cons = cons + h.size;
+
+ qemu_co_queue_init(&pdu->complete);
+ pdu_submit(pdu);
+
+ return 0;
+}
+
static void xen_9pfs_bh(void *opaque)
{
+ struct Xen9pfsRing *ring = opaque;
+ xen_9pfs_receive(ring);
}
static void xen_9pfs_evtchn_event(void *opaque)
{
+ struct Xen9pfsRing *ring = opaque;
+ evtchn_port_t port;
+
+ port = xenevtchn_pending(ring->evtchndev);
+ xenevtchn_unmask(ring->evtchndev, port);
+
+ qemu_bh_schedule(ring->bh);
}
static int xen_9pfs_free(struct XenDevice *xendev)
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 6/8] xen/9pfs: implement in/out_iov_from_pdu and vmarshal/vunmarshal
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
` (3 preceding siblings ...)
2017-03-07 2:12 ` [Qemu-devel] [PATCH 5/8] xen/9pfs: receive requests from " Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 7/8] xen/9pfs: send responses back to the frontend Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 8/8] xen/9pfs: build and register Xen 9pfs backend Stefano Stabellini
6 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross, Aneesh Kumar K.V, Greg Kurz
Implement xen_9pfs_init_in/out_iov_from_pdu and
xen_9pfs_pdu_vmarshal/vunmarshall by creating new sg pointing to the
data on the ring.
This is safe as we only handle one request per ring at any given time.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
hw/9pfs/xen-9p-backend.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 2 deletions(-)
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index d4c3d36..0570e07 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -48,12 +48,77 @@ struct Xen9pfsDev {
struct Xen9pfsRing *rings;
};
+static void xen_9pfs_in_sg(struct Xen9pfsRing *ring,
+ struct iovec *in_sg,
+ int *num,
+ uint32_t idx,
+ uint32_t size)
+{
+ RING_IDX cons, prod, masked_prod, masked_cons;
+
+ cons = ring->intf->in_cons;
+ prod = ring->intf->in_prod;
+ xen_rmb();
+ masked_prod = xen_9pfs_mask(prod, XEN_9PFS_RING_SIZE);
+ masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE);
+
+ if (masked_prod < masked_cons) {
+ in_sg[0].iov_base = ring->ring.in + masked_prod;
+ in_sg[0].iov_len = masked_cons - masked_prod;
+ *num = 1;
+ } else {
+ in_sg[0].iov_base = ring->ring.in + masked_prod;
+ in_sg[0].iov_len = XEN_9PFS_RING_SIZE - masked_prod;
+ in_sg[1].iov_base = ring->ring.in;
+ in_sg[1].iov_len = masked_cons;
+ *num = 2;
+ }
+}
+
+static void xen_9pfs_out_sg(struct Xen9pfsRing *ring,
+ struct iovec *out_sg,
+ int *num,
+ uint32_t idx)
+{
+ RING_IDX cons, prod, masked_prod, masked_cons;
+
+ cons = ring->intf->out_cons;
+ prod = ring->intf->out_prod;
+ xen_rmb();
+ masked_prod = xen_9pfs_mask(prod, XEN_9PFS_RING_SIZE);
+ masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE);
+
+ if (masked_cons < masked_prod) {
+ out_sg[0].iov_base = ring->ring.out + masked_cons;
+ out_sg[0].iov_len = ring->out_size;
+ *num = 1;
+ } else {
+ if (ring->out_size > (XEN_9PFS_RING_SIZE - masked_cons)) {
+ out_sg[0].iov_base = ring->ring.out + masked_cons;
+ out_sg[0].iov_len = XEN_9PFS_RING_SIZE - masked_cons;
+ out_sg[1].iov_base = ring->ring.out;
+ out_sg[1].iov_len = ring->out_size - (XEN_9PFS_RING_SIZE - masked_cons);
+ *num = 2;
+ } else {
+ out_sg[0].iov_base = ring->ring.out + masked_cons;
+ out_sg[0].iov_len = ring->out_size;
+ *num = 1;
+ }
+ }
+}
+
static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu,
size_t offset,
const char *fmt,
va_list ap)
{
- return 0;
+ struct Xen9pfsDev *xen_9pfs = container_of(pdu->s, struct Xen9pfsDev, state);
+ struct iovec in_sg[2];
+ int num;
+
+ xen_9pfs_in_sg(&xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings],
+ in_sg, &num, pdu->idx, ROUND_UP(offset + 128, 512));
+ return v9fs_iov_vmarshal(in_sg, num, offset, 0, fmt, ap);
}
static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
@@ -61,13 +126,27 @@ static ssize_t xen_9pfs_pdu_vunmarshal(V9fsPDU *pdu,
const char *fmt,
va_list ap)
{
- return 0;
+ struct Xen9pfsDev *xen_9pfs = container_of(pdu->s, struct Xen9pfsDev, state);
+ struct iovec out_sg[2];
+ int num;
+
+ xen_9pfs_out_sg(&xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings],
+ out_sg, &num, pdu->idx);
+ return v9fs_iov_vunmarshal(out_sg, num, offset, 0, fmt, ap);
}
static void xen_9pfs_init_out_iov_from_pdu(V9fsPDU *pdu,
struct iovec **piov,
unsigned int *pniov)
{
+ struct Xen9pfsDev *xen_9pfs = container_of(pdu->s, struct Xen9pfsDev, state);
+ struct Xen9pfsRing *ring = &xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings];
+ struct iovec *sg = g_malloc0(sizeof(*sg)*2);
+ int num;
+
+ xen_9pfs_out_sg(ring, sg, &num, pdu->idx);
+ *piov = sg;
+ *pniov = num;
}
static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
@@ -75,6 +154,14 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
unsigned int *pniov,
size_t size)
{
+ struct Xen9pfsDev *xen_9pfs = container_of(pdu->s, struct Xen9pfsDev, state);
+ struct Xen9pfsRing *ring = &xen_9pfs->rings[pdu->tag % xen_9pfs->num_rings];
+ struct iovec *sg = g_malloc0(sizeof(*sg)*2);
+ int num;
+
+ xen_9pfs_in_sg(ring, sg, &num, pdu->idx, size);
+ *piov = sg;
+ *pniov = num;
}
static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 7/8] xen/9pfs: send responses back to the frontend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
` (4 preceding siblings ...)
2017-03-07 2:12 ` [Qemu-devel] [PATCH 6/8] xen/9pfs: implement in/out_iov_from_pdu and vmarshal/vunmarshal Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-07 2:12 ` [Qemu-devel] [PATCH 8/8] xen/9pfs: build and register Xen 9pfs backend Stefano Stabellini
6 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross, Aneesh Kumar K.V, Greg Kurz
Once a request is completed, xen_9pfs_push_and_notify gets called. In
xen_9pfs_push_and_notify, update the indexes (data has already been
copied to the sg by the common code) and send a notification to the
frontend.
Schedule the bottom-half to check if we already have any other requests
pending.
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
hw/9pfs/xen-9p-backend.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index 0570e07..80a8810 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -166,6 +166,22 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu,
static void xen_9pfs_push_and_notify(V9fsPDU *pdu)
{
+ RING_IDX prod;
+ struct Xen9pfsDev *priv = container_of(pdu->s, struct Xen9pfsDev, state);
+ struct Xen9pfsRing *ring = &priv->rings[pdu->tag % priv->num_rings];
+
+ ring->intf->out_cons = ring->out_cons;
+ xen_wmb();
+
+ prod = ring->intf->in_prod;
+ xen_rmb();
+ ring->intf->in_prod = prod + pdu->size;
+ xen_wmb();
+
+ ring->inprogress = false;
+ xenevtchn_notify(ring->evtchndev, ring->local_port);
+
+ qemu_bh_schedule(ring->bh);
}
static const struct V9fsTransport xen_9p_transport = {
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 8/8] xen/9pfs: build and register Xen 9pfs backend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 1/8] xen: import ring.h from xen Stefano Stabellini
` (5 preceding siblings ...)
2017-03-07 2:12 ` [Qemu-devel] [PATCH 7/8] xen/9pfs: send responses back to the frontend Stefano Stabellini
@ 2017-03-07 2:12 ` Stefano Stabellini
2017-03-09 17:52 ` Greg Kurz
6 siblings, 1 reply; 13+ messages in thread
From: Stefano Stabellini @ 2017-03-07 2:12 UTC (permalink / raw)
To: qemu-devel
Cc: xen-devel, sstabellini, Stefano Stabellini, anthony.perard,
jgross, Aneesh Kumar K.V, Greg Kurz
Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
CC: anthony.perard@citrix.com
CC: jgross@suse.com
CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
CC: Greg Kurz <groug@kaod.org>
---
hw/9pfs/Makefile.objs | 1 +
hw/xen/xen_backend.c | 1 +
include/hw/xen/xen_backend.h | 1 +
3 files changed, 3 insertions(+)
diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs
index da0ae0c..76a81c3 100644
--- a/hw/9pfs/Makefile.objs
+++ b/hw/9pfs/Makefile.objs
@@ -7,3 +7,4 @@ common-obj-$(CONFIG_OPEN_BY_HANDLE) += 9p-handle.o
common-obj-y += 9p-proxy.o
obj-y += virtio-9p-device.o
+obj-y += xen-9p-backend.o
diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 6c21c37..7aa347d 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -585,6 +585,7 @@ void xen_be_register_common(void)
xen_be_register("console", &xen_console_ops);
xen_be_register("vkbd", &xen_kbdmouse_ops);
xen_be_register("qdisk", &xen_blkdev_ops);
+ xen_be_register("9pfs", &xen_9pfs_ops);
#ifdef CONFIG_USB_LIBUSB
xen_be_register("qusb", &xen_usb_ops);
#endif
diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
index 4f4799a..84e686c 100644
--- a/include/hw/xen/xen_backend.h
+++ b/include/hw/xen/xen_backend.h
@@ -49,6 +49,7 @@ extern struct XenDevOps xen_console_ops; /* xen_console.c */
extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
+extern struct XenDevOps xen_9pfs_ops; /* xen-9p-backend.c */
extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
#ifdef CONFIG_USB_LIBUSB
extern struct XenDevOps xen_usb_ops; /* xen-usb.c */
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH 8/8] xen/9pfs: build and register Xen 9pfs backend
2017-03-07 2:12 ` [Qemu-devel] [PATCH 8/8] xen/9pfs: build and register Xen 9pfs backend Stefano Stabellini
@ 2017-03-09 17:52 ` Greg Kurz
0 siblings, 0 replies; 13+ messages in thread
From: Greg Kurz @ 2017-03-09 17:52 UTC (permalink / raw)
To: Stefano Stabellini
Cc: qemu-devel, jgross, Stefano Stabellini, Aneesh Kumar K.V,
anthony.perard, xen-devel
[-- Attachment #1: Type: text/plain, Size: 2383 bytes --]
On Mon, 6 Mar 2017 18:12:48 -0800
Stefano Stabellini <sstabellini@kernel.org> wrote:
> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
> CC: anthony.perard@citrix.com
> CC: jgross@suse.com
> CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> CC: Greg Kurz <groug@kaod.org>
> ---
> hw/9pfs/Makefile.objs | 1 +
> hw/xen/xen_backend.c | 1 +
> include/hw/xen/xen_backend.h | 1 +
> 3 files changed, 3 insertions(+)
>
> diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs
> index da0ae0c..76a81c3 100644
> --- a/hw/9pfs/Makefile.objs
> +++ b/hw/9pfs/Makefile.objs
> @@ -7,3 +7,4 @@ common-obj-$(CONFIG_OPEN_BY_HANDLE) += 9p-handle.o
> common-obj-y += 9p-proxy.o
>
> obj-y += virtio-9p-device.o
> +obj-y += xen-9p-backend.o
The xen-9p-backend.c file seems to be target agnostic: it can be built
only once. Also, it should only be built if QEMU was configured with
Xen support. Hence:
obj-common-$(CONFIG_XEN_BACKEND) += xen-9p-backend.o
> diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
> index 6c21c37..7aa347d 100644
> --- a/hw/xen/xen_backend.c
> +++ b/hw/xen/xen_backend.c
> @@ -585,6 +585,7 @@ void xen_be_register_common(void)
> xen_be_register("console", &xen_console_ops);
> xen_be_register("vkbd", &xen_kbdmouse_ops);
> xen_be_register("qdisk", &xen_blkdev_ops);
#ifdef CONFIG_VIRTFS
> + xen_be_register("9pfs", &xen_9pfs_ops);
#endif
> #ifdef CONFIG_USB_LIBUSB
> xen_be_register("qusb", &xen_usb_ops);
> #endif
> diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
> index 4f4799a..84e686c 100644
> --- a/include/hw/xen/xen_backend.h
> +++ b/include/hw/xen/xen_backend.h
> @@ -49,6 +49,7 @@ extern struct XenDevOps xen_console_ops; /* xen_console.c */
> extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
> extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
> extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
> +extern struct XenDevOps xen_9pfs_ops; /* xen-9p-backend.c */
ditto
> extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
> #ifdef CONFIG_USB_LIBUSB
> extern struct XenDevOps xen_usb_ops; /* xen-usb.c */
With the above fixes.
Reviewed-by: Greg Kurz <groug@kaod.org>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread