Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1187C433E2 for ; Tue, 8 Sep 2020 14:19:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3DDA229F0 for ; Tue, 8 Sep 2020 14:19:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3DDA229F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kFeSi-0003Vz-Lj; Tue, 08 Sep 2020 14:19:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kFeSh-0003Vq-Hc for xen-devel@lists.xenproject.org; Tue, 08 Sep 2020 14:19:07 +0000 X-Inumbo-ID: 78ae6911-7781-4a6f-a21b-50aab8a1a643 Received: from mail-wr1-f65.google.com (unknown [209.85.221.65]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 78ae6911-7781-4a6f-a21b-50aab8a1a643; Tue, 08 Sep 2020 14:19:06 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id c18so19279286wrm.9 for ; Tue, 08 Sep 2020 07:19:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HmLARCgfbUmx3TuN76C/0dfbls9falHWREd4x46/g+8=; b=JgihbqFoPfg5h9fsucpQJv9SC8VJRVfBDl8/bghzPAwQlwc4zc4iL+iJZcbn4ubi+5 xKML9/J6ylYUxEDGCkfJDokirMNuddhz+/Y6jMLQw7PIzE2nncs3PSrBztAhGkn2saST nHZnF+H+t4l5dFuz8i5tecv3CrUGR94btPhlO91MBYAFIGEH+9L8awfhFm6MQ6khK9mI DZRv0odVt3p+UheWANlRIFk5IAlOeSR8q3kJqcu0icVYK0xhypVwntz45dMb7PDmw70t eQfzehNBU4+lrVQN1bXBWR+LBgidnt3zMCHuRd5WeuSyikVi5LIRDx+vOnFvV1p8mcs7 96yA== X-Gm-Message-State: AOAM532rh/CZ3E+rPpoDBUmbSQ6SFS3cV7aQdCYldSeSzx7CiZVb5sfS 0JMPd9I0B38yPizYU4xBDIQ= X-Google-Smtp-Source: ABdhPJxETGfyrxsjq29H/ESpEnCrMZSbto1whAW+ydmiS800zaTSKzy6kKwMV/ntO/z9e0HmVlKjVw== X-Received: by 2002:a5d:60d0:: with SMTP id x16mr26902264wrt.196.1599574745766; Tue, 08 Sep 2020 07:19:05 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id f1sm26722526wrx.75.2020.09.08.07.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 07:19:05 -0700 (PDT) Date: Tue, 8 Sep 2020 14:19:03 +0000 From: Wei Liu To: Paul Durrant Cc: xen-devel@lists.xenproject.org, Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: Re: [PATCH 2/2] libxl: do not automatically force detach of block devices Message-ID: <20200908141903.it25fe672dltw7pm@liuwe-devbox-debian-v2> References: <20200903100537.1337-1-paul@xen.org> <20200903100537.1337-3-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903100537.1337-3-paul@xen.org> User-Agent: NeoMutt/20180716 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Thu, Sep 03, 2020 at 11:05:37AM +0100, Paul Durrant wrote: > From: Paul Durrant > > The manpage for 'xl' documents that guest co-operation is required for a (non- > forced) block-detach operation and that it may consequently fail. Currently, > however, the implementation of generic device removal means that a time-out > of a block-detach is being automatically re-tried with the force flag set > rather than failing. This patch stops such behaviour. > > Signed-off-by: Paul Durrant I'm two-minded here. On the one hand, special-casing VBD in libxl to conform to xl's behaviour seems wrong to me. On the other hand, if we want to treat all devices the same in libxl, libxl should drop its force-removal behaviour all together, and the retry behaviour would need to be implemented in xl for all devices excepts for VBD. This requires a bit of code churn and, more importantly, changes how those device removal APIs behave. In the end this effort may not worth it. If we go with the patch here, we should document this special case on libxl level somehow. Anthony and Ian, do you have any opinion on this? Wei. > --- > Cc: Ian Jackson > Cc: Wei Liu > Cc: Anthony PERARD > --- > tools/libxl/libxl_device.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c > index 0381c5d509..d17ca78848 100644 > --- a/tools/libxl/libxl_device.c > +++ b/tools/libxl/libxl_device.c > @@ -1092,7 +1092,8 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds, > > if (rc == ERROR_TIMEDOUT && > aodev->action == LIBXL__DEVICE_ACTION_REMOVE && > - !aodev->force) { > + !aodev->force && > + aodev->dev->kind != LIBXL__DEVICE_KIND_VBD) { > LOGD(DEBUG, aodev->dev->domid, "Timeout reached, initiating forced remove"); > aodev->force = 1; > libxl__initiate_device_generic_remove(egc, aodev); > @@ -1103,7 +1104,8 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds, > LOGD(ERROR, aodev->dev->domid, "unable to %s device with path %s", > libxl__device_action_to_string(aodev->action), > libxl__device_backend_path(gc, aodev->dev)); > - goto out; > + if (!aodev->force) > + goto out; > } > > device_hotplug(egc, aodev); > @@ -1319,7 +1321,8 @@ static void device_hotplug_done(libxl__egc *egc, libxl__ao_device *aodev) > device_hotplug_clean(gc, aodev); > > /* Clean xenstore if it's a disconnection */ > - if (aodev->action == LIBXL__DEVICE_ACTION_REMOVE) { > + if (aodev->action == LIBXL__DEVICE_ACTION_REMOVE && > + (aodev->force || !aodev->rc)) { > rc = libxl__device_destroy(gc, aodev->dev); > if (!aodev->rc) > aodev->rc = rc; > -- > 2.20.1 >