diff mbox series

[3/6] domctl: return EEXIST from XEN_DOMCTL_createdomain...

Message ID 20191224130416.3570-4-pdurrant@amazon.com (mailing list archive)
State New, archived
Headers show
Series xl/libxl: allow creation of domains with a specified domid | expand

Commit Message

Paul Durrant Dec. 24, 2019, 1:04 p.m. UTC
...if a specified domid is already in use.

XEN_DOMCTL_createdomain allows a domid to be specified by its caller and
will correctly fail if that domid is already in use. However the errno
returned in this case will be EINVAL, making it indistinguishable from
several other failures. Also a value of EINVAL does not seem appropriate
as the specified domid is valid [1] but just not (transiently) available.

[1] any invalid value passed in is ignored and causes Xen to choose an
    unused and valid value.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien@xen.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Wei Liu <wl@xen.org>
---
 xen/common/domctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ian Jackson Jan. 2, 2020, 5:22 p.m. UTC | #1
Paul Durrant writes ("[PATCH 3/6] domctl: return EEXIST from XEN_DOMCTL_createdomain..."):
> ...if a specified domid is already in use.
> 
> XEN_DOMCTL_createdomain allows a domid to be specified by its caller and
> will correctly fail if that domid is already in use. However the errno
> returned in this case will be EINVAL, making it indistinguishable from
> several other failures. Also a value of EINVAL does not seem appropriate
> as the specified domid is valid [1] but just not (transiently) available.
> 
> [1] any invalid value passed in is ignored and causes Xen to choose an
>     unused and valid value.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox series

Patch

diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 03d0226039..650310e874 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -504,7 +504,7 @@  long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
         dom = op->domain;
         if ( (dom > 0) && (dom < DOMID_FIRST_RESERVED) )
         {
-            ret = -EINVAL;
+            ret = -EEXIST;
             if ( !is_free_domid(dom) )
                 break;
         }