From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v2 11/18] libxl: synchronise configuration when we hotplug a device Date: Wed, 27 Aug 2014 03:00:39 +0100 Message-ID: <1409104839.28009.73.camel@citrix.com> References: <1406744639-28782-1-git-send-email-wei.liu2@citrix.com> <1406744639-28782-12-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1406744639-28782-12-git-send-email-wei.liu2@citrix.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: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Wed, 2014-07-30 at 19:23 +0100, Wei Liu wrote: > As those routines are called both during domain creation and device > hotplug, we add a flag to indicate whether we need to update JSON > config. This flag is only set to true when we hotplug a device. We > cannot update JSON config during domain creation as JSON config is > committed to disk only when domain creation finishes. Rather than carry a flag around did you consider just checking for the presence of the file? I think you indicated in an earlier patch that you were going to treat lack of the file as meaning creation/destruction was happening. > + * They take 6 parameters: > + * type: the type of the device, say nic, vtpm, disk, pci etc > + * ptr: the pointer to array inside libxl_domain_config To the array or to a specific element of the array? I think the latter. You might also want to indicate that the ptr must be of type libxl_device_#type? > + * cnt: the counter of array I think you either mean index or length, I suspect the former? > + * domid: domain id of target domain > + * dev: the device that is to be added / removed / updated > + * compare: the COMPARE_* macro used to compare @dev's identifier to > + * those in the array pointed to by @ptr > + * > + * Return 0 if no error occurs, ERROR_* otherwise. > + * > + * For most device types (nic, vtpm), the array name @ptr and array > + * counter @cnt can be derived from @type, pci device being the > + * exception, hence we need to have @ptr and @cnt. You could get away with a single variable naming the Array ("nics", "pcidevs") to which you paste num_ on the front when you need cnt. Ian.