* [Qemu-devel] virtio-9p
@ 2015-08-07 16:21 Linda
2015-08-10 10:10 ` Stefan Hajnoczi
0 siblings, 1 reply; 9+ messages in thread
From: Linda @ 2015-08-07 16:21 UTC (permalink / raw)
To: qemu-devel, Julien Grall, Wei Liu
Hello,
I am a summer intern under the Outreachy program (returning to
software development after a long hiatus). I am developing a prototype
of a xen front/back end for a 9p file transport.
Since virtio is the most complete, and used, transport, I am using
that as a model.
I am encountering some problems that, to fix sanely, will require
making changes to virtio code. On the plus side, when I'm finished with
this project, any transport will be able to use the 9P server, with no
modification.
As background, for the backend, I have been looking at the code,
written by Anthony Liguori, and maintained by Aneesh Kumar (who I sent
this email to, earlier). It looks to me (please correct me if I'm
wrong, on this or any other point, below) as if Anthony wrote not just a
backend transport layer, but the server as well. AFAICT, there is no
other Linux 9p server.
virtio-9p.c contains a lot of this server code, the rest spread
between 13 other files which handle all file access operations,
converting them from 9p to Linux file system calls.
virtio-9p.c also contains some virtio-specific code (although most
of that is in virtio-device.c).
The problems I am encountering are the following:
1. In the virio-9p.h is a struct V9fsPDU that contains an element (in
the middle of the struct) of type VirtQueueElement. Every 9p I/O command
handler, as well as co-routines and support functions that go with them
(i.e., a large part of the server), passes a parameter that is a struct
V9fsPDU. Almost all of these use only the variable that defines state
information, and never touch the VirtQueueElement member.
The easiest fix for this is to have a separate header file with a
#define GENERIC_9P_SERVER
Then I could modify the virtio-9p.h with:
#ifdef GENERIC_9P_SERVER
a union of a void *, a char * (what I use), and a
VirtQueueElement (guaranteeing the size is unchanged)
#else
VirtQueueElement elem;
#endif
It's not my favorite construct, but it would involve the least
amount of changes to the code. Before I modify a header file, that
code, I'm not touching, is dependent on, I wanted to know if this is an
OK way. If not, is there another way (short of copying fourteen files,
and changing the names of all the functions in them, as well as the file
names), that you would prefer?
2. The other problem, is that most of the "server" functions
described above, end by calling complete_pdu. Complete_pdu (which is
defined in virtio-9p.c) does many things that are generic, and also a
few virito specific operations (pushing to the virtqueue, etc.).
Again, I can use a similar mechanism to the above. Or is there
some other way you'd prefer? I'm trying to find a way that has the least
impact on virtio/qemu maintainers.
Thank you for your time, and any help/insights you can provide.
Sincerely,
Linda Jacobson
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] virtio-9p
2015-08-07 16:21 [Qemu-devel] virtio-9p Linda
@ 2015-08-10 10:10 ` Stefan Hajnoczi
2015-08-10 13:20 ` Linda
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Hajnoczi @ 2015-08-10 10:10 UTC (permalink / raw)
To: Linda; +Cc: Julien Grall, Wei Liu, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 3723 bytes --]
On Fri, Aug 07, 2015 at 10:21:47AM -0600, Linda wrote:
> As background, for the backend, I have been looking at the code, written
> by Anthony Liguori, and maintained by Aneesh Kumar (who I sent this email
> to, earlier). It looks to me (please correct me if I'm wrong, on this or
> any other point, below) as if Anthony wrote not just a backend transport
> layer, but the server as well. AFAICT, there is no other Linux 9p server.
There are other Linux 9P servers. At least there is diod:
https://github.com/chaos/diod
Anthony Liguori didn't write all of the virtio-9p code in QEMU. Aneesh
Kumar, JV Rao, M. Mohan Kumar, and Harsh Prateek Bora did a lot of the
9P server development in QEMU.
Take a look at git shortlog -nse hw/9pfs
> virtio-9p.c contains a lot of this server code, the rest spread between
> 13 other files which handle all file access operations, converting them from
> 9p to Linux file system calls.
> virtio-9p.c also contains some virtio-specific code (although most of
> that is in virtio-device.c).
>
> The problems I am encountering are the following:
>
> 1. In the virio-9p.h is a struct V9fsPDU that contains an element (in the
> middle of the struct) of type VirtQueueElement. Every 9p I/O command
> handler, as well as co-routines and support functions that go with them
> (i.e., a large part of the server), passes a parameter that is a struct
> V9fsPDU. Almost all of these use only the variable that defines state
> information, and never touch the VirtQueueElement member.
> The easiest fix for this is to have a separate header file with a
> #define GENERIC_9P_SERVER
> Then I could modify the virtio-9p.h with:
> #ifdef GENERIC_9P_SERVER
> a union of a void *, a char * (what I use), and a
> VirtQueueElement (guaranteeing the size is unchanged)
> #else
> VirtQueueElement elem;
> #endif
>
> It's not my favorite construct, but it would involve the least amount of
> changes to the code. Before I modify a header file, that code, I'm not
> touching, is dependent on, I wanted to know if this is an OK way. If not,
> is there another way (short of copying fourteen files, and changing the
> names of all the functions in them, as well as the file names), that you
> would prefer?
What is the goal of your project?
If you just want a Linux 9P server, use diod. You might be able to find
other servers that suit your needs better too (e.g. programming
language, features, etc).
An #ifdef is ugly and if you are going to submit code upstream then a
cleaner solution should be used. Either separate a VirtIO9fsPDU struct
that contains the generic 9pfsPDU as a field (so that container_of() can
be used to go from 9pfsPDU back to VirtIO9fsPDU). Or add a void* into
the generic 9pfsPDU so transports can correlate the generic struct with
a transport-specific struct.
> 2. The other problem, is that most of the "server" functions described
> above, end by calling complete_pdu. Complete_pdu (which is defined in
> virtio-9p.c) does many things that are generic, and also a few virito
> specific operations (pushing to the virtqueue, etc.).
> Again, I can use a similar mechanism to the above. Or is there some
> other way you'd prefer? I'm trying to find a way that has the least impact
> on virtio/qemu maintainers.
The generic PDU struct could have a .complete() function pointer. This
is how the SCSI subsystem works, for example. scsi_req_complete() calls
req->bus->info->complete(req, req->status, req->resid) so that the
bus-specific completion behavior is invoked.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] virtio-9p
2015-08-10 10:10 ` Stefan Hajnoczi
@ 2015-08-10 13:20 ` Linda
0 siblings, 0 replies; 9+ messages in thread
From: Linda @ 2015-08-10 13:20 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Julien Grall, Wei Liu, qemu-devel
On 8/10/2015 4:10 AM, Stefan Hajnoczi wrote:
> On Fri, Aug 07, 2015 at 10:21:47AM -0600, Linda wrote:
>> As background, for the backend, I have been looking at the code,
>> written
>> by Anthony Liguori, and maintained by Aneesh Kumar (who I sent this
>> email
>> to, earlier). It looks to me (please correct me if I'm wrong, on
>> this or
>> any other point, below) as if Anthony wrote not just a backend transport
>> layer, but the server as well. AFAICT, there is no other Linux 9p
>> server.
> There are other Linux 9P servers. At least there is diod:
> https://github.com/chaos/diod
Thank you. I will look into that.
> Anthony Liguori didn't write all of the virtio-9p code in QEMU. Aneesh
> Kumar, JV Rao, M. Mohan Kumar, and Harsh Prateek Bora did a lot of the
> 9P server development in QEMU.
>
> Take a look at git shortlog -nse hw/9pfs
>
>> virtio-9p.c contains a lot of this server code, the rest spread
>> between
>> 13 other files which handle all file access operations, converting
>> them from
>> 9p to Linux file system calls.
>> virtio-9p.c also contains some virtio-specific code (although
>> most of
>> that is in virtio-device.c).
>>
>> The problems I am encountering are the following:
>>
>> 1. In the virio-9p.h is a struct V9fsPDU that contains an element
>> (in the
>> middle of the struct) of type VirtQueueElement. Every 9p I/O command
>> handler, as well as co-routines and support functions that go with them
>> (i.e., a large part of the server), passes a parameter that is a struct
>> V9fsPDU. Almost all of these use only the variable that defines state
>> information, and never touch the VirtQueueElement member.
>> The easiest fix for this is to have a separate header file with a
>> #define GENERIC_9P_SERVER
>> Then I could modify the virtio-9p.h with:
>> #ifdef GENERIC_9P_SERVER
>> a union of a void *, a char * (what I use), and a
>> VirtQueueElement (guaranteeing the size is unchanged)
>> #else
>> VirtQueueElement elem;
>> #endif
>>
>> It's not my favorite construct, but it would involve the least
>> amount of
>> changes to the code. Before I modify a header file, that code, I'm not
>> touching, is dependent on, I wanted to know if this is an OK way. If
>> not,
>> is there another way (short of copying fourteen files, and changing the
>> names of all the functions in them, as well as the file names), that you
>> would prefer?
> What is the goal of your project?
>
> If you just want a Linux 9P server, use diod. You might be able to find
> other servers that suit your needs better too (e.g. programming
> language, features, etc).
>
> An #ifdef is ugly and if you are going to submit code upstream then a
> cleaner solution should be used. Either separate a VirtIO9fsPDU struct
> that contains the generic 9pfsPDU as a field (so that container_of() can
> be used to go from 9pfsPDU back to VirtIO9fsPDU). Or add a void* into
> the generic 9pfsPDU so transports can correlate the generic struct with
> a transport-specific struct.
I agree about ifdefs being ugly. I guess I was just trying to save
space - all I did was add a void * and a pointer to a function
>
>> 2. The other problem, is that most of the "server" functions
>> described
>> above, end by calling complete_pdu. Complete_pdu (which is defined in
>> virtio-9p.c) does many things that are generic, and also a few virito
>> specific operations (pushing to the virtqueue, etc.).
>> Again, I can use a similar mechanism to the above. Or is there
>> some
>> other way you'd prefer? I'm trying to find a way that has the least
>> impact
>> on virtio/qemu maintainers.
> The generic PDU struct could have a .complete() function pointer. This
> is how the SCSI subsystem works, for example. scsi_req_complete() calls
> req->bus->info->complete(req, req->status, req->resid) so that the
> bus-specific completion behavior is invoked.
It has a function pointer to a function complete that returns a pointer
to a Coroutine. But it uses (in dozens of places) a straight call to a
complete function.
I will look into diod. If there are any problems with it, I'll take
your suggestions above.
Thanks.
Linda
>
> Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Virtio-9p
@ 2016-03-30 12:10 Pradeep Kiruvale
2016-03-30 14:13 ` Greg Kurz
0 siblings, 1 reply; 9+ messages in thread
From: Pradeep Kiruvale @ 2016-03-30 12:10 UTC (permalink / raw)
To: qemu-discuss@nongnu.org, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
Hi All,
Is virtio-9p-pci device only supports the fsdev deices? I am trying to use
-drive option for applying QoS for block device using Virtio-9p-pci device,
but failing to create/add a device other than fsdev. Can you please help me
on this?
Regards,
Pradeep
[-- Attachment #2: Type: text/html, Size: 343 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Virtio-9p
2016-03-30 12:10 [Qemu-devel] Virtio-9p Pradeep Kiruvale
@ 2016-03-30 14:13 ` Greg Kurz
2016-03-30 14:27 ` Pradeep Kiruvale
0 siblings, 1 reply; 9+ messages in thread
From: Greg Kurz @ 2016-03-30 14:13 UTC (permalink / raw)
To: Pradeep Kiruvale; +Cc: qemu-devel, qemu-discuss@nongnu.org
On Wed, 30 Mar 2016 14:10:38 +0200
Pradeep Kiruvale <pradeepkiruvale@gmail.com> wrote:
> Hi All,
>
> Is virtio-9p-pci device only supports the fsdev deices? I am trying to use
> -drive option for applying QoS for block device using Virtio-9p-pci device,
> but failing to create/add a device other than fsdev. Can you please help me
> on this?
>
> Regards,
> Pradeep
Hi Pradeep,
Not sure to catch what you want to do but I confirm that virti-9p-pci only supports
fsdev... if you want a block device, why don't you use virtio-blk-pci ?
Cheers.
--
Greg
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Virtio-9p
2016-03-30 14:13 ` Greg Kurz
@ 2016-03-30 14:27 ` Pradeep Kiruvale
2016-03-31 16:12 ` Greg Kurz
0 siblings, 1 reply; 9+ messages in thread
From: Pradeep Kiruvale @ 2016-03-30 14:27 UTC (permalink / raw)
To: Greg Kurz; +Cc: qemu-devel, qemu-discuss@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 989 bytes --]
Hi Greg,
Thanks for the reply.
Let me put it this way, virtio-blk-pci is used for block IO on the devices
shared between the guest and the host.
Here I want to share the file and have QoS between the guests. So I am
using the Virtio-9p-pci.
Basically I want to have QoS for virtio-9p-pci.
Regards,
Pradeep
On 30 March 2016 at 16:13, Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
> On Wed, 30 Mar 2016 14:10:38 +0200
> Pradeep Kiruvale <pradeepkiruvale@gmail.com> wrote:
>
> > Hi All,
> >
> > Is virtio-9p-pci device only supports the fsdev deices? I am trying to
> use
> > -drive option for applying QoS for block device using Virtio-9p-pci
> device,
> > but failing to create/add a device other than fsdev. Can you please help
> me
> > on this?
> >
> > Regards,
> > Pradeep
>
> Hi Pradeep,
>
> Not sure to catch what you want to do but I confirm that virti-9p-pci only
> supports
> fsdev... if you want a block device, why don't you use virtio-blk-pci ?
>
> Cheers.
>
> --
> Greg
>
>
[-- Attachment #2: Type: text/html, Size: 1601 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Virtio-9p
2016-03-30 14:27 ` Pradeep Kiruvale
@ 2016-03-31 16:12 ` Greg Kurz
[not found] ` <CAJ2SuLm3U354OOKhaEEH-m_HuoAbPEK4ib-H0hvR7Pn296offA@mail.gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Greg Kurz @ 2016-03-31 16:12 UTC (permalink / raw)
To: Pradeep Kiruvale; +Cc: qemu-devel, qemu-discuss@nongnu.org
On Wed, 30 Mar 2016 16:27:48 +0200
Pradeep Kiruvale <pradeepkiruvale@gmail.com> wrote:
> Hi Greg,
>
Hi Pradeep,
> Thanks for the reply.
>
> Let me put it this way, virtio-blk-pci is used for block IO on the devices
> shared between the guest and the host.
I don't really understand the "devices shared between the guest and the
host" wording... virtio-blk-pci exposes a virtio-blk device through PCI
to the guest. The virtio-blk device can be backed by a file or a block
device from the host.
> Here I want to share the file and have QoS between the guests. So I am
> using the Virtio-9p-pci.
>
What file ?
> Basically I want to have QoS for virtio-9p-pci.
>
Can you provide a more detailed scenario on the result you want to reach ?
> Regards,
> Pradeep
>
Cheers.
--
Greg
> On 30 March 2016 at 16:13, Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
>
> > On Wed, 30 Mar 2016 14:10:38 +0200
> > Pradeep Kiruvale <pradeepkiruvale@gmail.com> wrote:
> >
> > > Hi All,
> > >
> > > Is virtio-9p-pci device only supports the fsdev deices? I am trying to
> > use
> > > -drive option for applying QoS for block device using Virtio-9p-pci
> > device,
> > > but failing to create/add a device other than fsdev. Can you please help
> > me
> > > on this?
> > >
> > > Regards,
> > > Pradeep
> >
> > Hi Pradeep,
> >
> > Not sure to catch what you want to do but I confirm that virti-9p-pci only
> > supports
> > fsdev... if you want a block device, why don't you use virtio-blk-pci ?
> >
> > Cheers.
> >
> > --
> > Greg
> >
> >
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-04-04 14:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-07 16:21 [Qemu-devel] virtio-9p Linda
2015-08-10 10:10 ` Stefan Hajnoczi
2015-08-10 13:20 ` Linda
-- strict thread matches above, loose matches on Subject: below --
2016-03-30 12:10 [Qemu-devel] Virtio-9p Pradeep Kiruvale
2016-03-30 14:13 ` Greg Kurz
2016-03-30 14:27 ` Pradeep Kiruvale
2016-03-31 16:12 ` Greg Kurz
[not found] ` <CAJ2SuLm3U354OOKhaEEH-m_HuoAbPEK4ib-H0hvR7Pn296offA@mail.gmail.com>
2016-04-01 9:35 ` Greg Kurz
2016-04-04 14:39 ` Pradeep Kiruvale
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).