From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH v6 07/10] libxc: introduce soft reset for HVM domains Date: Wed, 20 May 2015 16:28:19 +0100 Message-ID: <555CA813.9040804@citrix.com> References: <1431510585-12544-1-git-send-email-vkuznets@redhat.com> <1431510585-12544-8-git-send-email-vkuznets@redhat.com> <555CA3CC.2080003@citrix.com> <87pp5v46oc.fsf@vitty.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yv605-0004aQ-HV for xen-devel@lists.xenproject.org; Wed, 20 May 2015 15:33:41 +0000 In-Reply-To: <87pp5v46oc.fsf@vitty.brq.redhat.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: Vitaly Kuznetsov , Julien Grall Cc: Andrew Jones , Keir Fraser , Ian Campbell , Stefano Stabellini , Andrew Cooper , Julien Grall , Ian Jackson , Olaf Hering , Tim Deegan , David Vrabel , Jan Beulich , xen-devel@lists.xenproject.org, Wei Liu , Daniel De Graaf List-Id: xen-devel@lists.xenproject.org On 20/05/15 16:20, Vitaly Kuznetsov wrote: > Julien Grall writes: > >> Hi Vitaly, >> >> On 13/05/15 10:49, Vitaly Kuznetsov wrote: >>> +int xc_domain_soft_reset(xc_interface *xch, uint32_t source_dom, >>> + uint32_t dest_dom, domid_t console_domid, >>> + unsigned long *console_mfn, domid_t store_domid, >>> + unsigned long *store_mfn) >>> +{ >>> + xc_dominfo_t old_info, new_info; >>> + int rc = 1; >>> + >>> + uint32_t hvm_buf_size = 0; >>> + uint64_t nr_trans; >>> + uint8_t *hvm_buf = NULL; >>> + unsigned long console_pfn, store_pfn, io_pfn, buffio_pfn; >>> + uint64_t hvm_params[HVM_NR_PARAMS]; >>> + xen_pfn_t sharedinfo_pfn; >>> + >>> + DPRINTF("%s: soft reset domid %u -> %u", __func__, source_dom, dest_dom); >>> + >>> + if ( xc_domain_getinfo(xch, source_dom, 1, &old_info) != 1 ) >>> + { >>> + PERROR("Could not get old domain info"); >>> + return 1; >>> + } >>> + >>> + if ( xc_domain_getinfo(xch, dest_dom, 1, &new_info) != 1 ) >>> + { >>> + PERROR("Could not get new domain info"); >>> + return 1; >>> + } >> >> xc_domain_getinfo returns the first domain ID used from dest_dom. If >> dest_dom doesn't exist it may return another domain. >> >> Therefore you have to check that the info correspond to the correct domain. > > Oh, thanks, I fixed xc_get_tot_pages() a while ago: > > commit 5dcd0dcb85941bd92336e01ae3f8c44730099c96 > Author: Vitaly Kuznetsov > Date: Tue Dec 2 16:18:08 2014 +0100 > > libxc: check in xc_get_tot_pages() that the proper domain is > reported > > but I already managed to forget that xc_domain_getinfo() needs > additional check. Its interface is a bit misleading :-( Agreed. There is multiple place in libxc and other xen related software where this function is misused. It would be worth to introduce a new xc function to return an error if it's not possible to return the info of the specified domid. Regards, -- Julien Grall