WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxl: prevent creation of domains with d

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: prevent creation of domains with duplicate names
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sat, 29 Jan 2011 15:06:03 -0800
Delivery-date: Sat, 29 Jan 2011 15:13:43 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
# Date 1296239949 0
# Node ID 88cf07fed7d21202d4b26e5161d10e92e771ea18
# Parent  29eaad8e388aa23993b144f0002c614c565e8e57
libxl: prevent creation of domains with duplicate names

libxl_domain_rename is where domain names are assigned.  Therefore
this is where we check that no two domains have the same name.  As a
special exception, domains whose names are "" are not considered to
clash.

We also take special care not to mind if we try to rename a domain to
the name it already has.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c        |   22 ++++++++++++++++++++++
 tools/libxl/libxl_create.c |    1 +
 2 files changed, 23 insertions(+)

diff -r 29eaad8e388a -r 88cf07fed7d2 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Jan 28 18:38:26 2011 +0000
+++ b/tools/libxl/libxl.c       Fri Jan 28 18:39:09 2011 +0000
@@ -138,6 +138,28 @@ int libxl_domain_rename(libxl_ctx *ctx, 
             LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno,
                             "create xs transaction for domain (re)name");
             goto x_fail;
+        }
+    }
+
+    if (new_name[0]) {
+        /* nonempty names must be unique */
+        uint32_t domid_e;
+        rc = libxl_name_to_domid(ctx, new_name, &domid_e);
+        if (rc == ERROR_INVAL) {
+            /* no such domain, good */
+        } else if (rc != 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unexpected error"
+                       "checking for existing domain");
+            goto x_rc;
+        } else if (domid_e == domid) {
+            /* domain already has this name, ok (but we do still
+             * need the rest of the code as we may need to check
+             * old_name, for example). */
+        } else {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "domain with name \"%s\""
+                       " already exists.", new_name);
+            rc = ERROR_INVAL;
+            goto x_rc;
         }
     }
 
diff -r 29eaad8e388a -r 88cf07fed7d2 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Fri Jan 28 18:38:26 2011 +0000
+++ b/tools/libxl/libxl_create.c        Fri Jan 28 18:39:09 2011 +0000
@@ -351,6 +351,7 @@ int libxl__domain_make(libxl_ctx *ctx, l
 
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
+
     xs_rm(ctx->xsh, t, dom_path);
     xs_mkdir(ctx->xsh, t, dom_path);
     xs_set_permissions(ctx->xsh, t, dom_path, roperm, ARRAY_SIZE(roperm));

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: prevent creation of domains with duplicate names, Xen patchbot-unstable <=