Improvements to libxl VIF hotplug and ocaml bindings (v2)
PATCH 1/1 Improvements to libxl VIF hotplug and ocaml bindings (v2)
Improvements to libxl VIF hotplug/unplug and ocaml bindings; xapi can now use these functions
This patch set includes:
1. addition of VIF QoS parameters to libxl (this code is ported from xapi/ xenops)
2. updates to the libxl ocaml bindings to make them more usable and more easily generatable from the IDL
3. bugfixes to the "xl network-attach" command so the QoS settings can be more easily tested.
FYI the corresponding xapi changes are in a branch here:
https://github.com/djs55/xen-api/tree/hackathon
Changes since the last submission include:
* updating the whole ocaml xl module to use the new style for consistency
* some dead ocaml functions were removed
* documentation for the QoS parameters added to the libxl IDL
* the QoS parameter was renamed to have "kb" rather than "kib" for consistency
PATCH 1/1 libxl: fix memory management in "xl network-attach"
# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 746e49e61dbc79797d1206a96e5b65651874b1bf # Parent a65612bcbb921e98a8843157bf365e4ab16e8144
libxl: fix memory management in "xl network-attach"
The libxl_device_nic struct has strings which are initially strdup()ed and then free()ed in libxl_device_nic_destroy(). In the "network-attach" parser we need to free() the existing string and strdup((*argv) + N), rather than just copying the pointer.
tools/libxl/xl_cmdimpl.c +8 -4
@@ -4277,12 +4277,14 @@ int main_networkattach(int argc, char ** nic.mac[i] = val; } }else if (!strncmp ("bridge=" , *argv,7 )) { - nic.bridge = (*argv) +7 ; +free (nic.bridge); + nic.bridge =strdup ((*argv) +7 ); }else if (!strncmp ("ip=" , *argv,3 )) {free (nic.ip); nic.ip =strdup ((*argv) +3 ); }else if (!strncmp ("script=" , *argv,6 )) { - nic.script = (*argv) +6 ; +free (nic.script); + nic.script =strdup ((*argv) +6 ); }else if (!strncmp ("backend=" , *argv,8 )) {if (libxl_name_to_domid (&ctx, ((*argv) +8 ), &val)) {fprintf (stderr,"Specified backend domain does not exist, defaulting to Dom0\n" );
@@ -4290,9 +4292,11 @@ int main_networkattach(int argc, char ** } nic.backend_domid = val; }else if (!strncmp ("vifname=" , *argv,8 )) { - nic.ifname = (*argv) +8 ; +free (nic.ifname); + nic.ifname =strdup ((*argv) +8 ); }else if (!strncmp ("model=" , *argv,6 )) { - nic.model = (*argv) +6 ; +free (nic.model); + nic.model =strdup ((*argv) +6 ); }else if (!strncmp ("rate=" , *argv,5 )) { }else if (!strncmp ("accel=" , *argv,6 )) { }else {
Ian Jackson
AppliedRe: [PATCH 01 of 14] libxl: fix memory management in "xl network-attach"
David Scott writes ("[Xen-devel] [PATCH 01 of 14] libxl: fix memory management in "xl network-attach""):
Quoted 1 line
libxl: fix memory management in "xl network-attach"
Applied, thanks all.
Ian.
PATCH 1/1 tools: ocaml: rename the device_nic types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 3050abaa45d6da7edeb8c7f4efd1ae8658740329 # Parent 746e49e61dbc79797d1206a96e5b65651874b1bf
tools: ocaml: rename the device_nic types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +17 -16
@@ -1,5 +1,5 @@ (* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -97,18 +97,22 @@ type nic_type = | NICTYPE_IOEMU | NICTYPE_VIF -type nic_info = -{ - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; -} +module Device_nic = struct + type t = + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end type console_type = | CONSOLETYPE_XENCONSOLED
@@ -179,9 +183,6 @@ external domain_build : build_info -> do external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" -external nic_add : nic_info -> domid -> unit = "stub_xl_nic_add" -external nic_remove : disk_info -> domid -> unit = "stub_xl_nic_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add"
tools/ocaml/libs/xl/xl.mli +17 -16
@@ -1,5 +1,5 @@ (* - * Copyright (C) 2009-2010 Citrix Ltd. + * Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -97,18 +97,22 @@ type nic_type = | NICTYPE_IOEMU | NICTYPE_VIF -type nic_info = -{ - backend_domid : domid; - devid : int; - mtu : int; - model : string; - mac : int array; - bridge : string; - ifname : string; - script : string; - nictype : nic_type; -} +module Device_nic : sig + type t = + { + backend_domid : domid; + devid : int; + mtu : int; + model : string; + mac : int array; + bridge : string; + ifname : string; + script : string; + nictype : nic_type; + } + external add : t -> domid -> unit = "stub_xl_device_nic_add" + external del : t -> domid -> unit = "stub_xl_device_nic_del" +end type console_type = | CONSOLETYPE_XENCONSOLED
@@ -179,9 +183,6 @@ external domain_build : build_info -> do external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" -external nic_add : nic_info -> domid -> unit = "stub_xl_nic_add" -external nic_remove : disk_info -> domid -> unit = "stub_xl_nic_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add"
tools/ocaml/libs/xl/xl_stubs.c +4 -4
@@ -1,5 +1,5 @@/* -* Copyright (C) 2009-2010 Citrix Ltd. +* Copyright (C) 2009-2011 Citrix Ltd. * Author Vincent Hanquez <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -397,7 +397,7 @@ value stub_xl_disk_remove(value info, vaCAMLreturn (Val_unit); } -value stub_xl_nic_add (value info,value domid) +value stub_xl_device_nic_add (value info,value domid) {CAMLparam2 (info, domid);libxl_device_nic c_info;
@@ -415,7 +415,7 @@ value stub_xl_nic_add(value info, valueCAMLreturn (Val_unit); } -value stub_xl_nic_remove (value info,value domid) +value stub_xl_device_nic_del (value info,value domid) {CAMLparam2 (info, domid);libxl_device_nic c_info;
@@ -428,7 +428,7 @@ value stub_xl_nic_remove(value info, valINIT_CTX (); ret =libxl_device_nic_del (&ctx, &c_info,0 );if (ret !=0 ) -failwith_xl ("nic_remove" , &lg); +failwith_xl ("nic_del" , &lg);FREE_CTX ();CAMLreturn (Val_unit); }
PATCH 1/1 tools: ocaml: rename the disk_info types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 6ca09bec9c49ccf3b93606fd3f5fd807c9438cc1 # Parent 3050abaa45d6da7edeb8c7f4efd1ae8658740329
tools: ocaml: rename the disk_info types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +15 -13
@@ -82,16 +82,21 @@ type disk_phystype = | PHYSTYPE_FILE | PHYSTYPE_PHY -type disk_info = -{ - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; -} +module Device_disk = struct + type t = + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end type nic_type = | NICTYPE_IOEMU
@@ -180,9 +185,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" -external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add"
tools/ocaml/libs/xl/xl.mli +15 -13
@@ -82,16 +82,21 @@ type disk_phystype = | PHYSTYPE_FILE | PHYSTYPE_PHY -type disk_info = -{ - backend_domid : domid; - physpath : string; - phystype : disk_phystype; - virtpath : string; - unpluggable : bool; - readwrite : bool; - is_cdrom : bool; -} +module Device_disk : sig + type t = + { + backend_domid : domid; + physpath : string; + phystype : disk_phystype; + virtpath : string; + unpluggable : bool; + readwrite : bool; + is_cdrom : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_disk_add" + external del : t -> domid -> unit = "stub_xl_device_disk_del" +end type nic_type = | NICTYPE_IOEMU
@@ -180,9 +185,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external disk_add : disk_info -> domid -> unit = "stub_xl_disk_add" -external disk_remove : disk_info -> domid -> unit = "stub_xl_disk_remove" - external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add"
tools/ocaml/libs/xl/xl_stubs.c +3 -3
@@ -361,7 +361,7 @@ static value Val_physinfo(libxl_physinfoCAMLreturn (v); } -value stub_xl_disk_add (value info,value domid) +value stub_xl_device_disk_add (value info,value domid) {CAMLparam2 (info, domid);libxl_device_disk c_info;
@@ -379,7 +379,7 @@ value stub_xl_disk_add(value info, valueCAMLreturn (Val_unit); } -value stub_xl_disk_remove (value info,value domid) +value stub_xl_device_disk_del (value info,value domid) {CAMLparam2 (info, domid);libxl_device_disk c_info;
@@ -392,7 +392,7 @@ value stub_xl_disk_remove(value info, vaINIT_CTX (); ret =libxl_device_disk_del (&ctx, &c_info,0 );if (ret !=0 ) -failwith_xl ("disk_remove" , &lg); +failwith_xl ("disk_del" , &lg);FREE_CTX ();CAMLreturn (Val_unit); }
PATCH 1/1 tools: ocaml: rename the console types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 6aa054dd7ba1d9bddb06a9499c1f292550f9435b # Parent 6ca09bec9c49ccf3b93606fd3f5fd807c9438cc1
tools: ocaml: rename the console types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +10 -8
@@ -123,12 +123,16 @@ type console_type = | CONSOLETYPE_XENCONSOLED | CONSOLETYPE_IOEMU -type console_info = -{ - backend_domid : domid; - devid : int; - consoletype : console_type; -} +module Device_console = struct + type t = + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" +end type vkb_info = {
@@ -185,8 +189,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" - external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown"
tools/ocaml/libs/xl/xl.mli +10 -8
@@ -123,12 +123,16 @@ type console_type = | CONSOLETYPE_XENCONSOLED | CONSOLETYPE_IOEMU -type console_info = -{ - backend_domid : domid; - devid : int; - consoletype : console_type; -} +module Device_console : sig + type t = + { + backend_domid : domid; + devid : int; + consoletype : console_type; + } + + external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" +end type vkb_info = {
@@ -185,8 +189,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external console_add : console_info -> build_state -> domid -> unit = "stub_xl_console_add" - external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown"
tools/ocaml/libs/xl/xl_stubs.c +1 -1
@@ -433,7 +433,7 @@ value stub_xl_device_nic_del(value info,CAMLreturn (Val_unit); } -value stub_xl_console_add (value info,value state,value domid) +value stub_xl_device_console_add (value info,value state,value domid) {CAMLparam3 (info, state, domid);libxl_device_console c_info;
PATCH 1/1 tools: ocaml: rename the vkb types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID e465e648db5f43d252a10594cbf68b2ee3732fd5 # Parent 6aa054dd7ba1d9bddb06a9499c1f292550f9435b
tools: ocaml: rename the vkb types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +32 -28
@@ -134,27 +134,39 @@ module Device_console = struct external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" end -type vkb_info = -{ - backend_domid : domid; - devid : int; -} +module Device_vkb = struct + type t = + { + backend_domid : domid; + devid : int; + } + + external add : t -> domid -> unit = "stub_xl_device_vkb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vkb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vkb_hard_shutdown" +end -type vfb_info = -{ - backend_domid : domid; - devid : int; - vnc : bool; - vnclisten : string; - vncpasswd : string; - vncdisplay : int; - vncunused : bool; - keymap : string; - sdl : bool; - opengl : bool; - display : string; - xauthority : string; -} +module Device_vfb = struct + type t = + { + backend_domid : domid; + devid : int; + vnc : bool; + vnclisten : string; + vncpasswd : string; + vncdisplay : int; + vncunused : bool; + keymap : string; + sdl : bool; + opengl : bool; + display : string; + xauthority : string; + } + external add : t -> domid -> unit = "stub_xl_device_vfb_add" + external clean_shutdown : domid -> unit = "stub_xl_device_vfb_clean_shutdown" + external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" +end + type pci_info = {
@@ -189,14 +201,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external vkb_add : vkb_info -> domid -> unit = "stub_xl_vkb_add" -external vkb_clean_shutdown : domid -> unit = "stub_vkb_clean_shutdown" -external vkb_hard_shutdown : domid -> unit = "stub_vkb_hard_shutdown" - -external vfb_add : vfb_info -> domid -> unit = "stub_xl_vfb_add" -external vfb_clean_shutdown : domid -> unit = "stub_vfb_clean_shutdown" -external vfb_hard_shutdown : domid -> unit = "stub_vfb_hard_shutdown" - external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown"
tools/ocaml/libs/xl/xl.mli +31 -28
72 lines not on this page · raw message
tools/ocaml/libs/xl/xl_stubs.c +6 -6
@@ -454,7 +454,7 @@ value stub_xl_device_console_add(value iCAMLreturn (Val_unit); } -value stub_xl_vkb_add (value info,value domid) +value stub_xl_device_vkb_add (value info,value domid) {CAMLparam2 (info, domid);libxl_device_vkb c_info;
@@ -473,7 +473,7 @@ value stub_xl_vkb_add(value info, valueCAMLreturn (Val_unit); } -value stub_xl_vkb_clean_shutdown (value domid) +value stub_xl_device_vkb_clean_shutdown (value domid) {CAMLparam1 (domid);int ret;
@@ -488,7 +488,7 @@ value stub_xl_vkb_clean_shutdown(value dCAMLreturn (Val_unit); } -value stub_xl_vkb_hard_shutdown (value domid) +value stub_xl_device_vkb_hard_shutdown (value domid) {CAMLparam1 (domid);int ret;
@@ -503,7 +503,7 @@ value stub_xl_vkb_hard_shutdown(value doCAMLreturn (Val_unit); } -value stub_xl_vfb_add (value info,value domid) +value stub_xl_device_vfb_add (value info,value domid) {CAMLparam2 (info, domid);libxl_device_vfb c_info;
@@ -522,7 +522,7 @@ value stub_xl_vfb_add(value info, valueCAMLreturn (Val_unit); } -value stub_xl_vfb_clean_shutdown (value domid) +value stub_xl_device_vfb_clean_shutdown (value domid) {CAMLparam1 (domid);int ret;
@@ -537,7 +537,7 @@ value stub_xl_vfb_clean_shutdown(value dCAMLreturn (Val_unit); } -value stub_xl_vfb_hard_shutdown (value domid) +value stub_xl_device_vfb_hard_shutdown (value domid) {CAMLparam1 (domid);int ret;
PATCH 1/1 tools: ocaml: rename the pci types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 139bf305233c45c02d1b64143dc135c78e16076f # Parent e465e648db5f43d252a10594cbf68b2ee3732fd5
tools: ocaml: rename the pci types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +13 -12
@@ -167,15 +167,20 @@ module Device_vfb = struct external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" end +module Device_pci = struct + type t = + { + v : int; (* domain * bus * dev * func multiplexed *) + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } -type pci_info = -{ - v : int; (* domain * bus * dev * func multiplexed *) - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; -} + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end type physinfo = {
@@ -201,10 +206,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" -external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" -external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown" - type button = | Button_Power | Button_Sleep
tools/ocaml/libs/xl/xl.mli +14 -12
@@ -167,14 +167,20 @@ module Device_vfb : sig external hard_shutdown : domid -> unit = "stub_xl_device_vfb_hard_shutdown" end -type pci_info = -{ - v : int; (* domain * bus * dev * func multiplexed *) - domain : int; - vdevfn : int; - msitranslate : bool; - power_mgmt : bool; -} +module Device_pci : sig + type t = + { + v : int; (* domain * bus * dev * func multiplexed *) + domain : int; + vdevfn : int; + msitranslate : bool; + power_mgmt : bool; + } + + external add : t -> domid -> unit = "stub_xl_device_pci_add" + external remove : t -> domid -> unit = "stub_xl_device_pci_remove" + external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" +end type physinfo = {
@@ -200,10 +206,6 @@ type sched_credit = external domain_make : create_info -> domid = "stub_xl_domain_make" external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" -external pci_add : pci_info -> domid -> unit = "stub_xl_pci_add" -external pci_remove : pci_info -> domid -> unit = "stub_xl_pci_remove" -external pci_shutdown : domid -> unit = "stub_xl_pci_shutdown" - type button = | Button_Power | Button_Sleep
tools/ocaml/libs/xl/xl_stubs.c +3 -3
@@ -552,7 +552,7 @@ value stub_xl_device_vfb_hard_shutdown(vCAMLreturn (Val_unit); } -value stub_xl_pci_add (value info,value domid) +value stub_xl_device_pci_add (value info,value domid) {CAMLparam2 (info, domid);libxl_device_pci c_info;
@@ -570,7 +570,7 @@ value stub_xl_pci_add(value info, valueCAMLreturn (Val_unit); } -value stub_xl_pci_remove (value info,value domid) +value stub_xl_device_pci_remove (value info,value domid) {CAMLparam2 (info, domid);libxl_device_pci c_info;
@@ -588,7 +588,7 @@ value stub_xl_pci_remove(value info, valCAMLreturn (Val_unit); } -value stub_xl_pci_shutdown (value domid) +value stub_xl_device_pci_shutdown (value domid) {CAMLparam1 (domid);int ret;
PATCH 1/1 tools: ocaml: remove the domain_make and domain_build functions since they don't work
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]>
# Date 1301507668 -3600
# Node ID 9cbc18430c281c6082381f67dc1ee739564f20d0
# Parent 139bf305233c45c02d1b64143dc135c78e16076f
tools: ocaml: remove the domain_make and domain_build functions since they don't work
The actual stubs are missing so these are currently a trap for the unwary.
tools/ocaml/libs/xl/xl.ml +0 -3
@@ -203,9 +203,6 @@ type sched_credit = cap: int; } -external domain_make : create_info -> domid = "stub_xl_domain_make" -external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" - type button = | Button_Power | Button_Sleep
tools/ocaml/libs/xl/xl.mli +0 -3
@@ -203,9 +203,6 @@ type sched_credit = cap: int; } -external domain_make : create_info -> domid = "stub_xl_domain_make" -external domain_build : build_info -> domid -> build_state = "stub_xl_domain_build" - type button = | Button_Power | Button_Sleep
PATCH 1/1 tools: ocaml: rename the create_info types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]>
# Date 1301507668 -3600
# Node ID 8ca5df5a9e813a783bc89226f902cd37a73ba09d # Parent 9cbc18430c281c6082381f67dc1ee739564f20d0
tools: ocaml: rename the create_info types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +15 -13
@@ -15,19 +15,21 @@ exception Error of string -type create_info = -{ - hvm : bool; - hap : bool; - oos : bool; - ssidref : int32; - name : string; - uuid : int array; - xsdata : (string * string) list; - platformdata : (string * string) list; - poolid : int32; - poolname : string; -} +module Domain_create_info = struct + type t = + { + hvm : bool; + hap : bool; + oos : bool; + ssidref : int32; + name : string; + uuid : int array; + xsdata : (string * string) list; + platformdata : (string * string) list; + poolid : int32; + poolname : string; + } +end type build_pv_info = {
tools/ocaml/libs/xl/xl.mli +15 -13
@@ -15,19 +15,21 @@ exception Error of string -type create_info = -{ - hvm : bool; - hap : bool; - oos : bool; - ssidref : int32; - name : string; - uuid : int array; - xsdata : (string * string) list; - platformdata : (string * string) list; - poolid : int32; - poolname : string; -} +module Domain_create_info : sig + type t = + { + hvm : bool; + hap : bool; + oos : bool; + ssidref : int32; + name : string; + uuid : int array; + xsdata : (string * string) list; + platformdata : (string * string) list; + poolid : int32; + poolname : string; + } +end type build_pv_info = {
PATCH 1/1 tools: ocaml: rename the build_info types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 3ca2e83310a56de7a025b2f2c50426a3b40598e4 # Parent 8ca5df5a9e813a783bc89226f902cd37a73ba09d
tools: ocaml: rename the build_info types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +36 -32
@@ -31,40 +31,44 @@ module Domain_create_info = struct } end -type build_pv_info = -{ - slack_memkb : int64; - cmdline : string; - ramdisk : string; - features : string; -} +module Domain_build_info = struct + module Hvm = struct + type t = + { + pae : bool; + apic : bool; + acpi : bool; + nx : bool; + viridian : bool; + timeoffset : string; + timer_mode : int; + hpet : int; + vpt_align : int; + } + end -type build_hvm_info = -{ - pae : bool; - apic : bool; - acpi : bool; - nx : bool; - viridian : bool; - timeoffset : string; - timer_mode : int; - hpet : int; - vpt_align : int; -} + module Pv = struct + type t = + { + slack_memkb : int64; + cmdline : string; + ramdisk : string; + features : string; + } + end -type build_spec = BuildHVM of build_hvm_info | BuildPV of build_pv_info - -type build_info = -{ - max_vcpus : int; - cur_vcpus : int; - max_memkb : int64; - target_memkb : int64; - video_memkb : int64; - shadow_memkb : int64; - kernel : string; - priv: build_spec; -} + type t = + { + max_vcpus : int; + cur_vcpus : int; + max_memkb : int64; + target_memkb : int64; + video_memkb : int64; + shadow_memkb : int64; + kernel : string; + u : [ `HVM of Hvm.t | `PV of Pv.t ]; + } +end type build_state = {
tools/ocaml/libs/xl/xl.mli +36 -32
76 lines not on this page · raw message
PATCH 1/1 tools: ocaml: rename the device_build_state types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]>
# Date 1301507668 -3600
# Node ID 976842c93bd399493c13ce71f4d9321fe2b2ffae
# Parent 3ca2e83310a56de7a025b2f2c50426a3b40598e4
tools: ocaml: rename the device_build_state types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +10 -8
@@ -70,13 +70,15 @@ module Domain_build_info = struct } end -type build_state = -{ - store_port : int; - store_mfn : int64; - console_port : int; - console_mfn : int64; -} +module Device_build_state = struct + type t = + { + store_port : int; + store_mfn : int64; + console_port : int; + console_mfn : int64; + } +end type domid = int
@@ -137,7 +139,7 @@ module Device_console = struct consoletype : console_type; } - external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" + external add : t -> Device_build_state.t -> domid -> unit = "stub_xl_device_console_add" end module Device_vkb = struct
tools/ocaml/libs/xl/xl.mli +10 -8
@@ -70,13 +70,15 @@ module Domain_build_info : sig } end -type build_state = -{ - store_port : int; - store_mfn : int64; - console_port : int; - console_mfn : int64; -} +module Device_build_state : sig + type t = + { + store_port : int; + store_mfn : int64; + console_port : int; + console_mfn : int64; + } +end type domid = int
@@ -137,7 +139,7 @@ module Device_console : sig consoletype : console_type; } - external add : t -> build_state -> domid -> unit = "stub_xl_device_console_add" + external add : t -> Device_build_state.t -> domid -> unit = "stub_xl_device_console_add" end module Device_vkb : sig
PATCH 1/1 tools: ocaml: rename the physinfo types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID b8aa09368adbc3863d7ed1e008c5bffb15e3ae4c # Parent 976842c93bd399493c13ce71f4d9321fe2b2ffae
tools: ocaml: rename the physinfo types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +18 -15
@@ -190,20 +190,24 @@ module Device_pci = struct external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" end -type physinfo = -{ - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; -} +module Physinfo = struct + type t = + { + threads_per_core: int; + cores_per_socket: int; + max_cpu_id: int; + nr_cpus: int; + cpu_khz: int; + total_pages: int64; + free_pages: int64; + scrub_pages: int64; + nr_nodes: int; + hwcap: int32 array; + physcap: int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end type sched_credit = {
@@ -216,7 +220,6 @@ type button = | Button_Sleep external button_press : domid -> button -> unit = "stub_xl_button_press" -external physinfo : unit -> physinfo = "stub_xl_physinfo" external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get" external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set"
tools/ocaml/libs/xl/xl.mli +18 -15
@@ -190,20 +190,24 @@ module Device_pci : sig external shutdown : domid -> unit = "stub_xl_device_pci_shutdown" end -type physinfo = -{ - threads_per_core: int; - cores_per_socket: int; - max_cpu_id: int; - nr_cpus: int; - cpu_khz: int; - total_pages: int64; - free_pages: int64; - scrub_pages: int64; - nr_nodes: int; - hwcap: int32 array; - physcap: int32; -} +module Physinfo : sig + type t = + { + threads_per_core: int; + cores_per_socket: int; + max_cpu_id: int; + nr_cpus: int; + cpu_khz: int; + total_pages: int64; + free_pages: int64; + scrub_pages: int64; + nr_nodes: int; + hwcap: int32 array; + physcap: int32; + } + external get : unit -> t = "stub_xl_physinfo" + +end type sched_credit = {
@@ -216,7 +220,6 @@ type button = | Button_Sleep external button_press : domid -> button -> unit = "stub_xl_button_press" -external physinfo : unit -> physinfo = "stub_xl_physinfo" external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get" external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set"
PATCH 1/1 tools: ocaml: rename the sched_credit types and functions
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]>
# Date 1301507668 -3600
# Node ID 62443233adf0d2319da50210057041380d7bd07f # Parent b8aa09368adbc3863d7ed1e008c5bffb15e3ae4c
tools: ocaml: rename the sched_credit types and functions
The aims are:
1. make the records instantiable if they have field names in common; and
2. to make it easier to derive the names programatically from the IDL
tools/ocaml/libs/xl/xl.ml +9 -8
@@ -209,11 +209,15 @@ module Physinfo = struct end -type sched_credit = -{ - weight: int; - cap: int; -} +module Sched_credit = struct + type t = + { + weight: int; + cap: int; + } + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end type button = | Button_Power
@@ -221,9 +225,6 @@ type button = external button_press : domid -> button -> unit = "stub_xl_button_press" -external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get" -external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set" - external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys"
tools/ocaml/libs/xl/xl.mli +10 -8
@@ -209,11 +209,16 @@ module Physinfo : sig end -type sched_credit = -{ - weight: int; - cap: int; -} +module Sched_credit : sig + type t = + { + weight: int; + cap: int; + } + + external domain_get : domid -> t = "stub_xl_sched_credit_domain_get" + external domain_set : domid -> t -> unit = "stub_xl_sched_credit_domain_set" +end type button = | Button_Power
@@ -221,9 +226,6 @@ type button = external button_press : domid -> button -> unit = "stub_xl_button_press" -external domain_sched_credit_get : domid -> sched_credit = "stub_xl_sched_credit_domain_get" -external domain_sched_credit_set : domid -> sched_credit -> unit = "stub_xl_sched_credit_domain_set" - external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger" external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq" external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys"
PATCH 1/1 libxl: add NIC QoS parameters
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]> # Date 1301507668 -3600
# Node ID 2501899ab12fcc128ac62b0319b7a6f0b8982a42 # Parent 62443233adf0d2319da50210057041380d7bd07f
libxl: add NIC QoS parameters
The parameters are:
qos_kb_per_sec: maximum rate in KiB/sec
qos_timeslice_usec: time period over which the average rate is enforced in
usec
One can now execute commands like
xl network-attach ... rate=1024,50000
which should impose an average limit of 1MiB/sec, over intervals of 50ms
The "rate" key in the network backend is interpreted by netback. It wants:
bytes_per_interval, interval_length
tools/libxl/libxl.c +11 -0
@@ -1194,6 +1194,8 @@ int libxl_device_nic_init(libxl_device_n libxl_xen_script_dir_path()) < 0 )return ERROR_FAIL ; nic_info->nictype =NICTYPE_IOEMU ; + nic_info->qos_kb_per_sec =0 ; + nic_info->qos_timeslice_usec =0 ;return 0 ; }
@@ -1205,6 +1207,7 @@ int libxl_device_nic_add(libxl_ctx *ctx,libxl__device device;char *dompath, **l;unsigned int nb, rc; +uint32_t bytes_per_interval; front =flexarray_make (16 ,1 );if (!front) {
@@ -1263,6 +1266,14 @@ int libxl_device_nic_add(libxl_ctx *ctx,flexarray_append (back,libxl__strdup (&gc, nic->bridge));flexarray_append (back,"handle" );flexarray_append (back,libxl__sprintf (&gc,"%d" , nic->devid)); +if (nic->qos_timeslice_usec >0 ) { + bytes_per_interval = (uint32_t ) + (((uint64_t )nic->qos_kb_per_sec *1024L * + (uint64_t )nic->qos_timeslice_usec) /1000000L ); +flexarray_append (back,"rate" ); +flexarray_append (back,libxl__sprintf (&gc,"%u,%u" , + bytes_per_interval, nic->qos_timeslice_usec)); + }flexarray_append (front,"backend-id" );flexarray_append (front,libxl__sprintf (&gc,"%d" , nic->backend_domid));
tools/libxl/libxl.idl +2 -0
@@ -225,6 +225,8 @@ libxl_device_nic = Struct("device_nic", ("ifname", string), ("script", string), ("nictype", libxl_nic_type), + ("qos_kb_per_sec", uint32, False, "maximum rate in KiB/sec"), + ("qos_timeslice_usec", uint32, False, "time period over which the rate is enforced in usec"), ]) libxl_device_net2 = Struct("device_net2", [
tools/libxl/xl_cmdimpl.c +8 -1
@@ -880,7 +880,10 @@ static void parse_config_data(const char nic->backend_domid =0 ; } }else if (!strcmp (p,"rate" )) { -fprintf (stderr,"the rate parameter for vifs is currently not supported\n" ); +if (sscanf (p2 +1 ,"%" PRIu32",%" PRIu32, &(nic->qos_kb_per_sec), &(nic->qos_timeslice_usec)) !=2 ) { +fprintf (stderr,"Specified rate parameter needs to take the form: kb_per_sec,timeslice_usec\n" ); +break ; + } }else if (!strcmp (p,"accel" )) {fprintf (stderr,"the accel parameter for vifs is currently not supported\n" ); }
@@ -4298,6 +4301,10 @@ int main_networkattach(int argc, char **free (nic.model); nic.model =strdup ((*argv) +6 ); }else if (!strncmp ("rate=" , *argv,5 )) { +if (sscanf ((*argv) +5 ,"%u,%u" , &(nic.qos_kb_per_sec), &(nic.qos_timeslice_usec)) !=2 ) { +fprintf (stderr,"Specified rate parameter needs to take the form: kb_per_sec,timeslice_usec\n" ); +return 1 ; + } }else if (!strncmp ("accel=" , *argv,6 )) { }else {fprintf (stderr,"unrecognized argument `%s'\n" , *argv);
Re: [PATCH 13 of 14] libxl: add NIC QoS parameters
tools/libxl/xl_cmdimpl.c static void parse_config_data(const char · line 886
Quoted 12 lines · Dave Scott
diff -r
62443233adf0-r2501899ab12ftools/libxl/xl_cmdimpl.ctools/libxl/xl_cmdimpl.c +4
-1@@ -880,7 +880,10 @@ static void parse_config_data(const char nic->backend_domid =0 ; } }else if (!strcmp (p,"rate" )) { -fprintf (stderr,"the rate parameter for vifs is currently not supported\n" ); +if (sscanf (p2 +1 ,"%" PRIu32",%" PRIu32, &(nic->qos_kb_per_sec), &(nic->qos_timeslice_usec)) !=2 ) { +fprintf (stderr,"Specified rate parameter needs to take the form: kb_per_sec,timeslice_usec\n" ); +break ; + }
The xend equivalent to the xl function is tools/python/xen/xend/server/netif.py parseRate() which seems to support a different syntax to xapi:
rate_re = re.compile("^([0-9]+)([GMK]?)([Bb])/s(@([0-9]+)([mu]?)s)?$")
The xend syntax seems to be e.g. 1Mb/s@1ms.
I don't know how widely used the full power of this syntax is but our general principal thus far has been to retain compatibility with xm where we can.
Since the xend syntax allows for b/Mb/Kb suffixes and therefore byte granularity that suggests the base unit for qos_kb_per_sec should actually be bytes.
Ian.
PATCH 1/1 tools: ocaml: add NIC QoS parameters to the ocaml libxl interface
In reply to David Scott# HG changeset patch
# User David Scott <[email protected]>
# Date 1301507668 -3600
# Node ID 852635d6df5cc507361e5a608a4953dd1eb98b0c
# Parent 2501899ab12fcc128ac62b0319b7a6f0b8982a42
tools: ocaml: add NIC QoS parameters to the ocaml libxl interface
tools/ocaml/libs/xl/xl.ml +2 -0
@@ -122,6 +122,8 @@ module Device_nic = struct ifname : string; script : string; nictype : nic_type; + qos_kb_per_sec : int32; + qos_timeslice_usec : int32; } external add : t -> domid -> unit = "stub_xl_device_nic_add" external del : t -> domid -> unit = "stub_xl_device_nic_del"
tools/ocaml/libs/xl/xl.mli +2 -0
@@ -122,6 +122,8 @@ module Device_nic : sig ifname : string; script : string; nictype : nic_type; + qos_kb_per_sec : int32; + qos_timeslice_usec : int32; } external add : t -> domid -> unit = "stub_xl_device_nic_add" external del : t -> domid -> unit = "stub_xl_device_nic_del"
tools/ocaml/libs/xl/xl_stubs.c +2 -1
@@ -225,7 +225,8 @@ static int device_nic_val(caml_gc *gc, l c_val->ifname =dup_String_val (gc,Field (v,6 )); c_val->script =dup_String_val (gc,Field (v,7 )); c_val->nictype = (Int_val (Field (v,8 ))) +NICTYPE_IOEMU ; - + c_val->qos_kb_per_sec = (Int_val (Field (v,9 ))); + c_val->qos_timeslice_usec = (Int_val (Field (v,10 ))); out:CAMLreturn (ret); }
Quoted 10 lines · Dave Scott
Improvements to libxl VIF hotplug/unplug and ocaml bindings; xapi can now use these functions
This patch set includes:
1. addition of VIF QoS parameters to libxl (this code is ported from xapi/ xenops)
2. updates to the libxl ocaml bindings to make them more usable and more easily generatable from the IDL
3. bugfixes to the "xl network-attach" command so the QoS settings can be more easily tested.
Quoted 3 lines
FYI the corresponding xapi changes are in a branch here:
Not up to date with the latest API changes? I'm just curious how this ends up looking on the user side.
I already acked 1 and 14/14. 2-12/14 all seem pretty mechanical. I suspect I will need to tweak things as I autogenerate things (esp. the build info tagged union stuff) but lets cross that bridge when we get there. On that basis 2-12 are all:
14/14 I already acked so that just leaves 13/14 -- see you over there in a moment ;-)
Thanks.
Quoted 13 lines
Changes since the last submission include:
* updating the whole ocaml xl module to use the new style for consistency
* some dead ocaml functions were removed
* documentation for the QoS parameters added to the libxl IDL
* the QoS parameter was renamed to have "kb" rather than "kib" for consistencySigned-off-by David Scott <dave.scott@xxxxxxxxxxxxx>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel