From: Michael S. Tsirkin Date: Tue, 14 Jun 2011 14:51:11 +0000 (+0300) Subject: Merge remote-tracking branch 'origin/master' into pci X-Git-Tag: v0.15.0-rc0~154^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=befeac45d4d9afb587eca9a27d975db4a7950960;p=thirdparty%2Fqemu.git Merge remote-tracking branch 'origin/master' into pci Conflicts: hw/virtio-pci.c --- befeac45d4d9afb587eca9a27d975db4a7950960 diff --cc hw/9pfs/virtio-9p-device.c index 00000000000,a2b6acc4082..f235236ea0a mode 000000,100644..100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@@ -1,0 -1,173 +1,173 @@@ + /* + * Virtio 9p backend + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Anthony Liguori + * + * 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, - PCI_VENDOR_ID_REDHAT_QUMRANET, - 0x1009, - 0x2, - 0x00); ++ 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/ide/ich.c index 976cc9244b0,6150ce3343f..054e0734e43 --- a/hw/ide/ich.c +++ b/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/msix.c index 28559b6d600,af40e266fe9..03d7becaafb --- a/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/piix_pci.c index b927f01bdc0,85a320e7297..e0da0bdf911 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@@ -417,10 -464,14 +452,18 @@@ 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", diff --cc hw/usb-uhci.c index 536c24c825b,c0de05b4ffe..872a995575a --- a/hw/usb-uhci.c +++ b/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 index b86c4416235,c0183510957..b3e7ba5d126 --- a/hw/virtio-pci.c +++ b/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 00000000000,a4b5fd30e14..b5189172de0 mode 000000,100644..100644 --- a/hw/virtio-pci.h +++ b/hw/virtio-pci.h @@@ -1,0 -1,43 +1,45 @@@ + /* + * Virtio PCI Bindings + * + * Copyright IBM, Corp. 2007 + * Copyright (c) 2009 CodeSourcery + * + * Authors: + * Anthony Liguori + * Paul Brook + * + * 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; + -extern 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); ++ ++/* Virtio ABI version, if we increment this, we break the guest driver. */ ++#define VIRTIO_PCI_ABI_VERSION 0 ++ + #endif