From: "Roger Pau Monné" <roger.pau@entel.upc.edu>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 6 of 9 v2] libxl: execute hotplug scripts directly from libxl
Date: Mon, 21 Nov 2011 12:42:01 +0100 [thread overview]
Message-ID: <CAPLaKK5JF1NeXkq4zkZtaSjvOfY=VrsrvJ-YHE+aFXd1+pkAgw@mail.gmail.com> (raw)
In-Reply-To: <1321623730.3664.352.camel@zakaz.uk.xensource.com>
2011/11/18 Ian Campbell <Ian.Campbell@citrix.com>:
> On Fri, 2011-11-18 at 11:59 +0000, Roger Pau Monne wrote:
>> # HG changeset patch
>> # User Roger Pau Monne <roger.pau@entel.upc.edu>
>> # Date 1317386335 -7200
>> # Node ID 1d81d1c4c851c0b07696373304801df56a221e90
>> # Parent 4ad998fddb16a299cb230ea23ba944d84adbd2bf
>> libxl: execute hotplug scripts directly from libxl.
>>
>> Added the necessary handlers to execute hotplug scripts when necessary
>> from libxl. Split NetBSD and Linux hotplug calls into two separate
>> files, because parameters for hotplug scripts are different. Linux
>> has empty functions, since the calling of hotplug scripts is still
>> done using udev.
>>
>> Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
>>
>> diff -r 4ad998fddb16 -r 1d81d1c4c851 tools/libxl/Makefile
>> --- a/tools/libxl/Makefile Fri Nov 18 11:29:14 2011 +0100
>> +++ b/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
>> @@ -34,8 +34,10 @@ LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpu
>
> Should be:
>
>> ifeq ($(CONFIG_NetBSD),y)
>> LIBXL_OBJS-y += libxl_phybackend.o
>> +LIBXL_OBJS-y += hotplug_netbsd.o
> elsif ($(CONFIG_Linux),y)
>> LIBXL_OBJS-y += libxl_nophybackend.o
>> +LIBXL_OBJS-y += hotplug_linux.o
> else
> $(error A message of some sort)
>> endif
Done, I've moved PHY backend selection and hotplug specific functions
to libxl_netbsd.c and libxl_linux.c, and added an error message in
case someone tries to use a different OS.
>> diff -r 4ad998fddb16 -r 1d81d1c4c851 tools/libxl/libxl_device.c
>> --- a/tools/libxl/libxl_device.c Fri Nov 18 11:29:14 2011 +0100
>> +++ b/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
>> @@ -68,6 +68,24 @@ int libxl__parse_backend_path(libxl__gc
>> return libxl__device_kind_from_string(strkind, &dev->backend_kind);
>> }
>>
>> +int libxl__device_execute_hotplug(libxl__gc *gc, libxl__device *dev)
>
> No need for a add/remove type parameter?
Although you could pass this kind of parameter, the action to perform
is based on the state of the device in the corresponding xenstore
entry. State 2 means that the device should be connected, state 6
means the device should be disconnected.
>> +{
>> + int rc = 0;
>> +
>> + switch(dev->kind) {
>> + case LIBXL__DEVICE_KIND_VIF:
>> + rc = libxl__nic_hotplug(gc, dev);
>> + break;
>> + case LIBXL__DEVICE_KIND_VBD:
>> + rc = libxl__disk_hotplug(gc, dev);
>> + break;
>> + default:
>> + break;
>> + }
>> +
>> + return rc;
>> +}
>> +
>> int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
>> char **bents, char **fents)
>> {
>> @@ -449,6 +467,7 @@ int libxl__device_remove(libxl__gc *gc,
>> if (!state)
>> goto out;
>> if (atoi(state) != 4) {
>> + libxl__device_execute_hotplug(gc, dev);
>> libxl__device_destroy_tapdisk(gc, be_path);
>> xs_rm(ctx->xsh, XBT_NULL, be_path);
>> goto out;
>> @@ -492,6 +511,12 @@ int libxl__device_destroy(libxl__gc *gc,
>> char *be_path = libxl__device_backend_path(gc, dev);
>> char *fe_path = libxl__device_frontend_path(gc, dev);
>>
>> + /*
>> + * Run hotplug scripts, which will probably not be able to
>> + * execute successfully since the device may still be plugged
>
> What does this mean? If we don't expect it to work why are we calling
> them?
If you call the libxl_domain_destroy function with force == 1, the
destroy process doesn't wait for devices to be disconnected, but we
might as well try to execute hotplug scripts, since we don't know the
actual state of the device. If we are lucky, the device might be
disconnected (state == 6), and we should be able to execute hotplug
scripts successfully.
>> + */
>> + libxl__device_execute_hotplug(gc, dev);
>> +
>> xs_rm(ctx->xsh, XBT_NULL, be_path);
>> xs_rm(ctx->xsh, XBT_NULL, fe_path);
>>
>> diff -r 4ad998fddb16 -r 1d81d1c4c851 tools/libxl/libxl_internal.h
>> --- a/tools/libxl/libxl_internal.h Fri Nov 18 11:29:14 2011 +0100
>> +++ b/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
>> @@ -287,6 +287,34 @@ _hidden int libxl__wait_for_device_state
>> */
>> _hidden int libxl__try_phy_backend(mode_t st_mode);
>>
>> +/* hotplug functions */
>> +/*
>> + * libxl__device_execute_hotplug - generic function to execute hotplug scripts
>> + * gc: allocation pool
>> + * dev: reference to the device that executes the hotplug scripts
>> + *
>> + * Returns 0 on success, and < 0 on error.
>> + */
>> +_hidden int libxl__device_execute_hotplug(libxl__gc *gc, libxl__device *dev);
>> +
>> +/*
>> + * libxl__disk_hotplug - execute hotplug script for a disk type device
>> + * gc: allocation pool
>> + * dev: reference to the disk device
>> + *
>> + * Returns 0 on success, and < 0 on error.
>> + */
>> +_hidden int libxl__disk_hotplug(libxl__gc *gc, libxl__device *dev);
>> +
>> +/*
>> + * libxl__nic_hotplug - execute hotplug script for a nic type device
>> + * gc: allocation pool
>> + * dev: reference to the nic device
>> + *
>> + * Returns 0 on success, and < 0 on error.
>> + */
>> +_hidden int libxl__nic_hotplug(libxl__gc *gc, libxl__device *dev);
>> +
>> /* from libxl_pci */
>>
>> _hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting);
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xensource.com
>> http://lists.xensource.com/xen-devel
>
>
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2011-11-21 11:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-18 11:59 [PATCH 0 of 9 v2] libxl: add support for hotplug script calling from libxl Roger Pau Monne
2011-11-18 11:59 ` [PATCH 1 of 9 v2] xenbackendd: pass type of block device to hotplug script Roger Pau Monne
2011-11-18 11:59 ` [PATCH 2 of 9 v2] libxl: add support for image files for NetBSD Roger Pau Monne
2011-11-18 13:27 ` Ian Campbell
2011-11-18 14:49 ` Roger Pau Monné
2011-11-18 15:20 ` Ian Campbell
2011-11-18 11:59 ` [PATCH 3 of 9 v2] libxl: add libxl__forkexec function to libxl_exec Roger Pau Monne
2011-11-18 13:31 ` Ian Campbell
2011-11-18 14:50 ` Roger Pau Monné
2011-11-24 18:11 ` Ian Jackson
2011-12-01 14:29 ` Roger Pau Monné
2011-12-01 14:57 ` Ian Jackson
2011-11-18 11:59 ` [PATCH 4 of 9 v2] libxl: introduce libxl__wait_for_device_state Roger Pau Monne
2011-11-18 13:34 ` Ian Campbell
2011-11-18 11:59 ` [PATCH 5 of 9 v2] libxl: wait for devices to initialize upon addition to the domain Roger Pau Monne
2011-11-18 13:38 ` Ian Campbell
2011-11-18 14:58 ` Roger Pau Monné
2011-11-18 11:59 ` [PATCH 6 of 9 v2] libxl: execute hotplug scripts directly from libxl Roger Pau Monne
2011-11-18 13:42 ` Ian Campbell
2011-11-21 11:42 ` Roger Pau Monné [this message]
2011-11-21 14:36 ` Ian Campbell
2011-11-24 12:19 ` Ian Campbell
2011-12-01 8:44 ` Roger Pau Monné
2011-11-18 11:59 ` [PATCH 7 of 9 v2] hotplug NetBSD: detach devices when state is 5 or 6 Roger Pau Monne
2011-11-18 11:59 ` [PATCH 8 of 9 v2] hotplug: remove debug messages from NetBSD hotplug scripts Roger Pau Monne
2011-11-18 11:59 ` [PATCH 9 of 9 v2] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it Roger Pau Monne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPLaKK5JF1NeXkq4zkZtaSjvOfY=VrsrvJ-YHE+aFXd1+pkAgw@mail.gmail.com' \
--to=roger.pau@entel.upc.edu \
--cc=Ian.Campbell@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).