[kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
This is the pci device side in qemu. It just used as a glue between the pci, tap and virtio code. Signed-off-by: Dor Laor <[EMAIL PROTECTED]> --- qemu/hw/paravirt_net.c | 213 1 files changed, 213 insertions(+), 0 deletions(-) create mode 100644 qemu/hw/paravirt_net.c diff --git a/qemu/hw/paravirt_net.c b/qemu/hw/paravirt_net.c new file mode 100644 index 000..fdf2f1c --- /dev/null +++ b/qemu/hw/paravirt_net.c @@ -0,0 +1,213 @@ +/* + * QEMU para virtual network emulation + * + * Copyright (c) 2007 Qumranet + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "vl.h" +#include "virtio.h" +#include "qemu-kvm.h" + +#define DEBUG_PARANET + +typedef struct PARANETState { +uint8_t macaddr[6]; +uint8_t mult[8]; /* multicast mask array */ +PCIDevice *pci_dev; +VLANClientState *vc; +struct virtio_device * vdev; +int tap_fd; +} PARANETState; + +#define MAX_PARANET_DEVICES 1 +static int used_devices = 0; +static PARANETState *paranet_devs[MAX_PARANET_DEVICES]; + +static void paranet_reset(void *opaque) +{ +} + +volatile int kvm_pvnet_pending_irq = 0; + +void paranet_update_irq(void *opaque) +{ +PARANETState *s = opaque; + +paravirt_set_irq(s->pci_dev->config[0x3c]); + +return; +} + +void paravirt_net_poll(void) +{ +int i; + +for (i=0; ivdev->handle_input(paranet_devs[i]->vdev); +} +} + +static int paranet_receive(void *opaque, const uint8_t *buf, int len) +{ + printf("PARANET:paravirt_receive\n"); + return 0; +} +static int paranet_can_receive(void *opaque) +{ +return 0; +} + +static void paranet_ioport_write(void *opaque, uint32_t addr, uint32_t val) +{ +addr &= 0xf; +#ifdef DEBUG_PARANET +printf("PARANET: write addr=0x%x val=0x%02x\n", addr, val); +#endif + +switch (addr) { +default: +printf("%s: BUG\n", __FUNCTION__); +break; +} +} + +static uint32_t paranet_ioport_read(void *opaque, uint32_t addr) +{ +PARANETState* s=(PARANETState*)opaque; +uint32_t val = 0; +addr &= 0xf; + +switch (addr) { + case 0: + val = 0; +default: +printf("%s: BUG\n", __FUNCTION__); +break; +} + +#ifdef DEBUG_PARANET +printf("PARANET: read addr=0x%x, val=%x\n", addr, val); +#endif +return val; +} + +static void paranet_save(QEMUFile* f,void* opaque) +{ +PARANETState* s=(PARANETState*)opaque; + +if (s->pci_dev) +pci_device_save(s->pci_dev, f); + +qemu_put_buffer(f, s->macaddr, 6); +qemu_put_buffer(f, s->mult, 8); +} + +static int paranet_load(QEMUFile* f,void* opaque,int version_id) +{ +PARANETState* s=(PARANETState*)opaque; +int ret = 0; + +if (s->pci_dev) { +ret = pci_device_load(s->pci_dev, f); +if (ret < 0) + return ret; +} + +qemu_get_buffer(f, s->macaddr, 6); +qemu_get_buffer(f, s->mult, 8); + +return ret; +} + +/***/ +/* PCI PARANET definitions */ + +typedef struct PCIPARANETState { +PCIDevice dev; +PARANETState PARANET; +} PCIPARANETState; + +static void paranet_map(PCIDevice *pci_dev, int region_num, + uint32_t addr, uint32_t size, int type) +{ +PCIPARANETState *d = (PCIPARANETState *)pci_dev; +PARANETState *s = &d->PARANET; + +register_ioport_write(addr, 16, 1, paranet_ioport_write, s); +register_ioport_read(addr, 16, 1, paranet_ioport_read, s); +} + +void pci_paranet_init(PCIBus *bus, NICInfo *nd, int devfn) +{ +PCIPARANETState *d; +PARANETState *s; +uint8_t *pci_conf; + +printf("PARANET: pci_paranet_init start\n"); + +virtio_init(); + +d = (PCIPARANETState *)pci_register_device(bus, + "PARANET", sizeof(PCIPARANETState), + devfn, + NULL, NULL); +
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
Am Samstag, 25. August 2007 schrieb Dor Laor: > + * Permission is hereby granted, free of charge, to any person > obtaining a copy Hi Dor, some of your patch lines seem line-wrapped. Is there place where I can download the whole series? Thanks Christian - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
On 8/25/07, Dor Laor <[EMAIL PROTECTED]> wrote: I just noticed this: > --- /dev/null > +++ b/qemu/hw/paravirt_net.c > @@ -0,0 +1,213 @@ > +/* > + * QEMU para virtual network emulation > + * > + * Copyright (c) 2007 Qumranet > + * > + * Permission is hereby granted, free of charge, to any person > obtaining a copy > + * of this software and associated documentation files (the > "Software"), to deal > + * in the Software without restriction, including without limitation > the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or > sell > + * copies of the Software, and to permit persons to whom the Software > is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be > included in > + * all copies or substantial portions of the Software. [cut] Shouldn't you use the standard GPL boilerplate? (IANAL, so maybe the text above is a superset of the GPL and is fine...) Luca - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
>I just noticed this: > >> --- /dev/null >> +++ b/qemu/hw/paravirt_net.c >> @@ -0,0 +1,213 @@ >> +/* >> + * QEMU para virtual network emulation >> + * >> + * Copyright (c) 2007 Qumranet >> + * >> + * Permission is hereby granted, free of charge, to any person >> obtaining a copy >> + * of this software and associated documentation files (the >> "Software"), to deal >> + * in the Software without restriction, including without limitation >> the rights >> + * to use, copy, modify, merge, publish, distribute, sublicense, >and/or >> sell >> + * copies of the Software, and to permit persons to whom the Software >> is >> + * furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be >> included in >> + * all copies or substantial portions of the Software. >[cut] > >Shouldn't you use the standard GPL boilerplate? (IANAL, so maybe the >text above is a superset of the GPL and is fine...) > >Luca I took it from the rtl8139 driver. Persoanly I don’t mind to switch to something better for the community. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
>> + * Permission is hereby granted, free of charge, to any person >> obtaining a copy > >Hi Dor, > >some of your patch lines seem line-wrapped. Is there place where I can >download the whole series? Thanks > >Christian The code can now be accessed by git: git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace. branch name virt-final. --Dor - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
Dor Laor wrote: > > The code can now be accessed by git: > git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and > git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace. > branch name virt-final. > --Dor > Hi Dor, I'm really new to git and don't quite grasp it's subtleties. Do I have to "git clone" your kvm kernel and user-space repos or is there some way to use your branch as a branch off Avi's? I tried finding an online reference, but none seem to cover this kind of setup. Thanks, Cam - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
On 8/29/07, Cam Macdonell <[EMAIL PROTECTED]> wrote: > Dor Laor wrote: > > The code can now be accessed by git: > > git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and > > git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace. > > branch name virt-final. > > --Dor > > I'm really new to git and don't quite grasp it's subtleties. Do I have > to "git clone" your kvm kernel and user-space repos or is there some way > to use your branch as a branch off Avi's? I tried finding an online > reference, but none seem to cover this kind of setup. If Dor's repository is based on the Avi's one (I think so) you can pull virt-final branch as a branch of you existing repository (see refspec parameter in git-pull). This is error prone though (after a while I tend to pull the wrong tree into the wrong branch ;-) ) I prefer to clone the whole tree (disk space is cheap...), sharing GIT object where possible, e.g. git clone --reference kvm.avi git://kvm.qumranet.com/home/dor/src/virtio/kvm kvm.dor where kvm.avi is you existing kvm git repository. Luca - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
Luca wrote: > On 8/29/07, Cam Macdonell <[EMAIL PROTECTED]> wrote: >> Dor Laor wrote: >>> The code can now be accessed by git: >>> git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and >>> git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace. >>> branch name virt-final. >>> --Dor >> I'm really new to git and don't quite grasp it's subtleties. Do I have >> to "git clone" your kvm kernel and user-space repos or is there some way >> to use your branch as a branch off Avi's? I tried finding an online >> reference, but none seem to cover this kind of setup. > > If Dor's repository is based on the Avi's one (I think so) you can > pull virt-final branch as a branch of you existing repository (see > refspec parameter in git-pull). This is error prone though (after a > while I tend to pull the wrong tree into the wrong branch ;-) ) > I prefer to clone the whole tree (disk space is cheap...), sharing GIT > object where possible, e.g. > > git clone --reference kvm.avi > git://kvm.qumranet.com/home/dor/src/virtio/kvm kvm.dor > Thanks Luca, I get this error: [EMAIL PROTECTED] ~/research/KVM]$ git clone --reference kvm git://kvm.qumranet.com/home/dor/src/virtio/kvm.git kvm.dor Initialized empty Git repository in /home/cam/research/KVM/kvm.dor/.git/ fatal: The remote end hung up unexpectedly fetch-pack from 'git://kvm.qumranet.com/home/dor/src/virtio/kvm.git' failed. Is there a problem with the repositor or am I doing something wrong? Thanks, Cam - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
On 8/29/07, Cam Macdonell <[EMAIL PROTECTED]> wrote: > Luca wrote: > > On 8/29/07, Cam Macdonell <[EMAIL PROTECTED]> wrote: > >> Dor Laor wrote: > >>> The code can now be accessed by git: > >>> git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and > >>> git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace. > >>> branch name virt-final. > >>> --Dor > >> I'm really new to git and don't quite grasp it's subtleties. Do I have > >> to "git clone" your kvm kernel and user-space repos or is there some way > >> to use your branch as a branch off Avi's? I tried finding an online > >> reference, but none seem to cover this kind of setup. > > > > If Dor's repository is based on the Avi's one (I think so) you can > > pull virt-final branch as a branch of you existing repository (see > > refspec parameter in git-pull). This is error prone though (after a > > while I tend to pull the wrong tree into the wrong branch ;-) ) > > I prefer to clone the whole tree (disk space is cheap...), sharing GIT > > object where possible, e.g. > > > > git clone --reference kvm.avi > > git://kvm.qumranet.com/home/dor/src/virtio/kvm kvm.dor > > > > Thanks Luca, > > I get this error: > > [EMAIL PROTECTED] ~/research/KVM]$ git clone --reference kvm > git://kvm.qumranet.com/home/dor/src/virtio/kvm.git kvm.dor > Initialized empty Git repository in /home/cam/research/KVM/kvm.dor/.git/ > fatal: The remote end hung up unexpectedly > fetch-pack from 'git://kvm.qumranet.com/home/dor/src/virtio/kvm.git' failed. > > Is there a problem with the repositor or am I doing something wrong? The command is correct. It seems that either the repository is not configured for export or the path is wrong. Luca - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
On Tue, 2007-08-28 at 23:40 -0700, Dor Laor wrote: > >I just noticed this: > > > >> --- /dev/null > >> +++ b/qemu/hw/paravirt_net.c > >> @@ -0,0 +1,213 @@ > >> +/* > >> + * QEMU para virtual network emulation > >> + * > >> + * Copyright (c) 2007 Qumranet > >> + * > >> + * Permission is hereby granted, free of charge, to any person > >> obtaining a copy > >> + * of this software and associated documentation files (the > >> "Software"), to deal > >> + * in the Software without restriction, including without limitation > >> the rights > >> + * to use, copy, modify, merge, publish, distribute, sublicense, > >and/or > >> sell > >> + * copies of the Software, and to permit persons to whom the Software > >> is > >> + * furnished to do so, subject to the following conditions: > >> + * > >> + * The above copyright notice and this permission notice shall be > >> included in > >> + * all copies or substantial portions of the Software. > >[cut] > > > >Shouldn't you use the standard GPL boilerplate? (IANAL, so maybe the > >text above is a superset of the GPL and is fine...) > > That text is the X11 license. It is not the GPL. Most device emulation in QEMU is not actually GPL'd but rather X11. Regards, Anthony Liguori > >Luca > > > I took it from the rtl8139 driver. Persoanly I don’t mind to switch to > something > better for the community. > - > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > ___ > kvm-devel mailing list > kvm-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/kvm-dev - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
Luca wrote: > On 8/29/07, Cam Macdonell <[EMAIL PROTECTED]> wrote: >> >> I get this error: >> >> [EMAIL PROTECTED] ~/research/KVM]$ git clone --reference kvm >> git://kvm.qumranet.com/home/dor/src/virtio/kvm.git kvm.dor >> Initialized empty Git repository in /home/cam/research/KVM/kvm.dor/.git/ >> fatal: The remote end hung up unexpectedly >> fetch-pack from 'git://kvm.qumranet.com/home/dor/src/virtio/kvm.git' failed. >> >> Is there a problem with the repositor or am I doing something wrong? > > The command is correct. It seems that either the repository is not > configured for export or the path is wrong. > > Luca Hi Dor, I can't seem to grab your tree. Is your repository setup properly? Thanks, Cam - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
Luca wrote: > On 8/29/07, Cam Macdonell <[EMAIL PROTECTED]> wrote: > >> Dor Laor wrote: >> >>> The code can now be accessed by git: >>> git://kvm.qumranet.com/home/dor/src/virtio/kvm (kernel) and >>> git://kvm.qumranet.com/home/dor/src/virtio/kvm-userspace. >>> branch name virt-final. >>> --Dor >>> >> I'm really new to git and don't quite grasp it's subtleties. Do I have >> to "git clone" your kvm kernel and user-space repos or is there some way >> to use your branch as a branch off Avi's? I tried finding an online >> reference, but none seem to cover this kind of setup. >> > > If Dor's repository is based on the Avi's one (I think so) you can > pull virt-final branch as a branch of you existing repository (see > refspec parameter in git-pull). This is error prone though (after a > while I tend to pull the wrong tree into the wrong branch ;-) ) > I prefer to clone the whole tree (disk space is cheap...), sharing GIT > object where possible, e.g. > > git clone --reference kvm.avi > git://kvm.qumranet.com/home/dor/src/virtio/kvm kvm.dor > > where kvm.avi is you existing kvm git repository. > My preference pulling random branches and repos is 'git fetch' (or, for longer lived branches, 'git remote') which doesn't cause fake merges. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code
Luca wrote: > On 8/25/07, Dor Laor <[EMAIL PROTECTED]> wrote: > > I just noticed this: > > >> --- /dev/null >> +++ b/qemu/hw/paravirt_net.c >> @@ -0,0 +1,213 @@ >> +/* >> + * QEMU para virtual network emulation >> + * >> + * Copyright (c) 2007 Qumranet >> + * >> + * Permission is hereby granted, free of charge, to any person >> obtaining a copy >> + * of this software and associated documentation files (the >> "Software"), to deal >> + * in the Software without restriction, including without limitation >> the rights >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or >> sell >> + * copies of the Software, and to permit persons to whom the Software >> is >> + * furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be >> included in >> + * all copies or substantial portions of the Software. >> > [cut] > > Shouldn't you use the standard GPL boilerplate? (IANAL, so maybe the > text above is a superset of the GPL and is fine...) > > My preference is to just add a copyright and refer to some file in the top-level, so we don't restrict qemu's licensing unnecessarily (this could hinder merging). -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel