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

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

 



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@xxxxxxxxxx>
> > 
> > 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@xxxxxxxxxx>
> > ---
> >  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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]