ia64/xen-unstable

changeset 12178:4ea1097252a1

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@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Sat Oct 28 12:04:08 2006 +0100 (2006-10-28)
parents 5cccc3ed0b1e
children b6dc7eecff33
files tools/libxen/include/xen_host.h tools/libxen/include/xen_network.h tools/libxen/include/xen_sr.h tools/libxen/include/xen_vdi.h tools/libxen/include/xen_vm.h tools/libxen/src/xen_host.c tools/libxen/src/xen_network.c tools/libxen/src/xen_sr.c tools/libxen/src/xen_vdi.c tools/libxen/src/xen_vm.c tools/libxen/test/test_bindings.c
line diff
     1.1 --- a/tools/libxen/include/xen_host.h	Sat Oct 28 12:00:02 2006 +0100
     1.2 +++ b/tools/libxen/include/xen_host.h	Sat Oct 28 12:04:08 2006 +0100
     1.3 @@ -175,10 +175,10 @@ xen_host_create(xen_session *session, xe
     1.4  
     1.5  
     1.6  /**
     1.7 - * Get a reference to the object with the specified label.
     1.8 + * Get all the host instances with the given label.
     1.9   */
    1.10  extern bool
    1.11 -xen_host_get_by_name_label(xen_session *session, xen_host *result, char *label);
    1.12 +xen_host_get_by_name_label(xen_session *session, struct xen_host_set **result, char *label);
    1.13  
    1.14  
    1.15  /**
     2.1 --- a/tools/libxen/include/xen_network.h	Sat Oct 28 12:00:02 2006 +0100
     2.2 +++ b/tools/libxen/include/xen_network.h	Sat Oct 28 12:04:08 2006 +0100
     2.3 @@ -173,10 +173,10 @@ xen_network_create(xen_session *session,
     2.4  
     2.5  
     2.6  /**
     2.7 - * Get a reference to the object with the specified label.
     2.8 + * Get all the network instances with the given label.
     2.9   */
    2.10  extern bool
    2.11 -xen_network_get_by_name_label(xen_session *session, xen_network *result, char *label);
    2.12 +xen_network_get_by_name_label(xen_session *session, struct xen_network_set **result, char *label);
    2.13  
    2.14  
    2.15  /**
     3.1 --- a/tools/libxen/include/xen_sr.h	Sat Oct 28 12:00:02 2006 +0100
     3.2 +++ b/tools/libxen/include/xen_sr.h	Sat Oct 28 12:04:08 2006 +0100
     3.3 @@ -174,10 +174,10 @@ xen_sr_create(xen_session *session, xen_
     3.4  
     3.5  
     3.6  /**
     3.7 - * Get a reference to the object with the specified label.
     3.8 + * Get all the SR instances with the given label.
     3.9   */
    3.10  extern bool
    3.11 -xen_sr_get_by_name_label(xen_session *session, xen_sr *result, char *label);
    3.12 +xen_sr_get_by_name_label(xen_session *session, struct xen_sr_set **result, char *label);
    3.13  
    3.14  
    3.15  /**
     4.1 --- a/tools/libxen/include/xen_vdi.h	Sat Oct 28 12:00:02 2006 +0100
     4.2 +++ b/tools/libxen/include/xen_vdi.h	Sat Oct 28 12:04:08 2006 +0100
     4.3 @@ -180,10 +180,10 @@ xen_vdi_create(xen_session *session, xen
     4.4  
     4.5  
     4.6  /**
     4.7 - * Get a reference to the object with the specified label.
     4.8 + * Get all the VDI instances with the given label.
     4.9   */
    4.10  extern bool
    4.11 -xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label);
    4.12 +xen_vdi_get_by_name_label(xen_session *session, struct xen_vdi_set **result, char *label);
    4.13  
    4.14  
    4.15  /**
     5.1 --- a/tools/libxen/include/xen_vm.h	Sat Oct 28 12:00:02 2006 +0100
     5.2 +++ b/tools/libxen/include/xen_vm.h	Sat Oct 28 12:04:08 2006 +0100
     5.3 @@ -217,10 +217,10 @@ xen_vm_create(xen_session *session, xen_
     5.4  
     5.5  
     5.6  /**
     5.7 - * Get a reference to the object with the specified label.
     5.8 + * Get all the VM instances with the given label.
     5.9   */
    5.10  extern bool
    5.11 -xen_vm_get_by_name_label(xen_session *session, xen_vm *result, char *label);
    5.12 +xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, char *label);
    5.13  
    5.14  
    5.15  /**
     6.1 --- a/tools/libxen/src/xen_host.c	Sat Oct 28 12:00:02 2006 +0100
     6.2 +++ b/tools/libxen/src/xen_host.c	Sat Oct 28 12:04:08 2006 +0100
     6.3 @@ -150,7 +150,7 @@ xen_host_create(xen_session *session, xe
     6.4  
     6.5  
     6.6  bool
     6.7 -xen_host_get_by_name_label(xen_session *session, xen_host *result, char *label)
     6.8 +xen_host_get_by_name_label(xen_session *session, struct xen_host_set **result, char *label)
     6.9  {
    6.10      abstract_value param_values[] =
    6.11          {
    6.12 @@ -158,7 +158,7 @@ xen_host_get_by_name_label(xen_session *
    6.13                .u.string_val = label }
    6.14          };
    6.15  
    6.16 -    abstract_type result_type = abstract_type_string;
    6.17 +    abstract_type result_type = abstract_type_string_set;
    6.18  
    6.19      *result = NULL;
    6.20      XEN_CALL_("host.get_by_name_label");
     7.1 --- a/tools/libxen/src/xen_network.c	Sat Oct 28 12:00:02 2006 +0100
     7.2 +++ b/tools/libxen/src/xen_network.c	Sat Oct 28 12:04:08 2006 +0100
     7.3 @@ -148,7 +148,7 @@ xen_network_create(xen_session *session,
     7.4  
     7.5  
     7.6  bool
     7.7 -xen_network_get_by_name_label(xen_session *session, xen_network *result, char *label)
     7.8 +xen_network_get_by_name_label(xen_session *session, struct xen_network_set **result, char *label)
     7.9  {
    7.10      abstract_value param_values[] =
    7.11          {
    7.12 @@ -156,7 +156,7 @@ xen_network_get_by_name_label(xen_sessio
    7.13                .u.string_val = label }
    7.14          };
    7.15  
    7.16 -    abstract_type result_type = abstract_type_string;
    7.17 +    abstract_type result_type = abstract_type_string_set;
    7.18  
    7.19      *result = NULL;
    7.20      XEN_CALL_("network.get_by_name_label");
     8.1 --- a/tools/libxen/src/xen_sr.c	Sat Oct 28 12:00:02 2006 +0100
     8.2 +++ b/tools/libxen/src/xen_sr.c	Sat Oct 28 12:04:08 2006 +0100
     8.3 @@ -152,7 +152,7 @@ xen_sr_create(xen_session *session, xen_
     8.4  
     8.5  
     8.6  bool
     8.7 -xen_sr_get_by_name_label(xen_session *session, xen_sr *result, char *label)
     8.8 +xen_sr_get_by_name_label(xen_session *session, struct xen_sr_set **result, char *label)
     8.9  {
    8.10      abstract_value param_values[] =
    8.11          {
    8.12 @@ -160,7 +160,7 @@ xen_sr_get_by_name_label(xen_session *se
    8.13                .u.string_val = label }
    8.14          };
    8.15  
    8.16 -    abstract_type result_type = abstract_type_string;
    8.17 +    abstract_type result_type = abstract_type_string_set;
    8.18  
    8.19      *result = NULL;
    8.20      XEN_CALL_("SR.get_by_name_label");
     9.1 --- a/tools/libxen/src/xen_vdi.c	Sat Oct 28 12:00:02 2006 +0100
     9.2 +++ b/tools/libxen/src/xen_vdi.c	Sat Oct 28 12:04:08 2006 +0100
     9.3 @@ -167,7 +167,7 @@ xen_vdi_create(xen_session *session, xen
     9.4  
     9.5  
     9.6  bool
     9.7 -xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label)
     9.8 +xen_vdi_get_by_name_label(xen_session *session, struct xen_vdi_set **result, char *label)
     9.9  {
    9.10      abstract_value param_values[] =
    9.11          {
    9.12 @@ -175,7 +175,7 @@ xen_vdi_get_by_name_label(xen_session *s
    9.13                .u.string_val = label }
    9.14          };
    9.15  
    9.16 -    abstract_type result_type = abstract_type_string;
    9.17 +    abstract_type result_type = abstract_type_string_set;
    9.18  
    9.19      *result = NULL;
    9.20      XEN_CALL_("VDI.get_by_name_label");
    10.1 --- a/tools/libxen/src/xen_vm.c	Sat Oct 28 12:00:02 2006 +0100
    10.2 +++ b/tools/libxen/src/xen_vm.c	Sat Oct 28 12:04:08 2006 +0100
    10.3 @@ -280,7 +280,7 @@ xen_vm_create(xen_session *session, xen_
    10.4  
    10.5  
    10.6  bool
    10.7 -xen_vm_get_by_name_label(xen_session *session, xen_vm *result, char *label)
    10.8 +xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, char *label)
    10.9  {
   10.10      abstract_value param_values[] =
   10.11          {
   10.12 @@ -288,7 +288,7 @@ xen_vm_get_by_name_label(xen_session *se
   10.13                .u.string_val = label }
   10.14          };
   10.15  
   10.16 -    abstract_type result_type = abstract_type_string;
   10.17 +    abstract_type result_type = abstract_type_string_set;
   10.18  
   10.19      *result = NULL;
   10.20      XEN_CALL_("VM.get_by_name_label");
    11.1 --- a/tools/libxen/test/test_bindings.c	Sat Oct 28 12:00:02 2006 +0100
    11.2 +++ b/tools/libxen/test/test_bindings.c	Sat Oct 28 12:04:08 2006 +0100
    11.3 @@ -1,5 +1,5 @@
    11.4  /*
    11.5 -  Copyright (c) 2006 XenSource, Inc.
    11.6 + * Copyright (c) 2006 XenSource, Inc.
    11.7   *
    11.8   * This library is free software; you can redistribute it and/or
    11.9   * modify it under the terms of the GNU Lesser General Public
   11.10 @@ -14,7 +14,7 @@
   11.11   * You should have received a copy of the GNU Lesser General Public
   11.12   * License along with this library; if not, write to the Free Software
   11.13   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   11.14 -*/
   11.15 + */
   11.16  
   11.17  #define _GNU_SOURCE
   11.18  #include <inttypes.h>
   11.19 @@ -320,8 +320,9 @@ static void create_new_vm(xen_session *s
   11.20      /*
   11.21       * Create a new disk for the new VM.
   11.22       */
   11.23 -    xen_sr sr;
   11.24 -    if (!xen_sr_get_by_name_label(session, &sr, "Local"))
   11.25 +    xen_sr_set *srs;
   11.26 +    if (!xen_sr_get_by_name_label(session, &srs, "Local") ||
   11.27 +        srs->size < 1)
   11.28      {
   11.29          fprintf(stderr, "SR lookup failed.\n");
   11.30          print_error(session);
   11.31 @@ -331,7 +332,7 @@ static void create_new_vm(xen_session *s
   11.32  
   11.33      xen_sr_record_opt sr_record =
   11.34          {
   11.35 -            .u.handle = sr
   11.36 +            .u.handle = srs->contents[0]
   11.37          };
   11.38      xen_vdi_record vdi0_record =
   11.39          {
   11.40 @@ -351,16 +352,24 @@ static void create_new_vm(xen_session *s
   11.41          fprintf(stderr, "VDI creation failed.\n");
   11.42          print_error(session);
   11.43  
   11.44 -        xen_sr_free(sr);
   11.45 +        xen_sr_set_free(srs);
   11.46          xen_vm_free(vm);
   11.47          return;
   11.48      }
   11.49  
   11.50  
   11.51 +    xen_vm_record_opt vm_record_opt =
   11.52 +        {
   11.53 +            .u.handle = vm
   11.54 +        };
   11.55 +    xen_vdi_record_opt vdi0_record_opt =
   11.56 +        {
   11.57 +            .u.handle = vdi0
   11.58 +        };
   11.59      xen_vbd_record vbd0_record =
   11.60          {
   11.61 -            .vm = vm,
   11.62 -            .vdi = vdi0,
   11.63 +            .vm = &vm_record_opt,
   11.64 +            .vdi = &vdi0_record_opt,
   11.65              .device = "sda1",
   11.66              .mode = XEN_VBD_MODE_RW,
   11.67              .driver = XEN_DRIVER_TYPE_PARAVIRTUALISED
   11.68 @@ -373,7 +382,7 @@ static void create_new_vm(xen_session *s
   11.69          print_error(session);
   11.70  
   11.71          xen_vdi_free(vdi0);
   11.72 -        xen_sr_free(sr);
   11.73 +        xen_sr_set_free(srs);
   11.74          xen_vm_free(vm);
   11.75          return;
   11.76      }
   11.77 @@ -396,7 +405,7 @@ static void create_new_vm(xen_session *s
   11.78          xen_uuid_free(vbd0_uuid);
   11.79          xen_vbd_free(vbd0);
   11.80          xen_vdi_free(vdi0);
   11.81 -        xen_sr_free(sr);
   11.82 +        xen_sr_set_free(srs);
   11.83          xen_vm_free(vm);
   11.84          return;
   11.85      }
   11.86 @@ -410,6 +419,6 @@ static void create_new_vm(xen_session *s
   11.87      xen_uuid_free(vbd0_uuid);
   11.88      xen_vbd_free(vbd0);
   11.89      xen_vdi_free(vdi0);
   11.90 -    xen_sr_free(sr);
   11.91 +    xen_sr_set_free(srs);
   11.92      xen_vm_free(vm);
   11.93  }