From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH v1 07/10] libxl: make libxl_cd_insert "eject" + "insert" Date: Thu, 17 Jul 2014 15:20:12 +0100 Message-ID: <20140717142012.GO4913@zion.uk.xensource.com> References: <1405002745-5034-1-git-send-email-wei.liu2@citrix.com> <1405002745-5034-8-git-send-email-wei.liu2@citrix.com> <1405593875.12538.7.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1405593875.12538.7.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: ian.jackson@eu.citrix.com, Wei Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, Jul 17, 2014 at 11:44:35AM +0100, Ian Campbell wrote: [...] > > > > +/* > > + * A "cdrom insert" is always processed as "eject" + "insert", with > > + * updating JSON in between. So that we can know the current state of > > + * CDROM later when we try to retrieve domain configuration: if > > + * xenstore is "empty", then CDROM is "empty"; otherwise use the image > > + * in JSON. > > I think you could short circuit the case where the user inserts an empty > disk (AKA ejects), right now you will eject twice. (We don't have an > explicit libxl_cdrom_eject so I presume this is how it is intended to be > done). > OK. This is a valid optimisation. > I think this function also handles HVM emulated IDE CDROM, which are > semantically a bit different from PV CDROMs in that the empty drive is > still an actual thing. Not sure if/how this impacts on your handling of > the JSON though. > IMO it wouldn't impact that much. I don't actually care what type of backend it is using. I only care about whether the operation succeeds or not. > > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > > index b4f518a..f8f2ba2 100644 > > --- a/tools/libxl/libxl_internal.h > > +++ b/tools/libxl/libxl_internal.h > > @@ -3355,6 +3355,40 @@ static inline void libxl__update_config_vtpm(libxl__gc *gc, > > libxl_domain_config_dispose(&d_config); \ > > } while (0) > > > > +/* Search device list for device with the same identifier as "dev", > > + * update that device with the content pointed to by "dev". > > + */ > > +#define DEVICE_UPDATE_JSON(type, ptr, cnt, domid, dev, compare, rc) \ > > You could define this in terms of REMOVE+ADD, which would match the > behaviour of the actual operation. Slightly less efficient but less code > perhaps? > Correct, it's less efficient. But if you prefer it that way I can make it that way. I guess one extra read and one extra write won't slow down things much. Wei.