[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/7] tools: Create xc_domain_getinfo_single()


  • To: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 27 Apr 2023 10:53:34 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2hxBeI8ESlA1z5ElHS4zF+BjfYcILnTjOYa7geTM/DA=; b=kBIHsMogI/hCfQOGg+Wdi0/yIKHzNM/hFcHngw/Z4URZBDH2hCjcz4H25LSfiTmCR2FVPsH1cTn+aNmcvoa1CERHIH+vLBNgurptg8TCdkio7XDpvPoY4RRc060rjhAletVqQvhW5nD8OFV6C2Hxp1ygxvWQfu+ay343ukZmL04oIWr9Q2Tbu+QxDzatWGiBP+V+KNOzDAop6XHj680GSzy1JWqoHu4RUuvEsNtRwPIW2NwACb0+IWiR78wh9jzDDz8XcPfqV+7IGdtVK6oZOO40/7vtlLcYXKo4fFIQjfvflWHV7qgyEyFAWEfmwho39zX0ib/JFRaJ8cB36MiGQA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIROtLFGVcvUIfhD8n2f3vVOkFb01LGbOL906wTwI3WRPREy9UNvtbQyFFWBcaYHSi294+Mdo+zV1Tv8VAYdGrcpu3e92m/RabLfPlaztnvCpk0gigAido3jJfGK2w9DibRfto8z65/kJ+NiVNFJxo1kSvDDQ115kYvL+BYP8Go1aImaNlYjWOQitiOHBpq2feHhyao+r0JMxLocePY+WWiPbKhFjxyujuNJQO+6orHmokNKtCUKFiKf8zxUIQs0XTlrS71KwnhxfKFOqdzcN0W5OO8EVP9+//9BYzXJSsvg+nBfF3jbTonnTRaU5QKAZFUE180sREIsIhn+cTDfzA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 27 Apr 2023 09:53:58 +0000
  • Ironport-data: A9a23:QmMGRq7CEGOR1OJOcQ55dgxRtP7GchMFZxGqfqrLsTDasY5as4F+v mdKXjzTbPbfMzb1KIpwOo239UkHuZeHx9JhTwBuqHtgHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+7ZwehBtC5gZlPawR4weE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5mq P0GGhlVViy/ifu/+pOhbeNqr9pkBZy+VG8fkikIITDxK98DGMiGaYOVoNhS0XE3m9xEGuvYa 4wBcz1zYR/cYhpJfFAKFJY5m+TujX76G9FagAvN+exrvC6MlEooiOmF3Nn9I7RmQe18mEqCq 32A1GP+GhwAb/SUyCaf82LqjejK9c/+cNtKSe3hpqA72jV/wEQRGDAyRX2Si8W9k2S/YvB7E FA58G0X+P1aGEuDC4OVsweDiHeAsxwVXdZKFKsk4QWJx6jTyw2dAXUICDVGbbQOpMIwADAny FKNt9foHiB09q2YT2qH8bWZpi/0PjIaRUcdYQcUQA1D5MPsyKkxgQjIVc1LC7Oug5v+HjSY/ tyRhC03hrFWh8hU0ay+pAjDm2j1/smPSRMp7ALKWG7j9hl+eIOue42v7x7c8OpEK4GaCFKGu RDohvSj0QzHNrnV/ATlfQnHNOvBCyqtWNEEvWNSIg==
  • Ironport-hdrordr: A9a23:DjjAgK15/32CD7NbAKXNNgqjBIgkLtp133Aq2lEZdPUzSKClfq GV88jzsCWetN9/Yh8dcLy7WZVoI0mslqKdkLNwAV7KZmCP0gaVxepZnOnfKlPbakrD398Y+a B8c7VvTP3cZGIK6/oSOTPIdurIFuP3lJyVuQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26/04/2023 3:59 pm, Alejandro Vallejo wrote:
> It's a stricter version of xc_domain_getinfo() where the returned domid
> always matches the requested domid or the error code shows an error instead.
> A few patches ahead usages of xc_domain_getinfo() are removed until only
> xc_domain_getinfo_single() and xc_domain_getinfolist() remain.
>
> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
> ---
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Cc: Wei Liu <wl@xxxxxxx>
> Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> Cc: Juergen Gross <jgross@xxxxxxxx>
> ---
>  tools/include/xenctrl.h     | 16 ++++++++++++++++
>  tools/libs/ctrl/xc_domain.c | 22 ++++++++++++++++++++++
>  2 files changed, 38 insertions(+)
>
> diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
> index 90b33aa3a7..73b07955c6 100644
> --- a/tools/include/xenctrl.h
> +++ b/tools/include/xenctrl.h
> @@ -696,6 +696,22 @@ int xc_vcpu_getaffinity(xc_interface *xch,
>  int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
>                                unsigned int *guest_width);
>  
> +/**
> + * This function will return information about a single domain. It looks
> + * up the domain by the provided domid and succeeds if the domain exists
> + * and is accesible by the current domain, or fails otherwise. A buffer
> + * may optionally passed on the `info` parameter in order to retrieve
> + * information about the domain. The buffer is ignored if NULL is
> + * passed instead.
> + *
> + * @parm xch a handle to an open hypervisor interface
> + * @parm domid domid to lookup
> + * @parm info Optional domain information buffer (may be NULL)
> + * @return 0 on success, otherwise the call failed and info is undefined
> + */
> +int xc_domain_getinfo_single(xc_interface *xch,
> +                             uint32_t domid,
> +                             xc_domaininfo_t *info);
>  
>  /**
>   * This function will return information about one or more domains. It is
> diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c
> index e939d07157..3ff91023bf 100644
> --- a/tools/libs/ctrl/xc_domain.c
> +++ b/tools/libs/ctrl/xc_domain.c
> @@ -345,6 +345,28 @@ int xc_dom_vuart_init(xc_interface *xch,
>      return rc;
>  }
>  
> +int xc_domain_getinfo_single(xc_interface *xch,
> +                             uint32_t domid,
> +                             xc_domaininfo_t *info)
> +{
> +    struct xen_domctl domctl = {
> +        .cmd = XEN_DOMCTL_getdomaininfo,
> +        .domain = domid,
> +    };
> +
> +    int rc = do_domctl(xch, &domctl);

Minor style.  Should have a newline here, and drop the one 2 lines up.

By and large, this library is mostly Xen style and we're trying to make
it more consistent than it is, so we want extra spaces in the if
conditions below.

Otherwise, LGTM.

Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

> +    if (rc < 0)
> +        return rc;
> +
> +    if (domctl.u.getdomaininfo.domain != domid)
> +        return -ESRCH;
> +
> +    if (info)
> +        *info = domctl.u.getdomaininfo;
> +
> +    return rc;
> +}
> +
>  int xc_domain_getinfo(xc_interface *xch,
>                        uint32_t first_domid,
>                        unsigned int max_doms,




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.