From patchwork Tue Jun 12 23:51:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Rogers X-Patchwork-Id: 10461359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3183D601A0 for ; Tue, 12 Jun 2018 23:53:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23804287AD for ; Tue, 12 Jun 2018 23:53:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1830728AE0; Tue, 12 Jun 2018 23:53:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AA46D287AD for ; Tue, 12 Jun 2018 23:53:31 +0000 (UTC) Received: from localhost ([::1]:58909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSt6Q-0002Vn-Vv for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Jun 2018 19:53:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSt4Y-0001j3-Ae for qemu-devel@nongnu.org; Tue, 12 Jun 2018 19:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSt4X-0006Y1-9B for qemu-devel@nongnu.org; Tue, 12 Jun 2018 19:51:34 -0400 Received: from inet-orm.provo.novell.com ([137.65.248.124]:35071 helo=mail.novell.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSt4Q-0006VR-VE; Tue, 12 Jun 2018 19:51:27 -0400 Received: from brogers1.provo.novell.com (brogers1.dnsdhcp.provo.novell.com [137.65.133.7]) by mail.novell.com with ESMTP (NOT encrypted); Tue, 12 Jun 2018 17:51:09 -0600 From: Bruce Rogers To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 12 Jun 2018 17:51:02 -0600 Message-Id: <20180612235103.12633-2-brogers@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612235103.12633-1-brogers@suse.com> References: <20180612235103.12633-1-brogers@suse.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 137.65.248.124 Subject: [Qemu-devel] [PATCH 1/2] xen: add xen disk naming for use in monitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, sstabellini@kernel.org, armbru@redhat.com, Bruce Rogers , anthony.perard@citrix.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Provide monitor naming of xen disks, including associating an attached dev_id for a BlockBackend which has legacy_dev set. Currently, only xen disks have legacy_dev set to true. Signed-off-by: Bruce Rogers --- block/block-backend.c | 5 ++++- hw/block/xen_disk.c | 15 +++++++++++++++ include/hw/xen/xen.h | 2 ++ stubs/xen-common.c | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index d55c328736..db39dfe867 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -23,6 +23,7 @@ #include "qemu/option.h" #include "trace.h" #include "migration/misc.h" +#include "hw/xen/xen.h" /* Number of coroutines to reserve per attached device model */ #define COROUTINE_POOL_RESERVATION 64 @@ -895,7 +896,9 @@ char *blk_get_attached_dev_id(BlockBackend *blk) { DeviceState *dev; - assert(!blk->legacy_dev); + if (blk->legacy_dev) { + return xen_blk_get_attached_dev_id(blk->dev); + } dev = blk->dev; if (!dev) { diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 9fbc0cdb87..fca0597d36 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -745,6 +745,7 @@ static int blk_connect(struct XenDevice *xendev) int order, ring_ref; unsigned int ring_size, max_grants; unsigned int i; + Error *errp = NULL; trace_xen_disk_connect(xendev->name); @@ -801,6 +802,13 @@ static int blk_connect(struct XenDevice *xendev) blk_ref(blkdev->blk); } blk_attach_dev_legacy(blkdev->blk, blkdev); + if (!monitor_add_blk(blkdev->blk, g_strdup(blkdev->dev), &errp)) { + xen_pv_printf(&blkdev->xendev, 0, "error: %s\n", + error_get_pretty(errp)); + error_free(errp); + return -1; + } + blkdev->file_size = blk_getlength(blkdev->blk); if (blkdev->file_size < 0) { BlockDriverState *bs = blk_bs(blkdev->blk); @@ -951,6 +959,7 @@ static void blk_disconnect(struct XenDevice *xendev) if (blkdev->blk) { blk_set_aio_context(blkdev->blk, qemu_get_aio_context()); blk_detach_dev(blkdev->blk, blkdev); + monitor_remove_blk(blkdev->blk); blk_unref(blkdev->blk); blkdev->blk = NULL; } @@ -998,6 +1007,12 @@ static void blk_event(struct XenDevice *xendev) qemu_bh_schedule(blkdev->bh); } +char *xen_blk_get_attached_dev_id(void *dev) +{ + struct XenBlkDev *blkdev = dev; + return g_strdup_printf("xen-qdisk-%i", blkdev->xendev.dev); +} + struct XenDevOps xen_blkdev_ops = { .flags = DEVOPS_FLAG_NEED_GNTDEV, .size = sizeof(struct XenBlkDev), diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 7efcdaa8fe..a201517675 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -48,4 +48,6 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length); void xen_register_framebuffer(struct MemoryRegion *mr); +char *xen_blk_get_attached_dev_id(void *dev); + #endif /* QEMU_HW_XEN_H */ diff --git a/stubs/xen-common.c b/stubs/xen-common.c index 09fce2dd36..aeac0534ac 100644 --- a/stubs/xen-common.c +++ b/stubs/xen-common.c @@ -12,3 +12,8 @@ void xenstore_store_pv_console_info(int i, Chardev *chr) { } + +char *xen_blk_get_attached_dev_id(void *dev) +{ + return g_strdup(""); +}