Re: [PATCH 4/5] qemu: functions for dealing with input device namespaces and labels

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

 



On 11/21/2017 04:05 PM, Ján Tomko wrote:
> Introudce functions that will let us create the evdevs in namespaces
> and label the devices on input device hotplug/hotunplug.
> ---
>  src/qemu/qemu_domain.c   | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_domain.h   |  6 ++++
>  src/qemu/qemu_security.c | 58 ++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_security.h |  6 ++++
>  4 files changed, 142 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index b2fc3b816..5831a2025 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -9969,6 +9969,78 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver,
>  }
>  
>  
> +int
> +qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
> +                              virDomainInputDefPtr input)
> +{
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    virQEMUDriverPtr driver = priv->driver;
> +    virQEMUDriverConfigPtr cfg = NULL;
> +    char **devMountsPath = NULL;
> +    size_t ndevMountsPath = 0;
> +    const char *path = NULL;
> +    int ret = -1;
> +
> +    if (!(path = virDomainInputDefGetPath(input)))
> +        return 0;
> +
> +    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
> +        return 0;

Just a small nit. I prefer this namespace check to be the first in the
function (look at qemuDomainNamespaceSetupChardev() for instance).

> +
> +    cfg = virQEMUDriverGetConfig(driver);
> +    if (qemuDomainGetPreservedMounts(cfg, vm,
> +                                     &devMountsPath, NULL,
> +                                     &ndevMountsPath) < 0)
> +        goto cleanup;
> +
> +    if (qemuDomainAttachDeviceMknod(driver, vm, path,
> +                                    devMountsPath, ndevMountsPath) < 0)
> +        goto cleanup;
> +
> +    ret = 0;
> + cleanup:
> +    virStringListFreeCount(devMountsPath, ndevMountsPath);
> +    virObjectUnref(cfg);
> +    return ret;
> +}
> +
> +
> +int
> +qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
> +                                 virDomainInputDefPtr input)
> +{
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    virQEMUDriverPtr driver = priv->driver;
> +    virQEMUDriverConfigPtr cfg = NULL;
> +    char **devMountsPath = NULL;
> +    size_t ndevMountsPath = 0;
> +    const char *path = NULL;
> +    int ret = -1;
> +
> +    if (!(path = virDomainInputDefGetPath(input)))
> +        return 0;
> +
> +    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
> +        return 0;

Here too.

> +
> +    cfg = virQEMUDriverGetConfig(driver);
> +    if (qemuDomainGetPreservedMounts(cfg, vm,
> +                                     &devMountsPath, NULL,
> +                                     &ndevMountsPath) < 0)
> +        goto cleanup;
> +
> +    if (qemuDomainDetachDeviceUnlink(driver, vm, path,
> +                                     devMountsPath, ndevMountsPath) < 0)
> +        goto cleanup;
> +
> +    ret = 0;
> + cleanup:
> +    virStringListFreeCount(devMountsPath, ndevMountsPath);
> +    virObjectUnref(cfg);
> +    return ret;
> +}
> +

Michal

--
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]
  Powered by Linux