[libvirt] [PATCH v3 1/2] qemu: Add support for hot unplugging redirdev device which can use the detach-device --live

John Ferlan jferlan at redhat.com
Fri Jan 5 00:06:50 UTC 2018



On 12/22/2017 03:04 AM, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao at gmail.com>
> 
> We lacked of hot unplugging redirdev device.
> This patch add support for it.
> We could use detach-device --live now.

Change the commit message to:

Commit id '162efa1a' added support hotplug a redirdev, but
did not add the hot unplug. This patch will add that support
to allow usage of the detach-device --live on the device.

> 
> Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
> ---
> v3:
>   use helper qemuDomainDelChardevTLSObjects
>   address John's comments
> 
> v2:
>   rebase on master
> 
>  src/qemu/qemu_driver.c  |  4 ++-
>  src/qemu/qemu_hotplug.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_hotplug.h |  4 +++
>  3 files changed, 98 insertions(+), 1 deletion(-)
> 

[...]

> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index b79807300..724ee4f3f 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -4388,6 +4388,54 @@ qemuDomainRemoveInputDevice(virDomainObjPtr vm,
>  }
>  
>  
> +static int
> +qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
> +                               virDomainObjPtr vm,
> +                               virDomainRedirdevDefPtr dev)
> +{
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    virObjectEventPtr event;
> +    char *charAlias = NULL;
> +    ssize_t idx;
> +    int ret = -1;
> +
> +    VIR_DEBUG("Removing redirdev device %s from domain %p %s",
> +              dev->info.alias, vm, vm->def->name);
> +
> +    if (!(charAlias = qemuAliasChardevFromDevAlias(dev->info.alias)))
> +        goto cleanup;
> +
> +    qemuDomainObjEnterMonitor(driver, vm);
> +    /* DeviceDel from Detach may remove chardev,
> +     * so we cannot rely on return status to delete TLS chardevs.
> +     */
> +    ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
> +
> +    if (qemuDomainObjExitMonitor(driver, vm) < 0)
> +        goto cleanup;
> +
> +    if (qemuDomainDelChardevTLSObjects(driver, vm,
> +                                       dev->source, charAlias) < 0)

The above fits on one line.

> +        goto cleanup;
> +
> +    virDomainAuditRedirdev(vm, dev, "detach", true);
> +
> +    event = virDomainEventDeviceRemovedNewFromObj(vm, dev->info.alias);
> +    qemuDomainEventQueue(driver, event);
> +
> +    if ((idx = virDomainRedirdevDefFind(vm->def, dev)) >= 0)
> +        virDomainRedirdevDefRemove(vm->def, idx);
> +    qemuDomainReleaseDeviceAddress(vm, &dev->info, NULL);
> +    virDomainRedirdevDefFree(dev);
> +
> +    ret = 0;
> +
> + cleanup:
> +    VIR_FREE(charAlias);
> +    return ret;
> +}
> +
> +

[...]

Reviewed-by: John Ferlan <jferlan at redhat.com>

John

But I'll give it a day or so before pushing - just in case there's a
straggler comment or two...




More information about the libvir-list mailing list