[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: Multi-device passthrough coldplug: do not wait for unstarted guest
# HG changeset patch # User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> # Date 1298654120 0 # Node ID d6bd6e2c5ce1c9d0585fa30b65a34b81d15bc64c # Parent 23fd149c0d7631e686fc96ad55d1e8f0846a2d0e libxl: Multi-device passthrough coldplug: do not wait for unstarted guest When doing a PCI passthrough, the code checks to see whether there is an existing backend directory in xenstore with a nonzero "num_devs". If there isn't, it creates the backend directory with just the required device. If there is, it would assume that it was doing hotplug. If doing hotplug, it needs to set the "state" node in xenstore to "7" (reconfiguring) and thus avoid racing with the backend needs to wait for the backend to be "4" (connected). However during guest creation, the presence of "num_devs" doesn't necessarily mean hotplug. If we are still creating the initial xenstore setup (ie, adding devices as a subroutine of domain creation), we can just write the new devices to xenstore. So do that. This involves adding a new parameter "starting", indicating that we are still in domain creation, to libxl_device_pci_add_xenstore (a misnamed internal function) and its callers. Its callers include libxl_device_pci_add which we therefore split into an internal version with the new parameter, and an external version used only for hotplug by libxl-using applications. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- diff -r 23fd149c0d76 -r d6bd6e2c5ce1 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Fri Feb 25 17:13:53 2011 +0000 +++ b/tools/libxl/libxl_create.c Fri Feb 25 17:15:20 2011 +0000 @@ -538,7 +538,7 @@ } for (i = 0; i < d_config->num_pcidevs; i++) - libxl_device_pci_add(ctx, domid, &d_config->pcidevs[i]); + libxl__device_pci_add(ctx, domid, &d_config->pcidevs[i], 1); if ( cb && (d_config->c_info.hvm || d_config->b_info.u.pv.bootloader )) { if ( (*cb)(ctx, domid, priv) ) diff -r 23fd149c0d76 -r d6bd6e2c5ce1 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri Feb 25 17:13:53 2011 +0000 +++ b/tools/libxl/libxl_internal.h Fri Feb 25 17:15:20 2011 +0000 @@ -200,6 +200,10 @@ void *check_callback_userdata); _hidden int libxl__wait_for_backend(libxl_ctx *ctx, char *be_path, char *state); +/* from libxl_pci */ + +_hidden int libxl__device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev, int starting); + /* xl_exec */ /* higher-level double-fork and separate detach eg as for device models */ diff -r 23fd149c0d76 -r d6bd6e2c5ce1 tools/libxl/libxl_pci.c --- a/tools/libxl/libxl_pci.c Fri Feb 25 17:13:53 2011 +0000 +++ b/tools/libxl/libxl_pci.c Fri Feb 25 17:15:20 2011 +0000 @@ -286,7 +286,7 @@ return 0; } -static int libxl_device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev) +static int libxl_device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting) { libxl_ctx *ctx = libxl__gc_owner(gc); flexarray_t *back; @@ -299,7 +299,7 @@ if (!num_devs) return libxl_create_pci_backend(gc, domid, pcidev, 1); - if (!libxl__domain_is_hvm(ctx, domid)) { + if (!starting && !libxl__domain_is_hvm(ctx, domid)) { if (libxl__wait_for_backend(ctx, be_path, "4") < 0) return ERROR_FAIL; } @@ -312,7 +312,8 @@ num = atoi(num_devs); libxl_create_pci_backend_device(gc, back, num, pcidev); flexarray_vappend(back, "num_devs", libxl__sprintf(gc, "%d", num + 1), NULL); - flexarray_vappend(back, "state", libxl__sprintf(gc, "%d", 7), NULL); + if (!starting) + flexarray_vappend(back, "state", libxl__sprintf(gc, "%d", 7), NULL); retry_transaction: t = xs_transaction_start(ctx->xsh); @@ -616,7 +617,7 @@ return 1; } -static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev) +static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting) { libxl_ctx *ctx = libxl__gc_owner(gc); char *path; @@ -760,6 +761,11 @@ int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev) { + return libxl__device_pci_add(ctx, domid, pcidev, 0); +} + +int libxl__device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev, int starting) +{ libxl__gc gc = LIBXL_INIT_GC(ctx); unsigned int orig_vdev, pfunc_mask; libxl_device_pci *assigned; @@ -783,7 +789,7 @@ stubdomid = libxl_get_stubdom_id(ctx, domid); if (stubdomid != 0) { libxl_device_pci pcidev_s = *pcidev; - rc = do_pci_add(&gc, stubdomid, &pcidev_s); + rc = do_pci_add(&gc, stubdomid, &pcidev_s, starting); if ( rc ) goto out; } @@ -818,7 +824,7 @@ */ pcidev->vdevfn = orig_vdev; } - if ( do_pci_add(&gc, domid, pcidev) ) + if ( do_pci_add(&gc, domid, pcidev, starting) ) rc = ERROR_FAIL; } } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |