From patchwork Mon Sep 17 10:00:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Voevodin X-Patchwork-Id: 184362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0DFB42C0091 for ; Mon, 17 Sep 2012 20:01:07 +1000 (EST) Received: from localhost ([::1]:60776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDY8X-00066R-2s for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 06:01:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDY8P-00066A-KX for qemu-devel@nongnu.org; Mon, 17 Sep 2012 06:00:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDY8O-00052n-5d for qemu-devel@nongnu.org; Mon, 17 Sep 2012 06:00:57 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:24529) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDY8O-00052Z-0A for qemu-devel@nongnu.org; Mon, 17 Sep 2012 06:00:56 -0400 Received: from eusync3.samsung.com (mailout4.w1.samsung.com [210.118.77.14]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAH00I3ZNUIN490@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:01:30 +0100 (BST) Received: from evvoevodinPC.rnd.samsung.ru ([106.109.8.14]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0MAH00DV7NT8FQ90@eusync3.samsung.com> for qemu-devel@nongnu.org; Mon, 17 Sep 2012 11:00:55 +0100 (BST) From: Evgeny Voevodin To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2012 14:00:38 +0400 Message-id: <1347876042-22609-9-git-send-email-e.voevodin@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1347876042-22609-1-git-send-email-e.voevodin@samsung.com> References: <1347876042-22609-1-git-send-email-e.voevodin@samsung.com> X-TM-AS-MML: No X-detected-operating-system: by eggs.gnu.org: Solaris 10 (1203?) X-Received-From: 210.118.77.14 Cc: peter.maydell@linaro.org, kyungmin.park@samsung.com, aliguori@us.ibm.com, Evgeny Voevodin Subject: [Qemu-devel] [RFC v2 08/12] hw/virtio-balloon.c: Add virtio-balloon device. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Evgeny Voevodin --- hw/virtio-balloon.c | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/virtio-balloon.h | 9 +++++++++ 2 files changed, 51 insertions(+) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index dd1a650..d6fe2aa 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -20,6 +20,7 @@ #include "cpu.h" #include "balloon.h" #include "virtio-balloon.h" +#include "virtio-transport.h" #include "kvm.h" #include "exec-memory.h" @@ -272,3 +273,44 @@ void virtio_balloon_exit(VirtIODevice *vdev) unregister_savevm(s->qdev, "virtio-balloon", s); virtio_cleanup(vdev); } + +/******************** VirtIOBaloon Device **********************/ + +static int virtio_balloondev_init(DeviceState *dev) +{ + VirtIODevice *vdev; + VirtIOBaloonState *s = VIRTIO_BALLOON_FROM_QDEV(dev); + vdev = virtio_balloon_init(dev); + if (!vdev) { + return -1; + } + + assert(s->trl != NULL); + + return virtio_call_backend_init_cb(dev, s->trl, vdev); +} + +static Property virtio_balloon_properties[] = { + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_balloon_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + dc->init = virtio_balloondev_init; + dc->props = virtio_balloon_properties; +} + +static TypeInfo virtio_balloon_info = { + .name = "virtio-balloon", + .parent = TYPE_DEVICE, + .instance_size = sizeof(VirtIOBaloonState), + .class_init = virtio_balloon_class_init, +}; + +static void virtio_baloon_register_types(void) +{ + type_register_static(&virtio_balloon_info); +} + +type_init(virtio_baloon_register_types) diff --git a/hw/virtio-balloon.h b/hw/virtio-balloon.h index 73300dd..b925186 100644 --- a/hw/virtio-balloon.h +++ b/hw/virtio-balloon.h @@ -15,8 +15,10 @@ #ifndef _QEMU_VIRTIO_BALLOON_H #define _QEMU_VIRTIO_BALLOON_H +#include "sysbus.h" #include "virtio.h" #include "pci.h" +#include "virtio-transport.h" /* from Linux's linux/virtio_balloon.h */ @@ -52,4 +54,11 @@ typedef struct VirtIOBalloonStat { uint64_t val; } QEMU_PACKED VirtIOBalloonStat; +typedef struct { + DeviceState qdev; + VirtIOTransportLink *trl; +} VirtIOBaloonState; + +#define VIRTIO_BALLOON_FROM_QDEV(dev) DO_UPCAST(VirtIOBaloonState, qdev, dev) + #endif