[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 09/18] libxl: disallow attaching the same device more than once
On Wed, Aug 27, 2014 at 02:48:30AM +0100, Ian Campbell wrote: > On Wed, 2014-07-30 at 19:23 +0100, Wei Liu wrote: > > Originally the code allowed users to attach the same device more than > > once. It just stupidly overwrites xenstore entries. This is bogus as > > frontend will be very confused. > > > > Introduce a helper function to check if the device to be written to > > xenstore already exists. A new error code is also introduced. > > > > Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> > > --- > > tools/libxl/libxl.c | 50 > > ++++++++++++++++++++++++++++++++++++++++++ > > tools/libxl/libxl_device.c | 19 ++++++++++++++++ > > tools/libxl/libxl_internal.h | 3 +++ > > tools/libxl/libxl_pci.c | 12 ++++++++++ > > tools/libxl/libxl_types.idl | 1 + > > 5 files changed, 85 insertions(+) > > > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > > index 01dffa0..e6fe238 100644 > > --- a/tools/libxl/libxl.c > > +++ b/tools/libxl/libxl.c > > @@ -1906,6 +1906,15 @@ void libxl__device_vtpm_add(libxl__egc *egc, > > uint32_t domid, > > rc = libxl__device_from_vtpm(gc, domid, vtpm, device); > > if ( rc != 0 ) goto out; > > > > + rc = libxl__device_exists(gc, XBT_NULL, device); > > Do we hold any locks from here until the code which actually creates the > device? I don't think we have an active transaction either which would > serve a similar purpose. > At this point we hold libxl context lock, so it should be safe against other threads in the same process. But I can see there's problem WRT to other processes trying to manipulate device. I think we need to have a xs transaction here. What do you think? Wei. > Otherwise can't another thread come and create another device after the > check and similarly confuse us? > > (likewise for the other cases). > > Ian. > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |