From patchwork Wed Apr 18 20:56:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 153604 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 EA4B9B6EE6 for ; Thu, 19 Apr 2012 07:30:53 +1000 (EST) Received: from localhost ([::1]:54046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKbxB-0000Jr-P0 for incoming@patchwork.ozlabs.org; Wed, 18 Apr 2012 16:58:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKbwS-0006oM-5K for qemu-devel@nongnu.org; Wed, 18 Apr 2012 16:57:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKbwQ-0006wm-ES for qemu-devel@nongnu.org; Wed, 18 Apr 2012 16:57:31 -0400 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:59688 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKbwQ-0006wV-7p for qemu-devel@nongnu.org; Wed, 18 Apr 2012 16:57:30 -0400 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu2) with ESMTP id q3IKvMUs019412; Wed, 18 Apr 2012 15:57:23 -0500 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id q3IKvKj6019402; Wed, 18 Apr 2012 15:57:20 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 18 Apr 2012 15:56:44 -0500 Message-Id: <1334782613-5421-6-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1334782613-5421-1-git-send-email-aliguori@us.ibm.com> References: <1334782613-5421-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Wanpeng Li , Paolo Bonzini , Anthony Liguori , Andreas Faerber , Peter Maydell Subject: [Qemu-devel] [PATCH 05/14] qdev: use wrapper for qdev_get_path 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 This makes it easier to remove it from BusInfo. Signed-off-by: Anthony Liguori --- exec.c | 4 ++-- hw/qdev.c | 16 ++++++++++++++++ hw/qdev.h | 2 ++ savevm.c | 12 ++++++------ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/exec.c b/exec.c index 77d6866..4632b24 100644 --- a/exec.c +++ b/exec.c @@ -2878,8 +2878,8 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) assert(new_block); assert(!new_block->idstr[0]); - if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { - char *id = dev->parent_bus->info->get_dev_path(dev); + if (dev) { + char *id = qdev_get_dev_path(dev); if (id) { snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id); g_free(id); diff --git a/hw/qdev.c b/hw/qdev.c index c8dda31..d265963 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -518,6 +518,22 @@ char* qdev_get_fw_dev_path(DeviceState *dev) return strdup(path); } +char *qdev_get_dev_path(DeviceState *dev) +{ + BusClass *bc; + + if (!dev->parent_bus) { + return NULL; + } + + bc = BUS_GET_CLASS(dev->parent_bus); + if (bc->get_dev_path) { + return bc->get_dev_path(dev); + } + + return NULL; +} + static char *qdev_get_type(Object *obj, Error **errp) { return g_strdup(object_get_typename(obj)); diff --git a/hw/qdev.h b/hw/qdev.h index ca8386a..fc3b50f 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -362,4 +362,6 @@ extern int qdev_hotplug; void qdev_add_properties(DeviceState *dev, Property *props); +char *qdev_get_dev_path(DeviceState *dev); + #endif diff --git a/savevm.c b/savevm.c index 2d18bab..818ddfc 100644 --- a/savevm.c +++ b/savevm.c @@ -1248,8 +1248,8 @@ int register_savevm_live(DeviceState *dev, se->is_ram = 1; } - if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { - char *id = dev->parent_bus->info->get_dev_path(dev); + if (dev) { + char *id = qdev_get_dev_path(dev); if (id) { pstrcpy(se->idstr, sizeof(se->idstr), id); pstrcat(se->idstr, sizeof(se->idstr), "/"); @@ -1292,8 +1292,8 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) SaveStateEntry *se, *new_se; char id[256] = ""; - if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { - char *path = dev->parent_bus->info->get_dev_path(dev); + if (dev) { + char *path = qdev_get_dev_path(dev); if (path) { pstrcpy(id, sizeof(id), path); pstrcat(id, sizeof(id), "/"); @@ -1334,8 +1334,8 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, se->alias_id = alias_id; se->no_migrate = vmsd->unmigratable; - if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { - char *id = dev->parent_bus->info->get_dev_path(dev); + if (dev) { + char *id = qdev_get_dev_path(dev); if (id) { pstrcpy(se->idstr, sizeof(se->idstr), id); pstrcat(se->idstr, sizeof(se->idstr), "/");