libxl: rationalise libxl_device_* APIs
PATCH 1/1 libxl: rationalise libxl_device_* APIs
The following series overhauls the libxl_device_* APIs in an attempt to make them more consistent across the types of devices and move towards something we can support as a stable API longterm.
This is broadly speaking the changes I discussed in [0]
One of the early patches adds a big comment describing the API. It would be useful if this got a particularly close eye with a view to supporting it long term -- especially from actual and potential consumers of the API (of who I've CC a few who sprang to mind).
Along the way I filed some rough edges of the internal implementation of this stuff but my primary concern is to make the public facing API one that we can commit to keeping stable.
One aspect which is missing is the ability to do asynchronous add/remove etc. This requires the overhaul of the libxl event system which Ian Jackson described at [1]. I did bear this in mind so hopefully I have provided the majority of the necessary moving parts internally.
[0] http://www.gossamer-threads.com/lists/xen/devel/204668
[1] http://www.gossamer-threads.com/lists/xen/devel/212580
& http://www.gossamer-threads.com/lists/xen/devel/212578 & http://www.gossamer-threads.com/lists/xen/devel/212579 & http://www.gossamer-threads.com/lists/xen/devel/212581
PATCH 1/1 libxl: remove hard tabs from non-generated *.[ch]
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389247 -3600
# Node ID 42dee7039d911db8b82e9f857fcad92a689d0318 # Parent de01831eb2a92600dac56c9791dfaa9445777f03
libxl: remove hard tabs from non-generated *.[ch]
The vast majority of this code uses four spaces and the tabs make my subsequent patches look funny...
tools/libxl/libxl.c +7 -7
@@ -696,13 +696,13 @@ int libxl_event_get_disk_eject_info(libxsscanf (backend, "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE) "[a-z]/%*d/%*d", &disk->backend_domid, backend_type); -if (!strcmp (backend_type,"tap" ) || !strcmp (backend_type,"vbd" )) { - disk->backend =LIBXL_DISK_BACKEND_TAP ; - }else if (!strcmp (backend_type,"qdisk" )) { - disk->backend =LIBXL_DISK_BACKEND_QDISK ; - }else { - disk->backend =LIBXL_DISK_BACKEND_UNKNOWN ; - } +if (!strcmp (backend_type,"tap" ) || !strcmp (backend_type,"vbd" )) { + disk->backend =LIBXL_DISK_BACKEND_TAP ; + }else if (!strcmp (backend_type,"qdisk" )) { + disk->backend =LIBXL_DISK_BACKEND_QDISK ; + }else { + disk->backend =LIBXL_DISK_BACKEND_UNKNOWN ; + } disk->pdev_path =strdup ("" ); disk->format =LIBXL_DISK_FORMAT_EMPTY ;
tools/libxl/libxl.h +1 -1
@@ -420,7 +420,7 @@ int libxl_cpuid_parse_config_xend(libxl_ const char* str);void libxl_cpuid_apply_policy (libxl_ctx *ctx,uint32_t domid);void libxl_cpuid_set (libxl_ctx *ctx,uint32_t domid, -libxl_cpuid_policy_list cpuid); +libxl_cpuid_policy_list cpuid);/* * Functions for allowing users of libxl to store private data
tools/libxl/libxl_bootloader.c +5 -5
@@ -81,14 +81,14 @@ static int open_xenconsoled_pty(int *mas ret =openpty (master, slave,NULL ,NULL ,NULL );if (ret <0 ) -return -1 ; +return -1 ; ret =ttyname_r (*slave, slave_path, slave_path_len);if (ret ==-1 ) { -close (*master); -close (*slave); - *master = *slave =-1 ; -return -1 ; +close (*master); +close (*slave); + *master = *slave =-1 ; +return -1 ; }/*
tools/libxl/libxl_cpuid.c +1 -1
@@ -317,7 +317,7 @@ void libxl_cpuid_apply_policy(libxl_ctx }void libxl_cpuid_set (libxl_ctx *ctx,uint32_t domid, -libxl_cpuid_policy_list cpuid) +libxl_cpuid_policy_list cpuid) {int i;char *cpuid_res[4 ];
tools/libxl/libxl_internal.c +32 -32
85 lines not on this page · raw message
tools/libxl/libxl_nocpuid.c +1 -1
@@ -32,6 +32,6 @@ void libxl_cpuid_apply_policy(libxl_ctx }void libxl_cpuid_set (libxl_ctx *ctx,uint32_t domid, -libxl_cpuid_policy_list cpuid) +libxl_cpuid_policy_list cpuid) { }
tools/libxl/libxl_pci.c +9 -9
@@ -1114,7 +1114,7 @@ static int e820_sanitize(libxl_ctx *ctx,if ((src[i].type ==E820_RAM ) || (src[i].type ==E820_UNUSABLE ) || (src[i].type ==0 )) -continue ; +continue ; start = src[i].addr < start ? src[i].addr : start; last = src[i].addr + src[i].size > last ?
@@ -1159,14 +1159,14 @@ static int e820_sanitize(libxl_ctx *ctx,* to E820_UNUSED. We also need to move some of the E820_RAM regions if * the overlap with ram_end. */ for (i =0 ; i < nr; i++) { -uint64_t end = src[i].addr + src[i].size; +uint64_t end = src[i].addr + src[i].size; -/* We don't care about E820_UNUSABLE, but we need to +/* We don't care about E820_UNUSABLE, but we need to * change the type to zero b/c the loop after this * sticks E820_UNUSABLE on the guest's E820 but ignores * the ones with type zero. */ if ((src[i].type ==E820_UNUSABLE ) || -/* Any region that is within the "RAM region" can +/* Any region that is within the "RAM region" can * be safely ditched. */ (end < ram_end)) { src[i].type =0 ;
@@ -1174,15 +1174,15 @@ static int e820_sanitize(libxl_ctx *ctx, }/* Look only at RAM regions. */ -if (src[i].type !=E820_RAM ) +if (src[i].type !=E820_RAM )continue ;/* We only care about RAM regions below 4GB. */ if (src[i].addr >= (1ULL <<32 ))continue ; -/* E820_RAM overlaps with our RAM region. Move it */ -if (src[i].addr < ram_end) { +/* E820_RAM overlaps with our RAM region. Move it */ +if (src[i].addr < ram_end) {uint64_t delta; src[i].type =E820_UNUSABLE ;
@@ -1236,8 +1236,8 @@ static int e820_sanitize(libxl_ctx *ctx,/* Almost done: copy them over, ignoring the undesireable ones */ for (i =0 ; i < nr; i++) {if ((src[i].type ==E820_RAM ) || - (src[i].type ==0 )) -continue ; + (src[i].type ==0 )) +continue ; e820[idx].type = src[i].type; e820[idx].addr = src[i].addr;
tools/libxl/libxl_utils.c +2 -2
@@ -457,7 +457,7 @@ int libxl_mac_to_device_nic(libxl_ctx *c rc =libxl__parse_mac (mac, mac_n);if (rc) -return rc; +return rc; nics =libxl_list_nics (ctx, domid, &nb);if (!nics)
@@ -509,7 +509,7 @@ int libxl_devid_to_device_nic(libxl_ctx val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/mac" , nic_path_fe)); rc =libxl__parse_mac (val, nic->mac);if (rc) - goto out; + goto out; nic->script =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"%s/script" , nic_path_be),NULL ); rc =0 ;
tools/libxl/libxlutil.h +1 -1
@@ -64,7 +64,7 @@ const char *xlu_cfg_get_listitem(const X*/ int xlu_disk_parse (XLU_Config *cfg,int nspecs,const char *const *specs, -libxl_device_disk *disk); +libxl_device_disk *disk);/* disk must have been initialised. * * On error, returns errno value. Bad strings cause EINVAL and
tools/libxl/xl_cmdimpl.c +4 -4
@@ -557,15 +557,15 @@ static void parse_disk_config_multistrinmemset (disk,0 ,sizeof (*disk));if (!*config) { - *config =xlu_cfg_init (stderr,"command line" ); -if (!*config) {perror ("xlu_cfg_init" );exit (-1 ); } + *config =xlu_cfg_init (stderr,"command line" ); +if (!*config) {perror ("xlu_cfg_init" );exit (-1 ); } } e =xlu_disk_parse (*config, nspecs, specs, disk);if (e ==EINVAL )exit (-1 );if (e) { -fprintf (stderr,"xlu_disk_parse failed: %s\n" ,strerror (errno)); -exit (-1 ); +fprintf (stderr,"xlu_disk_parse failed: %s\n" ,strerror (errno)); +exit (-1 ); } }
PATCH 1/1 libxl: add a comment describing the device interfaces
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389247 -3600
# Node ID 7c845e974def74de73f67123f39d6fd2769082e9 # Parent 42dee7039d911db8b82e9f857fcad92a689d0318
libxl: add a comment describing the device interfaces.
Subsequent patches will endevour to make reality match this defined interface.
tools/libxl/libxl.h +72 -0
@@ -379,6 +379,78 @@ libxl_dominfo * libxl_list_domain(libxl_libxl_cpupoolinfo *libxl_list_cpupool (libxl_ctx *,int *nb_pool);libxl_vminfo *libxl_list_vm (libxl_ctx *ctx,int *nb_vm); +/* +* Devices +* ======= +* +* Each device is represented by a libxl_device_<TYPE> data structure +* which is defined via the IDL. In addition some devices have an +* additional data type libxl_device_<TYPE>_getinfo which contains +* further runtime information about the device. +* +* A common set of methods are available for each device type. These +* are described below. +* +* Querying +* -------- +* +* libxl_device_<type>_list(ctx, domid, nr): +* +* Returns an array of libxl_device_<type> length nr representing +* the devices attached to the specified domain. +* +* libxl_device_<type>_getinfo(ctx, domid, device, info): +* +* Initialises info with details of the given device which must be +* attached to the specified domain. +* +* Creation / Control +* ------------------ +* +* libxl_device_<type>_init(ctx, device): +* +* Initalises device to a default configuration. +* +* libxl_device_<type>_add(ctx, domid, device): +* +* Adds the given device to the specified domain. This can be called +* while the guest is running (hotplug) or before boot (coldplug). +* +* This function only sets up the device but does not wait for the +* domain to connect to the device and therefore cannot block on the +* guest. +* +* XXX do we need a way to wait? e.g. wait_for_connect function? +* XXX perhaps an optional way to generate an event on connect? +* needs event system overhaul. +* +* libxl_device_<type>_remove(ctx, domid, device): +* +* Removes the given device from the specified domain by performing +* an orderly unplug with guest co-operation. This requires that the +* guest is running. +* +* This method is currently synchronous and therefore can block +* while interacting with the guest. +* +* XXX should provide an async version. needs event system overhaul. +* +* libxl_device_<type>_force_remove(ctx, domid, device): +* +* Removes the given device from the specified domain without guest +* co-operation. It is guest specific what affect this will have on +* a running guest. +* +* This function does not interact with the guest and therefore +* cannot block on the guest. +* +* Note +* ---- +* +* The function libxl_device_<type>_destroy is defined by the IDL and +* is used to free the members of the libxl_device_<type> data +* type. It has no impact on the devices attached to any domain. +*/ int libxl_device_disk_add (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk);int libxl_device_disk_del (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk,int wait);libxl_device_disk *libxl_device_disk_list (libxl_ctx *ctx,uint32_t domid,int *num);
PATCH 1/1 libxl: various fixes to libxl_device_disk_list (and internals)
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID 9fdae058b42c9a8981599d96e1de3131997e7b64
# Parent 7c845e974def74de73f67123f39d6fd2769082e9
libxl: various fixes to libxl_device_disk_list (and internals)
- handle realloc errors
- remove redundancy of libxl__append_disk_list_of_type return value and ndisks paramter.
tools/libxl/libxl.c +33 -13
@@ -1502,11 +1502,11 @@ int libxl_device_vkb_hard_shutdown(libxlreturn ERROR_NI ; } -static unsigned int libxl__append_disk_list_of_type (libxl__gc *gc, -uint32_t domid, -const char *type, -libxl_device_disk **disks, -unsigned int *ndisks) +static int libxl__append_disk_list_of_type (libxl__gc *gc, +uint32_t domid, +const char *type, +libxl_device_disk **disks, +int *ndisks) {libxl_ctx *ctx =libxl__gc_owner (gc);char *be_path =NULL ;
@@ -1520,11 +1520,16 @@ static unsigned int libxl__append_disk_l dir =libxl__xs_directory (gc,XBT_NULL , be_path, &n);if (dir) {char *removable; - *disks =realloc (*disks,sizeof (libxl_device_disk) * (*ndisks + n)); +libxl_device_disk *tmp; + tmp =realloc (*disks,sizeof (libxl_device_disk) * (*ndisks + n)); +if (tmp ==NULL ) +return ERROR_NOMEM ; + *disks = tmp; pdisk = *disks + *ndisks; *ndisks += n; pdisk_end = *disks + *ndisks;for (; pdisk < pdisk_end; pdisk++, dir++) { +memset (pdisk,0 ,sizeof (*pdisk)); pdisk->backend_domid =0 ; physpath_tmp =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (gc,"%s/%s/params" , be_path, *dir), &len);if (physpath_tmp &&strchr (physpath_tmp,':' )) {
@@ -1552,22 +1557,37 @@ static unsigned int libxl__append_disk_l pdisk->format =LIBXL_DISK_FORMAT_UNKNOWN ; } } - -return n; +return 0 ; }libxl_device_disk *libxl_device_disk_list (libxl_ctx *ctx,uint32_t domid,int *num) {libxl__gc gc =LIBXL_INIT_GC (ctx);libxl_device_disk *disks =NULL ; -unsigned int ndisks =0 ; - - *num =libxl__append_disk_list_of_type (&gc, domid,"vbd" , &disks, &ndisks); - *num +=libxl__append_disk_list_of_type (&gc, domid,"tap" , &disks, &ndisks); - *num +=libxl__append_disk_list_of_type (&gc, domid,"qdisk" , &disks, &ndisks); +int rc; + + *num =0 ; + + rc =libxl__append_disk_list_of_type (&gc, domid,"vbd" , &disks, num); +if (rc) goto out_err; + + rc =libxl__append_disk_list_of_type (&gc, domid,"tap" , &disks, num); +if (rc) goto out_err; + + rc =libxl__append_disk_list_of_type (&gc, domid,"qdisk" , &disks, num); +if (rc) goto out_err;libxl__free_all (&gc);return disks; + +out_err: +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Unable to list disks" ); +while (disks && *num) { + (*num)--; +libxl_device_disk_destroy (&disks[*num]); + } +free (disks); +return NULL ; } int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
PATCH 1/1 libxl: refactor code to construct disk from xenstore backend
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID 8645a81f04282ca4e3c51141b1c177ad9a8d5943 # Parent 9fdae058b42c9a8981599d96e1de3131997e7b64
libxl: refactor code to construct disk from xenstore backend
Temporarily retain unsafe behaviour of reading f.e. directory.
tools/libxl/libxl.c +52 -29
@@ -1502,24 +1502,69 @@ int libxl_device_vkb_hard_shutdown(libxlreturn ERROR_NI ; } +static void libxl__device_disk_from_xs_be (libxl__gc *gc, +const char *be_path, +libxl_device_disk *disk) +{ +libxl_ctx *ctx =libxl__gc_owner (gc); +unsigned int len; +char *tmp; +const char *fe_path;/* XXX unsafe */ + +memset (disk,0 ,sizeof (*disk)); + + tmp =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/params" , be_path), &len); +if (tmp &&strchr (tmp,':' )) { + disk->pdev_path =strdup (strchr (tmp,':' ) +1 ); +free (tmp); + }else { + disk->pdev_path = tmp; + } +libxl_string_to_backend (ctx, +libxl__xs_read (gc,XBT_NULL , +libxl__sprintf (gc,"%s/type" , be_path)), + &(disk->backend)); + disk->vdev =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/dev" , be_path), &len); + tmp =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf + (gc,"%s/removable" , be_path)); + +if (tmp) + disk->removable =atoi (tmp); +else + disk->removable =0 ; + + tmp =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/mode" , be_path)); +if (!strcmp (tmp,"w" )) + disk->readwrite =1 ; +else + disk->readwrite =0 ; + + fe_path =libxl__xs_read (gc,XBT_NULL , +libxl__sprintf (gc,"%s/frontend" , be_path)); + tmp =libxl__xs_read (gc,XBT_NULL , +libxl__sprintf (gc,"%s/device-type" , fe_path)); + disk->is_cdrom = !strcmp (tmp,"cdrom" ); + + disk->format =LIBXL_DISK_FORMAT_UNKNOWN ; +} +static int libxl__append_disk_list_of_type (libxl__gc *gc,uint32_t domid,const char *type,libxl_device_disk **disks,int *ndisks) { -libxl_ctx *ctx =libxl__gc_owner (gc);char *be_path =NULL ;char **dir =NULL ; -unsigned int n =0 , len =0 ; +unsigned int n =0 ;libxl_device_disk *pdisk =NULL , *pdisk_end =NULL ; -char *physpath_tmp =NULL ; be_path =libxl__sprintf (gc,"%s/backend/%s/%d" ,libxl__xs_get_dompath (gc,0 ), type, domid); dir =libxl__xs_directory (gc,XBT_NULL , be_path, &n);if (dir) { -char *removable;libxl_device_disk *tmp; tmp =realloc (*disks,sizeof (libxl_device_disk) * (*ndisks + n));if (tmp ==NULL )
@@ -1529,32 +1574,10 @@ static int libxl__append_disk_list_of_ty *ndisks += n; pdisk_end = *disks + *ndisks;for (; pdisk < pdisk_end; pdisk++, dir++) { -memset (pdisk,0 ,sizeof (*pdisk)); +const char *p; + p =libxl__sprintf (gc,"%s/%s" , be_path, *dir); +libxl__device_disk_from_xs_be (gc, p, pdisk); pdisk->backend_domid =0 ; - physpath_tmp =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (gc,"%s/%s/params" , be_path, *dir), &len); -if (physpath_tmp &&strchr (physpath_tmp,':' )) { - pdisk->pdev_path =strdup (strchr (physpath_tmp,':' ) +1 ); -free (physpath_tmp); - }else { - pdisk->pdev_path = physpath_tmp; - } -libxl_string_to_backend (ctx,libxl__xs_read (gc,XBT_NULL , -libxl__sprintf (gc,"%s/%s/type" , be_path, *dir)), - &(pdisk->backend)); - pdisk->vdev =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (gc,"%s/%s/dev" , be_path, *dir), &len); - removable =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf - (gc,"%s/%s/removable" , be_path, *dir)); -if (removable) - pdisk->removable =atoi (removable); -else - pdisk->removable =0 ; -if (!strcmp (libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/%s/mode" , be_path, *dir)),"w" )) - pdisk->readwrite =1 ; -else - pdisk->readwrite =0 ; - type =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/device-type" ,libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/%s/frontend" , be_path, *dir)))); - pdisk->is_cdrom = !strcmp (type,"cdrom" ); - pdisk->format =LIBXL_DISK_FORMAT_UNKNOWN ; } }return 0 ;
PATCH 1/1 libxl: do not read f.e. xenstore dir in disk list function
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID 4e640cbed20e8ef533f8eb27a82dcdac2be2e8ab # Parent 8645a81f04282ca4e3c51141b1c177ad9a8d5943
libxl: do not read f.e. xenstore dir in disk list function
Instead store a duplicate of the "device-type" node in the backend dir and use that instead.
This maintains the invariant that the list function is always "safe".
XXX I'm not sure this is an actual issue. The entries in the frontend device XXX area are writeable by the guest but maybe the solution is to restrict that?
tools/libxl/libxl.c +3 -4
@@ -1015,6 +1015,8 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_append (back,libxl__device_disk_string_of_backend (disk->backend));flexarray_append (back,"mode" );flexarray_append (back, disk->readwrite ?"w" :"r" ); +flexarray_append (back,"device-type" ); +flexarray_append (back, disk->is_cdrom ?"cdrom" :"disk" );flexarray_append (front,"backend-id" );flexarray_append (front,libxl__sprintf (&gc,"%d" , disk->backend_domid));
@@ -1509,7 +1511,6 @@ static void libxl__device_disk_from_xs_blibxl_ctx *ctx =libxl__gc_owner (gc);unsigned int len;char *tmp; -const char *fe_path;/* XXX unsafe */ memset (disk,0 ,sizeof (*disk));
@@ -1541,10 +1542,8 @@ static void libxl__device_disk_from_xs_belse disk->readwrite =0 ; - fe_path =libxl__xs_read (gc,XBT_NULL , -libxl__sprintf (gc,"%s/frontend" , be_path)); tmp =libxl__xs_read (gc,XBT_NULL , -libxl__sprintf (gc,"%s/device-type" , fe_path)); +libxl__sprintf (gc,"%s/device-type" , be_path)); disk->is_cdrom = !strcmp (tmp,"cdrom" ); disk->format =LIBXL_DISK_FORMAT_UNKNOWN ;
PATCH 1/1 libxl: update nic list API to use common device API style
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID cafd8b3f9e0c8bbf5c30cfcd512c1486661ca4d9 # Parent 4e640cbed20e8ef533f8eb27a82dcdac2be2e8ab
libxl: update nic list API to use common device API style
libxl_device_nic_list returns an array of libxl_device_nic and libxl_device_nic_getinfo retrieves further information.
tools/libxl/libxl.c +125 -47
@@ -1288,60 +1288,138 @@ int libxl_device_nic_del(libxl_ctx *ctx,return rc; } -libxl_nicinfo *libxl_list_nics (libxl_ctx *ctx,uint32_t domid,unsigned int *nb) +static void libxl__device_nic_from_xs_be (libxl__gc *gc, +const char *be_path, +libxl_device_nic *nic) +{ +libxl_ctx *ctx =libxl__gc_owner (gc); +unsigned int len; +char *tmp; +int rc; + +memset (nic,0 ,sizeof (*nic)); + + tmp =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/handle" , be_path), &len); +if ( tmp ) + nic->devid =atoi (tmp); +else + nic->devid =0 ; + +/* nic->mtu = */ + + tmp =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/mac" , be_path), &len); + rc =libxl__parse_mac (tmp, nic->mac); +if (rc) +memset (nic->mac,0 ,sizeof (nic->mac)); + + nic->ip =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/ip" , be_path), &len); + + nic->bridge =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/bridge" , be_path), &len); + + nic->script =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/script" , be_path), &len); + +/* XXX ioemu nics are not in xenstore at all? */ + nic->nictype =LIBXL_NIC_TYPE_VIF ; + nic->model =NULL ;/* XXX Only for TYPE_IOEMU */ + nic->ifname =NULL ;/* XXX Only for TYPE_IOEMU */ +} + +static int libxl__append_nic_list_of_type (libxl__gc *gc, +uint32_t domid, +const char *type, +libxl_device_nic **nics, +int *nnics) +{ +char *be_path =NULL ; +char **dir =NULL ; +unsigned int n =0 ; +libxl_device_nic *pnic =NULL , *pnic_end =NULL ; + + be_path =libxl__sprintf (gc,"%s/backend/%s/%d" , +libxl__xs_get_dompath (gc,0 ), type, domid); + dir =libxl__xs_directory (gc,XBT_NULL , be_path, &n); +if (dir) { +libxl_device_nic *tmp; + tmp =realloc (*nics,sizeof (libxl_device_nic) * (*nnics + n)); +if (tmp ==NULL ) +return ERROR_NOMEM ; + *nics = tmp; + pnic = *nics + *nnics; + *nnics += n; + pnic_end = *nics + *nnics; +for (; pnic < pnic_end; pnic++, dir++) { +const char *p; + p =libxl__sprintf (gc,"%s/%s" , be_path, *dir); +libxl__device_nic_from_xs_be (gc, p, pnic); + pnic->backend_domid =0 ; + } + } +return 0 ; +} + +libxl_device_nic *libxl_device_nic_list (libxl_ctx *ctx,uint32_t domid,int *num) {libxl__gc gc =LIBXL_INIT_GC (ctx); -char *dompath, *nic_path_fe; -char **l, **list; -char *val, *tok; -unsigned int nb_nics, i; -libxl_nicinfo *res, *nics; +libxl_device_nic *nics =NULL ; +int rc; + + *num =0 ; + + rc =libxl__append_nic_list_of_type (&gc, domid,"vif" , &nics, num); +if (rc) goto out_err; + +libxl__free_all (&gc); +return nics; + +out_err: +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Unable to list nics" ); +while (*num) { + (*num)--; +libxl_device_nic_destroy (&nics[*num]); + } +free (nics); +return NULL ; +} + +int libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid, +libxl_device_nic *nic,libxl_nicinfo *nicinfo) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +char *dompath, *nicpath; +char *val; dompath =libxl__xs_get_dompath (&gc, domid); -if (!dompath) - goto err; - list = l =libxl__xs_directory (&gc,XBT_NULL , -libxl__sprintf (&gc,"%s/device/vif" , dompath), &nb_nics); -if (!l) - goto err; - nics = res =calloc (nb_nics,sizeof (libxl_nicinfo)); -if (!res) - goto err; -for (*nb = nb_nics; nb_nics >0 ; --nb_nics, ++l, ++nics) { - nic_path_fe =libxl__sprintf (&gc,"%s/device/vif/%s" , dompath, *l); - - nics->backend =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (&gc,"%s/backend" , nic_path_fe),NULL ); - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/backend-id" , nic_path_fe)); - nics->backend_id = val ?strtoul (val,NULL ,10 ) :-1 ; - - nics->devid =strtoul (*l,NULL ,10 ); - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/state" , nic_path_fe)); - nics->state = val ?strtoul (val,NULL ,10 ) :-1 ; - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/mac" , nic_path_fe)); -for (i =0 , tok =strtok (val,":" ); tok && (i <6 ); - ++i, tok =strtok (NULL ,":" )) { - nics->mac[i] =strtoul (tok,NULL ,16 ); - } - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/event-channel" , nic_path_fe)); - nics->evtch = val ?strtol (val,NULL ,10 ) :-1 ; - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/tx-ring-ref" , nic_path_fe)); - nics->rref_tx = val ?strtol (val,NULL ,10 ) :-1 ; - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/rx-ring-ref" , nic_path_fe)); - nics->rref_rx = val ?strtol (val,NULL ,10 ) :-1 ; - nics->frontend =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (&gc,"%s/frontend" , nics->backend),NULL ); - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/frontend-id" , nics->backend)); - nics->frontend_id = val ?strtoul (val,NULL ,10 ) :-1 ; - nics->script =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (&gc,"%s/script" , nics->backend),NULL ); + nicinfo->devid = nic->devid; + + nicpath =libxl__sprintf (&gc,"%s/device/vif/%d" , dompath, nicinfo->devid); + nicinfo->backend =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (&gc,"%s/backend" , nicpath),NULL ); +if (!nicinfo->backend) { +libxl__free_all (&gc); +return ERROR_FAIL ; } + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/backend-id" , nicpath)); + nicinfo->backend_id = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/state" , nicpath)); + nicinfo->state = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/event-channel" , nicpath)); + nicinfo->evtch = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/tx-ring-ref" , nicpath)); + nicinfo->rref_tx = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/rx-ring-ref" , nicpath)); + nicinfo->rref_rx = val ?strtoul (val,NULL ,10 ) :-1 ; + nicinfo->frontend =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (&gc,"%s/frontend" , nicinfo->backend),NULL ); + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/frontend-id" , nicinfo->backend)); + nicinfo->frontend_id = val ?strtoul (val,NULL ,10 ) :-1 ;libxl__free_all (&gc); -return res; -err: -libxl__free_all (&gc); -return NULL ; +return 0 ; }/******************************************************************************/
tools/libxl/libxl.h +3 -1
@@ -467,7 +467,9 @@ int libxl_device_disk_local_detach(libxlint libxl_device_nic_init (libxl_device_nic *nic,int dev_num);int libxl_device_nic_add (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic);int libxl_device_nic_del (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,int wait); -libxl_nicinfo *libxl_list_nics (libxl_ctx *ctx,uint32_t domid,unsigned int *nb); +libxl_device_nic *libxl_device_nic_list (libxl_ctx *ctx,uint32_t domid,int *num); +int libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid, +libxl_device_nic *nic,libxl_nicinfo *nicinfo);int libxl_device_console_add (libxl_ctx *ctx,uint32_t domid,libxl_device_console *console);
tools/libxl/libxl_types.idl +0 -2
@@ -330,8 +330,6 @@ libxl_nicinfo = Struct("nicinfo", [ ("frontend_id", uint32), ("devid", integer), ("state", integer), - ("script", string), - ("mac", libxl_mac), ("evtch", integer), ("rref_tx", integer), ("rref_rx", integer),
tools/libxl/libxl_utils.c +9 -9
@@ -451,15 +451,15 @@ int libxl_pipe(libxl_ctx *ctx, int pipesint libxl_mac_to_device_nic (libxl_ctx *ctx,uint32_t domid,const char *mac,libxl_device_nic *nic) { -libxl_nicinfo *nics; -unsigned int nb, rc, i; +libxl_device_nic *nics; +int nb, rc, i;libxl_mac mac_n; rc =libxl__parse_mac (mac, mac_n);if (rc)return rc; - nics =libxl_list_nics (ctx, domid, &nb); + nics =libxl_device_nic_list (ctx, domid, &nb);if (!nics)return ERROR_FAIL ;
@@ -468,17 +468,17 @@ int libxl_mac_to_device_nic(libxl_ctx *c rc =ERROR_INVAL ;for (i =0 ; i < nb; ++i) {if (!libxl__compare_macs (&mac_n, &nics[i].mac)) { - nic->backend_domid = nics[i].backend_id; - nic->devid = nics[i].devid; -memcpy (nic->mac, nics[i].mac,sizeof (nic->mac)); - nic->script =strdup (nics[i].script); + *nic = nics[i]; rc =0 ; + i++;/* Do not destroy this NIC on exit path */ break ; } +libxl_device_nic_destroy (&nics[i]); } -for (i=0 ; i<nb; i++) -libxl_nicinfo_destroy (&nics[i]); +for (; i<nb; i++) +libxl_device_nic_destroy (&nics[i]); +free (nics);return rc; }
tools/libxl/xl_cmdimpl.c +17 -12
@@ -4085,8 +4085,9 @@ int main_networkattach(int argc, char **int main_networklist (int argc,char **argv) {int opt; -libxl_nicinfo *nics; -unsigned int nb, i; +libxl_device_nic *nics; +libxl_nicinfo nicinfo; +int nb, i;if ((opt =def_getopt (argc, argv,"" ,"network-list" ,1 )) !=-1 )return opt;
@@ -4099,19 +4100,23 @@ int main_networklist(int argc, char **arfprintf (stderr,"%s is an invalid domain identifier\n" , *argv);continue ; } -if (!(nics =libxl_list_nics (ctx, domid, &nb))) { + nics =libxl_device_nic_list (ctx, domid, &nb); +if (!nics) {continue ; }for (i =0 ; i < nb; ++i) { -/* Idx BE */ -printf ("%-3d %-2d " , nics[i].devid, nics[i].backend_id); -/* MAC */ -printf (LIBXL_MAC_FMT ,LIBXL_MAC_BYTES (nics[i].mac)); -/* Hdl Sta evch txr/rxr BE-path */ -printf ("%6d %5d %6d %5d/%-11d %-30s\n" , - nics[i].devid, nics[i].state, nics[i].evtch, - nics[i].rref_tx, nics[i].rref_rx, nics[i].backend); -libxl_nicinfo_destroy (&nics[i]); +if (!libxl_device_nic_getinfo (ctx, domid, &nics[i], &nicinfo)) { +/* Idx BE */ +printf ("%-3d %-2d " , nicinfo.devid, nicinfo.backend_id); +/* MAC */ +printf (LIBXL_MAC_FMT ,LIBXL_MAC_BYTES (nics[i].mac)); +/* Hdl Sta evch txr/rxr BE-path */ +printf ("%6d %5d %6d %5d/%-11d %-30s\n" , + nicinfo.devid, nicinfo.state, nicinfo.evtch, + nicinfo.rref_tx, nicinfo.rref_rx, nicinfo.backend); +libxl_nicinfo_destroy (&nicinfo); + } +libxl_device_nic_destroy (&nics[i]); }free (nics); }
PATCH 1/1 libxl: reimplement devid->nic in terms of from_xs_be function
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID e65e18b230493e7886654d30838ce74407c36168
# Parent cafd8b3f9e0c8bbf5c30cfcd512c1486661ca4d9
libxl: reimplement devid->nic in terms of from_xs_be function.
tools/libxl/libxl.c +27 -1
@@ -1312,7 +1312,7 @@ static void libxl__device_nic_from_xs_be libxl__sprintf(gc, "%s/mac", be_path), &len); rc =libxl__parse_mac (tmp, nic->mac);if (rc) -memset (nic->mac,0 ,sizeof (nic->mac)); +memset (nic->mac,0 ,sizeof (nic->mac)); nic->ip =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (gc,"%s/ip" , be_path), &len);
@@ -1329,6 +1329,32 @@ static void libxl__device_nic_from_xs_be nic->ifname =NULL ;/* XXX Only for TYPE_IOEMU */ } +int libxl_devid_to_device_nic (libxl_ctx *ctx,uint32_t domid, +const char *devid,libxl_device_nic *nic) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +char *dompath, *path; +int rc =ERROR_FAIL ; + +memset (nic,0 ,sizeof (libxl_device_nic)); + dompath =libxl__xs_get_dompath (&gc, domid); +if (!dompath) + goto out; + + path =libxl__xs_read (&gc,XBT_NULL , +libxl__sprintf (&gc,"%s/device/vif/%s/backend" , + dompath, devid)); +if (!path) + goto out; + +libxl__device_nic_from_xs_be (&gc, path, nic); + + rc =0 ; +out: +libxl__free_all (&gc); +return rc; +} + static int libxl__append_nic_list_of_type(libxl__gc *gc, uint32_t domid, const char *type,
tools/libxl/libxl_utils.c +0 -35
@@ -483,41 +483,6 @@ int libxl_mac_to_device_nic(libxl_ctx *creturn rc; } -int libxl_devid_to_device_nic (libxl_ctx *ctx,uint32_t domid, -const char *devid,libxl_device_nic *nic) -{ -libxl__gc gc =LIBXL_INIT_GC (ctx); -char *val; -char *dompath, *nic_path_fe, *nic_path_be; -int rc =ERROR_FAIL ; - -memset (nic,0 ,sizeof (libxl_device_nic)); - dompath =libxl__xs_get_dompath (&gc, domid); -if (!dompath) { - goto out; - } - nic_path_fe =libxl__sprintf (&gc,"%s/device/vif/%s" , dompath, devid); - nic_path_be =libxl__xs_read (&gc,XBT_NULL , -libxl__sprintf (&gc,"%s/backend" , nic_path_fe)); - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/backend-id" , nic_path_fe)); -if (NULL == val ) { - goto out; - } - nic->backend_domid =strtoul (val,NULL ,10 ); - nic->devid =strtoul (devid,NULL ,10 ); - - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/mac" , nic_path_fe)); - rc =libxl__parse_mac (val, nic->mac); -if (rc) - goto out; - - nic->script =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"%s/script" , nic_path_be),NULL ); - rc =0 ; -out: -libxl__free_all (&gc); -return rc; -} -int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid,const char *devid,libxl_device_disk *disk) {
PATCH 1/1 libxl: reimplement devid->disk in terms of from_xs_be function
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID d78f45247f1c0a0c879e166010df5cdff2b16988
# Parent e65e18b230493e7886654d30838ce74407c36168
libxl: reimplement devid->disk in terms of from_xs_be function.
tools/libxl/libxl.c +27 -0
@@ -1653,6 +1653,33 @@ static void libxl__device_disk_from_xs_b disk->format =LIBXL_DISK_FORMAT_UNKNOWN ; } +int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid, +const char *devid,libxl_device_disk *disk) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +char *dompath, *path; +int rc =ERROR_FAIL ; + +memset (disk,0 ,sizeof (libxl_device_disk)); + dompath =libxl__xs_get_dompath (&gc, domid); +if (!dompath) { + goto out; + } + path =libxl__xs_read (&gc,XBT_NULL , +libxl__sprintf (&gc,"%s/device/vbd/%s/backend" , + dompath, devid)); +if (!path) + goto out; + +libxl__device_disk_from_xs_be (&gc, path, disk); + + rc =0 ; +out: +libxl__free_all (&gc); +return rc; +} + + static int libxl__append_disk_list_of_type(libxl__gc *gc, uint32_t domid, const char *type,
tools/libxl/libxl_utils.c +0 -44
50 lines not on this page · raw message
PATCH 1/1 libxl: libxl_devid_to_* should take an integer device id
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID cefb64e94c5e47858ebe2d76d2448da3d9caa7fb # Parent d78f45247f1c0a0c879e166010df5cdff2b16988
libxl: libxl_devid_to_* should take an integer device id
Currently takes a string.
tools/libxl/libxl.c +4 -4
@@ -1330,7 +1330,7 @@ static void libxl__device_nic_from_xs_be }int libxl_devid_to_device_nic (libxl_ctx *ctx,uint32_t domid, -const char *devid,libxl_device_nic *nic) +int devid,libxl_device_nic *nic) {libxl__gc gc =LIBXL_INIT_GC (ctx);char *dompath, *path;
@@ -1342,7 +1342,7 @@ int libxl_devid_to_device_nic(libxl_ctx goto out; path =libxl__xs_read (&gc,XBT_NULL , -libxl__sprintf (&gc,"%s/device/vif/%s/backend" , +libxl__sprintf (&gc,"%s/device/vif/%d/backend" , dompath, devid));if (!path) goto out;
@@ -1654,7 +1654,7 @@ static void libxl__device_disk_from_xs_b }int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid, -const char *devid,libxl_device_disk *disk) +int devid,libxl_device_disk *disk) {libxl__gc gc =LIBXL_INIT_GC (ctx);char *dompath, *path;
@@ -1666,7 +1666,7 @@ int libxl_devid_to_device_disk(libxl_ctx goto out; } path =libxl__xs_read (&gc,XBT_NULL , -libxl__sprintf (&gc,"%s/device/vbd/%s/backend" , +libxl__sprintf (&gc,"%s/device/vbd/%d/backend" , dompath, devid));if (!path) goto out;
tools/libxl/libxl_utils.h +4 -4
@@ -60,11 +60,11 @@ void libxl_report_child_exitstatus(libxlint libxl_mac_to_device_nic (libxl_ctx *ctx,uint32_t domid,const char *mac,libxl_device_nic *nic); -int libxl_devid_to_device_nic (libxl_ctx *ctx,uint32_t domid, -const char *devid,libxl_device_nic *nic); +int libxl_devid_to_device_nic (libxl_ctx *ctx,uint32_t domid,int devid, +libxl_device_nic *nic); -int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid, -const char *devid,libxl_device_disk *disk); +int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid,int devid, +libxl_device_disk *disk);int libxl_cpumap_alloc (libxl_ctx *ctx,libxl_cpumap *cpumap);int libxl_cpumap_test (libxl_cpumap *cpumap,int cpu);
tools/libxl/xl_cmdimpl.c +2 -2
@@ -4137,7 +4137,7 @@ int main_networkdetach(int argc, char ** }if (!strchr (argv[optind+1 ],':' )) { -if (libxl_devid_to_device_nic (ctx, domid, argv[optind+1 ], &nic)) { +if (libxl_devid_to_device_nic (ctx, domid,atoi (argv[optind+1 ]), &nic)) {fprintf (stderr,"Unknown device %s.\n" , argv[optind+1 ]);return 1 ; }
@@ -4238,7 +4238,7 @@ int main_blockdetach(int argc, char **arfprintf (stderr,"%s is an invalid domain identifier\n" , argv[optind]);return 1 ; } -if (libxl_devid_to_device_disk (ctx, domid, argv[optind+1 ], &disk)) { +if (libxl_devid_to_device_disk (ctx, domid,atoi (argv[optind+1 ]), &disk)) {fprintf (stderr,"Error: Device %s not connected.\n" , argv[optind+1 ]);return 1 ; }
PATCH 1/1 libxl: separate forced and non-forced device remove
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389247 -3600
# Node ID dd195d45be273cf85ef0a614ac69b4498bac6d10 # Parent cefb64e94c5e47858ebe2d76d2448da3d9caa7fb
libxl: separate forced and non-forced device remove.
The function libxl__device_destroy currently takes a force parameter however:
* in the forced case we initiate a graceful shutdown and then immediately nuke the backend directory, quite likely before anyone got a chance to react.
* the callers all have a "wait" variable and pass in "!wait" as the force argument which is confusing since not waiting is not really the same thing as forcing the destroy.
* the term "destroy" is normally used in libxl for data-type destructors.
Therefore split the function into libxl__device_remove and libxl__device_force_remove. The latter simply nukes the backend directory.
This makes some of the callers look a bit odd but that should fall out as I continue to pull this piece of string.
tools/libxl/libxl_device.c +22 -10
@@ -365,7 +365,7 @@ int libxl__device_disk_dev_number(constreturn -1 ; } -int libxl__device_destroy (libxl__gc *gc,char *be_path,int force) +int libxl__device_remove (libxl__gc *gc,char *be_path) {libxl_ctx *ctx =libxl__gc_owner (gc);xs_transaction_t t;
@@ -393,17 +393,22 @@ retry_transaction: goto out; } } -if (!force) { -xs_watch (ctx->xsh, state_path, be_path); - rc =1 ; - }else { -xs_rm (ctx->xsh,XBT_NULL , be_path); - } + +xs_watch (ctx->xsh, state_path, be_path);libxl__device_destroy_tapdisk (gc, be_path); + rc =1 ; out:return rc; } +int libxl__device_force_remove (libxl__gc *gc,char *be_path) +{ +libxl_ctx *ctx =libxl__gc_owner (gc); +xs_rm (ctx->xsh,XBT_NULL , be_path); +libxl__device_destroy_tapdisk (gc, be_path); +return 0 ; +} +static int wait_for_dev_destroy (libxl__gc *gc,struct timeval *tv) {libxl_ctx *ctx =libxl__gc_owner (gc);
@@ -461,7 +466,9 @@ int libxl__devices_destroy(libxl__gc *gc fe_path =libxl__sprintf (gc,"/local/domain/%d/device/%s/%s" , domid, l1[i], l2[j]); be_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/backend" , fe_path));if (be_path !=NULL ) { -if (libxl__device_destroy (gc, be_path, force) >0 ) +int rc = force ?libxl__device_force_remove (gc, be_path) + :libxl__device_remove (gc, be_path); +if (rc >0 ) n_watches++; }else {xs_rm (ctx->xsh,XBT_NULL , path);
@@ -473,7 +480,9 @@ int libxl__devices_destroy(libxl__gc *gc fe_path =libxl__sprintf (gc,"/local/domain/%d/console" , domid); be_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/backend" , fe_path));if (be_path &&strcmp (be_path,"" )) { -if (libxl__device_destroy (gc, be_path, force) >0 ) +int rc = force ?libxl__device_force_remove (gc, be_path) + :libxl__device_remove (gc, be_path); +if (rc >0 ) n_watches++; }
@@ -506,7 +515,10 @@ int libxl__device_del(libxl__gc *gc, lib backend_path =libxl__device_backend_path (gc, dev); - rc =libxl__device_destroy (gc, backend_path, !wait); +if (wait) + rc =libxl__device_remove (gc, backend_path); +else + rc =libxl__device_force_remove (gc, backend_path);if (rc ==-1 ) { rc =ERROR_FAIL ; goto out;
tools/libxl/libxl_internal.h +2 -1
@@ -253,7 +253,8 @@ _hidden int libxl__device_generic_add(li _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device); _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device); _hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev, int wait); -_hidden int libxl__device_destroy(libxl__gc *gc, char *be_path, int force); +_hidden int libxl__device_remove(libxl__gc *gc, char *be_path); +_hidden int libxl__device_force_remove(libxl__gc *gc, char *be_path); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
tools/libxl/libxl_pci.c +1 -2
@@ -411,8 +411,7 @@ retry_transaction2:if (num ==1 ) {char *fe_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/frontend" , be_path)); -libxl__device_destroy (gc, be_path,1 ); -xs_rm (ctx->xsh,XBT_NULL , be_path); +libxl__device_force_remove (gc, be_path);xs_rm (ctx->xsh,XBT_NULL , fe_path);return 0 ; }
PATCH 1/1 libxl: split forced and non-forced uses of libxl__device_del
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389247 -3600
# Node ID ed800095162c2d459ba6bdd651ef6f246858c458 # Parent dd195d45be273cf85ef0a614ac69b4498bac6d10
libxl: split forced and non-forced uses of libxl__device_del
Most forced users can now simply call libxl__device_force_remove directly.
libxl__devices_destroy is something of a special case, it is really just iterating over an opaque set of xenstore directories and removing them. Until this can be refactored just do the force-remove case manually, doing otherwise led to too much entanglement with the other callers of libxl__device_force_remove which do know about specific device types.
For the time being do the same in libxl__device_pci_remove_xenstore.
tools/libxl/libxl.c +9 -2
@@ -1071,7 +1071,10 @@ int libxl_device_disk_del(libxl_ctx *ctx device.domid = domid; device.devid = devid; device.kind =DEVICE_VBD ; - rc =libxl__device_del (&gc, &device, wait); +if (wait) + rc =libxl__device_del (&gc, &device); +else + rc =libxl__device_force_remove (&gc, &device); out_free:libxl__free_all (&gc);return rc;
@@ -1283,7 +1286,11 @@ int libxl_device_nic_del(libxl_ctx *ctx, device.domid = domid; device.kind =DEVICE_VIF ; - rc =libxl__device_del (&gc, &device, wait); +if (wait) + rc =libxl__device_del (&gc, &device); +else + rc =libxl__device_force_remove (&gc, &device); +libxl__free_all (&gc);return rc; }
tools/libxl/libxl_device.c +28 -20
88 lines not on this page · raw message
tools/libxl/libxl_internal.h +2 -2
@@ -252,9 +252,9 @@ _hidden int libxl__device_generic_add(li char **bents, char **fents); _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device); _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device); -_hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev, int wait); +_hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev); _hidden int libxl__device_remove(libxl__gc *gc, char *be_path); -_hidden int libxl__device_force_remove(libxl__gc *gc, char *be_path); +_hidden int libxl__device_force_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
tools/libxl/libxl_pci.c +1 -1
@@ -411,7 +411,7 @@ retry_transaction2:if (num ==1 ) {char *fe_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/frontend" , be_path)); -libxl__device_force_remove (gc, be_path); +xs_rm (ctx->xsh,XBT_NULL , be_path);xs_rm (ctx->xsh,XBT_NULL , fe_path);return 0 ; }
PATCH 1/1 libxl: use IDL to define device front- and back-end kinds
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node ID e8cff01ad4b5519be66e726db124cbdfab4f1e04 # Parent ed800095162c2d459ba6bdd651ef6f246858c458
libxl: use IDL to define device front- and back-end kinds
I'd like to use the from_string functionality...
tools/libxl/libxl.c +17 -17
@@ -959,7 +959,7 @@ int libxl_device_disk_add(libxl_ctx *ctx device.backend_domid = disk->backend_domid; device.devid = devid; device.domid = domid; - device.kind =DEVICE_VBD ; + device.kind =LIBXL__DEVICE_KIND_VBD ;switch (disk->backend) {case LIBXL_DISK_BACKEND_PHY :
@@ -972,7 +972,7 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_append (back,"params" );flexarray_append (back, dev); - device.backend_kind =DEVICE_VBD ; + device.backend_kind =LIBXL__DEVICE_KIND_VBD ;break ;case LIBXL_DISK_BACKEND_TAP : dev =libxl__blktap_devpath (&gc, disk->pdev_path, disk->format);
@@ -991,7 +991,7 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_append (back,"params" );flexarray_append (back,libxl__sprintf (&gc,"%s:%s" ,libxl__device_disk_string_of_format (disk->format), disk->pdev_path)); - device.backend_kind =DEVICE_QDISK ; + device.backend_kind =LIBXL__DEVICE_KIND_QDISK ;break ;default :LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"unrecognized disk backend type: %d\n" , disk->backend);
@@ -1054,13 +1054,13 @@ int libxl_device_disk_del(libxl_ctx *ctxswitch (disk->backend) {case LIBXL_DISK_BACKEND_PHY : - device.backend_kind =DEVICE_VBD ; + device.backend_kind =LIBXL__DEVICE_KIND_VBD ;break ;case LIBXL_DISK_BACKEND_TAP : - device.backend_kind =DEVICE_VBD ; + device.backend_kind =LIBXL__DEVICE_KIND_VBD ;break ;case LIBXL_DISK_BACKEND_QDISK : - device.backend_kind =DEVICE_QDISK ; + device.backend_kind =LIBXL__DEVICE_KIND_QDISK ;break ;default : LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n",
@@ -1070,7 +1070,7 @@ int libxl_device_disk_del(libxl_ctx *ctx } device.domid = domid; device.devid = devid; - device.kind =DEVICE_VBD ; + device.kind =LIBXL__DEVICE_KIND_VBD ;if (wait) rc =libxl__device_del (&gc, &device);else
@@ -1218,10 +1218,10 @@ int libxl_device_nic_add(libxl_ctx *ctx, device.backend_devid = nic->devid; device.backend_domid = nic->backend_domid; - device.backend_kind =DEVICE_VIF ; + device.backend_kind =LIBXL__DEVICE_KIND_VIF ; device.devid = nic->devid; device.domid = domid; - device.kind =DEVICE_VIF ; + device.kind =LIBXL__DEVICE_KIND_VIF ;flexarray_append (back,"frontend-id" );flexarray_append (back,libxl__sprintf (&gc,"%d" , domid));
@@ -1281,10 +1281,10 @@ int libxl_device_nic_del(libxl_ctx *ctx, device.backend_devid = nic->devid; device.backend_domid = nic->backend_domid; - device.backend_kind =DEVICE_VIF ; + device.backend_kind =LIBXL__DEVICE_KIND_VIF ; device.devid = nic->devid; device.domid = domid; - device.kind =DEVICE_VIF ; + device.kind =LIBXL__DEVICE_KIND_VIF ;if (wait) rc =libxl__device_del (&gc, &device);
@@ -1483,10 +1483,10 @@ int libxl__device_console_add(libxl__gc device.backend_devid = console->devid; device.backend_domid = console->backend_domid; - device.backend_kind =DEVICE_CONSOLE ; + device.backend_kind =LIBXL__DEVICE_KIND_CONSOLE ; device.devid = console->devid; device.domid = domid; - device.kind =DEVICE_CONSOLE ; + device.kind =LIBXL__DEVICE_KIND_CONSOLE ;flexarray_append (back,"frontend-id" );flexarray_append (back,libxl__sprintf (gc,"%d" , domid));
@@ -1574,10 +1574,10 @@ int libxl_device_vkb_add(libxl_ctx *ctx, device.backend_devid = vkb->devid; device.backend_domid = vkb->backend_domid; - device.backend_kind =DEVICE_VKBD ; + device.backend_kind =LIBXL__DEVICE_KIND_VKBD ; device.devid = vkb->devid; device.domid = domid; - device.kind =DEVICE_VKBD ; + device.kind =LIBXL__DEVICE_KIND_VKBD ;flexarray_append (back,"frontend-id" );flexarray_append (back,libxl__sprintf (&gc,"%d" , domid));
@@ -1861,10 +1861,10 @@ int libxl_device_vfb_add(libxl_ctx *ctx, device.backend_devid = vfb->devid; device.backend_domid = vfb->backend_domid; - device.backend_kind =DEVICE_VFB ; + device.backend_kind =LIBXL__DEVICE_KIND_VFB ; device.devid = vfb->devid; device.domid = domid; - device.kind =DEVICE_VFB ; + device.kind =LIBXL__DEVICE_KIND_VFB ;flexarray_append_pair (back,"frontend-id" ,libxl__sprintf (&gc,"%d" , domid));flexarray_append_pair (back,"online" ,"1" );
tools/libxl/libxl_device.c +6 -23
@@ -24,30 +24,20 @@#include <unistd.h> #include <fcntl.h> -#include "libxl.h" #include "libxl_internal.h" -static const char *string_of_kinds[] = { - [DEVICE_VIF ] ="vif" , - [DEVICE_VBD ] ="vbd" , - [DEVICE_QDISK ] ="qdisk" , - [DEVICE_PCI ] ="pci" , - [DEVICE_VFB ] ="vfb" , - [DEVICE_VKBD ] ="vkbd" , - [DEVICE_CONSOLE ] ="console" , -}; -char *libxl__device_frontend_path (libxl__gc *gc,libxl__device *device) {char *dom_path =libxl__xs_get_dompath (gc, device->domid);/* Console 0 is a special case */ -if (device->kind ==DEVICE_CONSOLE && device->devid ==0 ) +if (device->kind ==LIBXL__DEVICE_KIND_CONSOLE && device->devid ==0 )return libxl__sprintf (gc,"%s/console" , dom_path);return libxl__sprintf (gc,"%s/device/%s/%d" , dom_path, - string_of_kinds[device->kind], device->devid); +libxl__device_kind_to_string (device->kind), + device->devid); }char *libxl__device_backend_path (libxl__gc *gc,libxl__device *device)
@@ -55,7 +45,7 @@ char *libxl__device_backend_path(libxl__char *dom_path =libxl__xs_get_dompath (gc, device->backend_domid);return libxl__sprintf (gc,"%s/backend/%s/%u/%d" , dom_path, - string_of_kinds[device->backend_kind], +libxl__device_kind_to_string (device->backend_kind), device->domid, device->devid); }
@@ -67,12 +57,6 @@ int libxl__device_generic_add(libxl__gcxs_transaction_t t;struct xs_permissions frontend_perms[2 ];struct xs_permissions backend_perms[2 ]; -int rc; - -if (!is_valid_device_kind (device->backend_kind) || !is_valid_device_kind (device->kind)) { - rc =ERROR_INVAL ; - goto out; - } frontend_path =libxl__device_frontend_path (gc, device); backend_path =libxl__device_backend_path (gc, device);
@@ -113,9 +97,8 @@ retry_transaction:else LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"xs transaction failed" ); } - rc =0 ; -out: -return rc; + +return 0 ; } typedef struct {
tools/libxl/libxl_internal.h +2 -14
@@ -97,25 +97,13 @@ struct libxl__ctx {libxl_version_info version_info; }; -typedef enum { -DEVICE_VIF =1 , -DEVICE_VBD , -DEVICE_QDISK , -DEVICE_PCI , -DEVICE_VFB , -DEVICE_VKBD , -DEVICE_CONSOLE , -}libxl__device_kinds ; - -#define is_valid_device_kind (kind) (((kind) >= DEVICE_VIF) && ((kind) <= DEVICE_CONSOLE)) -typedef struct {uint32_t backend_devid;uint32_t backend_domid;uint32_t devid;uint32_t domid; -libxl__device_kinds backend_kind; -libxl__device_kinds kind; +libxl__device_kind backend_kind; +libxl__device_kind kind; }libxl__device ;#define XC_PCI_BDF "0x%x, 0x%x, 0x%x, 0x%x"
tools/libxl/libxl_pci.c +2 -2
@@ -244,10 +244,10 @@ int libxl__create_pci_backend(libxl__gc/* add pci device */ device.backend_devid =0 ; device.backend_domid =0 ; - device.backend_kind =DEVICE_PCI ; + device.backend_kind =LIBXL__DEVICE_KIND_PCI ; device.devid =0 ; device.domid = domid; - device.kind =DEVICE_PCI ; + device.kind =LIBXL__DEVICE_KIND_PCI ;flexarray_append_pair (back,"frontend-id" ,libxl__sprintf (gc,"%d" , domid));flexarray_append_pair (back,"online" ,"1" );
tools/libxl/libxl_types_internal.idl +11 -1
@@ -1,9 +1,19 @@ namespace("libxl__") -libxl__qmp_message_type = Enumeration("qmp_message_type", [ +libxl__qmp_message_type = Enumeration("qmp_message_type", [ (1, "QMP"), (2, "return"), (3, "error"), (4, "event"), (5, "invalid"), ]) + +libxl__device_kind = Enumeration("device_kind", [ + (1, "VIF"), + (2, "VBD"), + (3, "QDISK"), + (4, "PCI"), + (5, "VFB"), + (6, "VKBD"), + (7, "CONSOLE"), + ])
PATCH 1/1 libxl: do not remove unidentified frontend paths in libxl__devices_destroy
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node ID e5a70a3b61a1acfa7d73db548a591486024d01b7
# Parent e8cff01ad4b5519be66e726db124cbdfab4f1e04
libxl: do not remove unidentified frontend paths in libxl__devices_destroy
Currently this appears to only include "/local/domain/<domid>/device/suspend". Ultimately the caller will nuke the whole guest directory anyway but not having this function remove things which don't look like devices seems less surprising.
tools/libxl/libxl_device.c +0 -2
@@ -463,8 +463,6 @@ int libxl__devices_destroy(libxl__gc *gcif (libxl__device_remove (gc, be_path) >0 ) n_watches++; } - }else { -xs_rm (ctx->xsh,XBT_NULL , path); } } }
PATCH 1/1 libxl: use libxl__device in libxl_devices_destroy and libxl__device_pci_remove_xenstore
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node ID ec28ee6dace513c3d009d498341f9537a19b2d98
# Parent e5a70a3b61a1acfa7d73db548a591486024d01b7
libxl: use libxl__device in libxl_devices_destroy and libxl__device_pci_remove_xenstore
Doing this allows us to use the common functions for removing devices.
tools/libxl/libxl_device.c +48 -20
@@ -49,6 +49,25 @@ char *libxl__device_backend_path(libxl__ device->domid, device->devid); } +int libxl__parse_backend_path (libxl__gc *gc, +const char *path, +libxl__device *dev) +{ +/* /local/domain/<domid>/backend/<kind>/<domid>/<devid> */ +char strkind[16 ];/* Longest is actually "console" */ +uint32_t domain; +int rc =sscanf (path,"/local/domain/%d/backend/%15[^/]/%d/%d" , + &dev->backend_domid, + strkind, + &domain, + &dev->backend_devid); + +if (rc !=4 ) +return ERROR_FAIL ; + +return libxl__device_kind_from_string (strkind, &dev->backend_kind); +} +int libxl__device_generic_add (libxl__gc *gc,libxl__device *device,char **bents,char **fents) {
@@ -348,10 +367,11 @@ int libxl__device_disk_dev_number(constreturn -1 ; } -int libxl__device_remove (libxl__gc *gc,char *be_path) +int libxl__device_remove (libxl__gc *gc,libxl__device *dev) {libxl_ctx *ctx =libxl__gc_owner (gc);xs_transaction_t t; +char *be_path =libxl__device_backend_path (gc, dev);char *state_path =libxl__sprintf (gc,"%s/state" , be_path);char *state =libxl__xs_read (gc,XBT_NULL , state_path);int rc =0 ;
@@ -429,10 +449,12 @@ static int wait_for_dev_destroy(libxl__gint libxl__devices_destroy (libxl__gc *gc,uint32_t domid,int force) {libxl_ctx *ctx =libxl__gc_owner (gc); -char *path, *be_path, *fe_path; +char *path;unsigned int num1, num2;char **l1 =NULL , **l2 =NULL ;int i, j, n_watches =0 ; +libxl__device dev; +libxl__device_kind kind; path =libxl__sprintf (gc,"/local/domain/%d/device" , domid); l1 =libxl__xs_directory (gc,XBT_NULL , path, &num1);
@@ -445,22 +467,27 @@ int libxl__devices_destroy(libxl__gc *gc num1 =0 ; }for (i =0 ; i < num1; i++) { -if (!strcmp ("vfs" , l1[i])) +if (libxl__device_kind_from_string (l1[i], &kind)) +continue ; +if (kind ==LIBXL__DEVICE_KIND_VBD )continue ; path =libxl__sprintf (gc,"/local/domain/%d/device/%s" , domid, l1[i]); l2 =libxl__xs_directory (gc,XBT_NULL , path, &num2);if (!l2)continue ;for (j =0 ; j < num2; j++) { - fe_path =libxl__sprintf (gc,"/local/domain/%d/device/%s/%s" , domid, l1[i], l2[j]); - be_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/backend" , fe_path)); -if (be_path !=NULL ) { + path =libxl__sprintf (gc,"/local/domain/%d/device/%s/%s/backend" , + domid, l1[i], l2[j]); + path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc, path)); +if (path &&libxl__parse_backend_path (gc, path, &dev) ==0 ) { + dev.domid = domid; + dev.kind = kind; + dev.devid =atoi (l2[j]); +if (force) { -xs_rm (ctx->xsh,XBT_NULL , be_path); -xs_rm (ctx->xsh,XBT_NULL , fe_path); -libxl__device_destroy_tapdisk (gc, be_path); +libxl__device_force_remove (gc, &dev); }else { -if (libxl__device_remove (gc, be_path) >0 ) +if (libxl__device_remove (gc, &dev) >0 ) n_watches++; } }
@@ -468,14 +495,18 @@ int libxl__devices_destroy(libxl__gc *gc }/* console 0 frontend directory is not under /local/domain/<domid>/device */ - fe_path =libxl__sprintf (gc,"/local/domain/%d/console" , domid); - be_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/backend" , fe_path)); -if (be_path &&strcmp (be_path,"" )) { + path =libxl__sprintf (gc,"/local/domain/%d/console/backend" , domid); + path =libxl__xs_read (gc,XBT_NULL , path); +if (path &&strcmp (path,"" ) && +libxl__parse_backend_path (gc, path, &dev) ==0 ) { + dev.domid = domid; + dev.kind =LIBXL__DEVICE_KIND_CONSOLE ; + dev.devid =0 ; +if (force) { -xs_rm (ctx->xsh,XBT_NULL , be_path); -xs_rm (ctx->xsh,XBT_NULL , fe_path); +libxl__device_force_remove (gc, &dev); }else { -if (libxl__device_remove (gc, be_path) >0 ) +if (libxl__device_remove (gc, &dev) >0 ) n_watches++; } }
@@ -505,12 +536,9 @@ int libxl__device_del(libxl__gc *gc, lib {libxl_ctx *ctx =libxl__gc_owner (gc);struct timeval tv; -char *backend_path;int rc; - backend_path =libxl__device_backend_path (gc, dev); - - rc =libxl__device_remove (gc, backend_path); + rc =libxl__device_remove (gc, dev);if (rc ==-1 ) { rc =ERROR_FAIL ; goto out;
tools/libxl/libxl_internal.h +3 -1
@@ -240,8 +240,10 @@ _hidden int libxl__device_generic_add(li char **bents, char **fents); _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device); _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device); +_hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path, +libxl__device *dev); _hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev); -_hidden int libxl__device_remove(libxl__gc *gc, char *be_path); +_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__device_force_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
tools/libxl/libxl_pci.c +9 -3
@@ -410,9 +410,15 @@ retry_transaction2: goto retry_transaction2;if (num ==1 ) { -char *fe_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/frontend" , be_path)); -xs_rm (ctx->xsh,XBT_NULL , be_path); -xs_rm (ctx->xsh,XBT_NULL , fe_path); +libxl__device dev; +if (libxl__parse_backend_path (gc, be_path, &dev) !=0 ) +return ERROR_FAIL ; + + dev.domid = domid; + dev.kind =LIBXL__DEVICE_KIND_PCI ; + dev.devid =0 ; + +libxl__device_force_remove (gc, &dev);return 0 ; }
PATCH 1/1 libxl: merge libxl__device_del into libxl__device_remove
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node ID 7a8cd032b63cf91d3fe04501997405d53cf5d8b3 # Parent ec28ee6dace513c3d009d498341f9537a19b2d98
libxl: merge libxl__device_del into libxl__device_remove
Note that the "wait" parameter added to libxl_device_remove is different to the wait paramter previously used by similar functions. In the past not-wait meant forced whereas now in means wait for a graceful shutdown, as opposed to setting off a graceful shutdown but not waiting.
tools/libxl/libxl.c +2 -2
@@ -1072,7 +1072,7 @@ int libxl_device_disk_del(libxl_ctx *ctx device.devid = devid; device.kind =LIBXL__DEVICE_KIND_VBD ;if (wait) - rc =libxl__device_del (&gc, &device); + rc =libxl__device_remove (&gc, &device, wait);else rc =libxl__device_force_remove (&gc, &device); out_free:
@@ -1287,7 +1287,7 @@ int libxl_device_nic_del(libxl_ctx *ctx, device.kind =LIBXL__DEVICE_KIND_VIF ;if (wait) - rc =libxl__device_del (&gc, &device); + rc =libxl__device_remove (&gc, &device, wait);else rc =libxl__device_force_remove (&gc, &device);
tools/libxl/libxl_device.c +63 -76
169 lines not on this page · raw message
tools/libxl/libxl_internal.h +1 -2
@@ -242,8 +242,7 @@ _hidden char *libxl__device_backend_path _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device); _hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,libxl__device *dev); -_hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev); -_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev); +_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev, int wait); _hidden int libxl__device_force_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
PATCH 1/1 libxl: use more descriptive variable names in libxl__devices_destroy
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node ID b3e80fe9f014f03700ca4846dde58d3473236223
# Parent 7a8cd032b63cf91d3fe04501997405d53cf5d8b3
libxl: use more descriptive variable names in libxl__devices_destroy.
It's not immediately clear that "l1" iterates over device types and "l2" iterates over individual devices. Name things in a way which makes this more obvious.
tools/libxl/libxl_device.c +14 -13
@@ -460,39 +460,40 @@ int libxl__devices_destroy(libxl__gc *gc {libxl_ctx *ctx =libxl__gc_owner (gc);char *path; -unsigned int num1, num2; -char **l1 =NULL , **l2 =NULL ; +unsigned int num_kinds, num_devs; +char **kinds =NULL , **devs =NULL ;int i, j, n_watches =0 ;libxl__device dev;libxl__device_kind kind; path =libxl__sprintf (gc,"/local/domain/%d/device" , domid); - l1 =libxl__xs_directory (gc,XBT_NULL , path, &num1); -if (!l1) { + kinds =libxl__xs_directory (gc,XBT_NULL , path, &num_kinds); +if (!kinds) {if (errno !=ENOENT ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"unable to get xenstore" " device listing %s" , path); goto out; } - num1 =0 ; + num_kinds =0 ; } -for (i =0 ; i < num1; i++) { -if (libxl__device_kind_from_string (l1[i], &kind)) +for (i =0 ; i < num_kinds; i++) { +if (libxl__device_kind_from_string (kinds[i], &kind))continue ;if (kind ==LIBXL__DEVICE_KIND_VBD )continue ; - path =libxl__sprintf (gc,"/local/domain/%d/device/%s" , domid, l1[i]); - l2 =libxl__xs_directory (gc,XBT_NULL , path, &num2); -if (!l2) + + path =libxl__sprintf (gc,"/local/domain/%d/device/%s" , domid, kinds[i]); + devs =libxl__xs_directory (gc,XBT_NULL , path, &num_devs); +if (!devs)continue ; -for (j =0 ; j < num2; j++) { +for (j =0 ; j < num_devs; j++) { path =libxl__sprintf (gc,"/local/domain/%d/device/%s/%s/backend" , - domid, l1[i], l2[j]); + domid, kinds[i], devs[j]); path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc, path));if (path &&libxl__parse_backend_path (gc, path, &dev) ==0 ) { dev.domid = domid; dev.kind = kind; - dev.devid =atoi (l2[j]); + dev.devid =atoi (devs[j]);if (force) {libxl__device_force_remove (gc, &dev);
PATCH 1/1 libxl: convert disk handling to device API
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389248 -3600
# Node ID 1892dad72518f5253af2282db650cdd70c56a218 # Parent b3e80fe9f014f03700ca4846dde58d3473236223
libxl: convert disk handling to device API
tools/libxl/libxl.c +80 -49
@@ -916,13 +916,58 @@ int libxl_vncviewer_exec(libxl_ctx *ctx,/******************************************************************************/ +int libxl_device_disk_init (libxl_ctx *ctx,libxl_device_disk *disk) +{ +memset (disk,0x00 ,sizeof (libxl_device_disk)); +return 0 ; +} + +static int libxl__device_from_disk (libxl__gc *gc,uint32_t domid, +libxl_device_disk *disk, +libxl__device *device) +{ +libxl_ctx *ctx =libxl__gc_owner (gc); +int devid; + + devid =libxl__device_disk_dev_number (disk->vdev,NULL ,NULL ); +if (devid==-1 ) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Invalid or unsupported" +" virtual disk identifier %s" , disk->vdev); +return ERROR_INVAL ; + } + + device->backend_domid = disk->backend_domid; + device->backend_devid = devid; + +switch (disk->backend) { +case LIBXL_DISK_BACKEND_PHY : + device->backend_kind =LIBXL__DEVICE_KIND_VBD ; +break ; +case LIBXL_DISK_BACKEND_TAP : + device->backend_kind =LIBXL__DEVICE_KIND_VBD ; +break ; +case LIBXL_DISK_BACKEND_QDISK : + device->backend_kind =LIBXL__DEVICE_KIND_QDISK ; +break ; +default : +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"unrecognized disk backend type: %d\n" , + disk->backend); +return ERROR_INVAL ; + } + + device->domid = domid; + device->devid = devid; + device->kind =LIBXL__DEVICE_KIND_VBD ; + +return 0 ; +} +int libxl_device_disk_add (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk) {libxl__gc gc =LIBXL_INIT_GC (ctx);flexarray_t *front;flexarray_t *back;char *dev; -int devid;libxl__device device;int major, minor, rc;
@@ -947,20 +992,13 @@ int libxl_device_disk_add(libxl_ctx *ctx goto out_free; } - devid =libxl__device_disk_dev_number (disk->vdev,NULL ,NULL ); -if (devid==-1 ) { + rc =libxl__device_from_disk (&gc, domid, disk, &device); +if (rc !=0 ) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Invalid or unsupported" " virtual disk identifier %s" , disk->vdev); - rc =ERROR_INVAL ; goto out_free; } - device.backend_devid = devid; - device.backend_domid = disk->backend_domid; - device.devid = devid; - device.domid = domid; - device.kind =LIBXL__DEVICE_KIND_VBD ; -switch (disk->backend) {case LIBXL_DISK_BACKEND_PHY : dev = disk->pdev_path;
@@ -972,7 +1010,7 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_append (back,"params" );flexarray_append (back, dev); - device.backend_kind =LIBXL__DEVICE_KIND_VBD ; +assert (device.backend_kind ==LIBXL__DEVICE_KIND_VBD );break ;case LIBXL_DISK_BACKEND_TAP : dev =libxl__blktap_devpath (&gc, disk->pdev_path, disk->format);
@@ -991,7 +1029,7 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_append (back,"params" );flexarray_append (back,libxl__sprintf (&gc,"%s:%s" ,libxl__device_disk_string_of_format (disk->format), disk->pdev_path)); - device.backend_kind =LIBXL__DEVICE_KIND_QDISK ; +assert (device.backend_kind ==LIBXL__DEVICE_KIND_QDISK );break ;default :LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"unrecognized disk backend type: %d\n" , disk->backend);
@@ -1023,7 +1061,7 @@ int libxl_device_disk_add(libxl_ctx *ctxflexarray_append (front,"state" );flexarray_append (front,libxl__sprintf (&gc,"%d" ,1 ));flexarray_append (front,"virtual-device" ); -flexarray_append (front,libxl__sprintf (&gc,"%d" , devid)); +flexarray_append (front,libxl__sprintf (&gc,"%d" , device.devid));flexarray_append (front,"device-type" );flexarray_append (front, disk->is_cdrom ?"cdrom" :"disk" );
@@ -1041,45 +1079,37 @@ out:return rc; } -int libxl_device_disk_del (libxl_ctx *ctx,uint32_t domid, -libxl_device_disk *disk,int wait) +int libxl_device_disk_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk) {libxl__gc gc =LIBXL_INIT_GC (ctx);libxl__device device; -int devid, rc; - - devid =libxl__device_disk_dev_number (disk->vdev,NULL ,NULL ); - device.backend_domid = disk->backend_domid; - device.backend_devid = devid; - -switch (disk->backend) { -case LIBXL_DISK_BACKEND_PHY : - device.backend_kind =LIBXL__DEVICE_KIND_VBD ; -break ; -case LIBXL_DISK_BACKEND_TAP : - device.backend_kind =LIBXL__DEVICE_KIND_VBD ; -break ; -case LIBXL_DISK_BACKEND_QDISK : - device.backend_kind =LIBXL__DEVICE_KIND_QDISK ; -break ; -default : -LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"unrecognized disk backend type: %d\n" , - disk->backend); - rc =ERROR_INVAL ; - goto out_free; - } - device.domid = domid; - device.devid = devid; - device.kind =LIBXL__DEVICE_KIND_VBD ; -if (wait) - rc =libxl__device_remove (&gc, &device, wait); -else - rc =libxl__device_force_remove (&gc, &device); -out_free: +int rc; + + rc =libxl__device_from_disk (&gc, domid, disk, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_remove (&gc, &device,1 ); +out:libxl__free_all (&gc);return rc; } +int libxl_device_disk_force_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl__device device; +int rc; + + rc =libxl__device_from_disk (&gc, domid, disk, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_force_remove (&gc, &device); +out: +libxl__free_all (&gc); +return rc; +}char *libxl_device_disk_local_attach (libxl_ctx *ctx,libxl_device_disk *disk) {libxl__gc gc =LIBXL_INIT_GC (ctx);
@@ -1623,7 +1653,7 @@ static void libxl__device_disk_from_xs_bunsigned int len;char *tmp; -memset (disk,0 ,sizeof (*disk)); +libxl_device_disk_init (ctx, disk); tmp =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (gc,"%s/params" , be_path), &len);
@@ -1667,7 +1697,8 @@ int libxl_devid_to_device_disk(libxl_ctxchar *dompath, *path;int rc =ERROR_FAIL ; -memset (disk,0 ,sizeof (libxl_device_disk)); +libxl_device_disk_init (ctx, disk); + dompath =libxl__xs_get_dompath (&gc, domid);if (!dompath) { goto out;
@@ -1809,11 +1840,11 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u ret =0 ; -libxl_device_disk_del (ctx, domid, disks + i,1 ); +libxl_device_disk_remove (ctx, domid, disks + i);libxl_device_disk_add (ctx, domid, disk); stubdomid =libxl_get_stubdom_id (ctx, domid);if (stubdomid) { -libxl_device_disk_del (ctx, stubdomid, disks + i,1 ); +libxl_device_disk_remove (ctx, stubdomid, disks + i);libxl_device_disk_add (ctx, stubdomid, disk); } out:
tools/libxl/libxl.h +14 -2
@@ -451,15 +451,27 @@ libxl_vminfo * libxl_list_vm(libxl_ctx ** is used to free the members of the libxl_device_<type> data * type. It has no impact on the devices attached to any domain. */ + +/* Disks */ +int libxl_device_disk_init (libxl_ctx *ctx,libxl_device_disk *disk);int libxl_device_disk_add (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk); -int libxl_device_disk_del (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk,int wait); +int libxl_device_disk_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk); +int libxl_device_disk_force_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk); +libxl_device_disk *libxl_device_disk_list (libxl_ctx *ctx,uint32_t domid,int *num);int libxl_device_disk_getinfo (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk,libxl_diskinfo *diskinfo); + +/* +* Insert a CD-ROM device. A device corresponding to disk must already +* be attached to the guest. +*/ int libxl_cdrom_insert (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk);/* -* Make a disk available in this domain. Returns path to a device. +* Make a disk available in this (the control) domain. Returns path to +* a device. */ char *libxl_device_disk_local_attach (libxl_ctx *ctx,libxl_device_disk *disk);int libxl_device_disk_local_detach (libxl_ctx *ctx,libxl_device_disk *disk);
tools/libxl/xl_cmdimpl.c +5 -3
@@ -554,7 +554,7 @@ static void parse_disk_config_multistrin {int e; -memset (disk,0 ,sizeof (*disk)); +libxl_device_disk_init (ctx, disk);if (!*config) { *config =xlu_cfg_init (stderr,"command line" );
@@ -1953,6 +1953,8 @@ static void cd_insert(const char *dom, c disk.backend_domid =0 ;libxl_cdrom_insert (ctx, domid, &disk); + +libxl_device_disk_destroy (&disk);free (buf); }
@@ -4242,8 +4244,8 @@ int main_blockdetach(int argc, char **arfprintf (stderr,"Error: Device %s not connected.\n" , argv[optind+1 ]);return 1 ; } -if (libxl_device_disk_del (ctx, domid, &disk,1 )) { -fprintf (stderr,"libxl_device_disk_del failed.\n" ); +if (libxl_device_disk_remove (ctx, domid, &disk)) { +fprintf (stderr,"libxl_device_disk_remove failed.\n" ); }return 0 ; }
PATCH 1/1 libxl: convert NIC handling to device API
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389248 -3600
# Node ID 9b58180714357f9879f7ff88a267e7d1f5dfdbb2 # Parent 1892dad72518f5253af2282db650cdd70c56a218
libxl: convert NIC handling to device API
tools/libxl/libxl.c +56 -38
@@ -1184,32 +1184,46 @@ int libxl_device_disk_local_detach(libxl }/******************************************************************************/ -int libxl_device_nic_init (libxl_device_nic *nic_info,int devnum) +int libxl_device_nic_init (libxl_ctx *ctx,libxl_device_nic *nic) {const uint8_t *r;libxl_uuid uuid;libxl_uuid_generate (&uuid); r =libxl_uuid_bytearray (&uuid); -memset (nic_info,'\0' ,sizeof (*nic_info)); - - nic_info->backend_domid =0 ; - nic_info->devid = devnum; - nic_info->mtu =1492 ; - nic_info->model =strdup ("rtl8139" ); - nic_info->mac[0 ] =0x00 ; - nic_info->mac[1 ] =0x16 ; - nic_info->mac[2 ] =0x3e ; - nic_info->mac[3 ] = r[0 ] &0x7f ; - nic_info->mac[4 ] = r[1 ]; - nic_info->mac[5 ] = r[2 ]; - nic_info->ifname =NULL ; - nic_info->bridge =strdup ("xenbr0" ); - nic_info->ip =NULL ; -if (asprintf (&nic_info->script,"%s/vif-bridge" , +memset (nic,'\0' ,sizeof (*nic)); + + nic->backend_domid =0 ; + nic->devid =-1 ; + nic->mtu =1492 ; + nic->model =strdup ("rtl8139" ); + nic->mac[0 ] =0x00 ; + nic->mac[1 ] =0x16 ; + nic->mac[2 ] =0x3e ; + nic->mac[3 ] = r[0 ] &0x7f ; + nic->mac[4 ] = r[1 ]; + nic->mac[5 ] = r[2 ]; + nic->ifname =NULL ; + nic->bridge =strdup ("xenbr0" ); + nic->ip =NULL ; +if (asprintf (&nic->script,"%s/vif-bridge" ,libxl_xen_script_dir_path ()) <0 )return ERROR_FAIL ; - nic_info->nictype =LIBXL_NIC_TYPE_IOEMU ; + nic->nictype =LIBXL_NIC_TYPE_IOEMU ; +return 0 ; +} + +static int libxl__device_from_nic (libxl__gc *gc,uint32_t domid, +libxl_device_nic *nic, +libxl__device *device) +{ + device->backend_devid = nic->devid; + device->backend_domid = nic->backend_domid; + device->backend_kind =LIBXL__DEVICE_KIND_VIF ; + device->devid = nic->devid; + device->domid = domid; + device->kind =LIBXL__DEVICE_KIND_VIF ; +return 0 ; }
@@ -1246,12 +1260,8 @@ int libxl_device_nic_add(libxl_ctx *ctx, } } - device.backend_devid = nic->devid; - device.backend_domid = nic->backend_domid; - device.backend_kind =LIBXL__DEVICE_KIND_VIF ; - device.devid = nic->devid; - device.domid = domid; - device.kind =LIBXL__DEVICE_KIND_VIF ; + rc =libxl__device_from_nic (&gc, domid, nic, &device); +if ( rc !=0 ) goto out_free;flexarray_append (back,"frontend-id" );flexarray_append (back,libxl__sprintf (&gc,"%d" , domid));
@@ -1302,29 +1312,37 @@ out:return rc; } -int libxl_device_nic_del (libxl_ctx *ctx,uint32_t domid, -libxl_device_nic *nic,int wait) +int libxl_device_nic_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_nic *nic) {libxl__gc gc =LIBXL_INIT_GC (ctx);libxl__device device;int rc; - device.backend_devid = nic->devid; - device.backend_domid = nic->backend_domid; - device.backend_kind =LIBXL__DEVICE_KIND_VIF ; - device.devid = nic->devid; - device.domid = domid; - device.kind =LIBXL__DEVICE_KIND_VIF ; - -if (wait) - rc =libxl__device_remove (&gc, &device, wait); -else - rc =libxl__device_force_remove (&gc, &device); - + rc =libxl__device_from_nic (&gc, domid, nic, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_remove (&gc, &device,1 ); +out:libxl__free_all (&gc);return rc; } +int libxl_device_nic_force_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_nic *nic) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl__device device; +int rc; + + rc =libxl__device_from_nic (&gc, domid, nic, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_force_remove (&gc, &device); +out: +libxl__free_all (&gc); +return rc; +}static void libxl__device_nic_from_xs_be (libxl__gc *gc,const char *be_path,libxl_device_nic *nic)
tools/libxl/libxl.h +5 -2
@@ -476,9 +476,12 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uchar *libxl_device_disk_local_attach (libxl_ctx *ctx,libxl_device_disk *disk);int libxl_device_disk_local_detach (libxl_ctx *ctx,libxl_device_disk *disk); -int libxl_device_nic_init (libxl_device_nic *nic,int dev_num); +/* Network Interfaces */ +int libxl_device_nic_init (libxl_ctx *ctx,libxl_device_nic *nic);int libxl_device_nic_add (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic); -int libxl_device_nic_del (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,int wait); +int libxl_device_nic_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic); +int libxl_device_nic_force_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic); +libxl_device_nic *libxl_device_nic_list (libxl_ctx *ctx,uint32_t domid,int *num);int libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,libxl_nicinfo *nicinfo);
tools/libxl/xl_cmdimpl.c +4 -3
@@ -822,7 +822,8 @@ static void parse_config_data(const char d_config->vifs = (libxl_device_nic *)realloc (d_config->vifs,sizeof (libxl_device_nic) * (d_config->num_vifs+1 )); nic = d_config->vifs + d_config->num_vifs; -CHK_ERRNO (libxl_device_nic_init (nic, d_config->num_vifs) ); +CHK_ERRNO (libxl_device_nic_init (ctx, nic) ); + nic->devid = d_config->num_vifs;if (default_vifscript) {free (nic->script);
@@ -4032,7 +4033,7 @@ int main_networkattach(int argc, char **fprintf (stderr,"%s is an invalid domain identifier\n" , argv[optind]);return 1 ; } -libxl_device_nic_init (&nic,-1 ); +libxl_device_nic_init (ctx, &nic);for (argv += optind+1 , argc -= optind+1 ; argc >0 ; ++argv, --argc) {if (MATCH_OPTION ("type" , *argv, oparg)) {if (!strcmp ("vif" , oparg)) {
@@ -4149,7 +4150,7 @@ int main_networkdetach(int argc, char **return 1 ; } } -if (libxl_device_nic_del (ctx, domid, &nic,1 )) { +if (libxl_device_nic_remove (ctx, domid, &nic)) {fprintf (stderr,"libxl_device_nic_del failed.\n" );return 1 ; }
PATCH 1/1 libxl: remove libxl_device_console_add
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389248 -3600
# Node ID 51dd4ee904718c59b7a05620a4e42e9f531adf81 # Parent 9b58180714357f9879f7ff88a267e7d1f5dfdbb2
libxl: remove libxl_device_console_add.
It has no callers, the only code which adds consoles in internal to libxl and uses libxl__device_console_add directly.
Rather than worrying about what the public API should look like in this case simply remove it, adding new APIs is much easier than fixing broken ones...
tools/libxl/libxl.c +0 -12
@@ -1582,18 +1582,6 @@ out:return rc; } -int libxl_device_console_add (libxl_ctx *ctx,uint32_t domid, -libxl_device_console *console) -{ -libxl__gc gc =LIBXL_INIT_GC (ctx); -int rc =ERROR_INVAL ; - - rc =libxl__device_console_add (&gc, domid, console,NULL ); - -libxl__free_all (&gc); -return rc; -} -/******************************************************************************/ void libxl_device_vkb_init (libxl_device_vkb *vkb,int dev_num) {
tools/libxl/libxl.h +0 -2
@@ -486,8 +486,6 @@ libxl_device_nic *libxl_device_nic_list(int libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,libxl_nicinfo *nicinfo); -int libxl_device_console_add (libxl_ctx *ctx,uint32_t domid,libxl_device_console *console); -void libxl_device_vkb_init (libxl_device_vkb *vkb,int dev_num);int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb);int libxl_device_vkb_clean_shutdown (libxl_ctx *ctx,uint32_t domid);
PATCH 1/1 libxl: convert VKB handling to device API
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389248 -3600
# Node ID afe568282807e64005da85453153c89a64e3b8cd # Parent 51dd4ee904718c59b7a05620a4e42e9f531adf81
libxl: convert VKB handling to device API
tools/libxl/libxl.c +44 -22
@@ -1583,10 +1583,24 @@ out: }/******************************************************************************/ -void libxl_device_vkb_init (libxl_device_vkb *vkb,int dev_num) +int libxl_device_vkb_init (libxl_ctx *ctx,libxl_device_vkb *vkb) {memset (vkb,0x00 ,sizeof (libxl_device_vkb)); - vkb->devid = dev_num; +return 0 ; +} + +static int libxl__device_from_vkb (libxl__gc *gc,uint32_t domid, +libxl_device_vkb *vkb, +libxl__device *device) +{ + device->backend_devid = vkb->devid; + device->backend_domid = vkb->backend_domid; + device->backend_kind =LIBXL__DEVICE_KIND_VKBD ; + device->devid = vkb->devid; + device->domid = domid; + device->kind =LIBXL__DEVICE_KIND_VKBD ; + +return 0 ; }int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb)
@@ -1608,12 +1622,8 @@ int libxl_device_vkb_add(libxl_ctx *ctx, goto out_free; } - device.backend_devid = vkb->devid; - device.backend_domid = vkb->backend_domid; - device.backend_kind =LIBXL__DEVICE_KIND_VKBD ; - device.devid = vkb->devid; - device.domid = domid; - device.kind =LIBXL__DEVICE_KIND_VKBD ; + rc =libxl__device_from_vkb (&gc, domid, vkb, &device); +if (rc !=0 ) goto out_free;flexarray_append (back,"frontend-id" );flexarray_append (back,libxl__sprintf (&gc,"%d" , domid));
@@ -1641,14 +1651,36 @@ out:return rc; } -int libxl_device_vkb_clean_shutdown (libxl_ctx *ctx,uint32_t domid) +int libxl_device_vkb_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_vkb *vkb) { -return ERROR_NI ; +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl__device device; +int rc; + + rc =libxl__device_from_vkb (&gc, domid, vkb, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_remove (&gc, &device,1 ); +out: +libxl__free_all (&gc); +return rc; } -int libxl_device_vkb_hard_shutdown (libxl_ctx *ctx,uint32_t domid) +int libxl_device_vkb_force_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_vkb *vkb) { -return ERROR_NI ; +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl__device device; +int rc; + + rc =libxl__device_from_vkb (&gc, domid, vkb, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_force_remove (&gc, &device); +out: +libxl__free_all (&gc); +return rc; } static void libxl__device_disk_from_xs_be(libxl__gc *gc,
@@ -1936,16 +1968,6 @@ out:return rc; } -int libxl_device_vfb_clean_shutdown (libxl_ctx *ctx,uint32_t domid) -{ -return ERROR_NI ; -} - -int libxl_device_vfb_hard_shutdown (libxl_ctx *ctx,uint32_t domid) -{ -return ERROR_NI ; -} -/******************************************************************************/ int libxl_domain_setmaxmem (libxl_ctx *ctx,uint32_t domid,uint32_t max_memkb)
tools/libxl/libxl.h +4 -3
@@ -486,10 +486,11 @@ libxl_device_nic *libxl_device_nic_list(int libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,libxl_nicinfo *nicinfo); -void libxl_device_vkb_init (libxl_device_vkb *vkb,int dev_num); +/* Keyboard */ +int libxl_device_vkb_init (libxl_ctx *ctx,libxl_device_vkb *vkb);int libxl_device_vkb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb); -int libxl_device_vkb_clean_shutdown (libxl_ctx *ctx,uint32_t domid); -int libxl_device_vkb_hard_shutdown (libxl_ctx *ctx,uint32_t domid); +int libxl_device_vkb_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb); +int libxl_device_vkb_force_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb);void libxl_device_vfb_init (libxl_device_vfb *vfb,int dev_num);int libxl_device_vfb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb);
tools/libxl/xl_cmdimpl.c +2 -1
@@ -917,7 +917,8 @@ skip: d_config->vkbs = (libxl_device_vkb *)realloc (d_config->vkbs,sizeof (libxl_device_vkb) * (d_config->num_vkbs +1 )); vkb = d_config->vkbs + d_config->num_vkbs; -libxl_device_vkb_init (vkb, d_config->num_vkbs); +libxl_device_vkb_init (ctx, vkb); + vkb->devid = d_config->num_vkbs; p =strtok (buf2,"," );if (!p)
PATCH 1/1 libxl: convert VKB handling to device API
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389248 -3600
# Node ID 73c7b1d5d8cee5fd32ca5c60dc8830dbff23eaef # Parent afe568282807e64005da85453153c89a64e3b8cd
libxl: convert VKB handling to device API
tools/libxl/libxl.c +49 -8
@@ -1893,10 +1893,9 @@ out: }/******************************************************************************/ -void libxl_device_vfb_init (libxl_device_vfb *vfb,int dev_num) +int libxl_device_vfb_init (libxl_ctx *ctx,libxl_device_vfb *vfb) {memset (vfb,0x00 ,sizeof (libxl_device_vfb)); - vfb->devid = dev_num; vfb->display =NULL ; vfb->xauthority =NULL ; vfb->vnc =1 ;
@@ -1907,6 +1906,20 @@ void libxl_device_vfb_init(libxl_device_ vfb->keymap =NULL ; vfb->sdl =0 ; vfb->opengl =0 ; +return 0 ; +} + +static int libxl__device_from_vfb (libxl__gc *gc,uint32_t domid, +libxl_device_vfb *vfb, +libxl__device *device) +{ + device->backend_devid = vfb->devid; + device->backend_domid = vfb->backend_domid; + device->backend_kind =LIBXL__DEVICE_KIND_VFB ; + device->devid = vfb->devid; + device->domid = domid; + device->kind =LIBXL__DEVICE_KIND_VFB ; +return 0 ; }int libxl_device_vfb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb)
@@ -1928,12 +1941,8 @@ int libxl_device_vfb_add(libxl_ctx *ctx, goto out_free; } - device.backend_devid = vfb->devid; - device.backend_domid = vfb->backend_domid; - device.backend_kind =LIBXL__DEVICE_KIND_VFB ; - device.devid = vfb->devid; - device.domid = domid; - device.kind =LIBXL__DEVICE_KIND_VFB ; + rc =libxl__device_from_vfb (&gc, domid, vfb, &device); +if (rc !=0 ) goto out_free;flexarray_append_pair (back,"frontend-id" ,libxl__sprintf (&gc,"%d" , domid));flexarray_append_pair (back,"online" ,"1" );
@@ -1968,6 +1977,38 @@ out:return rc; } +int libxl_device_vfb_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_vfb *vfb) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl__device device; +int rc; + + rc =libxl__device_from_vfb (&gc, domid, vfb, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_remove (&gc, &device,1 ); +out: +libxl__free_all (&gc); +return rc; +} + +int libxl_device_vfb_force_remove (libxl_ctx *ctx,uint32_t domid, +libxl_device_vfb *vfb) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl__device device; +int rc; + + rc =libxl__device_from_vfb (&gc, domid, vfb, &device); +if (rc !=0 ) goto out; + + rc =libxl__device_force_remove (&gc, &device); +out: +libxl__free_all (&gc); +return rc; +} +/******************************************************************************/ int libxl_domain_setmaxmem (libxl_ctx *ctx,uint32_t domid,uint32_t max_memkb)
tools/libxl/libxl.h +4 -3
@@ -492,10 +492,11 @@ int libxl_device_vkb_add(libxl_ctx *ctx,int libxl_device_vkb_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb);int libxl_device_vkb_force_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vkb *vkb); -void libxl_device_vfb_init (libxl_device_vfb *vfb,int dev_num); +/* Framebuffer */ +int libxl_device_vfb_init (libxl_ctx *ctx,libxl_device_vfb *vfb);int libxl_device_vfb_add (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb); -int libxl_device_vfb_clean_shutdown (libxl_ctx *ctx,uint32_t domid); -int libxl_device_vfb_hard_shutdown (libxl_ctx *ctx,uint32_t domid); +int libxl_device_vfb_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb); +int libxl_device_vfb_force_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb);int libxl_device_pci_add (libxl_ctx *ctx,uint32_t domid,libxl_device_pci *pcidev);int libxl_device_pci_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_pci *pcidev,int force);
tools/libxl/xl_cmdimpl.c +2 -1
@@ -913,7 +913,8 @@ skip: d_config->vfbs = (libxl_device_vfb *)realloc (d_config->vfbs,sizeof (libxl_device_vfb) * (d_config->num_vfbs +1 )); vfb = d_config->vfbs + d_config->num_vfbs; -libxl_device_vfb_init (vfb, d_config->num_vfbs); +libxl_device_vfb_init (ctx, vfb); + vfb->devid = d_config->num_vfbs; d_config->vkbs = (libxl_device_vkb *)realloc (d_config->vkbs,sizeof (libxl_device_vkb) * (d_config->num_vkbs +1 )); vkb = d_config->vkbs + d_config->num_vkbs;
PATCH 1/1 libxl: reorder device functions to put functions for each device together
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node ID dc967a4691d5a7e05eac3522ab78c573a084b63c
# Parent 73c7b1d5d8cee5fd32ca5c60dc8830dbff23eaef
libxl: reorder device functions to put functions for each device together.
tools/libxl/libxl.c +211 -209
@@ -1110,6 +1110,216 @@ out:libxl__free_all (&gc);return rc; } + +static void libxl__device_disk_from_xs_be (libxl__gc *gc, +const char *be_path, +libxl_device_disk *disk) +{ +libxl_ctx *ctx =libxl__gc_owner (gc); +unsigned int len; +char *tmp; + +libxl_device_disk_init (ctx, disk); + + tmp =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/params" , be_path), &len); +if (tmp &&strchr (tmp,':' )) { + disk->pdev_path =strdup (strchr (tmp,':' ) +1 ); +free (tmp); + }else { + disk->pdev_path = tmp; + } +libxl_string_to_backend (ctx, +libxl__xs_read (gc,XBT_NULL , +libxl__sprintf (gc,"%s/type" , be_path)), + &(disk->backend)); + disk->vdev =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (gc,"%s/dev" , be_path), &len); + tmp =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf + (gc,"%s/removable" , be_path)); + +if (tmp) + disk->removable =atoi (tmp); +else + disk->removable =0 ; + + tmp =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/mode" , be_path)); +if (!strcmp (tmp,"w" )) + disk->readwrite =1 ; +else + disk->readwrite =0 ; + + tmp =libxl__xs_read (gc,XBT_NULL , +libxl__sprintf (gc,"%s/device-type" , be_path)); + disk->is_cdrom = !strcmp (tmp,"cdrom" ); + + disk->format =LIBXL_DISK_FORMAT_UNKNOWN ; +} + +int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid, +int devid,libxl_device_disk *disk) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +char *dompath, *path; +int rc =ERROR_FAIL ; + +libxl_device_disk_init (ctx, disk); + + dompath =libxl__xs_get_dompath (&gc, domid); +if (!dompath) { + goto out; + } + path =libxl__xs_read (&gc,XBT_NULL , +libxl__sprintf (&gc,"%s/device/vbd/%d/backend" , + dompath, devid)); +if (!path) + goto out; + +libxl__device_disk_from_xs_be (&gc, path, disk); + + rc =0 ; +out: +libxl__free_all (&gc); +return rc; +} + + +static int libxl__append_disk_list_of_type (libxl__gc *gc, +uint32_t domid, +const char *type, +libxl_device_disk **disks, +int *ndisks) +{ +char *be_path =NULL ; +char **dir =NULL ; +unsigned int n =0 ; +libxl_device_disk *pdisk =NULL , *pdisk_end =NULL ; + + be_path =libxl__sprintf (gc,"%s/backend/%s/%d" , +libxl__xs_get_dompath (gc,0 ), type, domid); + dir =libxl__xs_directory (gc,XBT_NULL , be_path, &n); +if (dir) { +libxl_device_disk *tmp; + tmp =realloc (*disks,sizeof (libxl_device_disk) * (*ndisks + n)); +if (tmp ==NULL ) +return ERROR_NOMEM ; + *disks = tmp; + pdisk = *disks + *ndisks; + *ndisks += n; + pdisk_end = *disks + *ndisks; +for (; pdisk < pdisk_end; pdisk++, dir++) { +const char *p; + p =libxl__sprintf (gc,"%s/%s" , be_path, *dir); +libxl__device_disk_from_xs_be (gc, p, pdisk); + pdisk->backend_domid =0 ; + } + } +return 0 ; +} + +libxl_device_disk *libxl_device_disk_list (libxl_ctx *ctx,uint32_t domid,int *num) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +libxl_device_disk *disks =NULL ; +int rc; + + *num =0 ; + + rc =libxl__append_disk_list_of_type (&gc, domid,"vbd" , &disks, num); +if (rc) goto out_err; + + rc =libxl__append_disk_list_of_type (&gc, domid,"tap" , &disks, num); +if (rc) goto out_err; + + rc =libxl__append_disk_list_of_type (&gc, domid,"qdisk" , &disks, num); +if (rc) goto out_err; + +libxl__free_all (&gc); +return disks; + +out_err: +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Unable to list disks" ); +while (disks && *num) { + (*num)--; +libxl_device_disk_destroy (&disks[*num]); + } +free (disks); +return NULL ; +} + +int libxl_device_disk_getinfo (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk,libxl_diskinfo *diskinfo) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +char *dompath, *diskpath; +char *val; + + dompath =libxl__xs_get_dompath (&gc, domid); + diskinfo->devid =libxl__device_disk_dev_number (disk->vdev,NULL ,NULL ); + +/* tap devices entries in xenstore are written as vbd devices. */ + diskpath =libxl__sprintf (&gc,"%s/device/vbd/%d" , dompath, diskinfo->devid); + diskinfo->backend =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (&gc,"%s/backend" , diskpath),NULL ); +if (!diskinfo->backend) { +libxl__free_all (&gc); +return ERROR_FAIL ; + } + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/backend-id" , diskpath)); + diskinfo->backend_id = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/state" , diskpath)); + diskinfo->state = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/event-channel" , diskpath)); + diskinfo->evtch = val ?strtoul (val,NULL ,10 ) :-1 ; + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/ring-ref" , diskpath)); + diskinfo->rref = val ?strtoul (val,NULL ,10 ) :-1 ; + diskinfo->frontend =xs_read (ctx->xsh,XBT_NULL , +libxl__sprintf (&gc,"%s/frontend" , diskinfo->backend),NULL ); + val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/frontend-id" , diskinfo->backend)); + diskinfo->frontend_id = val ?strtoul (val,NULL ,10 ) :-1 ; + +libxl__free_all (&gc); +return 0 ; +} + +int libxl_cdrom_insert (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk) +{ +int num, i; +uint32_t stubdomid; +libxl_device_disk *disks; +int ret =ERROR_FAIL ; + +if (!disk->pdev_path) { + disk->pdev_path =strdup ("" ); + disk->format =LIBXL_DISK_FORMAT_EMPTY ; + } + disks =libxl_device_disk_list (ctx, domid, &num); +for (i =0 ; i < num; i++) { +if (disks[i].is_cdrom && !strcmp (disk->vdev, disks[i].vdev)) +/* found */ +break ; + } +if (i == num) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Virtual device not found" ); + goto out; + } + + ret =0 ; + +libxl_device_disk_remove (ctx, domid, disks + i); +libxl_device_disk_add (ctx, domid, disk); + stubdomid =libxl_get_stubdom_id (ctx, domid); +if (stubdomid) { +libxl_device_disk_remove (ctx, stubdomid, disks + i); +libxl_device_disk_add (ctx, stubdomid, disk); + } +out: +for (i =0 ; i < num; i++) +libxl_device_disk_destroy (&disks[i]); +free (disks); +return ret; +} +char *libxl_device_disk_local_attach (libxl_ctx *ctx,libxl_device_disk *disk) {libxl__gc gc =LIBXL_INIT_GC (ctx);
@@ -1343,6 +1553,7 @@ out:libxl__free_all (&gc);return rc; } +static void libxl__device_nic_from_xs_be (libxl__gc *gc,const char *be_path,libxl_device_nic *nic)
@@ -1683,215 +1894,6 @@ out:return rc; } -static void libxl__device_disk_from_xs_be (libxl__gc *gc, -const char *be_path, -libxl_device_disk *disk) -{ -libxl_ctx *ctx =libxl__gc_owner (gc); -unsigned int len; -char *tmp; - -libxl_device_disk_init (ctx, disk); - - tmp =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (gc,"%s/params" , be_path), &len); -if (tmp &&strchr (tmp,':' )) { - disk->pdev_path =strdup (strchr (tmp,':' ) +1 ); -free (tmp); - }else { - disk->pdev_path = tmp; - } -libxl_string_to_backend (ctx, -libxl__xs_read (gc,XBT_NULL , -libxl__sprintf (gc,"%s/type" , be_path)), - &(disk->backend)); - disk->vdev =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (gc,"%s/dev" , be_path), &len); - tmp =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf - (gc,"%s/removable" , be_path)); - -if (tmp) - disk->removable =atoi (tmp); -else - disk->removable =0 ; - - tmp =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/mode" , be_path)); -if (!strcmp (tmp,"w" )) - disk->readwrite =1 ; -else - disk->readwrite =0 ; - - tmp =libxl__xs_read (gc,XBT_NULL , -libxl__sprintf (gc,"%s/device-type" , be_path)); - disk->is_cdrom = !strcmp (tmp,"cdrom" ); - - disk->format =LIBXL_DISK_FORMAT_UNKNOWN ; -} - -int libxl_devid_to_device_disk (libxl_ctx *ctx,uint32_t domid, -int devid,libxl_device_disk *disk) -{ -libxl__gc gc =LIBXL_INIT_GC (ctx); -char *dompath, *path; -int rc =ERROR_FAIL ; - -libxl_device_disk_init (ctx, disk); - - dompath =libxl__xs_get_dompath (&gc, domid); -if (!dompath) { - goto out; - } - path =libxl__xs_read (&gc,XBT_NULL , -libxl__sprintf (&gc,"%s/device/vbd/%d/backend" , - dompath, devid)); -if (!path) - goto out; - -libxl__device_disk_from_xs_be (&gc, path, disk); - - rc =0 ; -out: -libxl__free_all (&gc); -return rc; -} - - -static int libxl__append_disk_list_of_type (libxl__gc *gc, -uint32_t domid, -const char *type, -libxl_device_disk **disks, -int *ndisks) -{ -char *be_path =NULL ; -char **dir =NULL ; -unsigned int n =0 ; -libxl_device_disk *pdisk =NULL , *pdisk_end =NULL ; - - be_path =libxl__sprintf (gc,"%s/backend/%s/%d" , -libxl__xs_get_dompath (gc,0 ), type, domid); - dir =libxl__xs_directory (gc,XBT_NULL , be_path, &n); -if (dir) { -libxl_device_disk *tmp; - tmp =realloc (*disks,sizeof (libxl_device_disk) * (*ndisks + n)); -if (tmp ==NULL ) -return ERROR_NOMEM ; - *disks = tmp; - pdisk = *disks + *ndisks; - *ndisks += n; - pdisk_end = *disks + *ndisks; -for (; pdisk < pdisk_end; pdisk++, dir++) { -const char *p; - p =libxl__sprintf (gc,"%s/%s" , be_path, *dir); -libxl__device_disk_from_xs_be (gc, p, pdisk); - pdisk->backend_domid =0 ; - } - } -return 0 ; -} - -libxl_device_disk *libxl_device_disk_list (libxl_ctx *ctx,uint32_t domid,int *num) -{ -libxl__gc gc =LIBXL_INIT_GC (ctx); -libxl_device_disk *disks =NULL ; -int rc; - - *num =0 ; - - rc =libxl__append_disk_list_of_type (&gc, domid,"vbd" , &disks, num); -if (rc) goto out_err; - - rc =libxl__append_disk_list_of_type (&gc, domid,"tap" , &disks, num); -if (rc) goto out_err; - - rc =libxl__append_disk_list_of_type (&gc, domid,"qdisk" , &disks, num); -if (rc) goto out_err; - -libxl__free_all (&gc); -return disks; - -out_err: -LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Unable to list disks" ); -while (disks && *num) { - (*num)--; -libxl_device_disk_destroy (&disks[*num]); - } -free (disks); -return NULL ; -} - -int libxl_device_disk_getinfo (libxl_ctx *ctx,uint32_t domid, -libxl_device_disk *disk,libxl_diskinfo *diskinfo) -{ -libxl__gc gc =LIBXL_INIT_GC (ctx); -char *dompath, *diskpath; -char *val; - - dompath =libxl__xs_get_dompath (&gc, domid); - diskinfo->devid =libxl__device_disk_dev_number (disk->vdev,NULL ,NULL ); - -/* tap devices entries in xenstore are written as vbd devices. */ - diskpath =libxl__sprintf (&gc,"%s/device/vbd/%d" , dompath, diskinfo->devid); - diskinfo->backend =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (&gc,"%s/backend" , diskpath),NULL ); -if (!diskinfo->backend) { -libxl__free_all (&gc); -return ERROR_FAIL ; - } - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/backend-id" , diskpath)); - diskinfo->backend_id = val ?strtoul (val,NULL ,10 ) :-1 ; - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/state" , diskpath)); - diskinfo->state = val ?strtoul (val,NULL ,10 ) :-1 ; - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/event-channel" , diskpath)); - diskinfo->evtch = val ?strtoul (val,NULL ,10 ) :-1 ; - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/ring-ref" , diskpath)); - diskinfo->rref = val ?strtoul (val,NULL ,10 ) :-1 ; - diskinfo->frontend =xs_read (ctx->xsh,XBT_NULL , -libxl__sprintf (&gc,"%s/frontend" , diskinfo->backend),NULL ); - val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/frontend-id" , diskinfo->backend)); - diskinfo->frontend_id = val ?strtoul (val,NULL ,10 ) :-1 ; - -libxl__free_all (&gc); -return 0 ; -} - -int libxl_cdrom_insert (libxl_ctx *ctx,uint32_t domid,libxl_device_disk *disk) -{ -int num, i; -uint32_t stubdomid; -libxl_device_disk *disks; -int ret =ERROR_FAIL ; - -if (!disk->pdev_path) { - disk->pdev_path =strdup ("" ); - disk->format =LIBXL_DISK_FORMAT_EMPTY ; - } - disks =libxl_device_disk_list (ctx, domid, &num); -for (i =0 ; i < num; i++) { -if (disks[i].is_cdrom && !strcmp (disk->vdev, disks[i].vdev)) -/* found */ -break ; - } -if (i == num) { -LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"Virtual device not found" ); - goto out; - } - - ret =0 ; - -libxl_device_disk_remove (ctx, domid, disks + i); -libxl_device_disk_add (ctx, domid, disk); - stubdomid =libxl_get_stubdom_id (ctx, domid); -if (stubdomid) { -libxl_device_disk_remove (ctx, stubdomid, disks + i); -libxl_device_disk_add (ctx, stubdomid, disk); - } -out: -for (i =0 ; i < num; i++) -libxl_device_disk_destroy (&disks[i]); -free (disks); -return ret; -} -/******************************************************************************/ int libxl_device_vfb_init (libxl_ctx *ctx,libxl_device_vfb *vfb) {
PATCH 1/1 libxl: convert PCI device handling to device API
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317389278 -3600
# Node ID f0ab7f2102b37968da2181825ac492b14bc4b449 # Parent dc967a4691d5a7e05eac3522ab78c573a084b63c
libxl: convert PCI device handling to device API
tools/libxl/libxl.c +1 -1
@@ -754,7 +754,7 @@ int libxl_domain_destroy(libxl_ctx *ctx, goto out; } -if (libxl_device_pci_shutdown (ctx, domid) <0 ) +if (libxl__device_pci_force_remove_all (&gc, domid) <0 )LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"pci shutdown failed for domid %d" , domid); rc =xc_domain_pause (ctx->xch, domid);if (rc <0 ) {
tools/libxl/libxl.h +21 -5
@@ -498,12 +498,28 @@ int libxl_device_vfb_add(libxl_ctx *ctx,int libxl_device_vfb_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb);int libxl_device_vfb_force_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_vfb *vfb); +/* PCI Passthrough */ +int libxl_device_pci_init (libxl_ctx *ctx,libxl_device_pci *pci);int libxl_device_pci_add (libxl_ctx *ctx,uint32_t domid,libxl_device_pci *pcidev); -int libxl_device_pci_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_pci *pcidev,int force); -int libxl_device_pci_shutdown (libxl_ctx *ctx,uint32_t domid); -int libxl_device_pci_list_assigned (libxl_ctx *ctx,libxl_device_pci **list,uint32_t domid,int *num); -int libxl_device_pci_list_assignable (libxl_ctx *ctx,libxl_device_pci **list,int *num); -int libxl_device_pci_parse_bdf (libxl_ctx *ctx,libxl_device_pci *pcidev,const char *str); +int libxl_device_pci_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_pci *pcidev); +int libxl_device_pci_force_remove (libxl_ctx *ctx,uint32_t domid,libxl_device_pci *pcidev); +libxl_device_pci *libxl_device_pci_list (libxl_ctx *ctx,uint32_t domid,int *num); + +/* +* Parse a PCI BDF into a PCI device structure. +*/ +int libxl_device_pci_parse_bdf (libxl_ctx *ctx, +libxl_device_pci *pcidev, +const char *str); + +/* +* Similar to libxl_device_pci_list but returns all devices which +* could be assigned to a domain (i.e. are bound to the backend +* driver) but are not currently. +*/ +libxl_device_pci *libxl_device_pci_list_assignable (libxl_ctx *ctx,int *num); + +/* CPUID handling */ int libxl_cpuid_parse_config (libxl_cpuid_policy_list *cpuid,const char * str);int libxl_cpuid_parse_config_xend (libxl_cpuid_policy_list *cpuid,const char * str);
tools/libxl/libxl_internal.h +1 -0
@@ -252,6 +252,7 @@ _hidden int libxl__wait_for_backend(libx _hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting); _hidden int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,libxl_device_pci *pcidev,int num); +_hidden int libxl__device_pci_force_remove_all(libxl__gc *gc, uint32_t domid);/* xl_exec */
tools/libxl/libxl_pci.c +115 -71
287 lines not on this page · raw message
tools/libxl/xl_cmdimpl.c +11 -4
@@ -2078,11 +2078,14 @@ static void pcilist_assignable(void)libxl_device_pci *pcidevs;int num, i; -if (libxl_device_pci_list_assignable (ctx, &pcidevs, &num) ) + pcidevs =libxl_device_pci_list_assignable (ctx, &num); + +if ( pcidevs ==NULL )return ;for (i =0 ; i < num; i++) {printf ("%04x:%02x:%02x.%01x\n" , - pcidevs[i].domain, pcidevs[i].bus, pcidevs[i].dev, pcidevs[i].func); + pcidevs[i].domain, pcidevs[i].bus, pcidevs[i].dev, pcidevs[i].func); +libxl_device_pci_destroy (&pcidevs[i]); }free (pcidevs); }
@@ -2105,7 +2108,8 @@ static void pcilist(const char *dom)find_domain (dom); -if (libxl_device_pci_list_assigned (ctx, &pcidevs, domid, &num)) + pcidevs =libxl_device_pci_list (ctx, domid, &num); +if (pcidevs ==NULL )return ;printf ("Vdev Device\n" );for (i =0 ; i < num; i++) {
@@ -2142,7 +2146,10 @@ static void pcidetach(const char *dom, cfprintf (stderr,"pci-detach: malformed BDF specification \"%s\"\n" , bdf);exit (2 ); } -libxl_device_pci_remove (ctx, domid, &pcidev, force); +if (force) +libxl_device_pci_force_remove (ctx, domid, &pcidev); +else +libxl_device_pci_remove (ctx, domid, &pcidev);libxl_device_pci_destroy (&pcidev); }
tools/python/xen/lowlevel/xl/xl.c +14 -5
@@ -521,9 +521,16 @@ static PyObject *pyxl_pci_del(XlObject *return NULL ; } pci = (Py_device_pci *)obj; -if (libxl_device_pci_remove (self->ctx, domid, &pci->obj, force) ) { -PyErr_SetString (xl_error_obj,"cannot remove pci device" ); -return NULL ; +if ( force ) { +if (libxl_device_pci_force_remove (self->ctx, domid, &pci->obj) ) { +PyErr_SetString (xl_error_obj,"cannot remove pci device" ); +return NULL ; + } + }else { +if (libxl_device_pci_remove (self->ctx, domid, &pci->obj) ) { +PyErr_SetString (xl_error_obj,"cannot remove pci device" ); +return NULL ; + } }Py_INCREF (Py_None);return Py_None;
@@ -558,7 +565,8 @@ static PyObject *pyxl_pci_list_assignablPyObject *list;int nr_dev, i; -if (libxl_device_pci_list_assignable (self->ctx, &dev, &nr_dev) ) { + dev =libxl_device_pci_list_assignable (self->ctx, &nr_dev); +if ( dev ==NULL ) {PyErr_SetString (xl_error_obj,"Cannot list assignable devices" );return NULL ; }
@@ -594,7 +602,8 @@ static PyObject *pyxl_pci_list(XlObjectif ( !PyArg_ParseTuple (args,"i" , &domid) )return NULL ; -if (libxl_device_pci_list_assigned (self->ctx, &dev, domid, &nr_dev) ) { + dev =libxl_device_pci_list (self->ctx, domid, &nr_dev); +if ( dev ==NULL ) {PyErr_SetString (xl_error_obj,"Cannot list assignable devices" );return NULL ; }
I hope this patches will be applied to unstable soon, so I can rewrite the NetBSD file disk backend with the new features introduced in the series.
Great work, regards Roger.
Quoted 3 lines · Roger Pau Monné
I hope this patches will be applied to unstable soon, so I can rewrite the NetBSD file disk backend with the new features introduced in the series.
What I tend to do in these cases is to import the other persons series into the head of my own patch queue (using the mq extension) and switch it out as new revisions are posted etc.
Ian.
Quoted 2 lines
Great work, regards Roger.
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Roger Pau Monné
I hope this patches will be applied to unstable soon, so I can rewrite the NetBSD file disk backend with the new features introduced in the series.
What I tend to do in these cases is to import the other persons series into the head of my own patch queue (using the mq extension) and switch it out as new revisions are posted etc.
BTW the mbox extension (http://mercurial.selenic.com/wiki/MboxExtension)
can make this a bit easier for larger series, since you can save all the messages to an mbox and import that in one go.
I think Chris Masons mseries extension is similar too
http://oss.oracle.com/~mason/mseries/
Ian.
RE: [PATCH 02 of 23] libxl: add a comment describing the device interfaces
In reply to Ian CampbellHi Ian,
I think the shape of this interface looks sensible.
[ snip ]
Quoted 10 lines
+ * libxl_device_<type>_add(ctx, domid, device):
+ *
+ * Adds the given device to the specified domain. This can be called
+ * while the guest is running (hotplug) or before boot (coldplug).
+ *+ * This function only sets up the device but does not wait for the + * domain to connect to the device and therefore cannot block on the + * guest.+ *
+ * XXX do we need a way to wait? e.g.wait_for_connectfunction?
I don't know about other users but xapi doesn't currently care whether a domain has actually connected to the device (in the sense of xenstore state = 4). Xapi only cares about whether the device has been connected to the domain from the host's PoV; i.e. the "virtual cable" has been plugged in and the domain can use the device if it chooses to.
BTW Xapi's disk hotplug command will block until it gets a completion signal from a backend udev script. While the command is in progress it holds a lock which prevents an old xenstore watch being processed which might cause xapi to think a async unplug has just occurred (more below)
Quoted 5 lines
+ * XXX perhaps an optional way to generate an event on connect?
+ * needs event system overhaul.
+ *
+ * libxl_device_<type>_remove(ctx, domid, device):
+ *
Quoted 8 lines
+ * Removes the given device from the specified domain by performing + * an orderly unplug with guest co-operation. This requires that the + * guest is running.+ *
+ * This method is currently synchronous and therefore can block
+ * while interacting with the guest.
+ *
+ * XXX should provide an async version. needs event system overhaul.
Xapi normally performs a synchronous unplug, waiting for completion signaled via a backend udev script. However if the disk is mounted inside the domain and the blkfront signals an error ("02 - refusing to close" ISTR) then xapi stops waiting and the synchronous unplug fails. Later when the admin inside the guest unmounts the disk and the unplug completes, xapi's xenstore watch fires, it grabs a lock, checks the state of xenstore and if necessary marks the disk as unplugged.
BTW I've always thought this behaviour a little weird and I'm not attached to it :) IMHO it would be nice to have a failed unplug request cause the whole operation to be aborted, and not to have the device unplug later by itself.
Cheers,
Dave
RE: [PATCH 02 of 23] libxl: add a comment describing the device interfaces
Quoted 3 lines · Dave Scott
Hi Ian,
I think the shape of this interface looks sensible.
Thanks for taking a look.
Quoted 12 lines
[ snip ]
Quoted 10 lines
+ * libxl_device_<type>_add(ctx, domid, device):
+ *
+ * Adds the given device to the specified domain. This can be called
+ * while the guest is running (hotplug) or before boot (coldplug).
+ *+ * This function only sets up the device but does not wait for the + * domain to connect to the device and therefore cannot block on the + * guest.+ *
+ * XXX do we need a way to wait? e.g.wait_for_connectfunction?
Quoted 5 lines
I don't know about other users but xapi doesn't currently care whether a domain has actually connected to the device (in the sense of xenstore state = 4). Xapi only cares about whether the device has been connected to the domain from the host's PoV; i.e. the "virtual cable" has been plugged in and the domain can use the device if it chooses to.
That's what I was thinking too but I expressed it badly, i.e. wait_for_backend_setup() might be a better name / concept.
Quoted 19 lines
BTW Xapi's disk hotplug command will block until it gets a completion signal from a backend udev script. While the command is in progress it holds a lock which prevents an old xenstore watch being processed which might cause xapi to think a async unplug has just occurred (more below)
Quoted 5 lines
+ * XXX perhaps an optional way to generate an event on connect?
+ * needs event system overhaul.
+ *
+ * libxl_device_<type>_remove(ctx, domid, device):
+ *Quoted 8 lines
+ * Removes the given device from the specified domain by performing + * an orderly unplug with guest co-operation. This requires that the + * guest is running.+ *
+ * This method is currently synchronous and therefore can block
+ * while interacting with the guest.
+ *
+ * XXX should provide an async version. needs event system overhaul.
Quoted 7 lines
Xapi normally performs a synchronous unplug, waiting for completion signaled via a backend udev script. However if the disk is mounted inside the domain and the blkfront signals an error ("02 - refusing to close" ISTR) then xapi stops waiting and the synchronous unplug fails. Later when the admin inside the guest unmounts the disk and the unplug completes, xapi's xenstore watch fires, it grabs a lock, checks the state of xenstore and if necessary marks the disk as unplugged.
Is this roughly the same as doing an async unplug followed by an event triggered by the udev script? The only difference is whether the event happens sooner or much later? Possibly we could have a separate "unplug deferred" style event which triggers when we notice that the guest is refusing to unplug, so the toolstack can at least report that fact?
Quoted 4 lines
BTW I've always thought this behaviour a little weird and I'm not attached to it :) IMHO it would be nice to have a failed unplug request cause the whole operation to be aborted, and not to have the device unplug later by itself.
We may find our hands tied by the existing backend/frontend implementations here, but we can see what we can do.
Ian.
Quoted 3 lines
BTW the mbox extension (http://mercurial.selenic.com/wiki/MboxExtension)
can make this a bit easier for larger series, since you can save all the messages to an mbox and import that in one go.
Thanks for the suggestion, the mbox extension helps a lot to import large series. I'm having trouble applying your patches to tip, your libxl_utils.c seems to be different from the one present in the xen-unstable repository, should I apply some other patches before yours?
Quoted 9 lines · Roger Pau Monné
Quoted 3 lines
BTW the mbox extension (http://mercurial.selenic.com/wiki/MboxExtension)
can make this a bit easier for larger series, since you can save all the messages to an mbox and import that in one go.Thanks for the suggestion, the mbox extension helps a lot to import large series. I'm having trouble applying your patches to tip, your
libxl_utils.cseems to be different from the one present in the xen-unstable repository, should I apply some other patches before yours?
Looks like I had two precursor patches which I thought I'd posted but apparently I had not. I'll dig them out...
Ian.
Hello (again),
After importing the series I realized that something is broken in xl_cmdimpl.c, I get the following errors:
gcc -L/usr/xen42/lib -o xl xl.o xl_cmdimpl.o xl_cmdtable.o
libxlutil.so -L/root/xen-04102011/tools/libxl/../../tools/libxl -Wl,-rpath-link=/root/xen-04102011/tools/libxl/../../tools/libxc -Wl,-rpath-link=/root/xen-04102011/tools/libxl/../../tools/xenstore -lxenlight -L/root/xen-04102011/tools/libxl/../../tools/libxc -lxenctrl
xl_cmdimpl.o: In function `parse_disk_config_multistring':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:497: undefined reference to `libxl_device_disk_init'
xl_cmdimpl.o: In function `main_blockdetach':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:4202: undefined reference to `libxl_device_disk_remove'
xl_cmdimpl.o: In function `main_networkdetach':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:4099: undefined reference to `libxl_device_nic_remove'
xl_cmdimpl.o: In function `main_networklist':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:4052: undefined reference to libxl_device_nic_list' /root/xen-04102011/tools/libxl/xl_cmdimpl.c:4057: undefined reference to libxl_device_nic_getinfo'
xl_cmdimpl.o: In function `pcidetach':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:2087: undefined reference to `libxl_device_pci_force_remove'
xl_cmdimpl.o: In function `pcilist':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:2048: undefined reference to `libxl_device_pci_list'
gmake: *** [xl] Error 1
PATCH 1/1 libxl: update nic list API to use common device API style
In reply to Ian Campbelllibxl_device_nic_list returns an array of libxl_device_nic and libxl_device_nic_getinfo retrieves further information.
tools/libxl/Makefile +1 -1
@@ -119,7 +119,7 @@ libxlutil.a: $(LIBXLU_OBJS) $(AR) rcs libxlutil.a $^ xl: $(XL_OBJS) libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so libxenlight.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) testidl: testidl.o libxlutil.so libxenlight.so $(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl)
tools/libxl/libxl.c +125 -47
185 lines not on this page · raw message
tools/libxl/libxl.h +3 -1
@@ -467,7 +467,9 @@ int libxl_device_disk_local_detach(libxlint libxl_device_nic_init (libxl_device_nic *nic,int dev_num);int libxl_device_nic_add (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic);int libxl_device_nic_del (libxl_ctx *ctx,uint32_t domid,libxl_device_nic *nic,int wait); -libxl_nicinfo *libxl_list_nics (libxl_ctx *ctx,uint32_t domid,unsigned int *nb); +libxl_device_nic *libxl_device_nic_list (libxl_ctx *ctx,uint32_t domid,int *num); +int libxl_device_nic_getinfo (libxl_ctx *ctx,uint32_t domid, +libxl_device_nic *nic,libxl_nicinfo *nicinfo);int libxl_device_console_add (libxl_ctx *ctx,uint32_t domid,libxl_device_console *console);
tools/libxl/libxl_types.idl +0 -2
@@ -330,8 +330,6 @@ libxl_nicinfo = Struct("nicinfo", [ ("frontend_id", uint32), ("devid", integer), ("state", integer), - ("script", string), - ("mac", libxl_mac), ("evtch", integer), ("rref_tx", integer), ("rref_rx", integer),
tools/libxl/libxl_utils.c +9 -9
@@ -451,15 +451,15 @@ int libxl_pipe(libxl_ctx *ctx, int pipesint libxl_mac_to_device_nic (libxl_ctx *ctx,uint32_t domid,const char *mac,libxl_device_nic *nic) { -libxl_nicinfo *nics; -unsigned int nb, rc, i; +libxl_device_nic *nics; +int nb, rc, i;libxl_mac mac_n; rc =libxl__parse_mac (mac, mac_n);if (rc)return rc; - nics =libxl_list_nics (ctx, domid, &nb); + nics =libxl_device_nic_list (ctx, domid, &nb);if (!nics)return ERROR_FAIL ;
@@ -468,17 +468,17 @@ int libxl_mac_to_device_nic(libxl_ctx *c rc =ERROR_INVAL ;for (i =0 ; i < nb; ++i) {if (!libxl__compare_macs (&mac_n, &nics[i].mac)) { - nic->backend_domid = nics[i].backend_id; - nic->devid = nics[i].devid; -memcpy (nic->mac, nics[i].mac,sizeof (nic->mac)); - nic->script =strdup (nics[i].script); + *nic = nics[i]; rc =0 ; + i++;/* Do not destroy this NIC on exit path */ break ; } +libxl_device_nic_destroy (&nics[i]); } -for (i=0 ; i<nb; i++) -libxl_nicinfo_destroy (&nics[i]); +for (; i<nb; i++) +libxl_device_nic_destroy (&nics[i]); +free (nics);return rc; }
tools/libxl/xl_cmdimpl.c +17 -12
@@ -4022,8 +4022,9 @@ int main_networkattach(int argc, char **int main_networklist (int argc,char **argv) {int opt; -libxl_nicinfo *nics; -unsigned int nb, i; +libxl_device_nic *nics; +libxl_nicinfo nicinfo; +int nb, i;if ((opt =def_getopt (argc, argv,"" ,"network-list" ,1 )) !=-1 )return opt;
@@ -4036,19 +4037,23 @@ int main_networklist(int argc, char **arfprintf (stderr,"%s is an invalid domain identifier\n" , *argv);continue ; } -if (!(nics =libxl_list_nics (ctx, domid, &nb))) { + nics =libxl_device_nic_list (ctx, domid, &nb); +if (!nics) {continue ; }for (i =0 ; i < nb; ++i) { -/* Idx BE */ -printf ("%-3d %-2d " , nics[i].devid, nics[i].backend_id); -/* MAC */ -printf (LIBXL_MAC_FMT ,LIBXL_MAC_BYTES (nics[i].mac)); -/* Hdl Sta evch txr/rxr BE-path */ -printf ("%6d %5d %6d %5d/%-11d %-30s\n" , - nics[i].devid, nics[i].state, nics[i].evtch, - nics[i].rref_tx, nics[i].rref_rx, nics[i].backend); -libxl_nicinfo_destroy (&nics[i]); +if (!libxl_device_nic_getinfo (ctx, domid, &nics[i], &nicinfo)) { +/* Idx BE */ +printf ("%-3d %-2d " , nicinfo.devid, nicinfo.backend_id); +/* MAC */ +printf (LIBXL_MAC_FMT ,LIBXL_MAC_BYTES (nics[i].mac)); +/* Hdl Sta evch txr/rxr BE-path */ +printf ("%6d %5d %6d %5d/%-11d %-30s\n" , + nicinfo.devid, nicinfo.state, nicinfo.evtch, + nicinfo.rref_tx, nicinfo.rref_rx, nicinfo.backend); +libxl_nicinfo_destroy (&nicinfo); + } +libxl_device_nic_destroy (&nics[i]); }free (nics); }
Quoted 11 lines · Roger Pau Monné
Hello (again),
After importing the series I realized that something is broken in
xl_cmdimpl.c, I get the following errors:gcc -L/usr/xen42/lib -o xl xl.o xl_cmdimpl.o xl_cmdtable.o
libxlutil.so -L/root/xen-04102011/tools/libxl/../../tools/libxl(quoted diff) +0
-4-Wl,-rpath-link=/root/xen-04102011/tools/libxl/../../tools/libxc -Wl,-rpath-link=/root/xen-04102011/tools/libxl/../../tools/xenstore -lxenlight -L/root/xen-04102011/tools/libxl/../../tools/libxc -lxenctrl
Quoted 3 lines
xl_cmdimpl.o: In function `parse_disk_config_multistring':
/root/xen-04102011/tools/libxl/xl_cmdimpl.c:497: undefined reference to `libxl_device_disk_init'
This function was added by "libxl: convert disk handling to device API" (patch #17/23). The others were generally added by the "convert XXX handling to ..." patches.
I suspect that the -L/usr/xen42/lib in your link line has caused it to
try and link against the installed libxenlight.so and not the just built
one. My link line does not include this, it is just:
gcc -o xl xl.o xl_cmdimpl.o xl_cmdtable.o libxlutil.so
-L/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/libxl -Wl,-rpath-link=/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/libxc -Wl,-rpath-link=/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/xenstore -Wl,-rpath-link=/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/blktap2/control -lxenlight -L/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/libxc -lxenctrl
SO I guess you have LDFLAGS=-L/usr/xen42/lib -- what is that for? It should not be necessary when building Xen itself.
Quoted 18 lines
xl_cmdimpl.o: In function `main_blockdetach':
/root/xen-04102011/tools/libxl/xl_cmdimpl.c:4202: undefined reference to `libxl_device_disk_remove'
xl_cmdimpl.o: In function `main_networkdetach':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:4099: undefined reference to `libxl_device_nic_remove'
xl_cmdimpl.o: In function `main_networklist':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:4052: undefined reference tolibxl_device_nic_list' /root/xen-04102011/tools/libxl/xl_cmdimpl.c:4057: undefined reference tolibxl_device_nic_getinfo'
xl_cmdimpl.o: In function `pcidetach':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:2087: undefined reference to `libxl_device_pci_force_remove'
xl_cmdimpl.o: In function `pcilist':/root/xen-04102011/tools/libxl/xl_cmdimpl.c:2048: undefined reference to `libxl_device_pci_list'
gmake: *** [xl] Error 1
Re: [PATCH] libxl: update nic list API to use common device API style
In reply to Roger Pau Monne(I assume everything but the following hunk was a mistake)
tools/libxl/Makefile Fri Sep 30 14:27:27 2011 +0100 libxlutil.a: $(LIBXLU_OBJS) · line 125
Quoted 12 lines
diff -r
25db0629e338-re94763a6bd34tools/libxl/Makefiletools/libxl/Makefile Fri Sep 30 14:27:27 2011 +0100 +1
-1@@ -119,7 +119,7 @@ libxlutil.a: $(LIBXLU_OBJS) $(AR) rcs libxlutil.a $^ xl: $(XL_OBJS) libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so libxenlight.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) testidl: testidl.o libxlutil.so libxenlight.so $(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl)
LDLIBS_libxenlight already has -lxenlight in it. I guess this changes works around you local addition LDFLAGS=-L/usr/xen42/lib?
I'm not sure what the right answer is here.
Ian.
Quoted 14 lines
Quoted 9 lines
gcc -L/usr/xen42/lib -o xl xl.o xl_cmdimpl.o xl_cmdtable.o libxlutil.so -L/root/xen-04102011/tools/libxl/../../tools/libxl
(quoted diff) +0
-4-Wl,-rpath-link=/root/xen-04102011/tools/libxl/../../tools/libxc -Wl,-rpath-link=/root/xen-04102011/tools/libxl/../../tools/xenstore -lxenlight -L/root/xen-04102011/tools/libxl/../../tools/libxc -lxenctrlxl_cmdimpl.o: In function `parse_disk_config_multistring':
/root/xen-04102011/tools/libxl/xl_cmdimpl.c:497: undefined reference to `libxl_device_disk_init'This function was added by "libxl: convert disk handling to device API" (patch #17/23). The others were generally added by the "convert XXX handling to ..." patches.
Quoted 8 lines
I suspect that the -L/usr/xen42/lib in your link line has caused it to
try and link against the installed libxenlight.so and not the just built
one. My link line does not include this, it is just:
gcc -o xl xl.o xl_cmdimpl.o xl_cmdtable.o libxlutil.so
-L/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/libxl -Wl,-rpath-link=/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/libxc -Wl,-rpath-link=/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/xenstore -Wl,-rpath-link=/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/blktap2/control -lxenlight -L/local/scratch/ianc/devel/xen-unstable.hg/tools/libxl/../../tools/libxc -lxenctrlSO I guess you have LDFLAGS=-L/usr/xen42/lib -- what is that for? It should not be necessary when building Xen itself.
The -L/usr/xen42/lib is for yajl, the problem was that it was missing libxenlight.so, so it could not link to the proper functions (or it was trying to use the old library from /usr/xen42/lib instead of the new one). I've modified a patch in your series to include libxenligh.so when compiling xl.
Now I have a similar problem, and I think it's because Xen is trying to use the old header files and libraries in /usr/xen42/ instead of the new ones.
gcc -O2 -g -DHAVE_DB_185_H -I/usr/include -I/usr/pkg/include -I/usr/xen42/include -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -D__XEN_TOOLS__ -MMD -MF .subdirs-install.d -fno-optimize-sibling-calls -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -D__XEN_TOOLS__ -MMD -MF .subdir-install-python.d -fno-optimize-sibling-calls -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -D__XEN_TOOLS__ -MMD -MF .build.d -fno-optimize-sibling-calls -fPIC -I../../tools/include -I../../tools/libxl -I../../tools/libxc -Ixen/lowlevel/xl -I/usr/pkg/include/python2.6 -c xen/lowlevel/xl/xl.c -o build/temp.netbsd-5.99.52-amd64-2.6-pydebug/xen/lowlevel/xl/xl.o -fno-strict-aliasing -Werror
cc1: warnings being treated as errors xen/lowlevel/xl/xl.c: In function 'pyxl_pci_del':xen/lowlevel/xl/xl.c:525: warning: implicit declaration of function 'libxl_device_pci_force_remove'xen/lowlevel/xl/xl.c:530: error: too few arguments to function 'libxl_device_pci_remove'xen/lowlevel/xl/xl.c: In function 'pyxl_pci_list_assignable':xen/lowlevel/xl/xl.c:568: warning: passing argument 2 of 'libxl_device_pci_list_assignable' from incompatible pointer type xen/lowlevel/xl/xl.c:568: error: too few arguments to function 'libxl_device_pci_list_assignable'xen/lowlevel/xl/xl.c: In function 'pyxl_pci_list':xen/lowlevel/xl/xl.c:605: warning: implicit declaration of function 'libxl_device_pci_list'xen/lowlevel/xl/xl.c:605: warning: assignment makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1
Re: [PATCH] libxl: update nic list API to use common device API style
In reply to Ian Campbell2011/10/5 Ian Campbell <[email protected]>:
Quoted 1 line
(I assume everything but the following hunk was a mistake)
I modified your patch and resubmitted it (sorry if that's not ok), since this is the first place where new functions are added to libxl.
Quoted 11 lines
Quoted 11 lines
diff -r
25db0629e338-re94763a6bd34tools/libxl/Makefiletools/libxl/Makefile Fri Sep 30 14:27:27 2011 +0100 +0
-0@@ -119,7 +119,7 @@ libxlutil.a: $(LIBXLU_OBJS)$(AR) rcs libxlutil.a $^
xl: $(XL_OBJS) libxlutil.so libxenlight.so
- $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl)
+ $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so libxenlight.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl)
Quoted 7 lines
Quoted 2 lines
testidl: testidl.o libxlutil.so libxenlight.so
$(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl)
LDLIBS_libxenlightalready has -lxenlight in it. I guess this changes works around you local addition LDFLAGS=-L/usr/xen42/lib?I'm not sure what the right answer is here.
Neither do I, I'm not an expert on build processes, but if I need to append CFLAGS and LDFLAGS to the build process to find my yajl library libxl should not try to use the libxenligh.so and libxenutil.so from the CFLAGS/LDFLAGS folder, because they are outdated. If not, the only option left is to clean my LDFLAGS and CFLAGS folders from previous Xen versions and compile the new version, but that's risky.
Re: [PATCH] libxl: update nic list API to use common device API style
Quoted 5 lines · Roger Pau Monné
2011/10/5 Ian Campbell <[email protected]>:
Quoted 1 line
(I assume everything but the following hunk was a mistake)
I modified your patch and resubmitted it (sorry if that's not ok), since this is the first place where new functions are added to libxl.
It is usually better to submit fixes separately, they can always be merged in later if necessary. In this case the bug is preexisting, it just happened to be this patch which exposed it for your particular case.
Quoted 16 lines
Quoted 16 lines
tools/libxl/Makefile Fri Sep 30 14:27:27 2011 +0100 libxlutil.a: $(LIBXLU_OBJS) · line 125
Quoted 12 lines
diff -r
25db0629e338-re94763a6bd34tools/libxl/Makefiletools/libxl/Makefile Fri Sep 30 14:27:27 2011 +0100 +1
-1@@ -119,7 +119,7 @@ libxlutil.a: $(LIBXLU_OBJS) $(AR) rcs libxlutil.a $^ xl: $(XL_OBJS) libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so libxenlight.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl) testidl: testidl.o libxlutil.so libxenlight.so $(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxenctrl)
LDLIBS_libxenlightalready has -lxenlight in it. I guess this changes works around you local addition LDFLAGS=-L/usr/xen42/lib?
Quoted 8 lines
Quoted 1 line
I'm not sure what the right answer is here.
Neither do I, I'm not an expert on build processes, but if I need to append CFLAGS and LDFLAGS to the build process to find my yajl library libxl should not try to use the libxenligh.so and libxenutil.so from the CFLAGS/LDFLAGS folder, because they are outdated. If not, the only option left is to clean my LDFLAGS and CFLAGS folders from previous Xen versions and compile the new version, but that's risky.
Hmm yes. Other options might be to move LDFLAGS to the end of the link line (or introduce LDLIBS at the end?) or perhaps add an explicit -L. somewhere. I'm really not sure though.
Whatever the solution is it applies to the other binary linked in this directory (testidl) as well.
Ian.
Re: [PATCH 01 of 23] libxl: remove hard tabs from non-generated *.[ch]
In reply to Ian CampbellIan Campbell writes ("[Xen-devel] [PATCH 01 of 23] libxl: remove hard tabs from non-generated *.[ch]"):
Quoted 1 line
libxl: remove hard tabs from non-generated *.[ch]
This didn't apply any more (obviously...)
Did you use some rune involving "expand" perhaps ? If you were to give me the rune as well as the effects, I could apply it to whatever the tree happened to look like.
Ian.
Re: [PATCH 10 of 23] libxl: separate forced and non-forced device remove
In reply to Ian CampbellIan Campbell writes ("[Xen-devel] [PATCH 10 of 23] libxl: separate forced and non-forced device remove"):
Quoted 1 line
libxl: separate forced and non-forced device remove.
...
Quoted 1 line
* the term "destroy" is normally used in libxl for data-type destructors.
I've always thought this was odd. Perhaps we should rename all of those "free" and then we could use "destroy" just for domain destruction and other kinds of violent activity.
Ian.
Ian Campbell writes ("[Xen-devel] [PATCH 00 of 23] libxl: rationalise libxl_device_* APIs"):
Quoted 3 lines
The following series overhauls the libxl_device_* APIs in an attempt to make them more consistent across the types of devices and move towards something we can support as a stable API longterm.
This all looks reasonably sensible although I by no means read every line of changed code.
Quoted 4 lines
One of the early patches adds a big comment describing the API. It would be useful if this got a particularly close eye with a view to supporting it long term -- especially from actual and potential consumers of the API (of who I've CC a few who sprang to mind).
The API comment looks good.
I'll give it a bit longer for people to have comments.
Thanks,
Ian.
Re: [PATCH 01 of 23] libxl: remove hard tabs from non-generated *.[ch]
In reply to Ian JacksonQuoted 8 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 01 of 23] libxl: remove hard tabs from non-generated *.[ch]"):
Quoted 1 line
libxl: remove hard tabs from non-generated *.[ch]
This didn't apply any more (obviously...)
Did you use some rune involving "expand" perhaps ? If you were to give me the rune as well as the effects, I could apply it to whatever the tree happened to look like.
I used search and replace +/- emacs reindent functionality.
You can either apply just whatever isn't rejected and I'll repost what gets left out (and iterate until none) or I can coordinate a time with you for me to regenerate and post while you aren't applying stuff.
Ian.
Re: [PATCH 10 of 23] libxl: separate forced and non-forced device remove
In reply to Ian JacksonQuoted 8 lines · Ian Jackson
Ian Campbell writes ("[Xen-devel] [PATCH 10 of 23] libxl: separate forced and non-forced device remove"):
Quoted 1 line
libxl: separate forced and non-forced device remove.
...
Quoted 1 line
* the term "destroy" is normally used in libxl for data-type destructors.
I've always thought this was odd. Perhaps we should rename all of those "free" and then we could use "destroy" just for domain destruction and other kinds of violent activity.
The original rationale for the name was that the libxl_TYPE_destroy functions only free the content of the datastructure but not the datastructure itself and that calling such a function free() would be potentially confusing.
On the other hand not being able to use "destroy" as a term for things related domain destruction is a pain too.
Thesaurus.com suggests various things for destroy and/or free which we could use for the type destructors. There's lots of fun sounding ones ("bollix up", "enfranchise") but "release" perhaps?
Ian.
Re: [PATCH 14 of 23] libxl: use libxl__device in libxl_devices_destroy and libxl__device_pci_remove_xenstore
In reply to Ian Campbell2011/9/30 Ian Campbell <[email protected]>:
Quoted 68 lines
# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317389248 -3600
# Node IDec28ee6dace513c3d009d498341f9537a19b2d98
# Parent e5a70a3b61a1acfa7d73db548a591486024d01b7
libxl: uselibxl__deviceinlibxl_devices_destroyandlibxl__device_pci_remove_xenstoreDoing this allows us to use the common functions for removing devices.
Signed-off-by Ian Campbell <[email protected]>diff -r
e5a70a3b61a1-rec28ee6dace5tools/libxl/libxl_device.ctools/libxl/libxl_device.c Fri Sep 30 14:27:28 2011 +0100 +24
-2@@ -49,6 +49,25 @@ char *libxl__device_backend_path(libxl__ device->domid, device->devid); } +int libxl__parse_backend_path(libxl__gc *gc, + const char *path, + libxl__device *dev) +{ + /* /local/domain/<domid>/backend/<kind>/<domid>/<devid> */ + char strkind[16]; /* Longest is actually "console" */ + uint32_t domain; + int rc = sscanf(path, "/local/domain/%d/backend/%15[^/]/%d/%d", + &dev->backend_domid, + strkind, + &domain, + &dev->backend_devid); + + if (rc != 4) + return ERROR_FAIL; + + return libxl__device_kind_from_string(strkind, &dev->backend_kind); +} + int libxl__device_generic_add(libxl__gc *gc, libxl__device *device, char **bents, char **fents) {@@ -348,10 +367,11 @@ int libxl__device_disk_dev_number(const return -1; } -int libxl__device_remove(libxl__gc *gc, char *be_path) +int libxl__device_remove(libxl__gc *gc, libxl__device *dev) { libxl_ctx *ctx = libxl__gc_owner(gc); xs_transaction_t t; + char *be_path = libxl__device_backend_path(gc, dev); char *state_path = libxl__sprintf(gc, "%s/state", be_path); char *state = libxl__xs_read(gc, XBT_NULL, state_path); int rc = 0;@@ -429,10 +449,12 @@ static int wait_for_dev_destroy(libxl__g int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force) { libxl_ctx *ctx = libxl__gc_owner(gc); - char *path, *be_path, *fe_path; + char *path; unsigned int num1, num2; char **l1 = NULL, **l2 = NULL; int i, j, n_watches = 0; + libxl__device dev; + libxl__device_kind kind; path = libxl__sprintf(gc, "/local/domain/%d/device", domid); l1 = libxl__xs_directory(gc, XBT_NULL, path, &num1);
tools/libxl/libxl_device.c Fri Sep 30 14:27:28 2011 +0100 int libxl__devices_destroy(libxl__gc *gc · line 473
Quoted 8 lines
tools/libxl/libxl_device.c Fri Sep 30 14:27:28 2011 +0100 +3
-1@@ -445,22 +467,27 @@ int libxl__devices_destroy(libxl__gc *gc num1 = 0; } for (i = 0; i < num1; i++) { - if (!strcmp("vfs", l1[i])) + if (libxl__device_kind_from_string(l1[i], &kind)) + continue; + if (kind == LIBXL__DEVICE_KIND_VBD) continue;
This should not be there, or hotplug scripts for VBD device types are not called. I know Linux doesn't need to call hotplug scripts for VBD, but NetBSD does. Should we add some kind of helper function or ifdef, or is it safe to remove this and handle VBD devices normally?
Quoted 109 lines
tools/libxl/libxl_device.c Fri Sep 30 14:27:28 2011 +0100 +21
-17path = libxl__sprintf(gc, "/local/domain/%d/device/%s", domid, l1[i]); l2 = libxl__xs_directory(gc, XBT_NULL, path, &num2); if (!l2) continue; for (j = 0; j < num2; j++) { - fe_path = libxl__sprintf(gc, "/local/domain/%d/device/%s/%s", domid, l1[i], l2[j]); - be_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/backend", fe_path)); - if (be_path != NULL) { + path = libxl__sprintf(gc, "/local/domain/%d/device/%s/%s/backend", + domid, l1[i], l2[j]); + path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, path)); + if (path && libxl__parse_backend_path(gc, path, &dev) == 0) { + dev.domid = domid; + dev.kind = kind; + dev.devid = atoi(l2[j]); + if (force) { - xs_rm(ctx->xsh, XBT_NULL, be_path); - xs_rm(ctx->xsh, XBT_NULL, fe_path); - libxl__device_destroy_tapdisk(gc, be_path); + libxl__device_force_remove(gc, &dev); } else { - if (libxl__device_remove(gc, be_path) > 0) + if (libxl__device_remove(gc, &dev) > 0) n_watches++; } }@@ -468,14 +495,18 @@ int libxl__devices_destroy(libxl__gc *gc } /* console 0 frontend directory is not under /local/domain/<domid>/device */ - fe_path = libxl__sprintf(gc, "/local/domain/%d/console", domid); - be_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/backend", fe_path)); - if (be_path && strcmp(be_path, "")) { + path = libxl__sprintf(gc, "/local/domain/%d/console/backend", domid); + path = libxl__xs_read(gc, XBT_NULL, path); + if (path && strcmp(path, "") && + libxl__parse_backend_path(gc, path, &dev) == 0) { + dev.domid = domid; + dev.kind = LIBXL__DEVICE_KIND_CONSOLE; + dev.devid = 0; + if (force) { - xs_rm(ctx->xsh, XBT_NULL, be_path); - xs_rm(ctx->xsh, XBT_NULL, fe_path); + libxl__device_force_remove(gc, &dev); } else { - if (libxl__device_remove(gc, be_path) > 0) + if (libxl__device_remove(gc, &dev) > 0) n_watches++; } }@@ -505,12 +536,9 @@ int libxl__device_del(libxl__gc *gc, lib { libxl_ctx *ctx = libxl__gc_owner(gc); struct timeval tv; - char *backend_path; int rc; - backend_path = libxl__device_backend_path(gc, dev); - - rc = libxl__device_remove(gc, backend_path); + rc = libxl__device_remove(gc, dev); if (rc == -1) { rc = ERROR_FAIL; goto out;diff -r
e5a70a3b61a1-rec28ee6dace5tools/libxl/libxl_internal.htools/libxl/libxl_internal.h Fri Sep 30 14:27:28 2011 +0100 +3
-1@@ -240,8 +240,10 @@ _hidden int libxl__device_generic_add(li char **bents, char **fents); _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device); _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device); +_hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path, + libxl__device *dev); _hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev); -_hidden int libxl__device_remove(libxl__gc *gc, char *be_path); +_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__device_force_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);diff -r
e5a70a3b61a1-rec28ee6dace5tools/libxl/libxl_pci.ctools/libxl/libxl_pci.c Fri Sep 30 14:27:28 2011 +0100 +9
-3@@ -410,9 +410,15 @@ retry_transaction2: goto retry_transaction2; if (num == 1) { - char *fe_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/frontend", be_path)); - xs_rm(ctx->xsh, XBT_NULL, be_path); - xs_rm(ctx->xsh, XBT_NULL, fe_path); + libxl__device dev; + if (libxl__parse_backend_path(gc, be_path, &dev) != 0) + return ERROR_FAIL; + + dev.domid = domid; + dev.kind = LIBXL__DEVICE_KIND_PCI; + dev.devid = 0; + + libxl__device_force_remove(gc, &dev); return 0; }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 14 of 23] libxl: use libxl__device in libxl_devices_destroy and libxl__device_pci_remove_xenstore
Quoted 16 lines · Roger Pau Monné
2011/9/30 Ian Campbell <[email protected]>:
tools/libxl/libxl_device.c int libxl__devices_destroy(libxl__gc *gc · line 473
Quoted 9 lines
tools/libxl/libxl_device.c +3
-1@@ -445,22 +467,27 @@ int libxl__devices_destroy(libxl__gc *gc num1 =0 ; }for (i =0 ; i < num1; i++) { -if (!strcmp ("vfs" , l1[i])) +if (libxl__device_kind_from_string (l1[i], &kind)) +continue ; +if (kind ==LIBXL__DEVICE_KIND_VBD )continue ;This should not be there, or hotplug scripts for VBD device types are not called. I know Linux doesn't need to call hotplug scripts for VBD, but NetBSD does. Should we add some kind of helper function or ifdef, or is it safe to remove this and handle VBD devices normally?
This is a bug -- I removed a check for "vfs" and replaced it with one for "vbd" which is not the same!
"vfs" was the fs-backend thing which was remove by 22716:3c78729b6f06 so I think the check can just be removed and I will do so in the next posting.
Ian
Quoted 110 lines
Quoted 110 lines
tools/libxl/libxl_device.c +21
-17path =libxl__sprintf (gc,"/local/domain/%d/device/%s" , domid, l1[i]); l2 =libxl__xs_directory (gc,XBT_NULL , path, &num2);if (!l2)continue ;for (j =0 ; j < num2; j++) { - fe_path =libxl__sprintf (gc,"/local/domain/%d/device/%s/%s" , domid, l1[i], l2[j]); - be_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/backend" , fe_path)); -if (be_path !=NULL ) { + path =libxl__sprintf (gc,"/local/domain/%d/device/%s/%s/backend" , + domid, l1[i], l2[j]); + path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc, path)); +if (path &&libxl__parse_backend_path (gc, path, &dev) ==0 ) { + dev.domid = domid; + dev.kind = kind; + dev.devid =atoi (l2[j]); +if (force) { -xs_rm (ctx->xsh,XBT_NULL , be_path); -xs_rm (ctx->xsh,XBT_NULL , fe_path); -libxl__device_destroy_tapdisk (gc, be_path); +libxl__device_force_remove (gc, &dev); }else { -if (libxl__device_remove (gc, be_path) >0 ) +if (libxl__device_remove (gc, &dev) >0 ) n_watches++; } }@@ -468,14 +495,18 @@ int libxl__devices_destroy(libxl__gc *gc }/* console 0 frontend directory is not under /local/domain/<domid>/device */ - fe_path =libxl__sprintf (gc,"/local/domain/%d/console" , domid); - be_path =libxl__xs_read (gc,XBT_NULL ,libxl__sprintf (gc,"%s/backend" , fe_path)); -if (be_path &&strcmp (be_path,"" )) { + path =libxl__sprintf (gc,"/local/domain/%d/console/backend" , domid); + path =libxl__xs_read (gc,XBT_NULL , path); +if (path &&strcmp (path,"" ) && +libxl__parse_backend_path (gc, path, &dev) ==0 ) { + dev.domid = domid; + dev.kind =LIBXL__DEVICE_KIND_CONSOLE ; + dev.devid =0 ; +if (force) { -xs_rm (ctx->xsh,XBT_NULL , be_path); -xs_rm (ctx->xsh,XBT_NULL , fe_path); +libxl__device_force_remove (gc, &dev); }else { -if (libxl__device_remove (gc, be_path) >0 ) +if (libxl__device_remove (gc, &dev) >0 ) n_watches++; } }@@ -505,12 +536,9 @@ int libxl__device_del(libxl__gc *gc, lib {libxl_ctx *ctx =libxl__gc_owner (gc);struct timeval tv; -char *backend_path;int rc; - backend_path =libxl__device_backend_path (gc, dev); - - rc =libxl__device_remove (gc, backend_path); + rc =libxl__device_remove (gc, dev);if (rc ==-1 ) { rc =ERROR_FAIL ; goto out;diff -r
e5a70a3b61a1-rec28ee6dace5tools/libxl/libxl_internal.htools/libxl/libxl_internal.h Fri Sep 30 14:27:28 2011 +0100 +3
-1@@ -240,8 +240,10 @@ _hidden int libxl__device_generic_add(li char **bents, char **fents); _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device); _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device); +_hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path, + libxl__device *dev); _hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev); -_hidden int libxl__device_remove(libxl__gc *gc, char *be_path); +_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__device_force_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);diff -r
e5a70a3b61a1-rec28ee6dace5tools/libxl/libxl_pci.ctools/libxl/libxl_pci.c Fri Sep 30 14:27:28 2011 +0100 +9
-3@@ -410,9 +410,15 @@ retry_transaction2: goto retry_transaction2; if (num == 1) { - char *fe_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/frontend", be_path)); - xs_rm(ctx->xsh, XBT_NULL, be_path); - xs_rm(ctx->xsh, XBT_NULL, fe_path); + libxl__device dev; + if (libxl__parse_backend_path(gc, be_path, &dev) != 0) + return ERROR_FAIL; + + dev.domid = domid; + dev.kind = LIBXL__DEVICE_KIND_PCI; + dev.devid = 0; + + libxl__device_force_remove(gc, &dev); return 0; }_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 14 of 23] libxl: use libxl__device in libxl_devices_destroy and libxl__device_pci_remove_xenstore
Quoted 18 lines · Ian Campbell
Quoted 16 lines · Roger Pau Monné
2011/9/30 Ian Campbell <[email protected]>:
Review int libxl__devices_destroy(libxl__gc *gc · line 473
Quoted 9 lines
(quoted diff) +3
-1@@ -445,22 +467,27 @@ int libxl__devices_destroy(libxl__gc *gc num1 = 0; } for (i = 0; i < num1; i++) { - if (!strcmp("vfs", l1[i])) + if (libxl__device_kind_from_string(l1[i], &kind)) + continue; + if (kind == LIBXL__DEVICE_KIND_VBD) continue;This should not be there, or hotplug scripts for VBD device types are not called. I know Linux doesn't need to call hotplug scripts for VBD, but NetBSD does. Should we add some kind of helper function or ifdef, or is it safe to remove this and handle VBD devices normally?
Quoted 6 lines
This is a bug -- I removed a check for "vfs" and replaced it with one for "vbd" which is not the same!
"vfs" was the fs-backend thing which was remove by 22716:3c78729b6f06 so I think the check can just be removed and I will do so in the next posting
incremental version:
tools/libxl/libxl_device.c +0 -2
@@ -469,8 +469,6 @@ int libxl__devices_destroy(libxl__gc *gcfor (i =0 ; i < num1; i++) {if (libxl__device_kind_from_string (l1[i], &kind))continue ; -if (kind ==LIBXL__DEVICE_KIND_VBD ) -continue ; path =libxl__sprintf (gc,"/local/domain/%d/device/%s" , domid, l1[i]); l2 =libxl__xs_directory (gc,XBT_NULL , path, &num2);if (!l2)
Re: [PATCH 10 of 23] libxl: separate forced and non-forced device remove
In reply to Ian CampbellIan Campbell writes ("Re: [Xen-devel] [PATCH 10 of 23] libxl: separate forced and non-forced device remove"):
Quoted 4 lines
The original rationale for the name was that the
libxl_TYPE_destroyfunctions only free the content of the datastructure but not the datastructure itself and that calling such a functionfree()would be potentially confusing.
Hmmm.
Quoted 2 lines
On the other hand not being able to use "destroy" as a term for things related domain destruction is a pain too.
Yes.
Quoted 3 lines
Thesaurus.com suggests various things for destroy and/or free which we could use for the type destructors. There's lots of fun sounding ones ("bollix up", "enfranchise") but "release" perhaps?
"dispose" ? "discard" ? "dealloc[ate]" ? "abandon" ?
"Release" sounds like it refers to some kind of lock or reservation.
Ian.
PATCH 1/1 libxl: fixup hard tabs and indentation
In reply to Ian JacksonThis is the whitespace cleanup bit of my "libxl: rationalise libxl_device_* APIs" series.
As requested I have used the expand utility to automatically fixup the majority of hard tabs and then fixed up the places which were actually just wrongly indented to start with by hand.
I added some emacs local-variable runes to stop this happening.
PATCH 1/1 libxl: expand hard tabs stops
# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317995956 -3600
# Node ID a440b0ad413b88ef7814f407b2fc3b412d586e9b # Parent 197e3be90f3245fb8f66281bf2759327bf051a9d
libxl: expand hard tabs stops
I ran the following and committed the result. ^I is an actual hard tab
for i in $(grep -l --exclude=*_[ly].\[ch\] '^I' tools/libxl/*.[ch]) ; do
cat $i | expand | sponge $i
done
There are some actually wrong indentations too, I'll fix thos up manually
tools/libxl/libxl.c +7 -7
@@ -696,13 +696,13 @@ int libxl_event_get_disk_eject_info(libxsscanf (backend, "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE) "[a-z]/%*d/%*d", &disk->backend_domid, backend_type); -if (!strcmp (backend_type,"tap" ) || !strcmp (backend_type,"vbd" )) { - disk->backend =LIBXL_DISK_BACKEND_TAP ; - }else if (!strcmp (backend_type,"qdisk" )) { - disk->backend =LIBXL_DISK_BACKEND_QDISK ; - }else { - disk->backend =LIBXL_DISK_BACKEND_UNKNOWN ; - } +if (!strcmp (backend_type,"tap" ) || !strcmp (backend_type,"vbd" )) { + disk->backend =LIBXL_DISK_BACKEND_TAP ; + }else if (!strcmp (backend_type,"qdisk" )) { + disk->backend =LIBXL_DISK_BACKEND_QDISK ; + }else { + disk->backend =LIBXL_DISK_BACKEND_UNKNOWN ; + } disk->pdev_path =strdup ("" ); disk->format =LIBXL_DISK_FORMAT_EMPTY ;
tools/libxl/libxl.h +1 -1
@@ -420,7 +420,7 @@ int libxl_cpuid_parse_config_xend(libxl_ const char* str);void libxl_cpuid_apply_policy (libxl_ctx *ctx,uint32_t domid);void libxl_cpuid_set (libxl_ctx *ctx,uint32_t domid, -libxl_cpuid_policy_list cpuid); +libxl_cpuid_policy_list cpuid);/* * Functions for allowing users of libxl to store private data
tools/libxl/libxl_bootloader.c +5 -5
@@ -81,14 +81,14 @@ static int open_xenconsoled_pty(int *mas ret =openpty (master, slave,NULL ,NULL ,NULL );if (ret <0 ) -return -1 ; +return -1 ; ret =ttyname_r (*slave, slave_path, slave_path_len);if (ret ==-1 ) { -close (*master); -close (*slave); - *master = *slave =-1 ; -return -1 ; +close (*master); +close (*slave); + *master = *slave =-1 ; +return -1 ; }/*
tools/libxl/libxl_cpuid.c +1 -1
@@ -317,7 +317,7 @@ void libxl_cpuid_apply_policy(libxl_ctx }void libxl_cpuid_set (libxl_ctx *ctx,uint32_t domid, -libxl_cpuid_policy_list cpuid) +libxl_cpuid_policy_list cpuid) {int i;char *cpuid_res[4 ];
tools/libxl/libxl_internal.c +32 -32
85 lines not on this page · raw message
tools/libxl/libxl_nocpuid.c +1 -1
@@ -32,6 +32,6 @@ void libxl_cpuid_apply_policy(libxl_ctx }void libxl_cpuid_set (libxl_ctx *ctx,uint32_t domid, -libxl_cpuid_policy_list cpuid) +libxl_cpuid_policy_list cpuid) { }
tools/libxl/libxl_pci.c +9 -9
@@ -1114,7 +1114,7 @@ static int e820_sanitize(libxl_ctx *ctx,if ((src[i].type ==E820_RAM ) || (src[i].type ==E820_UNUSABLE ) || (src[i].type ==0 )) -continue ; +continue ; start = src[i].addr < start ? src[i].addr : start; last = src[i].addr + src[i].size > last ?
@@ -1159,14 +1159,14 @@ static int e820_sanitize(libxl_ctx *ctx,* to E820_UNUSED. We also need to move some of the E820_RAM regions if * the overlap with ram_end. */ for (i =0 ; i < nr; i++) { -uint64_t end = src[i].addr + src[i].size; +uint64_t end = src[i].addr + src[i].size; -/* We don't care about E820_UNUSABLE, but we need to +/* We don't care about E820_UNUSABLE, but we need to * change the type to zero b/c the loop after this * sticks E820_UNUSABLE on the guest's E820 but ignores * the ones with type zero. */ if ((src[i].type ==E820_UNUSABLE ) || -/* Any region that is within the "RAM region" can +/* Any region that is within the "RAM region" can * be safely ditched. */ (end < ram_end)) { src[i].type =0 ;
@@ -1174,15 +1174,15 @@ static int e820_sanitize(libxl_ctx *ctx, }/* Look only at RAM regions. */ -if (src[i].type !=E820_RAM ) +if (src[i].type !=E820_RAM )continue ;/* We only care about RAM regions below 4GB. */ if (src[i].addr >= (1ULL <<32 ))continue ; -/* E820_RAM overlaps with our RAM region. Move it */ -if (src[i].addr < ram_end) { +/* E820_RAM overlaps with our RAM region. Move it */ +if (src[i].addr < ram_end) {uint64_t delta; src[i].type =E820_UNUSABLE ;
@@ -1236,8 +1236,8 @@ static int e820_sanitize(libxl_ctx *ctx,/* Almost done: copy them over, ignoring the undesireable ones */ for (i =0 ; i < nr; i++) {if ((src[i].type ==E820_RAM ) || - (src[i].type ==0 )) -continue ; + (src[i].type ==0 )) +continue ; e820[idx].type = src[i].type; e820[idx].addr = src[i].addr;
tools/libxl/libxl_utils.c +2 -2
@@ -457,7 +457,7 @@ int libxl_mac_to_device_nic(libxl_ctx *c rc =libxl__parse_mac (mac, mac_n);if (rc) -return rc; +return rc; nics =libxl_list_nics (ctx, domid, &nb);if (!nics)
@@ -509,7 +509,7 @@ int libxl_devid_to_device_nic(libxl_ctx val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/mac" , nic_path_fe)); rc =libxl__parse_mac (val, nic->mac);if (rc) - goto out; + goto out; nic->script =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"%s/script" , nic_path_be),NULL ); rc =0 ;
tools/libxl/libxlutil.h +1 -1
@@ -64,7 +64,7 @@ const char *xlu_cfg_get_listitem(const X*/ int xlu_disk_parse (XLU_Config *cfg,int nspecs,const char *const *specs, -libxl_device_disk *disk); +libxl_device_disk *disk);/* disk must have been initialised. * * On error, returns errno value. Bad strings cause EINVAL and
tools/libxl/xl_cmdimpl.c +4 -4
@@ -557,15 +557,15 @@ static void parse_disk_config_multistrinmemset (disk,0 ,sizeof (*disk));if (!*config) { - *config =xlu_cfg_init (stderr,"command line" ); -if (!*config) {perror ("xlu_cfg_init" );exit (-1 ); } + *config =xlu_cfg_init (stderr,"command line" ); +if (!*config) {perror ("xlu_cfg_init" );exit (-1 ); } } e =xlu_disk_parse (*config, nspecs, specs, disk);if (e ==EINVAL )exit (-1 );if (e) { -fprintf (stderr,"xlu_disk_parse failed: %s\n" ,strerror (errno)); -exit (-1 ); +fprintf (stderr,"xlu_disk_parse failed: %s\n" ,strerror (errno)); +exit (-1 ); } }
PATCH 1/1 libxl: fixup incorrect indentation
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1317996269 -3600
# Node ID ea75a1765a4a8da26089f42c68a1a1f15182a11f # Parent a440b0ad413b88ef7814f407b2fc3b412d586e9b
libxl: fixup incorrect indentation
Several places which were previsously indented using hard tabs are now incorrectly indented. Fix them up.
tools/libxl/libxl.c +7 -7
@@ -696,13 +696,13 @@ int libxl_event_get_disk_eject_info(libxsscanf (backend, "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE) "[a-z]/%*d/%*d", &disk->backend_domid, backend_type); -if (!strcmp (backend_type,"tap" ) || !strcmp (backend_type,"vbd" )) { - disk->backend =LIBXL_DISK_BACKEND_TAP ; - }else if (!strcmp (backend_type,"qdisk" )) { - disk->backend =LIBXL_DISK_BACKEND_QDISK ; - }else { - disk->backend =LIBXL_DISK_BACKEND_UNKNOWN ; - } +if (!strcmp (backend_type,"tap" ) || !strcmp (backend_type,"vbd" )) { + disk->backend =LIBXL_DISK_BACKEND_TAP ; + }else if (!strcmp (backend_type,"qdisk" )) { + disk->backend =LIBXL_DISK_BACKEND_QDISK ; + }else { + disk->backend =LIBXL_DISK_BACKEND_UNKNOWN ; + } disk->pdev_path =strdup ("" ); disk->format =LIBXL_DISK_FORMAT_EMPTY ;
tools/libxl/libxl_bootloader.c +5 -5
@@ -81,14 +81,14 @@ static int open_xenconsoled_pty(int *mas ret =openpty (master, slave,NULL ,NULL ,NULL );if (ret <0 ) -return -1 ; +return -1 ; ret =ttyname_r (*slave, slave_path, slave_path_len);if (ret ==-1 ) { -close (*master); -close (*slave); - *master = *slave =-1 ; -return -1 ; +close (*master); +close (*slave); + *master = *slave =-1 ; +return -1 ; }/*
tools/libxl/libxl_internal.c +32 -32
85 lines not on this page · raw message
tools/libxl/libxl_pci.c +1 -1
@@ -1114,7 +1114,7 @@ static int e820_sanitize(libxl_ctx *ctx,if ((src[i].type ==E820_RAM ) || (src[i].type ==E820_UNUSABLE ) || (src[i].type ==0 )) -continue ; +continue ; start = src[i].addr < start ? src[i].addr : start; last = src[i].addr + src[i].size > last ?
tools/libxl/libxl_utils.c +2 -2
@@ -457,7 +457,7 @@ int libxl_mac_to_device_nic(libxl_ctx *c rc =libxl__parse_mac (mac, mac_n);if (rc) -return rc; +return rc; nics =libxl_list_nics (ctx, domid, &nb);if (!nics)
@@ -509,7 +509,7 @@ int libxl_devid_to_device_nic(libxl_ctx val =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/mac" , nic_path_fe)); rc =libxl__parse_mac (val, nic->mac);if (rc) - goto out; + goto out; nic->script =xs_read (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"%s/script" , nic_path_be),NULL ); rc =0 ;
PATCH 1/1 libxl: add emacs local variables block to turn on four space indentation
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1317996290 -3600
# Node ID 0925bc3120d1f6474f235eea2ba9539009c47bd5
# Parent ea75a1765a4a8da26089f42c68a1a1f15182a11f
libxl: add emacs local variables block to turn on four space indentation
tools/libxl/flexarray.c +8 -0
@@ -107,3 +107,11 @@ void **flexarray_contents(flexarray_t *afree (array);return data; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/flexarray.h +8 -0
@@ -35,3 +35,11 @@ _hidden int flexarray_get(flexarray_t *a _hidden void **flexarray_contents(flexarray_t *array);#endif + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl.c +8 -0
@@ -3044,3 +3044,11 @@ int libxl_cpupool_movedomain(libxl_ctx *libxl__free_all (&gc);return 0 ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl.h +7 -0
@@ -541,3 +541,10 @@ const char *libxl_run_dir_path(void);#endif /* LIBXL_H */ +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_blktap2.c +8 -0
@@ -77,3 +77,11 @@ void libxl__device_destroy_tapdisk(libxltap_ctl_destroy (tap.id, tap.minor); } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_bootloader.c +7 -0
@@ -450,3 +450,10 @@ out:return rc; } +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_cpuid.c +8 -0
@@ -326,3 +326,11 @@ void libxl_cpuid_set(libxl_ctx *ctx, uinxc_cpuid_set (ctx->xch, domid, cpuid[i].input, (const char **)(cpuid[i].policy), cpuid_res); } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_create.c +8 -0
@@ -643,3 +643,11 @@ int libxl_domain_create_restore(libxl_ctlibxl__free_all (&gc);return rc; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_device.c +7 -0
@@ -654,3 +654,10 @@ out:return rc; } +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_dm.c +8 -0
@@ -1047,3 +1047,11 @@ int libxl__create_xenpv_qemu(libxl__gc *libxl__create_device_model (gc, info,NULL ,0 ,NULL ,0 , starting_r);return 0 ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_dom.c +8 -0
@@ -813,3 +813,11 @@ out:libxl__free_all (&gc);return rc; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_exec.c +8 -0
@@ -308,3 +308,11 @@ int libxl__spawn_check(libxl__gc *gc, vo for_spawn->intermediate =0 ;return ERROR_FAIL ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_flask.c +8 -0
@@ -69,3 +69,11 @@ int libxl_flask_loadpolicy(libxl_ctx *ctreturn rc; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_internal.c +8 -0
@@ -318,3 +318,11 @@ int libxl__fd_set_cloexec(int fd) }return fcntl (fd,F_SETFD , flags |FD_CLOEXEC ); } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_internal.h +8 -0
@@ -555,3 +555,11 @@ _hidden void libxl__json_object_free(lib _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc, const char *s);#endif + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_json.c +8 -0
@@ -834,3 +834,11 @@ out:return ret; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_json.h +8 -0
@@ -21,3 +21,11 @@#include <_libxl_types_internal_json.h> #endif /* LIBXL_JSON_H */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_noblktap2.c +8 -0
@@ -31,3 +31,11 @@ char *libxl__blktap_devpath(libxl__gc *gvoid libxl__device_destroy_tapdisk (libxl__gc *gc,char *be_path) { } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_nocpuid.c +8 -0
@@ -35,3 +35,11 @@ void libxl_cpuid_set(libxl_ctx *ctx, uin libxl_cpuid_policy_list cpuid) { } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_osdeps.h +8 -0
@@ -39,3 +39,11 @@ int vasprintf(char **buffer, const char#endif /*NEED_OWN_ASPRINTF*/ #endif + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_paths.c +8 -0
@@ -69,3 +69,11 @@ const char *libxl_run_dir_path(void) {return XEN_RUN_DIR ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_pci.c +8 -0
@@ -1305,3 +1305,11 @@ int libxl__e820_alloc(libxl__gc *gc, uin }return 0 ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_qmp.c +8 -0
@@ -594,3 +594,11 @@ int libxl__qmp_initializations(libxl_ctxlibxl__qmp_close (qmp);return ret; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_utils.c +8 -0
@@ -647,3 +647,11 @@ int libxl__enum_from_string(const libxl_ }return ERROR_FAIL ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_utils.h +7 -0
@@ -80,3 +80,10 @@ static inline uint32_t libxl__sizekb_to_#endif +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_uuid.c +8 -0
@@ -103,3 +103,11 @@ uint8_t *libxl_uuid_bytearray(libxl_uuid#error "Please update libxl_uuid.c for your OS"#endif + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_uuid.h +8 -0
@@ -62,3 +62,11 @@ int libxl_uuid_compare(libxl_uuid *uuid1uint8_t *libxl_uuid_bytearray (libxl_uuid *uuid);#endif /* __LIBXL_UUID_H__ */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxl_xshelp.c +8 -0
@@ -121,3 +121,11 @@ char **libxl__xs_directory(libxl__gc *gclibxl__ptr_add (gc, ret);return ret; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_cfg.c +8 -0
@@ -433,3 +433,11 @@ void xlu__cfg_yyerror(YYLTYPE *loc, CfgP msg);if (!ctx->err) ctx->err=EINVAL ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_cfg_i.h +8 -0
@@ -42,3 +42,11 @@ int xlu__cfg_yyparse(CfgParseContext *ct#endif /*LIBXLU_CFG_I_H*/ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_cfg_l.c +8 -0
@@ -2122,3 +2122,11 @@ void xlu__cfg_yyfree (void * ptr , yysca#define YYTABLES_NAME "yytables"#line 104 "libxlu_cfg_l.l" + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_cfg_l.h +8 -0
@@ -355,3 +355,11 @@ extern int xlu__cfg_yylex \#line 356 "libxlu_cfg_l.h"#undef xlu__cfg_yyIN_HEADER#endif /* xlu__cfg_yyHEADER_H */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_cfg_y.c +8 -0
@@ -1689,3 +1689,11 @@ yyreturn: + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_cfg_y.h +8 -0
@@ -85,3 +85,11 @@ typedef struct YYLTYPE#endif + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_disk.c +7 -0
@@ -91,3 +91,10 @@ int xlu_disk_parse(XLU_Config *cfg,return dpc.err; } +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_disk_i.h +8 -0
@@ -19,3 +19,11 @@ void xlu__disk_err(DiskParseContext *dpc#endif /*LIBXLU_DISK_I_H*/ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_disk_l.c +8 -0
@@ -2515,3 +2515,11 @@ void xlu__disk_yyfree (void * ptr , yysc#define YYTABLES_NAME "yytables"#line 227 "libxlu_disk_l.l" + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_disk_l.h +8 -0
@@ -345,3 +345,11 @@ extern int xlu__disk_yylex (yyscan_t yys#line 346 "libxlu_disk_l.h"#undef xlu__disk_yyIN_HEADER#endif /* xlu__disk_yyHEADER_H */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlu_internal.h +8 -0
@@ -50,3 +50,11 @@ typedef struct {#define TOSTRING (x) STRINGIFY(x)#endif /*LIBXLU_INTERNAL_H*/ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/libxlutil.h +8 -0
@@ -82,3 +82,11 @@ int xlu_disk_parse(XLU_Config *cfg, int#endif /* LIBXLUTIL_H */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/osdeps.c +8 -0
@@ -66,3 +66,11 @@ int asprintf(char **buffer, char *fmt, . }#endif + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/xl.c +8 -0
@@ -162,3 +162,11 @@ int main(int argc, char **argv)xtl_logger_destroy ((xentoollog_logger *)logger);return ret; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/xl.h +8 -0
@@ -109,3 +109,11 @@ extern char *lockfile;extern char *default_vifscript;#endif /* XL_H */ + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/xl_cmdimpl.c +8 -0
@@ -5413,3 +5413,11 @@ done:return ret; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxl/xl_cmdtable.c +8 -0
@@ -407,3 +407,11 @@ struct cmd_spec *cmdtable_lookup(const c }return (count ==1 ) ? cmd :NULL ; } + +/* +* Local variables: +* mode: C +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Re: [PATCH 3 of 3] libxl: add emacs local variables block to turn on four space indentation
Ian Campbell writes ("[Xen-devel] [PATCH 3 of 3] libxl: add emacs local variables block to turn on four space indentation"):
Quoted 1 line
libxl: add emacs local variables block to turn on four space indentation
FYI Emacs 23 has a new ".dir-locals.el" feature, but I think we should wait a while before starting to use it.
The rest of this series looks OK to me. I'll see if I can apply the other things in the libxl queue first though.
Ian.
Re: RE: [PATCH 02 of 23] libxl: add a comment describing the device interfaces
In reply to Ian CampbellHello,
I've applied this patches to my tree and modified my NetBSD hotplug and phy backend patches to conform to the new API. From what I can see the patches work ok, except for the small bugs that I've commented on some individual patches.
Should I wait for this patches to be committed to the Xen repository before sending my own, or is it fine to post them for review now?
Regards, Roger.
Ian Jackson
AppliedRe: [PATCH 2 of 3] libxl: fixup incorrect indentation
In reply to Ian CampbellIan Campbell writes ("[Xen-devel] [PATCH 2 of 3] libxl: fixup incorrect indentation"):
Quoted 1 line
libxl: fixup incorrect indentation
Applied all 3. 3/3 contained a change to libxl_json.h which seems to have gone missing, but it builds fine without.
Ian.
Re: RE: [PATCH 02 of 23] libxl: add a comment describing the device interfaces
In reply to Roger Pau MonnéQuoted 9 lines · Roger Pau Monné
Hello,
I've applied this patches to my tree and modified my NetBSD hotplug and phy backend patches to conform to the new API. From what I can see the patches work ok, except for the small bugs that I've commented on some individual patches.
Should I wait for this patches to be committed to the Xen repository before sending my own, or is it fine to post them for review now?
I would post them for review. I do have a second revision which I'm about to post, which is mainly a change to the IDL type destructors to "dispose" instead of "destroy" and "s/force_remove/destroy/" but that needn't stop us reviewing your changes.
Ian.