[libvirt] [PATCH 19/23] Add support for hotplug/unplug of USB host devices in LXC

Gao feng gaofeng at cn.fujitsu.com
Fri Dec 14 11:27:47 UTC 2012


On 2012/12/01 04:26, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Wire up the attach/detach device drivers in LXC to support the
> hotplug/unplug of USB host devices.
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  src/lxc/lxc_driver.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 332 insertions(+)
> 

[...]

>  static int
> +lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
> +                                    virDomainObjPtr vm,
> +                                    virDomainDeviceDefPtr dev)
> +{
> +    virLXCDomainObjPrivatePtr priv = vm->privateData;
> +    virDomainHostdevDefPtr def = NULL;
> +    virCgroupPtr group = NULL;
> +    int idx, ret = -1;
> +    char *dst = NULL;
> +    char *vroot = NULL;
> +    usbDevice *usb = NULL;
> +
> +    if (!priv->initpid) {

No need,already checked in lxcDomainDetachDeviceHostdevLive

> +        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                       _("Cannot attach hostdev until init PID is known"));
> +        goto cleanup;
> +    }
> +

[...]

> +static int
> +lxcDomainDetachDeviceHostdevLive(virLXCDriverPtr driver,
> +                                 virDomainObjPtr vm,
> +                                 virDomainDeviceDefPtr dev)
> +{
> +    virLXCDomainObjPrivatePtr priv = vm->privateData;
> +
> +    if (!priv->initpid) {
> +        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                       _("Cannot attach hostdev until init PID is known"));
> +        return -1;
> +    }
> +

ACK




More information about the libvir-list mailing list