From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uju0q-0006GR-AM for qemu-devel@nongnu.org; Tue, 04 Jun 2013 12:23:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uju0o-00068n-ON for qemu-devel@nongnu.org; Tue, 04 Jun 2013 12:23:08 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:56289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uju0o-00068X-Jf for qemu-devel@nongnu.org; Tue, 04 Jun 2013 12:23:06 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jun 2013 12:23:05 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 03C8F38C8045 for ; Tue, 4 Jun 2013 12:23:03 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r54GN24B62652436 for ; Tue, 4 Jun 2013 12:23:02 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r54GN0EZ031838 for ; Tue, 4 Jun 2013 13:23:02 -0300 From: Jesse Larrew Date: Tue, 4 Jun 2013 11:22:43 -0500 Message-Id: <1370362965-3937-2-git-send-email-jlarrew@linux.vnet.ibm.com> In-Reply-To: <1370362965-3937-1-git-send-email-jlarrew@linux.vnet.ibm.com> References: <1370362965-3937-1-git-send-email-jlarrew@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, Jesse Larrew , mdroth@linux.vnet.ibm.com, fred.konrad@greensocs.com Virtio devices are initialized prior to plugging them into a bus. However, other initializations (such as host_features) don't occur until after the device is plugged into the bus. If a device needs to modify it's configuration based on host_features, then it needs to be notified when the bus is attached and host_features is available for use. This patch extends struct VirtioDeviceClass to add a bus_plugged() method. If implemented by a device, it will be called after the device is attached to a bus. Signed-off-by: Jesse Larrew --- hw/virtio/virtio.c | 3 +++ include/hw/virtio/virtio.h | 1 + 2 files changed, 4 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8176c14..96735fa 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1114,6 +1114,9 @@ static int virtio_device_init(DeviceState *qdev) return -1; } virtio_bus_plug_device(vdev); + if (k->bus_plugged) { + k->bus_plugged(vdev); + } return 0; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 6afdfd8..31fad30 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -156,6 +156,7 @@ typedef struct VirtioDeviceClass { * must mask in frontend instead. */ void (*guest_notifier_mask)(VirtIODevice *vdev, int n, bool mask); + void (*bus_plugged)(VirtIODevice *vdev); } VirtioDeviceClass; void virtio_init(VirtIODevice *vdev, const char *name, -- 1.7.11.7