From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932832AbdEZANZ (ORCPT ); Thu, 25 May 2017 20:13:25 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:44703 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758760AbdEZANW (ORCPT ); Thu, 25 May 2017 20:13:22 -0400 From: Boris Ostrovsky Subject: Re: [PATCH v2 04/18] xen/pvcalls: xenbus state handling To: Stefano Stabellini , xen-devel@lists.xen.org References: <1495236179-27776-1-git-send-email-sstabellini@kernel.org> <1495236179-27776-4-git-send-email-sstabellini@kernel.org> Cc: linux-kernel@vger.kernel.org, jgross@suse.com, Stefano Stabellini Message-ID: <444d1853-6007-d3d9-e22b-7f6c6be77b05@oracle.com> Date: Thu, 25 May 2017 20:12:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1495236179-27776-4-git-send-email-sstabellini@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/19/2017 07:22 PM, Stefano Stabellini wrote: > Introduce the code to handle xenbus state changes. > > Implement the probe function for the pvcalls backend. Write the > supported versions, max-page-order and function-calls nodes to xenstore, > as required by the protocol. > > Introduce stub functions for disconnecting/connecting to a frontend. > > Signed-off-by: Stefano Stabellini > CC: boris.ostrovsky@oracle.com > CC: jgross@suse.com > --- > drivers/xen/pvcalls-back.c | 135 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 135 insertions(+) > > diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c > index 9044cf2..b4da138 100644 > --- a/drivers/xen/pvcalls-back.c > +++ b/drivers/xen/pvcalls-back.c > @@ -25,20 +25,155 @@ > #include > #include > > +#define PVCALLS_VERSIONS "1" Shouldn't this be in a header file that will be shared with frontends? > +#define MAX_RING_ORDER XENBUS_MAX_RING_GRANT_ORDER > + > struct pvcalls_back_global { > struct list_head frontends; > struct semaphore frontends_lock; > } pvcalls_back_global; > > +static int backend_connect(struct xenbus_device *dev) > +{ > + return 0; > +} > + > +static int backend_disconnect(struct xenbus_device *dev) > +{ > + return 0; > +} > + > static int pvcalls_back_probe(struct xenbus_device *dev, > const struct xenbus_device_id *id) > { > + int err; > + > + err = xenbus_printf(XBT_NIL, dev->nodename, "versions", "%s", > + PVCALLS_VERSIONS); > + if (err) { > + pr_warn("%s write out 'version' failed\n", __func__); > + return -EINVAL; err? > + } > + > + err = xenbus_printf(XBT_NIL, dev->nodename, "max-page-order", "%u", > + MAX_RING_ORDER); > + if (err) { > + pr_warn("%s write out 'max-page-order' failed\n", __func__); > + return err; > + } > + > + /* "1" means socket, connect, release, bind, listen, accept and poll*/ This comment is obsolete, or at least should refer to XENBUS_FUNCTIONS_CALLS (and is missing a space at the end). > + err = xenbus_printf(XBT_NIL, dev->nodename, "function-calls", > + XENBUS_FUNCTIONS_CALLS); > + if (err) { > + pr_warn("%s write out 'function-calls' failed\n", __func__); > + return err; > + } In case of errors we will end up with all previous entries. I think this should be done as a transaction which would be aborted in case of an error. > + > + err = xenbus_switch_state(dev, XenbusStateInitWait); > + if (err) > + return err; Not sure what to do on an error here (wrt xenstore entries). xenbus_switch_state() itself uses transactions. Are we allowed to have nested transactions? OTOH, xenbus_switch_state() never returns an error, at least now. In fact, in most cases we ignore return value. -boris > + > return 0; > } > >