Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 0 of 6 ACKED v5] libxl: add support for hotplug script calling from libxl
Previously acked patches from the series.
Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 1 of 6 ACKED v5] libxl: add support for image files for NetBSD
# HG changeset patch # User Roger Pau Monne <roger.pau@entel.upc.edu> # Date 1317386335 -7200 # Node ID c8de7762b28386a8867b305660673c11eb5cf512 # Parent 8e129474fc0ac87623ba814ea865326d45cb8436 libxl: add support for image files for NetBSD Created a helper function to detect if the OS is capable of using image files as phy backends. Create two OS specific files, and changed the Makefile to choose the correct one at compile time. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 8e129474fc0a -r c8de7762b283 tools/libxl/Makefile --- a/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200 @@ -33,6 +33,15 @@ endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o +ifeq ($(CONFIG_NetBSD),y) +LIBXL_OBJS-y += libxl_netbsd.o +else ifeq ($(CONFIG_Linux),y) +LIBXL_OBJS-y += libxl_linux.o +else +$(error Your Operating System is not supported by libxenlight, \ +please check libxl_linux.c and libxl_netbsd.c to see how to get it ported) +endif + LIBXL_LIBS += -lyajl LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ diff -r 8e129474fc0a -r c8de7762b283 tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200 @@ -137,15 +137,14 @@ static int disk_try_backend(disk_try_bac a->disk->format == LIBXL_DISK_FORMAT_EMPTY)) { goto bad_format; } - if (a->disk->format != LIBXL_DISK_FORMAT_EMPTY && - !S_ISBLK(a->stab.st_mode)) { - LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy" - " unsuitable as phys path not a block device", - a->disk->vdev); - return 0; - } - return backend; + if (libxl__try_phy_backend(a->stab.st_mode)) + return backend; + + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy" + " unsuitable as phys path not a block device", + a->disk->vdev); + return 0; case LIBXL_DISK_BACKEND_TAP: if (!libxl__blktap_enabled(a->gc)) { diff -r 8e129474fc0a -r c8de7762b283 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200 @@ -271,6 +271,15 @@ _hidden int libxl__device_destroy(libxl_ _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); +/* + * libxl__try_phy_backend - Check if there''s support for the passed + * type of file using the PHY backend + * st_mode: mode_t of the file, as returned by stat function + * + * Returns 0 on success, and < 0 on error. + */ +_hidden int libxl__try_phy_backend(mode_t st_mode); + /* from libxl_pci */ _hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting); diff -r 8e129474fc0a -r c8de7762b283 tools/libxl/libxl_linux.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxl/libxl_linux.c Fri Sep 30 14:38:55 2011 +0200 @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2011 + * Author Roger Pau Monne <roger.pau@entel.upc.edu> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include <sys/stat.h> + +#include "libxl_internal.h" + +int libxl__try_phy_backend(mode_t st_mode) +{ + if (!S_ISBLK(st_mode)) { + return 0; + } + + return 1; +} diff -r 8e129474fc0a -r c8de7762b283 tools/libxl/libxl_netbsd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxl/libxl_netbsd.c Fri Sep 30 14:38:55 2011 +0200 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2011 + * Author Roger Pau Monne <roger.pau@entel.upc.edu> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include <sys/stat.h> + +#include "libxl_internal.h" + +int libxl__try_phy_backend(mode_t st_mode) +{ + if (S_ISREG(st_mode) || S_ISBLK(st_mode)) + return 1; + + return 0; +}
Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 2 of 6 ACKED v5] libxl: introduce libxl__wait_for_device_state
# HG changeset patch # User Roger Pau Monne <roger.pau@entel.upc.edu> # Date 1323971745 -3600 # Node ID 492fa4832e68f6493e5f61b72e598c164572eb41 # Parent e428efb092ffdaab1eeee5c304fd5f3b824ad958 libxl: introduce libxl__wait_for_device_state This is a generic function, that waits for xs watches to reach a certain state and then executes the passed helper function. Removed wait_for_dev_destroy and used this new function instead. This function will also be used by future patches that need to wait for the initialization of devices before executing hotplug scripts. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r e428efb092ff -r 492fa4832e68 tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Thu Dec 15 18:55:45 2011 +0100 +++ b/tools/libxl/libxl_device.c Thu Dec 15 18:55:45 2011 +0100 @@ -369,7 +369,9 @@ int libxl__device_disk_dev_number(const * Returns 0 if a device is removed, ERROR_* if an error * or timeout occurred. */ -static int wait_for_dev_destroy(libxl__gc *gc, struct timeval *tv) +int libxl__wait_for_device_state(libxl__gc *gc, struct timeval *tv, + XenbusState state, + libxl__device_state_handler handler) { libxl_ctx *ctx = libxl__gc_owner(gc); int nfds, rc; @@ -394,17 +396,14 @@ start: default: l1 = xs_read_watch(ctx->xsh, &n); if (l1 != NULL) { - char *state = libxl__xs_read(gc, XBT_NULL, + char *sstate = libxl__xs_read(gc, XBT_NULL, l1[XS_WATCH_PATH]); - if (!state || atoi(state) == 6) { - xs_unwatch(ctx->xsh, l1[0], l1[1]); - xs_rm(ctx->xsh, XBT_NULL, l1[XS_WATCH_TOKEN]); - LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, - "Destroyed device backend at %s", - l1[XS_WATCH_TOKEN]); - rc = 0; + if (!sstate || atoi(sstate) == state) { + /* Call handler function if present */ + if (handler) + rc = handler(gc, l1, sstate); } else { - /* State is not "disconnected", continue waiting... */ + /* State is different than expected, continue waiting... */ goto start; } free(l1); @@ -417,6 +416,23 @@ start: } /* + * Handler function for device destruction to be passed to + * libxl__wait_for_device_state + */ +static int destroy_device(libxl__gc *gc, char **l1, char *state) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + + xs_unwatch(ctx->xsh, l1[0], l1[1]); + xs_rm(ctx->xsh, XBT_NULL, l1[XS_WATCH_TOKEN]); + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, + "Destroyed device backend at %s", + l1[XS_WATCH_TOKEN]); + + return 0; +} + +/* * Returns 0 (device already destroyed) or 1 (caller must * wait_for_dev_destroy) on success, ERROR_* on fail. */ @@ -457,7 +473,8 @@ retry_transaction: struct timeval tv; tv.tv_sec = LIBXL_DESTROY_TIMEOUT; tv.tv_usec = 0; - rc = wait_for_dev_destroy(gc, &tv); + rc = libxl__wait_for_device_state(gc, &tv, XenbusStateClosed, + destroy_device); if (rc < 0) /* an error or timeout occurred, clear watches */ xs_unwatch(ctx->xsh, state_path, be_path); xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(gc, dev)); @@ -565,7 +582,8 @@ int libxl__devices_destroy(libxl__gc *gc tv.tv_sec = LIBXL_DESTROY_TIMEOUT; tv.tv_usec = 0; while (n_watches > 0) { - if (wait_for_dev_destroy(gc, &tv) < 0) { + if (libxl__wait_for_device_state(gc, &tv, XenbusStateClosed, + destroy_device) < 0) { /* function returned ERROR_* */ break; } else { diff -r e428efb092ff -r 492fa4832e68 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Thu Dec 15 18:55:45 2011 +0100 +++ b/tools/libxl/libxl_internal.h Thu Dec 15 18:55:45 2011 +0100 @@ -24,11 +24,14 @@ #include <stdlib.h> #include <string.h> #include <pthread.h> +#include <sys/time.h> #include <xs.h> #include <xenctrl.h> #include "xentoollog.h" +#include <xen/io/xenbus.h> + #include "libxl.h" #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) @@ -271,6 +274,31 @@ _hidden int libxl__device_destroy(libxl_ _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); +/* Handler for the libxl__wait_for_device_state callback */ +/* + * libxl__device_state_handler - Handler for the libxl__wait_for_device_state + * gc: allocation pool + * l1: array containing the path and token + * state: string that contains the state of the device + * + * Returns 0 on success, and < 0 on error. + */ +typedef int libxl__device_state_handler(libxl__gc *gc, char **l1, char *state); + +/* + * libxl__wait_for_device_state - waits a given time for a device to + * reach a given state + * gc: allocation pool + * tv: timeval struct containing the maximum time to wait + * state: state to wait for (check xen/io/xenbus.h) + * handler: callback function to execute when state is reached + * + * Returns 0 on success, and < 0 on error. + */ +_hidden int libxl__wait_for_device_state(libxl__gc *gc, struct timeval *tv, + XenbusState state, + libxl__device_state_handler handler); + /* * libxl__try_phy_backend - Check if there''s support for the passed * type of file using the PHY backend
Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 3 of 6 ACKED v5] hotplug: remove debug messages from NetBSD hotplug scripts
# HG changeset patch # User Roger Pau Monne <roger.pau@entel.upc.edu> # Date 1323971746 -3600 # Node ID 75e1660cd4c350105e45f15b2ecbcdd564f2a290 # Parent f56b12b7e8d6979844639a88bb1c5118e498e096 hotplug: remove debug messages from NetBSD hotplug scripts Remove unecessary debug messages from NetBSD hotplug scripts, left error messages only. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r f56b12b7e8d6 -r 75e1660cd4c3 tools/hotplug/NetBSD/block --- a/tools/hotplug/NetBSD/block Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/hotplug/NetBSD/block Thu Dec 15 18:55:46 2011 +0100 @@ -69,14 +69,12 @@ 1) if [ "$status" = "free" ] && \ vnconfig /dev/${disk}d $xparams >/dev/null; then device=/dev/${disk}d - echo vnconfig /dev/${disk}d $xparams break fi done if [ x$device = x ] ; then error "no available vnd device" fi - echo xenstore-write $xpath/vnd $device xenstore-write $xpath/vnd $device ;; phy) @@ -84,9 +82,7 @@ 1) ;; esac physical_device=$(stat -f ''%r'' "$device") - echo xenstore-write $xpath/physical-device $physical_device xenstore-write $xpath/physical-device $physical_device - echo xenstore-write $xpath/hotplug-status connected xenstore-write $xpath/hotplug-status connected exit 0 ;; diff -r f56b12b7e8d6 -r 75e1660cd4c3 tools/hotplug/NetBSD/vif-bridge --- a/tools/hotplug/NetBSD/vif-bridge Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/hotplug/NetBSD/vif-bridge Thu Dec 15 18:55:46 2011 +0100 @@ -24,12 +24,9 @@ 1) xfid=$(xenstore-read "$xpath/frontend-id") xhandle=$(xenstore-read "$xpath/handle") iface=$(xenstore-read "$xpath/vifname") - echo ifconfig $iface up ifconfig $iface up brconfig $xbridge add $iface - echo brconfig $xbridge add $iface xenstore-write $xpath/hotplug-status connected - echo xenstore-write $xpath/hotplug-status connected exit 0 ;; *) diff -r f56b12b7e8d6 -r 75e1660cd4c3 tools/hotplug/NetBSD/vif-ip --- a/tools/hotplug/NetBSD/vif-ip Fri Sep 30 14:38:55 2011 +0200 +++ b/tools/hotplug/NetBSD/vif-ip Thu Dec 15 18:55:46 2011 +0100 @@ -24,10 +24,8 @@ 1) xfid=$(xenstore-read "$xpath/frontend-id") xhandle=$(xenstore-read "$xpath/handle") iface=$(xenstore-read "$xpath/vifname") - echo ifconfig $iface $xip up ifconfig $iface $xip up xenstore-write $xpath/hotplug-status connected - echo xenstore-write $xpath/hotplug-status connected exit 0 ;; *)
Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 4 of 6 ACKED v5] libxl: fix incorrect log message in libxl_domain_destroy
# HG changeset patch # User Roger Pau Monne <roger.pau@entel.upc.edu> # Date 1323971746 -3600 # Node ID f2274ad5e46301dcc4f3f24a06b1c5e394c61f55 # Parent 27003c971acf4064b60de68de9e4caec588b5b7d libxl: fix incorrect log message in libxl_domain_destroy Fix a log message that was referring to libxl_devices_dispose instead of libxl__devices_destroy. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 27003c971acf -r f2274ad5e463 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl.c Thu Dec 15 18:55:46 2011 +0100 @@ -773,7 +773,8 @@ int libxl_domain_destroy(libxl_ctx *ctx, libxl__qmp_cleanup(gc, domid); } if (libxl__devices_destroy(gc, domid, force) < 0) - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "libxl_devices_dispose failed for %d", domid); + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "libxl__devices_destroy failed for %d", domid); vm_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/vm", dom_path)); if (vm_path)
Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 5 of 6 ACKED v5] libxl: remove force parameter from libxl_domain_destroy
# HG changeset patch # User Roger Pau Monne <roger.pau@entel.upc.edu> # Date 1323971746 -3600 # Node ID 1ab9421bf75c620fabb8d02c921a877a323c1a03 # Parent e25ad5cc0963ca0a6d2b8efe2772afa77b4835c4 libxl: remove force parameter from libxl_domain_destroy Since a destroy is considered a forced shutdown, there''s no point in passing a force parameter. All the occurences of this function have been replaced with the proper syntax. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r e25ad5cc0963 -r 1ab9421bf75c tools/libxl/libxl.c --- a/tools/libxl/libxl.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl.c Thu Dec 15 18:55:46 2011 +0100 @@ -723,7 +723,7 @@ int libxl_event_get_disk_eject_info(libx return 1; } -int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force) +int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid) { GC_INIT(ctx); libxl_dominfo dominfo; @@ -772,7 +772,7 @@ int libxl_domain_destroy(libxl_ctx *ctx, libxl__qmp_cleanup(gc, domid); } - if (libxl__devices_destroy(gc, domid, force) < 0) + if (libxl__devices_destroy(gc, domid, 1) < 0) LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "libxl__devices_destroy failed for %d", domid); diff -r e25ad5cc0963 -r 1ab9421bf75c tools/libxl/libxl.h --- a/tools/libxl/libxl.h Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl.h Thu Dec 15 18:55:46 2011 +0100 @@ -269,7 +269,7 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd); int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid); int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid, int req); -int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force); +int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid); int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid); /* get max. number of cpus supported by hypervisor */ diff -r e25ad5cc0963 -r 1ab9421bf75c tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl_create.c Thu Dec 15 18:55:46 2011 +0100 @@ -662,7 +662,7 @@ static int do_domain_create(libxl__gc *g error_out: if (domid) - libxl_domain_destroy(ctx, domid, 0); + libxl_domain_destroy(ctx, domid); return ret; } diff -r e25ad5cc0963 -r 1ab9421bf75c tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl_dm.c Thu Dec 15 18:55:46 2011 +0100 @@ -917,7 +917,7 @@ int libxl__destroy_device_model(libxl__g goto out; } LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device model is a stubdom, domid=%d", stubdomid); - ret = libxl_domain_destroy(ctx, stubdomid, 0); + ret = libxl_domain_destroy(ctx, stubdomid); if (ret) goto out; } else { diff -r e25ad5cc0963 -r 1ab9421bf75c tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Thu Dec 15 18:55:46 2011 +0100 @@ -1283,7 +1283,7 @@ static int handle_domain_death(libxl_ctx /* fall-through */ case LIBXL_ACTION_ON_SHUTDOWN_DESTROY: LOG("Domain %d needs to be cleaned up: destroying the domain", domid); - libxl_domain_destroy(ctx, domid, 0); + libxl_domain_destroy(ctx, domid); break; case LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY: @@ -1786,7 +1786,7 @@ start: error_out: release_lock(); if (libxl_domid_valid_guest(domid)) - libxl_domain_destroy(ctx, domid, 0); + libxl_domain_destroy(ctx, domid); out: if (logfile != 2) @@ -2256,7 +2256,7 @@ static void destroy_domain(const char *p fprintf(stderr, "Cannot destroy privileged domain 0.\n\n"); exit(-1); } - rc = libxl_domain_destroy(ctx, domid, 0); + rc = libxl_domain_destroy(ctx, domid); if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); } } @@ -2502,7 +2502,7 @@ static int save_domain(const char *p, co if (checkpoint) libxl_domain_unpause(ctx, domid); else - libxl_domain_destroy(ctx, domid, 0); + libxl_domain_destroy(ctx, domid); exit(0); } @@ -2735,7 +2735,7 @@ static void migrate_domain(const char *d } fprintf(stderr, "migration sender: Target reports successful startup.\n"); - libxl_domain_destroy(ctx, domid, 1); /* bang! */ + libxl_domain_destroy(ctx, domid); /* bang! */ fprintf(stderr, "Migration successful.\n"); exit(0); @@ -2852,7 +2852,7 @@ static void migrate_receive(int debug, i if (rc) { fprintf(stderr, "migration target: Failure, destroying our copy.\n"); - rc2 = libxl_domain_destroy(ctx, domid, 1); + rc2 = libxl_domain_destroy(ctx, domid); if (rc2) { fprintf(stderr, "migration target: Failed to destroy our copy" " (code %d).\n", rc2); diff -r e25ad5cc0963 -r 1ab9421bf75c tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/python/xen/lowlevel/xl/xl.c Thu Dec 15 18:55:46 2011 +0100 @@ -437,10 +437,10 @@ static PyObject *pyxl_domain_shutdown(Xl static PyObject *pyxl_domain_destroy(XlObject *self, PyObject *args) { - int domid, force = 1; - if ( !PyArg_ParseTuple(args, "i|i", &domid, &force) ) + int domid; + if ( !PyArg_ParseTuple(args, "i", &domid) ) return NULL; - if ( libxl_domain_destroy(self->ctx, domid, force) ) { + if ( libxl_domain_destroy(self->ctx, domid) ) { PyErr_SetString(xl_error_obj, "cannot destroy domain"); return NULL; }
Roger Pau Monne
2011-Dec-15 17:58 UTC
[PATCH 6 of 6 ACKED v5] libxl: remove force parameter from libxl__devices_destroy
# HG changeset patch # User Roger Pau Monne <roger.pau@entel.upc.edu> # Date 1323971746 -3600 # Node ID 5cb746278dd800860267939f6208abeb3239dc9c # Parent 1ab9421bf75c620fabb8d02c921a877a323c1a03 libxl: remove force parameter from libxl__devices_destroy Remove the force flag, and always use forced destruction. Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r 1ab9421bf75c -r 5cb746278dd8 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl.c Thu Dec 15 18:55:46 2011 +0100 @@ -772,7 +772,7 @@ int libxl_domain_destroy(libxl_ctx *ctx, libxl__qmp_cleanup(gc, domid); } - if (libxl__devices_destroy(gc, domid, 1) < 0) + if (libxl__devices_destroy(gc, domid) < 0) LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "libxl__devices_destroy failed for %d", domid); diff -r 1ab9421bf75c -r 5cb746278dd8 tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl_device.c Thu Dec 15 18:55:46 2011 +0100 @@ -505,13 +505,13 @@ int libxl__device_destroy(libxl__gc *gc, return rc; } -int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force) +int libxl__devices_destroy(libxl__gc *gc, uint32_t domid) { libxl_ctx *ctx = libxl__gc_owner(gc); char *path; unsigned int num_kinds, num_devs; char **kinds = NULL, **devs = NULL; - int i, j, n_watches = 0; + int i, j; libxl__device dev; libxl__device_kind kind; @@ -542,16 +542,7 @@ int libxl__devices_destroy(libxl__gc *gc dev.kind = kind; dev.devid = atoi(devs[j]); - if (force) { - libxl__device_destroy(gc, &dev); - } else { - int rc = libxl__device_remove(gc, &dev, 0); - if (rc < 0) - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "cannot remove device %s\n", path); - else - n_watches += rc; - } + libxl__device_destroy(gc, &dev); } } } @@ -565,37 +556,9 @@ int libxl__devices_destroy(libxl__gc *gc dev.kind = LIBXL__DEVICE_KIND_CONSOLE; dev.devid = 0; - if (force) { - libxl__device_destroy(gc, &dev); - } else { - int rc = libxl__device_remove(gc, &dev, 0); - if (rc < 0) - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "cannot remove device %s\n", path); - else - n_watches += rc; - } + libxl__device_destroy(gc, &dev); } - if (!force) { - /* Linux-ism. Most implementations leave the timeout - * untouched after select. Linux, however, will chip - * away the elapsed time from it, which is what we - * need to enforce a single time span waiting for - * device destruction. */ - struct timeval tv; - tv.tv_sec = LIBXL_DESTROY_TIMEOUT; - tv.tv_usec = 0; - while (n_watches > 0) { - if (libxl__wait_for_device_state(gc, &tv, XenbusStateClosed, - destroy_device) < 0) { - /* function returned ERROR_* */ - break; - } else { - n_watches--; - } - } - } out: return 0; } diff -r 1ab9421bf75c -r 5cb746278dd8 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Thu Dec 15 18:55:46 2011 +0100 +++ b/tools/libxl/libxl_internal.h Thu Dec 15 18:55:46 2011 +0100 @@ -271,7 +271,7 @@ _hidden int libxl__parse_backend_path(li libxl__device *dev); _hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev, int wait); _hidden int libxl__device_destroy(libxl__gc *gc, libxl__device *dev); -_hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force); +_hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid); _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state); /* Handler for the libxl__wait_for_device_state callback */
Ian Jackson
2011-Dec-20 18:13 UTC
Re: [PATCH 0 of 6 ACKED v5] libxl: add support for hotplug script calling from libxl
Roger Pau Monne writes ("[Xen-devel] [PATCH 0 of 6 ACKED v5] libxl: add support for hotplug script calling from libxl"):> Previously acked patches from the series.Applied all six, thanks. Ian.