repository: /home/dor/src/virtio/kvm-userspace
branch: virt-final
commit e661a41b246d1cb6f7f213151440df68a5b65e03
Author: Dor Laor <[EMAIL PROTECTED]>
Date:   Tue Sep 11 11:35:10 2007 +0300

    [VIRTIO for KVM] enable compatiblity mode for older kernels
    
    Handle old scsi_cmd_ioctl, netdevice stats and skb_to_sg.
    
    Signed-off-by: Dor Laor <[EMAIL PROTECTED]>

diff --git a/kernel/Makefile b/kernel/Makefile
index 5278525..7e33c80 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -35,6 +35,8 @@ sync:
        ln -sf kvm_para.h include/linux/kvm_para_new.h
        sed -i '/include/ s/linux\/kvm.h/linux\/kvm_new.h/' *.[ch]
        sed -i '/include/ s/linux\/kvm_para.h/linux\/kvm_para_new.h/' *.[ch]
+       sed -i s/scsi_cmd_ioctl/SCSI_CMD_IOCTL/ virtio_blk.c
+       sed -i -e 
s/vi\-\>ndev\-\>stats./vi\-\>ndev\-\>get_stats\(vi\-\>ndev\)\-\>/ -e 
s/dev\-\>stats./dev\-\>get_stats\(dev\)\-\>/ virtio_net.c
        $(call hack, kvm_main.c)
        $(call hack, mmu.c)
        $(call hack, vmx.c)
diff --git a/kernel/external-module-compat.h b/kernel/external-module-compat.h
index 33f1675..1e895d4 100644
--- a/kernel/external-module-compat.h
+++ b/kernel/external-module-compat.h
@@ -362,3 +362,90 @@ static inline void preempt_notifier_sys_init(void) {}
 static inline void preempt_notifier_sys_exit(void) {}
 
 #endif
+
+#ifndef uninitialized_var
+#define uninitialized_var(x) x=0
+#endif
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+
+#include <linux/skbuff.h>
+#include <linux/scatterlist.h>
+/**
+ *      skb_to_sgvec - Fill a scatter-gather list from a socket buffer
+ *      @skb: Socket buffer containing the buffers to be mapped
+ *      @sg: The scatter-gather list to map into
+ *      @offset: The offset into the buffer's contents to start mapping
+ *      @len: Length of buffer space to be mapped
+ *
+ *      Fill the specified scatter-gather list with mappings/pointers into a
+ *      region of the buffer space attached to a socket buffer.
+ */
+static int
+skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
+{
+        int start = skb_headlen(skb);
+        int i, copy = start - offset;
+        int elt = 0;
+
+        if (copy > 0) {
+                if (copy > len)
+                        copy = len;
+                sg[elt].page = virt_to_page(skb->data + offset);
+                sg[elt].offset = (unsigned long)(skb->data + offset) % 
PAGE_SIZE;
+                sg[elt].length = copy;
+                elt++;
+                if ((len -= copy) == 0)
+                        return elt;
+                offset += copy;
+        }
+
+        for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+                int end;
+
+                end = start + skb_shinfo(skb)->frags[i].size;
+                if ((copy = end - offset) > 0) {
+                        skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+                        if (copy > len)
+                                copy = len;
+                        sg[elt].page = frag->page;
+                        sg[elt].offset = frag->page_offset+offset-start;
+                        sg[elt].length = copy;
+                        elt++;
+                        if (!(len -= copy))
+                                return elt;
+                        offset += copy;
+                }
+                start = end;
+        }
+
+        if (skb_shinfo(skb)->frag_list) {
+                struct sk_buff *list = skb_shinfo(skb)->frag_list;
+
+                for (; list; list = list->next) {
+                        int end;
+
+                        end = start + list->len;
+                        if ((copy = end - offset) > 0) {
+                                if (copy > len)
+                                        copy = len;
+                                elt += skb_to_sgvec(list, sg+elt, offset - 
start, copy);
+                                if ((len -= copy) == 0)
+                                        return elt;
+                                offset += copy;
+                        }
+                        start = end;
+                }
+        }
+        BUG_ON(len);
+        return elt;
+}
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+#define SCSI_CMD_IOCTL(a,b,c,d,e) scsi_cmd_ioctl(a,c,d,e)
+#elif
+#define SCSI_CMD_IOCTL(a,b,c,d,e) scsi_cmd_ioctl(a,b,c,d,e)
+#endif

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to