From patchwork Tue Apr 9 16:45:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 10891739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D8721805 for ; Tue, 9 Apr 2019 16:47:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19676285A5 for ; Tue, 9 Apr 2019 16:47:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DF5628917; Tue, 9 Apr 2019 16:47:51 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AD6DD285A5 for ; Tue, 9 Apr 2019 16:47:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDtsj-0008Cg-J7; Tue, 09 Apr 2019 16:45:57 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDtsh-0008B7-GG for xen-devel@lists.xenproject.org; Tue, 09 Apr 2019 16:45:55 +0000 X-Inumbo-ID: f01acfe4-5ae6-11e9-a469-bfc29035f770 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f01acfe4-5ae6-11e9-a469-bfc29035f770; Tue, 09 Apr 2019 16:45:53 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,330,1549929600"; d="scan'208";a="83137616" From: Anthony PERARD To: Date: Tue, 9 Apr 2019 17:45:42 +0100 Message-ID: <20190409164542.30274-10-anthony.perard@citrix.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190409164542.30274-1-anthony.perard@citrix.com> References: <20190409164542.30274-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 9/9] libxl_disk: Implement missing timeout for libxl_cdrom_insert X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since the previous patch "libxl_disk: Use ev_qmp in libxl_cdrom_insert", there are no kind of timeout anymore, add one back. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_disk.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 785c8a27e7..8ccbdf0da0 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -669,6 +669,7 @@ typedef struct { libxl__domain_qmp_lock *qmp_lock; int dm_ver; libxl__ev_qmp qmp; + libxl__ev_time time; } libxl__cdrom_insert_state; static void cdrom_insert_ejected(libxl__egc *egc, libxl__ev_qmp *, @@ -677,6 +678,9 @@ static void cdrom_insert_addfd_cb(libxl__egc *egc, libxl__ev_qmp *, const libxl__json_object *, int rc); static void cdrom_insert_inserted(libxl__egc *egc, libxl__ev_qmp *, const libxl__json_object *, int rc); +static void cdrom_insert_timout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc); static void cdrom_insert_done(libxl__egc *egc, libxl__cdrom_insert_state *cis, int rc); @@ -697,6 +701,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk, cis->disk = disk; libxl_device_disk_init(&cis->disk_saved); libxl_device_disk_copy(ctx, &cis->disk_saved, disk); + libxl__ev_time_init(&cis->time); libxl__ev_qmp_init(&cis->qmp); cis->qmp.ao = ao; cis->qmp.domid = domid; @@ -755,6 +760,11 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk, goto out; } + rc = libxl__ev_time_register_rel(ao, &cis->time, + cdrom_insert_timout, + LIBXL_HOTPLUG_TIMEOUT * 1000); + if (rc) goto out; + /* We need to eject the original image first. * JSON is not updated. */ @@ -1030,12 +1040,23 @@ static void cdrom_insert_inserted(libxl__egc *egc, cdrom_insert_done(egc, cis, rc); /* must be last */ } +static void cdrom_insert_timout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + EGC_GC; + libxl__cdrom_insert_state *cis = CONTAINER_OF(ev, *cis, time); + LOGD(ERROR, cis->domid, "cdrom insertion timed out"); + cdrom_insert_done(egc, cis, rc); +} + static void cdrom_insert_done(libxl__egc *egc, libxl__cdrom_insert_state *cis, int rc) { EGC_GC; + libxl__ev_time_deregister(gc, &cis->time); libxl__ev_qmp_dispose(gc, &cis->qmp); if (cis->qmp.payload_fd >= 0) close(cis->qmp.payload_fd); if (cis->qmp_lock) libxl__unlock_domain_qmp(cis->qmp_lock);