debuggers.hg

changeset 22768:77e8775fccef

libxl: move domain struct init functions from xl to libxl

This allows libxl users to get some sane default values for this complex
set of structures. This is purely code movement and there are no
functional changes except for a trivial error handling change in nic
device init.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Gianni Tedesco <gianni.tedesco@citrix.com>
date Tue Jan 11 18:32:32 2011 +0000 (2011-01-11)
parents ca75ceb02221
children 0bb8685eab9b
files tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/libxl_create.c tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Tue Jan 11 18:29:43 2011 +0000
     1.2 +++ b/tools/libxl/libxl.c	Tue Jan 11 18:32:32 2011 +0000
     1.3 @@ -1024,6 +1024,35 @@ int libxl_device_disk_local_detach(libxl
     1.4  }
     1.5  
     1.6  /******************************************************************************/
     1.7 +int libxl_device_nic_init(libxl_device_nic *nic_info, int devnum)
     1.8 +{
     1.9 +    const uint8_t *r;
    1.10 +    libxl_uuid uuid;
    1.11 +
    1.12 +    libxl_uuid_generate(&uuid);
    1.13 +    r = libxl_uuid_bytearray(&uuid);
    1.14 +    memset(nic_info, '\0', sizeof(*nic_info));
    1.15 +
    1.16 +    nic_info->backend_domid = 0;
    1.17 +    nic_info->domid = 0;
    1.18 +    nic_info->devid = devnum;
    1.19 +    nic_info->mtu = 1492;
    1.20 +    nic_info->model = strdup("e1000");
    1.21 +    nic_info->mac[0] = 0x00;
    1.22 +    nic_info->mac[1] = 0x16;
    1.23 +    nic_info->mac[2] = 0x3e;
    1.24 +    nic_info->mac[3] = r[0] & 0x7f;
    1.25 +    nic_info->mac[4] = r[1];
    1.26 +    nic_info->mac[5] = r[2];
    1.27 +    nic_info->ifname = NULL;
    1.28 +    nic_info->bridge = strdup("xenbr0");
    1.29 +    if ( asprintf(&nic_info->script, "%s/vif-bridge",
    1.30 +               libxl_xen_script_dir_path()) < 0 )
    1.31 +        return ERROR_FAIL;
    1.32 +    nic_info->nictype = NICTYPE_IOEMU;
    1.33 +    return 0;
    1.34 +}
    1.35 +
    1.36  int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)
    1.37  {
    1.38      libxl__gc gc = LIBXL_INIT_GC(ctx);
    1.39 @@ -1182,6 +1211,34 @@ err:
    1.40  }
    1.41  
    1.42  /******************************************************************************/
    1.43 +void libxl_device_net2_init(libxl_device_net2 *net2_info, int devnum)
    1.44 +{
    1.45 +    const uint8_t *r;
    1.46 +    libxl_uuid uuid;
    1.47 +
    1.48 +    libxl_uuid_generate(&uuid);
    1.49 +    r = libxl_uuid_bytearray(&uuid);
    1.50 +    memset(net2_info, '\0', sizeof(*net2_info));
    1.51 +
    1.52 +    net2_info->devid = devnum;
    1.53 +    net2_info->front_mac[0] = 0x00;
    1.54 +    net2_info->front_mac[1] = 0x16;
    1.55 +    net2_info->front_mac[2] = 0x3e;;
    1.56 +    net2_info->front_mac[3] = 0x7f & r[0];
    1.57 +    net2_info->front_mac[4] = r[1];
    1.58 +    net2_info->front_mac[5] = r[2];
    1.59 +    net2_info->back_mac[0] = 0x00;
    1.60 +    net2_info->back_mac[1] = 0x16;
    1.61 +    net2_info->back_mac[2] = 0x3e;
    1.62 +    net2_info->back_mac[3] = 0x7f & r[3];
    1.63 +    net2_info->back_mac[4] = r[4];
    1.64 +    net2_info->back_mac[5] = r[5];
    1.65 +    net2_info->back_trusted = 1;
    1.66 +    net2_info->filter_mac = 1;
    1.67 +    net2_info->max_bypasses = 5;
    1.68 +    net2_info->bridge = strdup("xenbr0");
    1.69 +}
    1.70 +
    1.71  int libxl_device_net2_add(libxl_ctx *ctx, uint32_t domid, libxl_device_net2 *net2)
    1.72  {
    1.73      libxl__gc gc = LIBXL_INIT_GC(ctx);
    1.74 @@ -1449,6 +1506,12 @@ out:
    1.75  }
    1.76  
    1.77  /******************************************************************************/
    1.78 +void libxl_device_vkb_init(libxl_device_vkb *vkb, int dev_num)
    1.79 +{
    1.80 +    memset(vkb, 0x00, sizeof(libxl_device_vkb));
    1.81 +    vkb->devid = dev_num;
    1.82 +}
    1.83 +
    1.84  int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb)
    1.85  {
    1.86      libxl__gc gc = LIBXL_INIT_GC(ctx);
    1.87 @@ -1647,6 +1710,22 @@ out:
    1.88  }
    1.89  
    1.90  /******************************************************************************/
    1.91 +void libxl_device_vfb_init(libxl_device_vfb *vfb, int dev_num)
    1.92 +{
    1.93 +    memset(vfb, 0x00, sizeof(libxl_device_vfb));
    1.94 +    vfb->devid = dev_num;
    1.95 +    vfb->display = NULL;
    1.96 +    vfb->xauthority = NULL;
    1.97 +    vfb->vnc = 1;
    1.98 +    vfb->vncpasswd = NULL;
    1.99 +    vfb->vnclisten = strdup("127.0.0.1");
   1.100 +    vfb->vncdisplay = 0;
   1.101 +    vfb->vncunused = 1;
   1.102 +    vfb->keymap = NULL;
   1.103 +    vfb->sdl = 0;
   1.104 +    vfb->opengl = 0;
   1.105 +}
   1.106 +
   1.107  int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
   1.108  {
   1.109      libxl__gc gc = LIBXL_INIT_GC(ctx);
     2.1 --- a/tools/libxl/libxl.h	Tue Jan 11 18:29:43 2011 +0000
     2.2 +++ b/tools/libxl/libxl.h	Tue Jan 11 18:32:32 2011 +0000
     2.3 @@ -280,6 +280,9 @@ int libxl_ctx_set_log(libxl_ctx *ctx, xe
     2.4  int libxl_ctx_postfork(libxl_ctx *ctx);
     2.5  
     2.6  /* domain related functions */
     2.7 +void libxl_init_create_info(libxl_domain_create_info *c_info);
     2.8 +void libxl_init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info);
     2.9 +void libxl_init_dm_info(libxl_device_model_info *dm_info, libxl_domain_create_info *c_info, libxl_domain_build_info *b_info);
    2.10  typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv);
    2.11  int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid);
    2.12  int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd);
    2.13 @@ -419,16 +422,19 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
    2.14  char * libxl_device_disk_local_attach(libxl_ctx *ctx, libxl_device_disk *disk);
    2.15  int libxl_device_disk_local_detach(libxl_ctx *ctx, libxl_device_disk *disk);
    2.16  
    2.17 +int libxl_device_nic_init(libxl_device_nic *nic, int dev_num);
    2.18  int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic);
    2.19  int libxl_device_nic_del(libxl_ctx *ctx, libxl_device_nic *nic, int wait);
    2.20  libxl_nicinfo *libxl_list_nics(libxl_ctx *ctx, uint32_t domid, unsigned int *nb);
    2.21  
    2.22  int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid, libxl_device_console *console);
    2.23  
    2.24 +void libxl_device_vkb_init(libxl_device_vkb *vkb, int dev_num);
    2.25  int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
    2.26  int libxl_device_vkb_clean_shutdown(libxl_ctx *ctx, uint32_t domid);
    2.27  int libxl_device_vkb_hard_shutdown(libxl_ctx *ctx, uint32_t domid);
    2.28  
    2.29 +void libxl_device_vfb_init(libxl_device_vfb *vfb, int dev_num);
    2.30  int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb);
    2.31  int libxl_device_vfb_clean_shutdown(libxl_ctx *ctx, uint32_t domid);
    2.32  int libxl_device_vfb_hard_shutdown(libxl_ctx *ctx, uint32_t domid);
    2.33 @@ -526,6 +532,7 @@ int libxl_tmem_shared_auth(libxl_ctx *ct
    2.34                             int auth);
    2.35  int libxl_tmem_freeable(libxl_ctx *ctx);
    2.36  
    2.37 +void libxl_device_net2_init(libxl_device_net2 *net2, int dev_num);
    2.38  int libxl_device_net2_add(libxl_ctx *ctx, uint32_t domid,
    2.39                            libxl_device_net2 *net2);
    2.40  libxl_net2info *libxl_device_net2_list(libxl_ctx *ctx, uint32_t domid,
     3.1 --- a/tools/libxl/libxl_create.c	Tue Jan 11 18:29:43 2011 +0000
     3.2 +++ b/tools/libxl/libxl_create.c	Tue Jan 11 18:32:32 2011 +0000
     3.3 @@ -60,6 +60,75 @@ void libxl_domain_config_destroy(libxl_d
     3.4      libxl_device_model_info_destroy(&d_config->dm_info);
     3.5  }
     3.6  
     3.7 +void libxl_init_create_info(libxl_domain_create_info *c_info)
     3.8 +{
     3.9 +    memset(c_info, '\0', sizeof(*c_info));
    3.10 +    c_info->xsdata = NULL;
    3.11 +    c_info->platformdata = NULL;
    3.12 +    c_info->hap = 1;
    3.13 +    c_info->hvm = 1;
    3.14 +    c_info->oos = 1;
    3.15 +    c_info->ssidref = 0;
    3.16 +    c_info->poolid = 0;
    3.17 +}
    3.18 +
    3.19 +void libxl_init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info)
    3.20 +{
    3.21 +    memset(b_info, '\0', sizeof(*b_info));
    3.22 +    b_info->max_vcpus = 1;
    3.23 +    b_info->max_memkb = 32 * 1024;
    3.24 +    b_info->target_memkb = b_info->max_memkb;
    3.25 +    b_info->disable_migrate = 0;
    3.26 +    b_info->cpuid = NULL;
    3.27 +    b_info->shadow_memkb = 0;
    3.28 +    if (c_info->hvm) {
    3.29 +        b_info->video_memkb = 8 * 1024;
    3.30 +        b_info->kernel.path = strdup("hvmloader");
    3.31 +        b_info->hvm = 1;
    3.32 +        b_info->u.hvm.pae = 1;
    3.33 +        b_info->u.hvm.apic = 1;
    3.34 +        b_info->u.hvm.acpi = 1;
    3.35 +        b_info->u.hvm.nx = 1;
    3.36 +        b_info->u.hvm.viridian = 0;
    3.37 +        b_info->u.hvm.hpet = 1;
    3.38 +        b_info->u.hvm.vpt_align = 1;
    3.39 +        b_info->u.hvm.timer_mode = 1;
    3.40 +    } else {
    3.41 +        b_info->u.pv.slack_memkb = 8 * 1024;
    3.42 +    }
    3.43 +}
    3.44 +
    3.45 +void libxl_init_dm_info(libxl_device_model_info *dm_info,
    3.46 +        libxl_domain_create_info *c_info, libxl_domain_build_info *b_info)
    3.47 +{
    3.48 +    memset(dm_info, '\0', sizeof(*dm_info));
    3.49 +
    3.50 +    libxl_uuid_generate(&dm_info->uuid);
    3.51 +
    3.52 +    dm_info->dom_name = strdup(c_info->name);
    3.53 +    dm_info->device_model = strdup("qemu-dm");
    3.54 +    dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb);
    3.55 +    dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb);
    3.56 +    dm_info->apic = b_info->u.hvm.apic;
    3.57 +    dm_info->vcpus = b_info->max_vcpus;
    3.58 +    dm_info->vcpu_avail = b_info->cur_vcpus;
    3.59 +
    3.60 +    dm_info->stdvga = 0;
    3.61 +    dm_info->vnc = 1;
    3.62 +    dm_info->vnclisten = strdup("127.0.0.1");
    3.63 +    dm_info->vncdisplay = 0;
    3.64 +    dm_info->vncunused = 1;
    3.65 +    dm_info->keymap = NULL;
    3.66 +    dm_info->sdl = 0;
    3.67 +    dm_info->opengl = 0;
    3.68 +    dm_info->nographic = 0;
    3.69 +    dm_info->serial = NULL;
    3.70 +    dm_info->boot = strdup("cda");
    3.71 +    dm_info->usb = 0;
    3.72 +    dm_info->usbdevice = NULL;
    3.73 +    dm_info->xen_platform_pci = 1;
    3.74 +}
    3.75 +
    3.76  static int init_console_info(libxl_device_console *console, int dev_num, libxl_domain_build_state *state)
    3.77  {
    3.78      memset(console, 0x00, sizeof(libxl_device_console));
     4.1 --- a/tools/libxl/xl_cmdimpl.c	Tue Jan 11 18:29:43 2011 +0000
     4.2 +++ b/tools/libxl/xl_cmdimpl.c	Tue Jan 11 18:32:32 2011 +0000
     4.3 @@ -249,152 +249,6 @@ static void dolog(const char *file, int 
     4.4          libxl_write_exactly(NULL, logfile, s, rc, NULL, NULL);
     4.5  }
     4.6  
     4.7 -static void init_create_info(libxl_domain_create_info *c_info)
     4.8 -{
     4.9 -    memset(c_info, '\0', sizeof(*c_info));
    4.10 -    c_info->xsdata = NULL;
    4.11 -    c_info->platformdata = NULL;
    4.12 -    c_info->hap = 1;
    4.13 -    c_info->hvm = 1;
    4.14 -    c_info->oos = 1;
    4.15 -    c_info->ssidref = 0;
    4.16 -    c_info->poolid = 0;
    4.17 -}
    4.18 -
    4.19 -static void init_build_info(libxl_domain_build_info *b_info, libxl_domain_create_info *c_info)
    4.20 -{
    4.21 -    memset(b_info, '\0', sizeof(*b_info));
    4.22 -    b_info->max_vcpus = 1;
    4.23 -    b_info->max_memkb = 32 * 1024;
    4.24 -    b_info->target_memkb = b_info->max_memkb;
    4.25 -    b_info->disable_migrate = 0;
    4.26 -    b_info->cpuid = NULL;
    4.27 -    b_info->shadow_memkb = 0;
    4.28 -    if (c_info->hvm) {
    4.29 -        b_info->video_memkb = 8 * 1024;
    4.30 -        b_info->kernel.path = strdup("hvmloader");
    4.31 -        b_info->hvm = 1;
    4.32 -        b_info->u.hvm.pae = 1;
    4.33 -        b_info->u.hvm.apic = 1;
    4.34 -        b_info->u.hvm.acpi = 1;
    4.35 -        b_info->u.hvm.nx = 1;
    4.36 -        b_info->u.hvm.viridian = 0;
    4.37 -        b_info->u.hvm.hpet = 1;
    4.38 -        b_info->u.hvm.vpt_align = 1;
    4.39 -        b_info->u.hvm.timer_mode = 1;
    4.40 -    } else {
    4.41 -        b_info->u.pv.slack_memkb = 8 * 1024;
    4.42 -    }
    4.43 -}
    4.44 -
    4.45 -static void init_dm_info(libxl_device_model_info *dm_info,
    4.46 -        libxl_domain_create_info *c_info, libxl_domain_build_info *b_info)
    4.47 -{
    4.48 -    memset(dm_info, '\0', sizeof(*dm_info));
    4.49 -
    4.50 -    libxl_uuid_generate(&dm_info->uuid);
    4.51 -
    4.52 -    dm_info->dom_name = strdup(c_info->name);
    4.53 -    dm_info->device_model = strdup("qemu-dm");
    4.54 -    dm_info->target_ram = libxl__sizekb_to_mb(b_info->target_memkb);
    4.55 -    dm_info->videoram = libxl__sizekb_to_mb(b_info->video_memkb);
    4.56 -    dm_info->apic = b_info->u.hvm.apic;
    4.57 -    dm_info->vcpus = b_info->max_vcpus;
    4.58 -    dm_info->vcpu_avail = b_info->cur_vcpus;
    4.59 -
    4.60 -    dm_info->stdvga = 0;
    4.61 -    dm_info->vnc = 1;
    4.62 -    dm_info->vnclisten = strdup("127.0.0.1");
    4.63 -    dm_info->vncdisplay = 0;
    4.64 -    dm_info->vncunused = 1;
    4.65 -    dm_info->keymap = NULL;
    4.66 -    dm_info->sdl = 0;
    4.67 -    dm_info->opengl = 0;
    4.68 -    dm_info->nographic = 0;
    4.69 -    dm_info->serial = NULL;
    4.70 -    dm_info->boot = strdup("cda");
    4.71 -    dm_info->usb = 0;
    4.72 -    dm_info->usbdevice = NULL;
    4.73 -    dm_info->xen_platform_pci = 1;
    4.74 -}
    4.75 -
    4.76 -static void init_nic_info(libxl_device_nic *nic_info, int devnum)
    4.77 -{
    4.78 -    const uint8_t *r;
    4.79 -    libxl_uuid uuid;
    4.80 -
    4.81 -    libxl_uuid_generate(&uuid);
    4.82 -    r = libxl_uuid_bytearray(&uuid);
    4.83 -    memset(nic_info, '\0', sizeof(*nic_info));
    4.84 -
    4.85 -    nic_info->backend_domid = 0;
    4.86 -    nic_info->domid = 0;
    4.87 -    nic_info->devid = devnum;
    4.88 -    nic_info->mtu = 1492;
    4.89 -    nic_info->model = strdup("e1000");
    4.90 -    nic_info->mac[0] = 0x00;
    4.91 -    nic_info->mac[1] = 0x16;
    4.92 -    nic_info->mac[2] = 0x3e;
    4.93 -    nic_info->mac[3] = r[0] & 0x7f;
    4.94 -    nic_info->mac[4] = r[1];
    4.95 -    nic_info->mac[5] = r[2];
    4.96 -    nic_info->ifname = NULL;
    4.97 -    nic_info->bridge = strdup("xenbr0");
    4.98 -    CHK_ERRNO( asprintf(&nic_info->script, "%s/vif-bridge",
    4.99 -               libxl_xen_script_dir_path()) );
   4.100 -    nic_info->nictype = NICTYPE_IOEMU;
   4.101 -}
   4.102 -
   4.103 -static void init_net2_info(libxl_device_net2 *net2_info, int devnum)
   4.104 -{
   4.105 -    const uint8_t *r;
   4.106 -    libxl_uuid uuid;
   4.107 -
   4.108 -    libxl_uuid_generate(&uuid);
   4.109 -    r = libxl_uuid_bytearray(&uuid);
   4.110 -    memset(net2_info, '\0', sizeof(*net2_info));
   4.111 -
   4.112 -    net2_info->devid = devnum;
   4.113 -    net2_info->front_mac[0] = 0x00;
   4.114 -    net2_info->front_mac[1] = 0x16;
   4.115 -    net2_info->front_mac[2] = 0x3e;;
   4.116 -    net2_info->front_mac[3] = 0x7f & r[0];
   4.117 -    net2_info->front_mac[4] = r[1];
   4.118 -    net2_info->front_mac[5] = r[2];
   4.119 -    net2_info->back_mac[0] = 0x00;
   4.120 -    net2_info->back_mac[1] = 0x16;
   4.121 -    net2_info->back_mac[2] = 0x3e;
   4.122 -    net2_info->back_mac[3] = 0x7f & r[3];
   4.123 -    net2_info->back_mac[4] = r[4];
   4.124 -    net2_info->back_mac[5] = r[5];
   4.125 -    net2_info->back_trusted = 1;
   4.126 -    net2_info->filter_mac = 1;
   4.127 -    net2_info->max_bypasses = 5;
   4.128 -    net2_info->bridge = strdup("xenbr0");
   4.129 -}
   4.130 -
   4.131 -static void init_vfb_info(libxl_device_vfb *vfb, int dev_num)
   4.132 -{
   4.133 -    memset(vfb, 0x00, sizeof(libxl_device_vfb));
   4.134 -    vfb->devid = dev_num;
   4.135 -    vfb->display = NULL;
   4.136 -    vfb->xauthority = NULL;
   4.137 -    vfb->vnc = 1;
   4.138 -    vfb->vncpasswd = NULL;
   4.139 -    vfb->vnclisten = strdup("127.0.0.1");
   4.140 -    vfb->vncdisplay = 0;
   4.141 -    vfb->vncunused = 1;
   4.142 -    vfb->keymap = NULL;
   4.143 -    vfb->sdl = 0;
   4.144 -    vfb->opengl = 0;
   4.145 -}
   4.146 -
   4.147 -static void init_vkb_info(libxl_device_vkb *vkb, int dev_num)
   4.148 -{
   4.149 -    memset(vkb, 0x00, sizeof(libxl_device_vkb));
   4.150 -    vkb->devid = dev_num;
   4.151 -}
   4.152 -
   4.153  static void printf_info(int domid,
   4.154                          libxl_domain_config *d_config,
   4.155                          libxl_device_model_info *dm_info)
   4.156 @@ -727,7 +581,7 @@ static void parse_config_data(const char
   4.157          exit(1);
   4.158      }
   4.159  
   4.160 -    init_create_info(c_info);
   4.161 +    libxl_init_create_info(c_info);
   4.162  
   4.163      c_info->hvm = 0;
   4.164      if (!xlu_cfg_get_string (config, "builder", &buf) &&
   4.165 @@ -762,7 +616,7 @@ static void parse_config_data(const char
   4.166          exit(1);
   4.167      }
   4.168  
   4.169 -    init_build_info(b_info, c_info);
   4.170 +    libxl_init_build_info(b_info, c_info);
   4.171  
   4.172      /* the following is the actual config parsing with overriding values in the structures */
   4.173      if (!xlu_cfg_get_long (config, "vcpus", &l)) {
   4.174 @@ -905,7 +759,7 @@ static void parse_config_data(const char
   4.175  
   4.176              d_config->vifs = (libxl_device_nic *) realloc(d_config->vifs, sizeof (libxl_device_nic) * (d_config->num_vifs+1));
   4.177              nic = d_config->vifs + d_config->num_vifs;
   4.178 -            init_nic_info(nic, d_config->num_vifs);
   4.179 +            CHK_ERRNO( libxl_device_nic_init(nic, d_config->num_vifs) );
   4.180  
   4.181              p = strtok(buf2, ",");
   4.182              if (!p)
   4.183 @@ -982,7 +836,7 @@ skip:
   4.184              d_config->vif2s = realloc(d_config->vif2s, sizeof (libxl_device_net2) * (d_config->num_vif2s + 1));
   4.185              net2 = d_config->vif2s + d_config->num_vif2s;
   4.186  
   4.187 -            init_net2_info(net2, d_config->num_vif2s);
   4.188 +            libxl_device_net2_init(net2, d_config->num_vif2s);
   4.189  
   4.190              for (p = strtok(buf2, ","); p; p = strtok(NULL, ",")) {
   4.191                  char* val;
   4.192 @@ -1034,11 +888,11 @@ skip:
   4.193  
   4.194              d_config->vfbs = (libxl_device_vfb *) realloc(d_config->vfbs, sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));
   4.195              vfb = d_config->vfbs + d_config->num_vfbs;
   4.196 -            init_vfb_info(vfb, d_config->num_vfbs);
   4.197 +            libxl_device_vfb_init(vfb, d_config->num_vfbs);
   4.198  
   4.199              d_config->vkbs = (libxl_device_vkb *) realloc(d_config->vkbs, sizeof(libxl_device_vkb) * (d_config->num_vkbs + 1));
   4.200              vkb = d_config->vkbs + d_config->num_vkbs;
   4.201 -            init_vkb_info(vkb, d_config->num_vkbs);
   4.202 +            libxl_device_vkb_init(vkb, d_config->num_vkbs);
   4.203  
   4.204              p = strtok(buf2, ",");
   4.205              if (!p)
   4.206 @@ -1188,7 +1042,7 @@ skip_vfb:
   4.207  
   4.208      if (c_info->hvm == 1) {
   4.209          /* init dm from c and b */
   4.210 -        init_dm_info(dm_info, c_info, b_info);
   4.211 +        libxl_init_dm_info(dm_info, c_info, b_info);
   4.212  
   4.213          /* then process config related to dm */
   4.214          xlu_cfg_replace_string (config, "device_model", &dm_info->device_model);
   4.215 @@ -4325,7 +4179,7 @@ int main_networkattach(int argc, char **
   4.216          fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
   4.217          return 1;
   4.218      }
   4.219 -    init_nic_info(&nic, -1);
   4.220 +    libxl_device_nic_init(&nic, -1);
   4.221      for (argv += optind+1, argc -= optind+1; argc > 0; ++argv, --argc) {
   4.222          if (!strncmp("type=", *argv, 5)) {
   4.223              if (!strncmp("vif", (*argv) + 5, 4)) {
   4.224 @@ -4659,7 +4513,7 @@ int main_network2attach(int argc, char *
   4.225          fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
   4.226          return 1;
   4.227      }
   4.228 -    init_net2_info(&net2, -1);
   4.229 +    libxl_device_net2_init(&net2, -1);
   4.230      for (argv += optind+1, argc -= optind+1; argc > 0; --argc, ++argv) {
   4.231          if (!strncmp("front_mac=", *argv, 10)) {
   4.232              tok = strtok((*argv) + 10, ":");