wok-6.x rev 17256

Up libzip (0.11.2)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Oct 21 12:15:20 2014 +0200 (2014-10-21)
parents 108901a0f197
children e9c56b27df13
files libzip-dev/receipt libzip/receipt qemu/stuff/virtio.u xarchive/stuff/slitaz-wrap.sh
line diff
     1.1 --- a/libzip-dev/receipt	Mon Oct 20 20:17:03 2014 +0200
     1.2 +++ b/libzip-dev/receipt	Tue Oct 21 12:15:20 2014 +0200
     1.3 @@ -1,7 +1,7 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="libzip-dev"
     1.7 -VERSION="0.10.1"
     1.8 +VERSION="0.11.2"
     1.9  CATEGORY="development"
    1.10  SHORT_DESC="C library for reading, creating, and modifying zip archives, development files."
    1.11  MAINTAINER="pascal.bellard@slitaz.org"
     2.1 --- a/libzip/receipt	Mon Oct 20 20:17:03 2014 +0200
     2.2 +++ b/libzip/receipt	Tue Oct 21 12:15:20 2014 +0200
     2.3 @@ -1,12 +1,12 @@
     2.4  # SliTaz package receipt.
     2.5  
     2.6  PACKAGE="libzip"
     2.7 -VERSION="0.10.1"
     2.8 +VERSION="0.11.2"
     2.9  CATEGORY="misc"
    2.10  SHORT_DESC="C library for reading, creating, and modifying zip archives."
    2.11  MAINTAINER="pascal.bellard@slitaz.org"
    2.12  LICENSE="BSD"
    2.13 -TARBALL="$PACKAGE-$VERSION.tar.bz2"
    2.14 +TARBALL="$PACKAGE-$VERSION.tar.xz"
    2.15  WEB_SITE="http://www.nih.at/libzip/"
    2.16  WGET_URL="${WEB_SITE}$TARBALL"
    2.17  HOST_ARCH="i486 arm"
     3.1 --- a/qemu/stuff/virtio.u	Mon Oct 20 20:17:03 2014 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,1076 +0,0 @@
     3.4 -Index: qemu-0.9.1/Makefile.target
     3.5 -===================================================================
     3.6 ---- qemu-0.9.1.orig/Makefile.target	2008-01-06 19:38:41.000000000 +0000
     3.7 -+++ qemu-0.9.1/Makefile.target	2008-02-07 13:36:23.000000000 +0000
     3.8 -@@ -436,6 +436,9 @@
     3.9 - VL_OBJS += pcnet.o
    3.10 - VL_OBJS += rtl8139.o
    3.11 - 
    3.12 -+# virtio devices
    3.13 -+VL_OBJS += virtio.o
    3.14 -+
    3.15 - ifeq ($(TARGET_BASE_ARCH), i386)
    3.16 - # Hardware support
    3.17 - VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
    3.18 -Index: qemu-0.9.1/hw/virtio.c
    3.19 -===================================================================
    3.20 ---- /dev/null	1970-01-01 00:00:00.000000000 +0000
    3.21 -+++ qemu-0.9.1/hw/virtio.c	2008-02-07 13:36:23.000000000 +0000
    3.22 -@@ -0,0 +1,422 @@
    3.23 -+/*
    3.24 -+ * Virtio Support
    3.25 -+ *
    3.26 -+ * Copyright IBM, Corp. 2007
    3.27 -+ *
    3.28 -+ * Authors:
    3.29 -+ *  Anthony Liguori   <address@hidden>
    3.30 -+ *
    3.31 -+ * This work is licensed under the terms of the GNU GPL, version 2.  See
    3.32 -+ * the COPYING file in the top-level directory.
    3.33 -+ *
    3.34 -+ */
    3.35 -+
    3.36 -+#include <inttypes.h>
    3.37 -+#include <err.h>
    3.38 -+
    3.39 -+#include "virtio.h"
    3.40 -+#include "sysemu.h"
    3.41 -+
    3.42 -+/* from Linux's linux/virtio_pci.h */
    3.43 -+
    3.44 -+/* A 32-bit r/o bitmask of the features supported by the host */
    3.45 -+#define VIRTIO_PCI_HOST_FEATURES       0
    3.46 -+
    3.47 -+/* A 32-bit r/w bitmask of features activated by the guest */
    3.48 -+#define VIRTIO_PCI_GUEST_FEATURES      4
    3.49 -+
    3.50 -+/* A 32-bit r/w PFN for the currently selected queue */
    3.51 -+#define VIRTIO_PCI_QUEUE_PFN           8
    3.52 -+
    3.53 -+/* A 16-bit r/o queue size for the currently selected queue */
    3.54 -+#define VIRTIO_PCI_QUEUE_NUM           12
    3.55 -+
    3.56 -+/* A 16-bit r/w queue selector */
    3.57 -+#define VIRTIO_PCI_QUEUE_SEL           14
    3.58 -+
    3.59 -+/* A 16-bit r/w queue notifier */
    3.60 -+#define VIRTIO_PCI_QUEUE_NOTIFY                16
    3.61 -+
    3.62 -+/* An 8-bit device status register.  */
    3.63 -+#define VIRTIO_PCI_STATUS              18
    3.64 -+
    3.65 -+/* An 8-bit r/o interrupt status register.  Reading the value will return the
    3.66 -+ * current contents of the ISR and will also clear it.  This is effectively
    3.67 -+ * a read-and-acknowledge. */
    3.68 -+#define VIRTIO_PCI_ISR                 19
    3.69 -+
    3.70 -+#define VIRTIO_PCI_CONFIG              20
    3.71 -+
    3.72 -+/* QEMU doesn't strictly need write barriers since everything runs in
    3.73 -+ * lock-step.  We'll leave the calls to wmb() in though to make it obvious for
    3.74 -+ * KVM or if kqemu gets SMP support.
    3.75 -+ */
    3.76 -+#define wmb() do { } while (0)
    3.77 -+
    3.78 -+/* virt queue functions */
    3.79 -+
    3.80 -+static void virtqueue_init(VirtQueue *vq, void *p)
    3.81 -+{
    3.82 -+    vq->vring.desc = p;
    3.83 -+    vq->vring.avail = p + vq->vring.num * sizeof(VRingDesc);
    3.84 -+    vq->vring.used = (void *)TARGET_PAGE_ALIGN((unsigned long)&vq->vring.avail->ring[vq->vring.num]);
    3.85 -+}
    3.86 -+
    3.87 -+static unsigned virtqueue_next_desc(VirtQueue *vq, unsigned int i)
    3.88 -+{
    3.89 -+    unsigned int next;
    3.90 -+
    3.91 -+    /* If this descriptor says it doesn't chain, we're done. */
    3.92 -+    if (!(vq->vring.desc[i].flags & VRING_DESC_F_NEXT))
    3.93 -+       return vq->vring.num;
    3.94 -+
    3.95 -+    /* Check they're not leading us off end of descriptors. */
    3.96 -+    next = vq->vring.desc[i].next;
    3.97 -+    /* Make sure compiler knows to grab that: we don't want it changing! */
    3.98 -+    wmb();
    3.99 -+
   3.100 -+    if (next >= vq->vring.num)
   3.101 -+       errx(1, "Desc next is %u", next);
   3.102 -+
   3.103 -+    return next;
   3.104 -+}
   3.105 -+
   3.106 -+void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
   3.107 -+                   unsigned int len)
   3.108 -+{
   3.109 -+    VRingUsedElem *used;
   3.110 -+
   3.111 -+    /* Get a pointer to the next entry in the used ring. */
   3.112 -+    used = &vq->vring.used->ring[vq->vring.used->idx % vq->vring.num];
   3.113 -+    used->id = elem->index;
   3.114 -+    used->len = len;
   3.115 -+    /* Make sure buffer is written before we update index. */
   3.116 -+    wmb();
   3.117 -+    vq->vring.used->idx++;
   3.118 -+}
   3.119 -+
   3.120 -+int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
   3.121 -+{
   3.122 -+    unsigned int i, head;
   3.123 -+    unsigned int position;
   3.124 -+
   3.125 -+    /* Check it isn't doing very strange things with descriptor numbers. */
   3.126 -+    if ((uint16_t)(vq->vring.avail->idx - vq->last_avail_idx) > vq->vring.num)
   3.127 -+       errx(1, "Guest moved used index from %u to %u",
   3.128 -+            vq->last_avail_idx, vq->vring.avail->idx);
   3.129 -+
   3.130 -+    /* If there's nothing new since last we looked, return invalid. */
   3.131 -+    if (vq->vring.avail->idx == vq->last_avail_idx)
   3.132 -+       return 0;
   3.133 -+
   3.134 -+    /* Grab the next descriptor number they're advertising, and increment
   3.135 -+     * the index we've seen. */
   3.136 -+    head = vq->vring.avail->ring[vq->last_avail_idx++ % vq->vring.num];
   3.137 -+
   3.138 -+    /* If their number is silly, that's a fatal mistake. */
   3.139 -+    if (head >= vq->vring.num)
   3.140 -+       errx(1, "Guest says index %u is available", head);
   3.141 -+
   3.142 -+    /* When we start there are none of either input nor output. */
   3.143 -+    position = elem->out_num = elem->in_num = 0;
   3.144 -+
   3.145 -+    i = head;
   3.146 -+    do {
   3.147 -+       struct iovec *sg;
   3.148 -+
   3.149 -+       if ((vq->vring.desc[i].addr + vq->vring.desc[i].len) > ram_size)
   3.150 -+           errx(1, "Guest sent invalid pointer");
   3.151 -+
   3.152 -+       if (vq->vring.desc[i].flags & VRING_DESC_F_WRITE)
   3.153 -+           sg = &elem->in_sg[elem->in_num++];
   3.154 -+       else
   3.155 -+           sg = &elem->out_sg[elem->out_num++];
   3.156 -+
   3.157 -+       /* Grab the first descriptor, and check it's OK. */
   3.158 -+       sg->iov_len = vq->vring.desc[i].len;
   3.159 -+       sg->iov_base = phys_ram_base + vq->vring.desc[i].addr;
   3.160 -+
   3.161 -+       /* If we've got too many, that implies a descriptor loop. */
   3.162 -+       if ((elem->in_num + elem->out_num) > vq->vring.num)
   3.163 -+           errx(1, "Looped descriptor");
   3.164 -+    } while ((i = virtqueue_next_desc(vq, i)) != vq->vring.num);
   3.165 -+
   3.166 -+    elem->index = head;
   3.167 -+
   3.168 -+    return elem->in_num + elem->out_num;
   3.169 -+}
   3.170 -+
   3.171 -+/* virtio device */
   3.172 -+
   3.173 -+static VirtIODevice *to_virtio_device(PCIDevice *pci_dev)
   3.174 -+{
   3.175 -+    return (VirtIODevice *)pci_dev;
   3.176 -+}
   3.177 -+
   3.178 -+static void virtio_update_irq(VirtIODevice *vdev)
   3.179 -+{
   3.180 -+    qemu_set_irq(vdev->pci_dev.irq[0], vdev->isr & 1);
   3.181 -+}
   3.182 -+
   3.183 -+static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
   3.184 -+{
   3.185 -+    VirtIODevice *vdev = to_virtio_device(opaque);
   3.186 -+    ram_addr_t pa;
   3.187 -+
   3.188 -+    addr -= vdev->addr;
   3.189 -+
   3.190 -+    switch (addr) {
   3.191 -+    case VIRTIO_PCI_GUEST_FEATURES:
   3.192 -+       if (vdev->set_features)
   3.193 -+           vdev->set_features(vdev, val);
   3.194 -+       vdev->features = val;
   3.195 -+       break;
   3.196 -+    case VIRTIO_PCI_QUEUE_PFN:
   3.197 -+       pa = (ram_addr_t)val << TARGET_PAGE_BITS;
   3.198 -+       vdev->vq[vdev->queue_sel].pfn = val;
   3.199 -+       if (pa == 0) {
   3.200 -+           vdev->vq[vdev->queue_sel].vring.desc = NULL;
   3.201 -+           vdev->vq[vdev->queue_sel].vring.avail = NULL;
   3.202 -+           vdev->vq[vdev->queue_sel].vring.used = NULL;
   3.203 -+       } else if (pa < (ram_size - TARGET_PAGE_SIZE)) {
   3.204 -+           virtqueue_init(&vdev->vq[vdev->queue_sel], phys_ram_base + pa);
   3.205 -+           /* FIXME if pa == 0, deal with device tear down */
   3.206 -+       }
   3.207 -+       break;
   3.208 -+    case VIRTIO_PCI_QUEUE_SEL:
   3.209 -+       if (val < VIRTIO_PCI_QUEUE_MAX)
   3.210 -+           vdev->queue_sel = val;
   3.211 -+       break;
   3.212 -+    case VIRTIO_PCI_QUEUE_NOTIFY:
   3.213 -+       if (val < VIRTIO_PCI_QUEUE_MAX && vdev->vq[val].vring.desc)
   3.214 -+           vdev->vq[val].handle_output(vdev, &vdev->vq[val]);
   3.215 -+       break;
   3.216 -+    case VIRTIO_PCI_STATUS:
   3.217 -+       vdev->status = val & 0xFF;
   3.218 -+       break;
   3.219 -+    }
   3.220 -+}
   3.221 -+
   3.222 -+static uint32_t virtio_ioport_read(void *opaque, uint32_t addr)
   3.223 -+{
   3.224 -+    VirtIODevice *vdev = to_virtio_device(opaque);
   3.225 -+    uint32_t ret = 0xFFFFFFFF;
   3.226 -+
   3.227 -+    addr -= vdev->addr;
   3.228 -+
   3.229 -+    switch (addr) {
   3.230 -+    case VIRTIO_PCI_HOST_FEATURES:
   3.231 -+       ret = vdev->get_features(vdev);
   3.232 -+       break;
   3.233 -+    case VIRTIO_PCI_GUEST_FEATURES:
   3.234 -+       ret = vdev->features;
   3.235 -+       break;
   3.236 -+    case VIRTIO_PCI_QUEUE_PFN:
   3.237 -+       ret = vdev->vq[vdev->queue_sel].pfn;
   3.238 -+       break;
   3.239 -+    case VIRTIO_PCI_QUEUE_NUM:
   3.240 -+       ret = vdev->vq[vdev->queue_sel].vring.num;
   3.241 -+       break;
   3.242 -+    case VIRTIO_PCI_QUEUE_SEL:
   3.243 -+       ret = vdev->queue_sel;
   3.244 -+       break;
   3.245 -+    case VIRTIO_PCI_STATUS:
   3.246 -+       ret = vdev->status;
   3.247 -+       break;
   3.248 -+    case VIRTIO_PCI_ISR:
   3.249 -+       /* reading from the ISR also clears it. */
   3.250 -+       ret = vdev->isr;
   3.251 -+       vdev->isr = 0;
   3.252 -+       virtio_update_irq(vdev);
   3.253 -+       break;
   3.254 -+    default:
   3.255 -+       break;
   3.256 -+    }
   3.257 -+
   3.258 -+    return ret;
   3.259 -+}
   3.260 -+
   3.261 -+static uint32_t virtio_config_readb(void *opaque, uint32_t addr)
   3.262 -+{
   3.263 -+    VirtIODevice *vdev = opaque;
   3.264 -+    uint8_t val;
   3.265 -+
   3.266 -+    addr -= vdev->addr + VIRTIO_PCI_CONFIG;
   3.267 -+    if (addr > (vdev->config_len - sizeof(val)))
   3.268 -+       return (uint32_t)-1;
   3.269 -+
   3.270 -+    memcpy(&val, vdev->config + addr, sizeof(val));
   3.271 -+    return val;
   3.272 -+}
   3.273 -+
   3.274 -+static uint32_t virtio_config_readw(void *opaque, uint32_t addr)
   3.275 -+{
   3.276 -+    VirtIODevice *vdev = opaque;
   3.277 -+    uint16_t val;
   3.278 -+
   3.279 -+    addr -= vdev->addr + VIRTIO_PCI_CONFIG;
   3.280 -+    if (addr > (vdev->config_len - sizeof(val)))
   3.281 -+       return (uint32_t)-1;
   3.282 -+
   3.283 -+    memcpy(&val, vdev->config + addr, sizeof(val));
   3.284 -+    return val;
   3.285 -+}
   3.286 -+
   3.287 -+static uint32_t virtio_config_readl(void *opaque, uint32_t addr)
   3.288 -+{
   3.289 -+    VirtIODevice *vdev = opaque;
   3.290 -+    uint32_t val;
   3.291 -+
   3.292 -+    addr -= vdev->addr + VIRTIO_PCI_CONFIG;
   3.293 -+    if (addr > (vdev->config_len - sizeof(val)))
   3.294 -+       return (uint32_t)-1;
   3.295 -+
   3.296 -+    memcpy(&val, vdev->config + addr, sizeof(val));
   3.297 -+    return val;
   3.298 -+}
   3.299 -+
   3.300 -+static void virtio_config_writeb(void *opaque, uint32_t addr, uint32_t data)
   3.301 -+{
   3.302 -+    VirtIODevice *vdev = opaque;
   3.303 -+    uint8_t val = data;
   3.304 -+
   3.305 -+    addr -= vdev->addr + VIRTIO_PCI_CONFIG;
   3.306 -+    if (addr > (vdev->config_len - sizeof(val)))
   3.307 -+       return;
   3.308 -+
   3.309 -+    memcpy(vdev->config + addr, &val, sizeof(val));
   3.310 -+}
   3.311 -+
   3.312 -+static void virtio_config_writew(void *opaque, uint32_t addr, uint32_t data)
   3.313 -+{
   3.314 -+    VirtIODevice *vdev = opaque;
   3.315 -+    uint16_t val = data;
   3.316 -+
   3.317 -+    addr -= vdev->addr + VIRTIO_PCI_CONFIG;
   3.318 -+    if (addr > (vdev->config_len - sizeof(val)))
   3.319 -+       return;
   3.320 -+
   3.321 -+    memcpy(vdev->config + addr, &val, sizeof(val));
   3.322 -+}
   3.323 -+
   3.324 -+static void virtio_config_writel(void *opaque, uint32_t addr, uint32_t data)
   3.325 -+{
   3.326 -+    VirtIODevice *vdev = opaque;
   3.327 -+    uint32_t val = data;
   3.328 -+
   3.329 -+    addr -= vdev->addr + VIRTIO_PCI_CONFIG;
   3.330 -+    if (addr > (vdev->config_len - sizeof(val)))
   3.331 -+       return;
   3.332 -+
   3.333 -+    memcpy(vdev->config + addr, &val, sizeof(val));
   3.334 -+}
   3.335 -+
   3.336 -+static void virtio_map(PCIDevice *pci_dev, int region_num,
   3.337 -+                      uint32_t addr, uint32_t size, int type)
   3.338 -+{
   3.339 -+    VirtIODevice *vdev = to_virtio_device(pci_dev);
   3.340 -+    int i;
   3.341 -+
   3.342 -+    vdev->addr = addr;
   3.343 -+    for (i = 0; i < 3; i++) {
   3.344 -+       register_ioport_write(addr, 20, 1 << i, virtio_ioport_write, vdev);
   3.345 -+       register_ioport_read(addr, 20, 1 << i, virtio_ioport_read, vdev);
   3.346 -+    }
   3.347 -+
   3.348 -+    if (vdev->config_len) {
   3.349 -+       register_ioport_write(addr + 20, vdev->config_len, 1,
   3.350 -+                             virtio_config_writeb, vdev);
   3.351 -+       register_ioport_write(addr + 20, vdev->config_len, 2,
   3.352 -+                             virtio_config_writew, vdev);
   3.353 -+       register_ioport_write(addr + 20, vdev->config_len, 4,
   3.354 -+                             virtio_config_writel, vdev);
   3.355 -+       register_ioport_read(addr + 20, vdev->config_len, 1,
   3.356 -+                            virtio_config_readb, vdev);
   3.357 -+       register_ioport_read(addr + 20, vdev->config_len, 2,
   3.358 -+                            virtio_config_readw, vdev);
   3.359 -+       register_ioport_read(addr + 20, vdev->config_len, 4,
   3.360 -+                            virtio_config_readl, vdev);
   3.361 -+
   3.362 -+       vdev->update_config(vdev, vdev->config);
   3.363 -+    }
   3.364 -+}
   3.365 -+
   3.366 -+VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
   3.367 -+                           void (*handle_output)(VirtIODevice *, VirtQueue *))
   3.368 -+{
   3.369 -+    int i;
   3.370 -+
   3.371 -+    for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
   3.372 -+       if (vdev->vq[i].vring.num == 0)
   3.373 -+           break;
   3.374 -+    }
   3.375 -+
   3.376 -+    if (i == VIRTIO_PCI_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE)
   3.377 -+       abort();
   3.378 -+
   3.379 -+    vdev->vq[i].vring.num = queue_size;
   3.380 -+    vdev->vq[i].handle_output = handle_output;
   3.381 -+    vdev->vq[i].index = i;
   3.382 -+
   3.383 -+    return &vdev->vq[i];
   3.384 -+}
   3.385 -+
   3.386 -+void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
   3.387 -+{
   3.388 -+    if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
   3.389 -+       return;
   3.390 -+
   3.391 -+    vdev->isr = 1;
   3.392 -+    virtio_update_irq(vdev);
   3.393 -+}
   3.394 -+
   3.395 -+VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name,
   3.396 -+                             uint16_t vendor, uint16_t device,
   3.397 -+                             uint16_t subvendor, uint16_t subdevice,
   3.398 -+                             uint8_t class_code, uint8_t subclass_code,
   3.399 -+                             uint8_t pif, size_t config_size,
   3.400 -+                             size_t struct_size)
   3.401 -+{
   3.402 -+    VirtIODevice *vdev;
   3.403 -+    PCIDevice *pci_dev;
   3.404 -+    uint8_t *config;
   3.405 -+
   3.406 -+    pci_dev = pci_register_device(bus, name, struct_size,
   3.407 -+                                 -1, NULL, NULL);
   3.408 -+    vdev = to_virtio_device(pci_dev);
   3.409 -+
   3.410 -+    vdev->status = 0;
   3.411 -+    vdev->isr = 0;
   3.412 -+    vdev->queue_sel = 0;
   3.413 -+    memset(vdev->vq, 0, sizeof(vdev->vq));
   3.414 -+
   3.415 -+    config = pci_dev->config;
   3.416 -+    config[0x00] = vendor & 0xFF;
   3.417 -+    config[0x01] = (vendor >> 8) & 0xFF;
   3.418 -+    config[0x02] = device & 0xFF;
   3.419 -+    config[0x03] = (device >> 8) & 0xFF;
   3.420 -+
   3.421 -+    config[0x09] = pif;
   3.422 -+    config[0x0a] = subclass_code;
   3.423 -+    config[0x0b] = class_code;
   3.424 -+    config[0x0e] = 0x00;
   3.425 -+
   3.426 -+    config[0x2c] = subvendor & 0xFF;
   3.427 -+    config[0x2d] = (subvendor >> 8) & 0xFF;
   3.428 -+    config[0x2e] = subdevice & 0xFF;
   3.429 -+    config[0x2f] = (subdevice >> 8) & 0xFF;
   3.430 -+
   3.431 -+    config[0x3d] = 1;
   3.432 -+
   3.433 -+    vdev->name = name;
   3.434 -+    vdev->config_len = config_size;
   3.435 -+    if (vdev->config_len)
   3.436 -+       vdev->config = qemu_mallocz(config_size);
   3.437 -+    else
   3.438 -+       vdev->config = NULL;
   3.439 -+
   3.440 -+    pci_register_io_region(pci_dev, 0, 20 + config_size, PCI_ADDRESS_SPACE_IO,
   3.441 -+                          virtio_map);
   3.442 -+
   3.443 -+    return vdev;
   3.444 -+}
   3.445 -Index: qemu-0.9.1/hw/virtio.h
   3.446 -===================================================================
   3.447 ---- /dev/null	1970-01-01 00:00:00.000000000 +0000
   3.448 -+++ qemu-0.9.1/hw/virtio.h	2008-02-07 13:36:23.000000000 +0000
   3.449 -@@ -0,0 +1,143 @@
   3.450 -+/*
   3.451 -+ * Virtio Support
   3.452 -+ *
   3.453 -+ * Copyright IBM, Corp. 2007
   3.454 -+ *
   3.455 -+ * Authors:
   3.456 -+ *  Anthony Liguori   <address@hidden>
   3.457 -+ *
   3.458 -+ * This work is licensed under the terms of the GNU GPL, version 2.  See
   3.459 -+ * the COPYING file in the top-level directory.
   3.460 -+ *
   3.461 -+ */
   3.462 -+
   3.463 -+#ifndef _QEMU_VIRTIO_H
   3.464 -+#define _QEMU_VIRTIO_H
   3.465 -+
   3.466 -+#include <sys/uio.h>
   3.467 -+#include "hw.h"
   3.468 -+#include "pci.h"
   3.469 -+
   3.470 -+/* from Linux's linux/virtio_config.h */
   3.471 -+
   3.472 -+/* Status byte for guest to report progress, and synchronize features. */
   3.473 -+/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
   3.474 -+#define VIRTIO_CONFIG_S_ACKNOWLEDGE    1
   3.475 -+/* We have found a driver for the device. */
   3.476 -+#define VIRTIO_CONFIG_S_DRIVER         2
   3.477 -+/* Driver has used its parts of the config, and is happy */
   3.478 -+#define VIRTIO_CONFIG_S_DRIVER_OK      4
   3.479 -+/* We've given up on this device. */
   3.480 -+#define VIRTIO_CONFIG_S_FAILED         0x80
   3.481 -+
   3.482 -+/* from Linux's linux/virtio_ring.h */
   3.483 -+
   3.484 -+/* This marks a buffer as continuing via the next field. */
   3.485 -+#define VRING_DESC_F_NEXT      1
   3.486 -+/* This marks a buffer as write-only (otherwise read-only). */
   3.487 -+#define VRING_DESC_F_WRITE     2
   3.488 -+
   3.489 -+/* This means don't notify other side when buffer added. */
   3.490 -+#define VRING_USED_F_NO_NOTIFY 1
   3.491 -+/* This means don't interrupt guest when buffer consumed. */
   3.492 -+#define VRING_AVAIL_F_NO_INTERRUPT     1
   3.493 -+
   3.494 -+typedef struct VirtQueue VirtQueue;
   3.495 -+typedef struct VirtIODevice VirtIODevice;
   3.496 -+
   3.497 -+typedef struct VRingDesc
   3.498 -+{
   3.499 -+    uint64_t addr;
   3.500 -+    uint32_t len;
   3.501 -+    uint16_t flags;
   3.502 -+    uint16_t next;
   3.503 -+} VRingDesc;
   3.504 -+
   3.505 -+typedef struct VRingAvail
   3.506 -+{
   3.507 -+    uint16_t flags;
   3.508 -+    uint16_t idx;
   3.509 -+    uint16_t ring[0];
   3.510 -+} VRingAvail;
   3.511 -+
   3.512 -+typedef struct VRingUsedElem
   3.513 -+{
   3.514 -+    uint32_t id;
   3.515 -+    uint32_t len;
   3.516 -+} VRingUsedElem;
   3.517 -+
   3.518 -+typedef struct VRingUsed
   3.519 -+{
   3.520 -+    uint16_t flags;
   3.521 -+    uint16_t idx;
   3.522 -+    VRingUsedElem ring[0];
   3.523 -+} VRingUsed;
   3.524 -+
   3.525 -+typedef struct VRing
   3.526 -+{
   3.527 -+    unsigned int num;
   3.528 -+    VRingDesc *desc;
   3.529 -+    VRingAvail *avail;
   3.530 -+    VRingUsed *used;
   3.531 -+} VRing;
   3.532 -+
   3.533 -+struct VirtQueue
   3.534 -+{
   3.535 -+    VRing vring;
   3.536 -+    uint32_t pfn;
   3.537 -+    uint16_t last_avail_idx;
   3.538 -+    void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
   3.539 -+    int index;
   3.540 -+};
   3.541 -+
   3.542 -+#define VIRTQUEUE_MAX_SIZE 1024
   3.543 -+
   3.544 -+typedef struct VirtQueueElement
   3.545 -+{
   3.546 -+    unsigned int index;
   3.547 -+    unsigned int out_num;
   3.548 -+    unsigned int in_num;
   3.549 -+    struct iovec in_sg[VIRTQUEUE_MAX_SIZE];
   3.550 -+    struct iovec out_sg[VIRTQUEUE_MAX_SIZE];
   3.551 -+} VirtQueueElement;
   3.552 -+
   3.553 -+#define VIRTIO_PCI_QUEUE_MAX   16
   3.554 -+
   3.555 -+struct VirtIODevice
   3.556 -+{
   3.557 -+    PCIDevice pci_dev;
   3.558 -+    const char *name;
   3.559 -+    uint32_t addr;
   3.560 -+    uint16_t vendor;
   3.561 -+    uint16_t device;
   3.562 -+    uint8_t status;
   3.563 -+    uint8_t isr;
   3.564 -+    uint16_t queue_sel;
   3.565 -+    uint32_t features;
   3.566 -+    size_t config_len;
   3.567 -+    void *config;
   3.568 -+    uint32_t (*get_features)(VirtIODevice *vdev);
   3.569 -+    void (*set_features)(VirtIODevice *vdev, uint32_t val);
   3.570 -+    void (*update_config)(VirtIODevice *vdev, uint8_t *config);
   3.571 -+    VirtQueue vq[VIRTIO_PCI_QUEUE_MAX];
   3.572 -+};
   3.573 -+
   3.574 -+VirtIODevice *virtio_init_pci(PCIBus *bus, const char *name,
   3.575 -+                             uint16_t vendor, uint16_t device,
   3.576 -+                             uint16_t subvendor, uint16_t subdevice,
   3.577 -+                             uint8_t class_code, uint8_t subclass_code,
   3.578 -+                             uint8_t pif, size_t config_size,
   3.579 -+                             size_t struct_size);
   3.580 -+
   3.581 -+VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
   3.582 -+                           void (*handle_output)(VirtIODevice *,
   3.583 -+                                                 VirtQueue *));
   3.584 -+
   3.585 -+void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
   3.586 -+                   unsigned int len);
   3.587 -+
   3.588 -+int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem);
   3.589 -+
   3.590 -+void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
   3.591 -+
   3.592 -+#endif
   3.593 -Index: qemu-0.9.1/Makefile.target
   3.594 -===================================================================
   3.595 ---- qemu-0.9.1.orig/Makefile.target	2008-02-07 13:36:23.000000000 +0000
   3.596 -+++ qemu-0.9.1/Makefile.target	2008-02-07 13:36:37.000000000 +0000
   3.597 -@@ -437,7 +437,7 @@
   3.598 - VL_OBJS += rtl8139.o
   3.599 - 
   3.600 - # virtio devices
   3.601 --VL_OBJS += virtio.o
   3.602 -+VL_OBJS += virtio.o virtio-net.o
   3.603 - 
   3.604 - ifeq ($(TARGET_BASE_ARCH), i386)
   3.605 - # Hardware support
   3.606 -Index: qemu-0.9.1/hw/pc.h
   3.607 -===================================================================
   3.608 ---- qemu-0.9.1.orig/hw/pc.h	2008-01-06 19:38:42.000000000 +0000
   3.609 -+++ qemu-0.9.1/hw/pc.h	2008-02-07 13:36:37.000000000 +0000
   3.610 -@@ -142,4 +142,9 @@
   3.611 - 
   3.612 - void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd);
   3.613 - 
   3.614 -+/* virtio-net.c */
   3.615 -+
   3.616 -+void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
   3.617 -+
   3.618 -+
   3.619 - #endif
   3.620 -Index: qemu-0.9.1/hw/pci.c
   3.621 -===================================================================
   3.622 ---- qemu-0.9.1.orig/hw/pci.c	2008-01-06 19:38:42.000000000 +0000
   3.623 -+++ qemu-0.9.1/hw/pci.c	2008-02-07 13:36:37.000000000 +0000
   3.624 -@@ -25,6 +25,7 @@
   3.625 - #include "pci.h"
   3.626 - #include "console.h"
   3.627 - #include "net.h"
   3.628 -+#include "pc.h"
   3.629 - 
   3.630 - //#define DEBUG_PCI
   3.631 - 
   3.632 -@@ -638,9 +639,11 @@
   3.633 -         pci_rtl8139_init(bus, nd, devfn);
   3.634 -     } else if (strcmp(nd->model, "pcnet") == 0) {
   3.635 -         pci_pcnet_init(bus, nd, devfn);
   3.636 -+    } else if (strcmp(nd->model, "virtio") == 0) {
   3.637 -+       virtio_net_init(bus, nd, devfn);
   3.638 -     } else if (strcmp(nd->model, "?") == 0) {
   3.639 -         fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
   3.640 --                        " ne2k_pci pcnet rtl8139\n");
   3.641 -+                        " ne2k_pci pcnet rtl8139 virtio\n");
   3.642 -         exit (1);
   3.643 -     } else {
   3.644 -         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
   3.645 -Index: qemu-0.9.1/hw/virtio-net.c
   3.646 -===================================================================
   3.647 ---- /dev/null	1970-01-01 00:00:00.000000000 +0000
   3.648 -+++ qemu-0.9.1/hw/virtio-net.c	2008-02-07 13:36:37.000000000 +0000
   3.649 -@@ -0,0 +1,178 @@
   3.650 -+/*
   3.651 -+ * Virtio Network Device
   3.652 -+ *
   3.653 -+ * Copyright IBM, Corp. 2007
   3.654 -+ *
   3.655 -+ * Authors:
   3.656 -+ *  Anthony Liguori   <address@hidden>
   3.657 -+ *
   3.658 -+ * This work is licensed under the terms of the GNU GPL, version 2.  See
   3.659 -+ * the COPYING file in the top-level directory.
   3.660 -+ *
   3.661 -+ */
   3.662 -+
   3.663 -+#include "virtio.h"
   3.664 -+#include "net.h"
   3.665 -+#include "pc.h"
   3.666 -+
   3.667 -+/* from Linux's virtio_net.h */
   3.668 -+
   3.669 -+/* The ID for virtio_net */
   3.670 -+#define VIRTIO_ID_NET  1
   3.671 -+
   3.672 -+/* The feature bitmap for virtio net */
   3.673 -+#define VIRTIO_NET_F_NO_CSUM   0
   3.674 -+#define VIRTIO_NET_F_TSO4      1
   3.675 -+#define VIRTIO_NET_F_UFO       2
   3.676 -+#define VIRTIO_NET_F_TSO4_ECN  3
   3.677 -+#define VIRTIO_NET_F_TSO6      4
   3.678 -+#define VIRTIO_NET_F_MAC       5
   3.679 -+
   3.680 -+/* The config defining mac address (6 bytes) */
   3.681 -+struct virtio_net_config
   3.682 -+{
   3.683 -+    uint8_t mac[6];
   3.684 -+} __attribute__((packed));
   3.685 -+
   3.686 -+/* This is the first element of the scatter-gather list.  If you don't
   3.687 -+ * specify GSO or CSUM features, you can simply ignore the header. */
   3.688 -+struct virtio_net_hdr
   3.689 -+{
   3.690 -+#define VIRTIO_NET_HDR_F_NEEDS_CSUM    1       // Use csum_start, csum_offset
   3.691 -+    uint8_t flags;
   3.692 -+#define VIRTIO_NET_HDR_GSO_NONE                0       // Not a GSO frame
   3.693 -+#define VIRTIO_NET_HDR_GSO_TCPV4       1       // GSO frame, IPv4 TCP (TSO)
   3.694 -+/* FIXME: Do we need this?  If they said they can handle ECN, do they care? */
   3.695 -+#define VIRTIO_NET_HDR_GSO_TCPV4_ECN   2       // GSO frame, IPv4 TCP w/ ECN
   3.696 -+#define VIRTIO_NET_HDR_GSO_UDP         3       // GSO frame, IPv4 UDP (UFO)
   3.697 -+#define VIRTIO_NET_HDR_GSO_TCPV6       4       // GSO frame, IPv6 TCP
   3.698 -+    uint8_t gso_type;
   3.699 -+    uint16_t gso_size;
   3.700 -+    uint16_t csum_start;
   3.701 -+    uint16_t csum_offset;
   3.702 -+};
   3.703 -+
   3.704 -+typedef struct VirtIONet
   3.705 -+{
   3.706 -+    VirtIODevice vdev;
   3.707 -+    uint8_t mac[6];
   3.708 -+    VirtQueue *rx_vq;
   3.709 -+    VirtQueue *tx_vq;
   3.710 -+    VLANClientState *vc;
   3.711 -+    int can_receive;
   3.712 -+} VirtIONet;
   3.713 -+
   3.714 -+static VirtIONet *to_virtio_net(VirtIODevice *vdev)
   3.715 -+{
   3.716 -+    return (VirtIONet *)vdev;
   3.717 -+}
   3.718 -+
   3.719 -+static void virtio_net_update_config(VirtIODevice *vdev, uint8_t *config)
   3.720 -+{
   3.721 -+    VirtIONet *n = to_virtio_net(vdev);
   3.722 -+    struct virtio_net_config netcfg;
   3.723 -+
   3.724 -+    memcpy(netcfg.mac, n->mac, 6);
   3.725 -+    memcpy(config, &netcfg, sizeof(netcfg));
   3.726 -+}
   3.727 -+
   3.728 -+static uint32_t virtio_net_get_features(VirtIODevice *vdev)
   3.729 -+{
   3.730 -+    return (1 << VIRTIO_NET_F_MAC);
   3.731 -+}
   3.732 -+
   3.733 -+/* RX */
   3.734 -+
   3.735 -+static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
   3.736 -+{
   3.737 -+    VirtIONet *n = to_virtio_net(vdev);
   3.738 -+    n->can_receive = 1;
   3.739 -+}
   3.740 -+
   3.741 -+static int virtio_net_can_receive(void *opaque)
   3.742 -+{
   3.743 -+    VirtIONet *n = opaque;
   3.744 -+
   3.745 -+    return (n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) && n->can_receive;
   3.746 -+}
   3.747 -+
   3.748 -+static void virtio_net_receive(void *opaque, const uint8_t *buf, int size)
   3.749 -+{
   3.750 -+    VirtIONet *n = opaque;
   3.751 -+    VirtQueueElement elem;
   3.752 -+    struct virtio_net_hdr *hdr;
   3.753 -+    int offset, i;
   3.754 -+
   3.755 -+    /* FIXME: the drivers really need to set their status better */
   3.756 -+    if (n->rx_vq->vring.avail == NULL) {
   3.757 -+       n->can_receive = 0;
   3.758 -+       return;
   3.759 -+    }
   3.760 -+
   3.761 -+    if (virtqueue_pop(n->rx_vq, &elem) == 0) {
   3.762 -+       /* wait until the guest adds some rx bufs */
   3.763 -+       n->can_receive = 0;
   3.764 -+       return;
   3.765 -+    }
   3.766 -+
   3.767 -+    hdr = (void *)elem.in_sg[0].iov_base;
   3.768 -+    hdr->flags = 0;
   3.769 -+    hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
   3.770 -+
   3.771 -+    /* copy in packet.  ugh */
   3.772 -+    offset = 0;
   3.773 -+    i = 1;
   3.774 -+    while (offset < size && i < elem.in_num) {
   3.775 -+       int len = MIN(elem.in_sg[i].iov_len, size - offset);
   3.776 -+       memcpy(elem.in_sg[i].iov_base, buf + offset, len);
   3.777 -+       offset += len;
   3.778 -+       i++;
   3.779 -+    }
   3.780 -+
   3.781 -+    /* signal other side */
   3.782 -+    virtqueue_push(n->rx_vq, &elem, sizeof(*hdr) + offset);
   3.783 -+    virtio_notify(&n->vdev, n->rx_vq);
   3.784 -+}
   3.785 -+
   3.786 -+/* TX */
   3.787 -+static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq)
   3.788 -+{
   3.789 -+    VirtIONet *n = to_virtio_net(vdev);
   3.790 -+    VirtQueueElement elem;
   3.791 -+
   3.792 -+    while (virtqueue_pop(vq, &elem)) {
   3.793 -+       int i;
   3.794 -+       size_t len = 0;
   3.795 -+
   3.796 -+       /* ignore the header for now */
   3.797 -+       for (i = 1; i < elem.out_num; i++) {
   3.798 -+           qemu_send_packet(n->vc, elem.out_sg[i].iov_base,
   3.799 -+                            elem.out_sg[i].iov_len);
   3.800 -+           len += elem.out_sg[i].iov_len;
   3.801 -+       }
   3.802 -+
   3.803 -+       virtqueue_push(vq, &elem, sizeof(struct virtio_net_hdr) + len);
   3.804 -+       virtio_notify(&n->vdev, vq);
   3.805 -+    }
   3.806 -+}
   3.807 -+
   3.808 -+void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
   3.809 -+{
   3.810 -+    VirtIONet *n;
   3.811 -+
   3.812 -+    n = (VirtIONet *)virtio_init_pci(bus, "virtio-net", 6900, 0x1000,
   3.813 -+                                    0, VIRTIO_ID_NET,
   3.814 -+                                    0x02, 0x00, 0x00,
   3.815 -+                                    6, sizeof(VirtIONet));
   3.816 -+
   3.817 -+    n->vdev.update_config = virtio_net_update_config;
   3.818 -+    n->vdev.get_features = virtio_net_get_features;
   3.819 -+    n->rx_vq = virtio_add_queue(&n->vdev, 512, virtio_net_handle_rx);
   3.820 -+    n->tx_vq = virtio_add_queue(&n->vdev, 128, virtio_net_handle_tx);
   3.821 -+    n->can_receive = 0;
   3.822 -+    memcpy(n->mac, nd->macaddr, 6);
   3.823 -+    n->vc = qemu_new_vlan_client(nd->vlan, virtio_net_receive,
   3.824 -+                                virtio_net_can_receive, n);
   3.825 -+
   3.826 -+    return &n->vdev;
   3.827 -+}
   3.828 -Index: qemu-0.9.1/Makefile.target
   3.829 -===================================================================
   3.830 ---- qemu-0.9.1.orig/Makefile.target	2008-02-07 13:36:37.000000000 +0000
   3.831 -+++ qemu-0.9.1/Makefile.target	2008-02-07 13:38:53.000000000 +0000
   3.832 -@@ -437,7 +437,7 @@
   3.833 - VL_OBJS += rtl8139.o
   3.834 - 
   3.835 - # virtio devices
   3.836 --VL_OBJS += virtio.o virtio-net.o
   3.837 -+VL_OBJS += virtio.o virtio-net.o virtio-blk.o
   3.838 - 
   3.839 - ifeq ($(TARGET_BASE_ARCH), i386)
   3.840 - # Hardware support
   3.841 -Index: qemu-0.9.1/hw/pc.c
   3.842 -===================================================================
   3.843 ---- qemu-0.9.1.orig/hw/pc.c	2008-01-06 19:38:42.000000000 +0000
   3.844 -+++ qemu-0.9.1/hw/pc.c	2008-02-07 13:38:53.000000000 +0000
   3.845 -@@ -1008,6 +1008,18 @@
   3.846 - 	    }
   3.847 -         }
   3.848 -     }
   3.849 -+
   3.850 -+    /* Add virtio block devices */
   3.851 -+    if (pci_enabled) {
   3.852 -+       int index;
   3.853 -+       int unit_id = 0;
   3.854 -+
   3.855 -+       while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
   3.856 -+           virtio_blk_init(pci_bus, 0x5002, 0x2258,
   3.857 -+                           drives_table[index].bdrv);
   3.858 -+           unit_id++;
   3.859 -+       }
   3.860 -+    }
   3.861 - }
   3.862 - 
   3.863 - static void pc_init_pci(int ram_size, int vga_ram_size,
   3.864 -Index: qemu-0.9.1/hw/pc.h
   3.865 -===================================================================
   3.866 ---- qemu-0.9.1.orig/hw/pc.h	2008-02-07 13:36:37.000000000 +0000
   3.867 -+++ qemu-0.9.1/hw/pc.h	2008-02-07 13:38:53.000000000 +0000
   3.868 -@@ -147,4 +147,8 @@
   3.869 - void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
   3.870 - 
   3.871 - 
   3.872 -+/* virtio-blk.h */
   3.873 -+void *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,
   3.874 -+                     BlockDriverState *bs);
   3.875 -+
   3.876 - #endif
   3.877 -Index: qemu-0.9.1/hw/virtio-blk.c
   3.878 -===================================================================
   3.879 ---- /dev/null	1970-01-01 00:00:00.000000000 +0000
   3.880 -+++ qemu-0.9.1/hw/virtio-blk.c	2008-02-07 13:38:53.000000000 +0000
   3.881 -@@ -0,0 +1,163 @@
   3.882 -+/*
   3.883 -+ * Virtio Block Device
   3.884 -+ *
   3.885 -+ * Copyright IBM, Corp. 2007
   3.886 -+ *
   3.887 -+ * Authors:
   3.888 -+ *  Anthony Liguori   <address@hidden>
   3.889 -+ *
   3.890 -+ * This work is licensed under the terms of the GNU GPL, version 2.  See
   3.891 -+ * the COPYING file in the top-level directory.
   3.892 -+ *
   3.893 -+ */
   3.894 -+
   3.895 -+#include "virtio.h"
   3.896 -+#include "block.h"
   3.897 -+#include "pc.h"
   3.898 -+
   3.899 -+/* from Linux's linux/virtio_blk.h */
   3.900 -+
   3.901 -+/* The ID for virtio_block */
   3.902 -+#define VIRTIO_ID_BLOCK        2
   3.903 -+
   3.904 -+/* Feature bits */
   3.905 -+#define VIRTIO_BLK_F_BARRIER   0       /* Does host support barriers? */
   3.906 -+#define VIRTIO_BLK_F_SIZE_MAX  1       /* Indicates maximum segment size */
   3.907 -+#define VIRTIO_BLK_F_SEG_MAX   2       /* Indicates maximum # of segments */
   3.908 -+
   3.909 -+struct virtio_blk_config
   3.910 -+{
   3.911 -+    uint64_t capacity;
   3.912 -+    uint32_t size_max;
   3.913 -+    uint32_t seg_max;
   3.914 -+};
   3.915 -+
   3.916 -+/* These two define direction. */
   3.917 -+#define VIRTIO_BLK_T_IN                0
   3.918 -+#define VIRTIO_BLK_T_OUT       1
   3.919 -+
   3.920 -+/* This bit says it's a scsi command, not an actual read or write. */
   3.921 -+#define VIRTIO_BLK_T_SCSI_CMD  2
   3.922 -+
   3.923 -+/* Barrier before this op. */
   3.924 -+#define VIRTIO_BLK_T_BARRIER   0x80000000
   3.925 -+
   3.926 -+/* This is the first element of the read scatter-gather list. */
   3.927 -+struct virtio_blk_outhdr
   3.928 -+{
   3.929 -+    /* VIRTIO_BLK_T* */
   3.930 -+    uint32_t type;
   3.931 -+    /* io priority. */
   3.932 -+    uint32_t ioprio;
   3.933 -+    /* Sector (ie. 512 byte offset) */
   3.934 -+    uint64_t sector;
   3.935 -+    /* Where to put reply. */
   3.936 -+    uint64_t id;
   3.937 -+};
   3.938 -+
   3.939 -+#define VIRTIO_BLK_S_OK                0
   3.940 -+#define VIRTIO_BLK_S_IOERR     1
   3.941 -+#define VIRTIO_BLK_S_UNSUPP    2
   3.942 -+
   3.943 -+/* This is the first element of the write scatter-gather list */
   3.944 -+struct virtio_blk_inhdr
   3.945 -+{
   3.946 -+    unsigned char status;
   3.947 -+};
   3.948 -+
   3.949 -+typedef struct VirtIOBlock
   3.950 -+{
   3.951 -+    VirtIODevice vdev;
   3.952 -+    BlockDriverState *bs;
   3.953 -+} VirtIOBlock;
   3.954 -+
   3.955 -+static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
   3.956 -+{
   3.957 -+    return (VirtIOBlock *)vdev;
   3.958 -+}
   3.959 -+
   3.960 -+static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
   3.961 -+{
   3.962 -+    VirtIOBlock *s = to_virtio_blk(vdev);
   3.963 -+    VirtQueueElement elem;
   3.964 -+    unsigned int count;
   3.965 -+
   3.966 -+    while ((count = virtqueue_pop(vq, &elem)) != 0) {
   3.967 -+       struct virtio_blk_inhdr *in;
   3.968 -+       struct virtio_blk_outhdr *out;
   3.969 -+       unsigned int wlen;
   3.970 -+       off_t off;
   3.971 -+       int i;
   3.972 -+
   3.973 -+       out = (void *)elem.out_sg[0].iov_base;
   3.974 -+       in = (void *)elem.in_sg[elem.in_num - 1].iov_base;
   3.975 -+       off = out->sector;
   3.976 -+
   3.977 -+       if (out->type & VIRTIO_BLK_T_SCSI_CMD) {
   3.978 -+           wlen = sizeof(*in);
   3.979 -+           in->status = VIRTIO_BLK_S_UNSUPP;
   3.980 -+       } else if (out->type & VIRTIO_BLK_T_OUT) {
   3.981 -+           wlen = sizeof(*in);
   3.982 -+
   3.983 -+           for (i = 1; i < elem.out_num; i++) {
   3.984 -+               bdrv_write(s->bs, off,
   3.985 -+                          elem.out_sg[i].iov_base,
   3.986 -+                          elem.out_sg[i].iov_len / 512);
   3.987 -+               off += elem.out_sg[i].iov_len / 512;
   3.988 -+           }
   3.989 -+
   3.990 -+           in->status = VIRTIO_BLK_S_OK;
   3.991 -+       } else {
   3.992 -+           wlen = sizeof(*in);
   3.993 -+
   3.994 -+           for (i = 0; i < elem.in_num - 1; i++) {
   3.995 -+               bdrv_read(s->bs, off,
   3.996 -+                         elem.in_sg[i].iov_base,
   3.997 -+                         elem.in_sg[i].iov_len / 512);
   3.998 -+               off += elem.in_sg[i].iov_len / 512;
   3.999 -+               wlen += elem.in_sg[i].iov_len;
  3.1000 -+           }
  3.1001 -+
  3.1002 -+           in->status = VIRTIO_BLK_S_OK;
  3.1003 -+       }
  3.1004 -+
  3.1005 -+       virtqueue_push(vq, &elem, wlen);
  3.1006 -+       virtio_notify(vdev, vq);
  3.1007 -+    }
  3.1008 -+}
  3.1009 -+
  3.1010 -+static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
  3.1011 -+{
  3.1012 -+    VirtIOBlock *s = to_virtio_blk(vdev);
  3.1013 -+    struct virtio_blk_config blkcfg;
  3.1014 -+    int64_t capacity;
  3.1015 -+
  3.1016 -+    bdrv_get_geometry(s->bs, &capacity);
  3.1017 -+    blkcfg.capacity = capacity;
  3.1018 -+    blkcfg.seg_max = 128 - 2;
  3.1019 -+    memcpy(config, &blkcfg, sizeof(blkcfg));
  3.1020 -+}
  3.1021 -+
  3.1022 -+static uint32_t virtio_blk_get_features(VirtIODevice *vdev)
  3.1023 -+{
  3.1024 -+    return (1 << VIRTIO_BLK_F_SEG_MAX);
  3.1025 -+}
  3.1026 -+
  3.1027 -+void *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,
  3.1028 -+                     BlockDriverState *bs)
  3.1029 -+{
  3.1030 -+    VirtIOBlock *s;
  3.1031 -+
  3.1032 -+    s = (VirtIOBlock *)virtio_init_pci(bus, "virtio-blk", 6900, 0x1001,
  3.1033 -+                                      0, VIRTIO_ID_BLOCK,
  3.1034 -+                                      0x01, 0x80, 0x00,
  3.1035 -+                                      16, sizeof(VirtIOBlock));
  3.1036 -+
  3.1037 -+    s->vdev.update_config = virtio_blk_update_config;
  3.1038 -+    s->vdev.get_features = virtio_blk_get_features;
  3.1039 -+    s->bs = bs;
  3.1040 -+
  3.1041 -+    virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output);
  3.1042 -+
  3.1043 -+    return &s->vdev;
  3.1044 -+}
  3.1045 -Index: qemu-0.9.1/sysemu.h
  3.1046 -===================================================================
  3.1047 ---- qemu-0.9.1.orig/sysemu.h	2008-01-06 19:38:42.000000000 +0000
  3.1048 -+++ qemu-0.9.1/sysemu.h	2008-02-07 13:38:53.000000000 +0000
  3.1049 -@@ -117,7 +117,7 @@
  3.1050 - #endif
  3.1051 - 
  3.1052 - typedef enum {
  3.1053 --    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD
  3.1054 -+    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO
  3.1055 - } BlockInterfaceType;
  3.1056 - 
  3.1057 - typedef struct DriveInfo {
  3.1058 -Index: qemu-0.9.1/vl.c
  3.1059 -===================================================================
  3.1060 ---- qemu-0.9.1.orig/vl.c	2008-01-06 19:38:42.000000000 +0000
  3.1061 -+++ qemu-0.9.1/vl.c	2008-02-07 13:40:52.000000000 +0000
  3.1062 -@@ -4953,6 +4953,9 @@
  3.1063 - 	} else if (!strcmp(buf, "sd")) {
  3.1064 - 	    type = IF_SD;
  3.1065 -             max_devs = 0;
  3.1066 -+	} else if (!strcmp(buf, "virtio")) {
  3.1067 -+	    type = IF_VIRTIO;
  3.1068 -+            max_devs = 0;
  3.1069 - 	} else {
  3.1070 -             fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);
  3.1071 -             return -1;
  3.1072 -@@ -5141,6 +5144,7 @@
  3.1073 -         break;
  3.1074 -     case IF_PFLASH:
  3.1075 -     case IF_MTD:
  3.1076 -+    case IF_VIRTIO:
  3.1077 -         break;
  3.1078 -     }
  3.1079 -     if (!file[0])
     4.1 --- a/xarchive/stuff/slitaz-wrap.sh	Mon Oct 20 20:17:03 2014 +0200
     4.2 +++ b/xarchive/stuff/slitaz-wrap.sh	Tue Oct 21 12:15:20 2014 +0200
     4.3 @@ -38,13 +38,17 @@
     4.4  ISO_EXTS="iso"
     4.5  SQUASHFS_EXTS="sfs sqfs squashfs"
     4.6  CROMFS_EXTS="cfs cromfs"
     4.7 -FS_EXTS="ext2 ext3 dos fat vfat xfs fd fs loop"
     4.8 +FAT_EXTS="dos fat vfat"
     4.9 +EXT2_EXTS="ext2 ext3 ext4"
    4.10 +FS_EXTS="$EXT2_EXTS $FAT_EXTS xfs fd fs loop"
    4.11  CLOOP_EXTS="cloop"
    4.12  RAR_EXTS="rar cbr"
    4.13  LHA_EXTS="lha lzh lzs"
    4.14  LZO_EXTS="lzo"
    4.15  ARJ_EXTS="arj pak arc j uc2 zoo"
    4.16 -_7Z_EXTS="7z bcj bcj2"
    4.17 +_7Z_EXTS="7z bcj bcj2 wim $BZIP2_EXTS $ZIP_EXTS $XZ_EXTS"
    4.18 +_7Z_EXTS_X="chm cramfs dmg hfs mbr msi nsis ntfs udf vhd xar arj cab lzh rar \
    4.19 +udf cpio $ISO_EXTS $FAT_EXTS $SQUASHFS_EXTS"
    4.20  
    4.21  while read var progs; do
    4.22  	eval $var=""
    4.23 @@ -310,7 +314,7 @@
    4.24  rar		$RAR_EXTS
    4.25  unace		ace
    4.26  arj		$ARJ_EXTS
    4.27 -7zr		$_7Z_EXTS
    4.28 +7zr		$_7Z_EXTS $_7Z_EXTS_X
    4.29  lha		$LHA_EXTS
    4.30  lzop		$LZO_EXTS
    4.31  cabextract	cab
    4.32 @@ -513,7 +517,7 @@
    4.33  lzop		-x		N/A		$LZO_EXTS
    4.34  rar		x\ -o-\ -p-	x\ -o-		$RAR_EXTS
    4.35  arj		x\ -y		x\ -y\ -g?	$ARJ_EXTS
    4.36 -7zr		x\ -y\ -p-	x\ -y		$_7Z_EXTS
    4.37 +7zr		x\ -y\ -p-	x\ -y		$_7Z_EXTS $_7Z_EXTS_X
    4.38  unace		N/A		x\ -o\ -y	ace
    4.39  cabextract	-q		N/A		cab
    4.40  EOT