Merge remote-tracking branch 'origin/master' into pci
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 14 Jun 2011 14:51:11 +0000 (17:51 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 15 Jun 2011 15:27:15 +0000 (18:27 +0300)
Conflicts:
hw/virtio-pci.c

21 files changed:
1  2 
exec.c
hw/9pfs/virtio-9p-device.c
hw/ac97.c
hw/acpi_piix4.c
hw/eepro100.c
hw/ide/ich.c
hw/lsi53c895a.c
hw/msi.c
hw/msix.c
hw/pc_piix.c
hw/pci.c
hw/pci.h
hw/pci_regs.h
hw/pcie_aer.c
hw/piix_pci.c
hw/qxl.c
hw/rtl8139.c
hw/usb-ohci.c
hw/usb-uhci.c
hw/virtio-pci.c
hw/virtio-pci.h

diff --cc exec.c
Simple merge
index 0000000,a2b6acc..f235236
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,173 +1,173 @@@
 -    virtio_init_pci(proxy, vdev,
 -                    PCI_VENDOR_ID_REDHAT_QUMRANET,
 -                    0x1009,
 -                    0x2,
 -                    0x00);
+ /*
+  * Virtio 9p backend
+  *
+  * Copyright IBM, Corp. 2010
+  *
+  * Authors:
+  *  Anthony Liguori   <aliguori@us.ibm.com>
+  *
+  * This work is licensed under the terms of the GNU GPL, version 2.  See
+  * the COPYING file in the top-level directory.
+  *
+  */
+ #include "hw/virtio.h"
+ #include "hw/pc.h"
+ #include "qemu_socket.h"
+ #include "hw/virtio-pci.h"
+ #include "virtio-9p.h"
+ #include "fsdev/qemu-fsdev.h"
+ #include "virtio-9p-xattr.h"
+ static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
+ {
+     features |= 1 << VIRTIO_9P_MOUNT_TAG;
+     return features;
+ }
+ static V9fsState *to_virtio_9p(VirtIODevice *vdev)
+ {
+     return (V9fsState *)vdev;
+ }
+ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
+ {
+     struct virtio_9p_config *cfg;
+     V9fsState *s = to_virtio_9p(vdev);
+     cfg = qemu_mallocz(sizeof(struct virtio_9p_config) +
+                         s->tag_len);
+     stw_raw(&cfg->tag_len, s->tag_len);
+     memcpy(cfg->tag, s->tag, s->tag_len);
+     memcpy(config, cfg, s->config_size);
+     qemu_free(cfg);
+ }
+ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
+  {
+     V9fsState *s;
+     int i, len;
+     struct stat stat;
+     FsTypeEntry *fse;
+     s = (V9fsState *)virtio_common_init("virtio-9p",
+                                     VIRTIO_ID_9P,
+                                     sizeof(struct virtio_9p_config)+
+                                     MAX_TAG_LEN,
+                                     sizeof(V9fsState));
+     /* initialize pdu allocator */
+     QLIST_INIT(&s->free_list);
+     for (i = 0; i < (MAX_REQ - 1); i++) {
+         QLIST_INSERT_HEAD(&s->free_list, &s->pdus[i], next);
+     }
+     s->vq = virtio_add_queue(&s->vdev, MAX_REQ, handle_9p_output);
+     fse = get_fsdev_fsentry(conf->fsdev_id);
+     if (!fse) {
+         /* We don't have a fsdev identified by fsdev_id */
+         fprintf(stderr, "Virtio-9p device couldn't find fsdev with the "
+                 "id = %s\n", conf->fsdev_id ? conf->fsdev_id : "NULL");
+         exit(1);
+     }
+     if (!fse->path || !conf->tag) {
+         /* we haven't specified a mount_tag or the path */
+         fprintf(stderr, "fsdev with id %s needs path "
+                 "and Virtio-9p device needs mount_tag arguments\n",
+                 conf->fsdev_id);
+         exit(1);
+     }
+     if (!strcmp(fse->security_model, "passthrough")) {
+         /* Files on the Fileserver set to client user credentials */
+         s->ctx.fs_sm = SM_PASSTHROUGH;
+         s->ctx.xops = passthrough_xattr_ops;
+     } else if (!strcmp(fse->security_model, "mapped")) {
+         /* Files on the fileserver are set to QEMU credentials.
+          * Client user credentials are saved in extended attributes.
+          */
+         s->ctx.fs_sm = SM_MAPPED;
+         s->ctx.xops = mapped_xattr_ops;
+     } else if (!strcmp(fse->security_model, "none")) {
+         /*
+          * Files on the fileserver are set to QEMU credentials.
+          */
+         s->ctx.fs_sm = SM_NONE;
+         s->ctx.xops = none_xattr_ops;
+     } else {
+         fprintf(stderr, "Default to security_model=none. You may want"
+                 " enable advanced security model using "
+                 "security option:\n\t security_model=passthrough\n\t "
+                 "security_model=mapped\n");
+         s->ctx.fs_sm = SM_NONE;
+         s->ctx.xops = none_xattr_ops;
+     }
+     if (lstat(fse->path, &stat)) {
+         fprintf(stderr, "share path %s does not exist\n", fse->path);
+         exit(1);
+     } else if (!S_ISDIR(stat.st_mode)) {
+         fprintf(stderr, "share path %s is not a directory\n", fse->path);
+         exit(1);
+     }
+     s->ctx.fs_root = qemu_strdup(fse->path);
+     len = strlen(conf->tag);
+     if (len > MAX_TAG_LEN) {
+         len = MAX_TAG_LEN;
+     }
+     /* s->tag is non-NULL terminated string */
+     s->tag = qemu_malloc(len);
+     memcpy(s->tag, conf->tag, len);
+     s->tag_len = len;
+     s->ctx.uid = -1;
+     s->ops = fse->ops;
+     s->vdev.get_features = virtio_9p_get_features;
+     s->config_size = sizeof(struct virtio_9p_config) +
+                         s->tag_len;
+     s->vdev.get_config = virtio_9p_get_config;
+     return &s->vdev;
+ }
+ static int virtio_9p_init_pci(PCIDevice *pci_dev)
+ {
+     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+     VirtIODevice *vdev;
+     vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
+     vdev->nvectors = proxy->nvectors;
++    virtio_init_pci(proxy, vdev);
+     /* make the actual value visible */
+     proxy->nvectors = vdev->nvectors;
+     return 0;
+ }
+ static PCIDeviceInfo virtio_9p_info = {
+     .qdev.name = "virtio-9p-pci",
+     .qdev.size = sizeof(VirtIOPCIProxy),
+     .init      = virtio_9p_init_pci,
++    .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
++    .device_id = 0x1009,
++    .revision  = VIRTIO_PCI_ABI_VERSION,
++    .class_id  = 0x2,
+     .qdev.props = (Property[]) {
+         DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
+         DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
+         DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
+         DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
+         DEFINE_PROP_END_OF_LIST(),
+     }
+ };
+ static void virtio_9p_register_devices(void)
+ {
+     pci_qdev_register(&virtio_9p_info);
+ }
+ device_init(virtio_9p_register_devices)
diff --cc hw/ac97.c
Simple merge
diff --cc hw/acpi_piix4.c
Simple merge
diff --cc hw/eepro100.c
Simple merge
diff --cc hw/ide/ich.c
@@@ -90,12 -93,14 +90,12 @@@ static int pci_ich9_ahci_init(PCIDevic
  
      qemu_register_reset(ahci_reset, d);
  
-     /* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
-     pci_register_bar_simple(&d->card, 5, 0x1000, 0, d->ahci.mem);
      msi_init(dev, 0x50, 1, true, false);
 -
 -    ahci_init(&d->ahci, &dev->qdev, 6);
      d->ahci.irq = d->card.irq[0];
  
+     /* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
+     pci_register_bar_simple(&d->card, 5, 0x1000, 0, d->ahci.mem);
      return 0;
  }
  
diff --cc hw/lsi53c895a.c
Simple merge
diff --cc hw/msi.c
Simple merge
diff --cc hw/msix.c
+++ b/hw/msix.c
@@@ -71,12 -82,12 +71,12 @@@ static int msix_add_config(struct PCIDe
  
      pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1);
      /* Table on top of BAR */
 -    pci_set_long(config + MSIX_TABLE_OFFSET, bar_size | bar_nr);
 +    pci_set_long(config + PCI_MSIX_TABLE, bar_size | bar_nr);
      /* Pending bits on top of that */
 -    pci_set_long(config + MSIX_PBA_OFFSET, (bar_size + MSIX_PAGE_PENDING) |
 +    pci_set_long(config + PCI_MSIX_PBA, (bar_size + MSIX_PAGE_PENDING) |
                   bar_nr);
      pdev->msix_cap = config_offset;
-     /* Make flags bit writeable. */
+     /* Make flags bit writable. */
      pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
            MSIX_MASKALL_MASK;
      return 0;
diff --cc hw/pc_piix.c
Simple merge
diff --cc hw/pci.c
Simple merge
diff --cc hw/pci.h
Simple merge
diff --cc hw/pci_regs.h
Simple merge
diff --cc hw/pcie_aer.c
Simple merge
diff --cc hw/piix_pci.c
@@@ -417,11 -464,15 +452,19 @@@ static PCIDeviceInfo i440fx_info[] = 
          .no_hotplug   = 1,
          .init         = i440fx_initfn,
          .config_write = i440fx_write_config,
 +        .vendor_id    = PCI_VENDOR_ID_INTEL,
 +        .device_id    = PCI_DEVICE_ID_INTEL_82441,
 +        .revision     = 0x02,
 +        .class_id     = PCI_CLASS_BRIDGE_HOST,
      },{
+         .qdev.name    = "i440FX-xen",
+         .qdev.desc    = "Host bridge",
+         .qdev.size    = sizeof(PCII440FXState),
+         .qdev.vmsd    = &vmstate_i440fx,
+         .qdev.no_user = 1,
+         .init         = i440fx_initfn,
+         .config_write = i440fx_write_config_xen,
+     },{
          .qdev.name    = "PIIX3",
          .qdev.desc    = "ISA bridge",
          .qdev.size    = sizeof(PIIX3State),
diff --cc hw/qxl.c
Simple merge
diff --cc hw/rtl8139.c
Simple merge
diff --cc hw/usb-ohci.c
Simple merge
diff --cc hw/usb-uhci.c
@@@ -1113,11 -1085,11 +1085,12 @@@ static USBPortOps uhci_port_ops = 
      .attach = uhci_attach,
      .detach = uhci_detach,
      .wakeup = uhci_wakeup,
+     .complete = uhci_async_complete,
  };
  
 -static int usb_uhci_common_initfn(UHCIState *s)
 +static int usb_uhci_common_initfn(PCIDevice *dev)
  {
 +    UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
      uint8_t *pci_conf = s->dev.config;
      int i;
  
diff --cc hw/virtio-pci.c
@@@ -74,9 -75,9 +75,6 @@@
                                           VIRTIO_PCI_CONFIG_MSI : \
                                           VIRTIO_PCI_CONFIG_NOMSI)
  
--/* Virtio ABI version, if we increment this, we break the guest driver. */
--#define VIRTIO_PCI_ABI_VERSION          0
--
  /* How many bits to shift physical queue address written to QUEUE_PFN.
   * 12 is historical, and due to x86 page size. */
  #define VIRTIO_PCI_QUEUE_ADDR_SHIFT    12
@@@ -671,7 -649,9 +648,7 @@@ static const VirtIOBindings virtio_pci_
      .vmstate_change = virtio_pci_vmstate_change,
  };
  
- static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev)
 -void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
 -                            uint16_t vendor, uint16_t device,
 -                            uint16_t class_code, uint8_t pif)
++void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev)
  {
      uint8_t *config;
      uint32_t size;
diff --cc hw/virtio-pci.h
index 0000000,a4b5fd3..b518917
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,43 +1,45 @@@
 -extern void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
 -                            uint16_t vendor, uint16_t device,
 -                            uint16_t class_code, uint8_t pif);
+ /*
+  * Virtio PCI Bindings
+  *
+  * Copyright IBM, Corp. 2007
+  * Copyright (c) 2009 CodeSourcery
+  *
+  * Authors:
+  *  Anthony Liguori   <aliguori@us.ibm.com>
+  *  Paul Brook        <paul@codesourcery.com>
+  *
+  * This work is licensed under the terms of the GNU GPL, version 2.  See
+  * the COPYING file in the top-level directory.
+  */
+ #ifndef QEMU_VIRTIO_PCI_H
+ #define QEMU_VIRTIO_PCI_H
+ #include "virtio-net.h"
+ #include "virtio-serial.h"
+ typedef struct {
+     PCIDevice pci_dev;
+     VirtIODevice *vdev;
+     uint32_t flags;
+     uint32_t addr;
+     uint32_t class_code;
+     uint32_t nvectors;
+     BlockConf block;
+     NICConf nic;
+     uint32_t host_features;
+ #ifdef CONFIG_LINUX
+     V9fsConf fsconf;
+ #endif
+     virtio_serial_conf serial;
+     virtio_net_conf net;
+     bool ioeventfd_disabled;
+     bool ioeventfd_started;
+ } VirtIOPCIProxy;
++void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
++
++/* Virtio ABI version, if we increment this, we break the guest driver. */
++#define VIRTIO_PCI_ABI_VERSION          0
++
+ #endif