From patchwork Thu Feb 4 15:28:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 77038 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o14FVQe8018083 for ; Thu, 4 Feb 2010 15:31:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932828Ab0BDPbY (ORCPT ); Thu, 4 Feb 2010 10:31:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6389 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932809Ab0BDPbY (ORCPT ); Thu, 4 Feb 2010 10:31:24 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o14FVNU4024329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Feb 2010 10:31:23 -0500 Received: from redhat.com (vpn2-9-138.ams2.redhat.com [10.36.9.138]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o14FVLYl005491 for ; Thu, 4 Feb 2010 10:31:22 -0500 Date: Thu, 4 Feb 2010 17:28:12 +0200 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org Subject: [PATCH 09/20] virtio: add status change callback Message-ID: <20100204152812.GJ8461@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 15:31:26 +0000 (UTC) diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index 6b6dafc..a4ce734 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -243,6 +243,9 @@ void s390_virtio_device_update_status(VirtIOS390Device *dev) uint32_t features; vdev->status = ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS); + if (vdev->set_status) { + vdev->set_status(vdev); + } /* Update guest supported feature bitmap */ diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c index 65239a0..19f6473 100644 --- a/hw/syborg_virtio.c +++ b/hw/syborg_virtio.c @@ -152,6 +152,8 @@ static void syborg_virtio_writel(void *opaque, target_phys_addr_t offset, vdev->status = value & 0xFF; if (vdev->status == 0) virtio_reset(vdev); + if (vdev->set_status) + vdev->set_status(vdev); break; case SYBORG_VIRTIO_INT_ENABLE: s->int_enable = value; diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 709d13e..dbb0b16 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -210,6 +210,9 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } + if (vdev->set_status) { + vdev->set_status(vdev); + } break; case VIRTIO_MSI_CONFIG_VECTOR: msix_vector_unuse(&proxy->pci_dev, vdev->config_vector); @@ -377,6 +380,9 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, if (PCI_COMMAND == address) { if (!(val & PCI_COMMAND_MASTER)) { proxy->vdev->status &= ~VIRTIO_CONFIG_S_DRIVER_OK; + if (proxy->vdev->set_status) { + proxy->vdev->set_status(proxy->vdev); + } } } diff --git a/hw/virtio.h b/hw/virtio.h index 92ad5d1..235e7c4 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -114,6 +114,7 @@ struct VirtIODevice void (*get_config)(VirtIODevice *vdev, uint8_t *config); void (*set_config)(VirtIODevice *vdev, const uint8_t *config); void (*reset)(VirtIODevice *vdev); + void (*set_status)(VirtIODevice *vdev); VirtQueue *vq; const VirtIOBindings *binding; void *binding_opaque;