[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 20/23] Add support for hotplug/unplug of host storage devices in LXC



On Fri, Dec 14, 2012 at 07:44:33PM +0800, Gao feng wrote:
> On 2012/12/01 04:26, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange redhat com>
> > 
> > Wire up the attach/detach device drivers in LXC to support the
> > hotplug/unplug of host storage devices.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange redhat com>
> > ---
> >  src/lxc/lxc_driver.c | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 237 insertions(+)
> > 
> > diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> > index 50050cf..27ee3d7 100644
> > --- a/src/lxc/lxc_driver.c
> > +++ b/src/lxc/lxc_driver.c
> > @@ -3224,6 +3224,12 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver,
> >      usbDevice *usb = NULL;
> >      virCgroupPtr group = NULL;
> >  
> > +    if (virDomainHostdevFind(vm->def, def, NULL) >= 0) {
> > +        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
> > +                       _("host USB device already exists"));
> > +        return -1;
> > +    }
> > +
> 
> It shouldn't be in patch [19/23]?

Yes, will move it.

> > +
> > +    vm->def->hostdevs[vm->def->nhostdevs++] = def;
> > +
> > +    ret = 0;
> > +
> > +cleanup:
> > +    virDomainAuditHostdev(vm, def, "attach", ret == 0);
> > +    if (group)
> > +        virCgroupFree(&group);
> > +    if (dst && created && ret < 0)
> > +        unlink(dst);
> 
> 
> dst and vroot should be freed.
> And I wonder vm->def->hostdevs shouldn't be restored when attaching failed?

It is harmless to have the array be 1 element too large IMHO,
so simpler to not try to re-alloc smaller.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]