debuggers.hg

changeset 22858:73b3debb90cf

xl: Check domain existance when doing domain identifier lookups

[ Code formatting fixed up to conform to libxl style. -iwj ]

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Gianni Tedesco <gianni.tedesco@citrix.com>
date Tue Jan 25 18:27:43 2011 +0000 (2011-01-25)
parents b457e2520074
children f28ab5926896
files tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/xl_cmdimpl.c	Tue Jan 25 18:24:36 2011 +0000
     1.2 +++ b/tools/libxl/xl_cmdimpl.c	Tue Jan 25 18:27:43 2011 +0000
     1.3 @@ -143,11 +143,25 @@ static int qualifier_to_id(const char *p
     1.4  static int domain_qualifier_to_domid(const char *p, uint32_t *domid_r,
     1.5                                       int *was_name_r)
     1.6  {
     1.7 -    int was_name;
     1.8 +    libxl_dominfo dominfo;
     1.9 +    int was_name, rc;
    1.10  
    1.11      was_name = qualifier_to_id(p, domid_r);
    1.12 -    if (was_name_r) *was_name_r = was_name;
    1.13 -    return was_name ? libxl_name_to_domid(&ctx, p, domid_r) : 0;
    1.14 +    if (was_name_r)
    1.15 +        *was_name_r = was_name;
    1.16 +
    1.17 +    if (was_name) {
    1.18 +        rc = libxl_name_to_domid(&ctx, p, domid_r);
    1.19 +        if (rc)
    1.20 +            return rc;
    1.21 +    } else {
    1.22 +        rc = libxl_domain_info(&ctx, &dominfo, *domid_r);
    1.23 +        /* error only if domain does not exist */
    1.24 +        if (rc == ERROR_INVAL)
    1.25 +            return rc;
    1.26 +    }
    1.27 +
    1.28 +    return 0;
    1.29  }
    1.30  
    1.31  static int cpupool_qualifier_to_cpupoolid(const char *p, uint32_t *poolid_r,