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] The get_by_name_label functions return a

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] The get_by_name_label functions return a set, not a singleton, because names
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 02 Nov 2006 22:09:43 +0000
Delivery-date: Thu, 02 Nov 2006 21:30:11 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID 4ea1097252a140cc2882f47733388ae8b7e42347
# Parent  5cccc3ed0b1e1207d5cb33101f8c6fa93260350b
The get_by_name_label functions return a set, not a singleton, because names
are not guaranteed to be unique.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/libxen/include/xen_host.h    |    8 +++----
 tools/libxen/include/xen_network.h |    8 +++----
 tools/libxen/include/xen_sr.h      |    8 +++----
 tools/libxen/include/xen_vdi.h     |    8 +++----
 tools/libxen/include/xen_vm.h      |    8 +++----
 tools/libxen/src/xen_host.c        |    4 +--
 tools/libxen/src/xen_network.c     |    4 +--
 tools/libxen/src/xen_sr.c          |    4 +--
 tools/libxen/src/xen_vdi.c         |    4 +--
 tools/libxen/src/xen_vm.c          |    4 +--
 tools/libxen/test/test_bindings.c  |   41 ++++++++++++++++++++++---------------
 11 files changed, 55 insertions(+), 46 deletions(-)

diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/include/xen_host.h
--- a/tools/libxen/include/xen_host.h   Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/include/xen_host.h   Sat Oct 28 12:04:08 2006 +0100
@@ -175,10 +175,10 @@ xen_host_create(xen_session *session, xe
 
 
 /**
- * Get a reference to the object with the specified label.
- */
-extern bool
-xen_host_get_by_name_label(xen_session *session, xen_host *result, char 
*label);
+ * Get all the host instances with the given label.
+ */
+extern bool
+xen_host_get_by_name_label(xen_session *session, struct xen_host_set **result, 
char *label);
 
 
 /**
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/include/xen_network.h
--- a/tools/libxen/include/xen_network.h        Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/include/xen_network.h        Sat Oct 28 12:04:08 2006 +0100
@@ -173,10 +173,10 @@ xen_network_create(xen_session *session,
 
 
 /**
- * Get a reference to the object with the specified label.
- */
-extern bool
-xen_network_get_by_name_label(xen_session *session, xen_network *result, char 
*label);
+ * Get all the network instances with the given label.
+ */
+extern bool
+xen_network_get_by_name_label(xen_session *session, struct xen_network_set 
**result, char *label);
 
 
 /**
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/include/xen_sr.h
--- a/tools/libxen/include/xen_sr.h     Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/include/xen_sr.h     Sat Oct 28 12:04:08 2006 +0100
@@ -174,10 +174,10 @@ xen_sr_create(xen_session *session, xen_
 
 
 /**
- * Get a reference to the object with the specified label.
- */
-extern bool
-xen_sr_get_by_name_label(xen_session *session, xen_sr *result, char *label);
+ * Get all the SR instances with the given label.
+ */
+extern bool
+xen_sr_get_by_name_label(xen_session *session, struct xen_sr_set **result, 
char *label);
 
 
 /**
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/include/xen_vdi.h
--- a/tools/libxen/include/xen_vdi.h    Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/include/xen_vdi.h    Sat Oct 28 12:04:08 2006 +0100
@@ -180,10 +180,10 @@ xen_vdi_create(xen_session *session, xen
 
 
 /**
- * Get a reference to the object with the specified label.
- */
-extern bool
-xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label);
+ * Get all the VDI instances with the given label.
+ */
+extern bool
+xen_vdi_get_by_name_label(xen_session *session, struct xen_vdi_set **result, 
char *label);
 
 
 /**
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/include/xen_vm.h
--- a/tools/libxen/include/xen_vm.h     Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/include/xen_vm.h     Sat Oct 28 12:04:08 2006 +0100
@@ -217,10 +217,10 @@ xen_vm_create(xen_session *session, xen_
 
 
 /**
- * Get a reference to the object with the specified label.
- */
-extern bool
-xen_vm_get_by_name_label(xen_session *session, xen_vm *result, char *label);
+ * Get all the VM instances with the given label.
+ */
+extern bool
+xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, 
char *label);
 
 
 /**
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/src/xen_host.c
--- a/tools/libxen/src/xen_host.c       Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/src/xen_host.c       Sat Oct 28 12:04:08 2006 +0100
@@ -150,7 +150,7 @@ xen_host_create(xen_session *session, xe
 
 
 bool
-xen_host_get_by_name_label(xen_session *session, xen_host *result, char *label)
+xen_host_get_by_name_label(xen_session *session, struct xen_host_set **result, 
char *label)
 {
     abstract_value param_values[] =
         {
@@ -158,7 +158,7 @@ xen_host_get_by_name_label(xen_session *
               .u.string_val = label }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_set;
 
     *result = NULL;
     XEN_CALL_("host.get_by_name_label");
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/src/xen_network.c
--- a/tools/libxen/src/xen_network.c    Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/src/xen_network.c    Sat Oct 28 12:04:08 2006 +0100
@@ -148,7 +148,7 @@ xen_network_create(xen_session *session,
 
 
 bool
-xen_network_get_by_name_label(xen_session *session, xen_network *result, char 
*label)
+xen_network_get_by_name_label(xen_session *session, struct xen_network_set 
**result, char *label)
 {
     abstract_value param_values[] =
         {
@@ -156,7 +156,7 @@ xen_network_get_by_name_label(xen_sessio
               .u.string_val = label }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_set;
 
     *result = NULL;
     XEN_CALL_("network.get_by_name_label");
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/src/xen_sr.c
--- a/tools/libxen/src/xen_sr.c Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/src/xen_sr.c Sat Oct 28 12:04:08 2006 +0100
@@ -152,7 +152,7 @@ xen_sr_create(xen_session *session, xen_
 
 
 bool
-xen_sr_get_by_name_label(xen_session *session, xen_sr *result, char *label)
+xen_sr_get_by_name_label(xen_session *session, struct xen_sr_set **result, 
char *label)
 {
     abstract_value param_values[] =
         {
@@ -160,7 +160,7 @@ xen_sr_get_by_name_label(xen_session *se
               .u.string_val = label }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_set;
 
     *result = NULL;
     XEN_CALL_("SR.get_by_name_label");
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/src/xen_vdi.c
--- a/tools/libxen/src/xen_vdi.c        Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/src/xen_vdi.c        Sat Oct 28 12:04:08 2006 +0100
@@ -167,7 +167,7 @@ xen_vdi_create(xen_session *session, xen
 
 
 bool
-xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label)
+xen_vdi_get_by_name_label(xen_session *session, struct xen_vdi_set **result, 
char *label)
 {
     abstract_value param_values[] =
         {
@@ -175,7 +175,7 @@ xen_vdi_get_by_name_label(xen_session *s
               .u.string_val = label }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_set;
 
     *result = NULL;
     XEN_CALL_("VDI.get_by_name_label");
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/src/xen_vm.c
--- a/tools/libxen/src/xen_vm.c Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/src/xen_vm.c Sat Oct 28 12:04:08 2006 +0100
@@ -280,7 +280,7 @@ xen_vm_create(xen_session *session, xen_
 
 
 bool
-xen_vm_get_by_name_label(xen_session *session, xen_vm *result, char *label)
+xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, 
char *label)
 {
     abstract_value param_values[] =
         {
@@ -288,7 +288,7 @@ xen_vm_get_by_name_label(xen_session *se
               .u.string_val = label }
         };
 
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_set;
 
     *result = NULL;
     XEN_CALL_("VM.get_by_name_label");
diff -r 5cccc3ed0b1e -r 4ea1097252a1 tools/libxen/test/test_bindings.c
--- a/tools/libxen/test/test_bindings.c Sat Oct 28 12:00:02 2006 +0100
+++ b/tools/libxen/test/test_bindings.c Sat Oct 28 12:04:08 2006 +0100
@@ -1,5 +1,5 @@
 /*
-  Copyright (c) 2006 XenSource, Inc.
+ * Copyright (c) 2006 XenSource, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
-*/
+ */
 
 #define _GNU_SOURCE
 #include <inttypes.h>
@@ -320,8 +320,9 @@ static void create_new_vm(xen_session *s
     /*
      * Create a new disk for the new VM.
      */
-    xen_sr sr;
-    if (!xen_sr_get_by_name_label(session, &sr, "Local"))
+    xen_sr_set *srs;
+    if (!xen_sr_get_by_name_label(session, &srs, "Local") ||
+        srs->size < 1)
     {
         fprintf(stderr, "SR lookup failed.\n");
         print_error(session);
@@ -331,7 +332,7 @@ static void create_new_vm(xen_session *s
 
     xen_sr_record_opt sr_record =
         {
-            .u.handle = sr
+            .u.handle = srs->contents[0]
         };
     xen_vdi_record vdi0_record =
         {
@@ -351,16 +352,24 @@ static void create_new_vm(xen_session *s
         fprintf(stderr, "VDI creation failed.\n");
         print_error(session);
 
-        xen_sr_free(sr);
-        xen_vm_free(vm);
-        return;
-    }
-
-
+        xen_sr_set_free(srs);
+        xen_vm_free(vm);
+        return;
+    }
+
+
+    xen_vm_record_opt vm_record_opt =
+        {
+            .u.handle = vm
+        };
+    xen_vdi_record_opt vdi0_record_opt =
+        {
+            .u.handle = vdi0
+        };
     xen_vbd_record vbd0_record =
         {
-            .vm = vm,
-            .vdi = vdi0,
+            .vm = &vm_record_opt,
+            .vdi = &vdi0_record_opt,
             .device = "sda1",
             .mode = XEN_VBD_MODE_RW,
             .driver = XEN_DRIVER_TYPE_PARAVIRTUALISED
@@ -373,7 +382,7 @@ static void create_new_vm(xen_session *s
         print_error(session);
 
         xen_vdi_free(vdi0);
-        xen_sr_free(sr);
+        xen_sr_set_free(srs);
         xen_vm_free(vm);
         return;
     }
@@ -396,7 +405,7 @@ static void create_new_vm(xen_session *s
         xen_uuid_free(vbd0_uuid);
         xen_vbd_free(vbd0);
         xen_vdi_free(vdi0);
-        xen_sr_free(sr);
+        xen_sr_set_free(srs);
         xen_vm_free(vm);
         return;
     }
@@ -410,6 +419,6 @@ static void create_new_vm(xen_session *s
     xen_uuid_free(vbd0_uuid);
     xen_vbd_free(vbd0);
     xen_vdi_free(vdi0);
-    xen_sr_free(sr);
+    xen_sr_set_free(srs);
     xen_vm_free(vm);
 }

_______________________________________________
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] The get_by_name_label functions return a set, not a singleton, because names, Xen patchbot-unstable <=