Resolution of a backend name to a domid needs to happen a little earlier in some cases. For example, if a domU is specified as a backend for a disk and, as previously written, libxl__device_disk_setdefault() calls libxl__resolve_domid() last, then disk->backend_domid still equals LIBXL_TOOLSTACK_DOMID when libxl__device_disk_set_backend() is called. This results in libxl__device_disk_set_backend() making an incorrect attempt to validate the target by calling stat() on a file on dom0, resulting in ERROR_INVAL (see libxl_device.c lines 239-248), which prevents creation of the frontend domain. Likewise, libxl__device_nic_setdefault() previously made use of nic->backend_domid before it was set. Signed-off-by: Eric Shelton <eshelton@pobox.com> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> --- tools/libxl/libxl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 30302c7..fcab76a 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1978,10 +1978,10 @@ int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk) { int rc; - rc = libxl__device_disk_set_backend(gc, disk); - if (rc) return rc; - rc = libxl__resolve_domid(gc, disk->backend_domname, &disk->backend_domid); + if (rc < 0) return rc; + + rc = libxl__device_disk_set_backend(gc, disk); return rc; } @@ -2812,6 +2812,10 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, LOG(ERROR, "unable to get current hotplug scripts execution setting"); return run_hotplug_scripts; } + + rc = libxl__resolve_domid(gc, nic->backend_domname, &nic->backend_domid); + if (rc < 0) return rc; + if (nic->backend_domid != LIBXL_TOOLSTACK_DOMID && run_hotplug_scripts) { LOG(ERROR, "cannot use a backend domain different than %d if" "hotplug scripts are executed from libxl", @@ -2837,7 +2841,6 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, abort(); } - rc = libxl__resolve_domid(gc, nic->backend_domname, &nic->backend_domid); return rc; } -- 1.7.10.2 (Apple Git-33) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2013-Apr-30 15:12 UTC
Re: [PATCH] libxl: adjust point of backend name resolution
On Tue, 2013-04-30 at 16:03 +0100, Eric Shelton wrote:> Resolution of a backend name to a domid needs to happen a little earlier > in some cases. > > For example, if a domU is specified as a backend for a > disk and, as previously written, libxl__device_disk_setdefault() calls > libxl__resolve_domid() last, then disk->backend_domid still equals > LIBXL_TOOLSTACK_DOMID when libxl__device_disk_set_backend() is called. > This results in libxl__device_disk_set_backend() making an incorrect > attempt to validate the target by calling stat() on a file on dom0, > resulting in ERROR_INVAL (see libxl_device.c lines 239-248), which > prevents creation of the frontend domain. > > Likewise, libxl__device_nic_setdefault() previously made use of > nic->backend_domid before it was set. > > Signed-off-by: Eric Shelton <eshelton@pobox.com>Acked-by: Ian Campbell <ian.campbell@citrix.com>> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>Daniel, any comments?
Daniel De Graaf
2013-Apr-30 17:55 UTC
Re: [PATCH] libxl: adjust point of backend name resolution
On 04/30/2013 11:12 AM, Ian Campbell wrote:> On Tue, 2013-04-30 at 16:03 +0100, Eric Shelton wrote: >> Resolution of a backend name to a domid needs to happen a little earlier >> in some cases. >> >> For example, if a domU is specified as a backend for a >> disk and, as previously written, libxl__device_disk_setdefault() calls >> libxl__resolve_domid() last, then disk->backend_domid still equals >> LIBXL_TOOLSTACK_DOMID when libxl__device_disk_set_backend() is called. >> This results in libxl__device_disk_set_backend() making an incorrect >> attempt to validate the target by calling stat() on a file on dom0, >> resulting in ERROR_INVAL (see libxl_device.c lines 239-248), which >> prevents creation of the frontend domain. >> >> Likewise, libxl__device_nic_setdefault() previously made use of >> nic->backend_domid before it was set. >> >> Signed-off-by: Eric Shelton <eshelton@pobox.com> > > Acked-by: Ian Campbell <ian.campbell@citrix.com> > >> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> > > Daniel, any comments? >Yes, the backend_domname conversion needs to happen earlier or the checks against LIBXL_TOOLSTACK_DOMID won''t work right - I actually had run into this and was bypassing it by specifying a script, so this fix is needed. Reviewed-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Ian Campbell
2013-May-01 12:34 UTC
Re: [PATCH] libxl: adjust point of backend name resolution
On Tue, 2013-04-30 at 18:55 +0100, Daniel De Graaf wrote:> On 04/30/2013 11:12 AM, Ian Campbell wrote: > > On Tue, 2013-04-30 at 16:03 +0100, Eric Shelton wrote: > >> Resolution of a backend name to a domid needs to happen a little earlier > >> in some cases. > >> > >> For example, if a domU is specified as a backend for a > >> disk and, as previously written, libxl__device_disk_setdefault() calls > >> libxl__resolve_domid() last, then disk->backend_domid still equals > >> LIBXL_TOOLSTACK_DOMID when libxl__device_disk_set_backend() is called. > >> This results in libxl__device_disk_set_backend() making an incorrect > >> attempt to validate the target by calling stat() on a file on dom0, > >> resulting in ERROR_INVAL (see libxl_device.c lines 239-248), which > >> prevents creation of the frontend domain. > >> > >> Likewise, libxl__device_nic_setdefault() previously made use of > >> nic->backend_domid before it was set. > >> > >> Signed-off-by: Eric Shelton <eshelton@pobox.com> > > > > Acked-by: Ian Campbell <ian.campbell@citrix.com> > > > >> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov> > > > > Daniel, any comments? > > > > Yes, the backend_domname conversion needs to happen earlier or the checks > against LIBXL_TOOLSTACK_DOMID won''t work right - I actually had run into > this and was bypassing it by specifying a script, so this fix is needed. > > Reviewed-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>Thanks, applied. Eric, The patch was whitespace wrapped, I fixed it by hand this time but for next time please consult some of the links from http://wiki.xen.org/wiki/Submitting_Xen_Patches about beating various MUAs into submission or use git send-email or something. Thanks, Ian.