Re: [PATCH v1 16/20] node_device_udev: Use a worker pool for processing events and emitting nodedev event

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

 



On Fri, Apr 19, 2024 at 04:49 PM +0200, Marc Hartmayer <mhartmay@xxxxxxxxxxxxx> wrote:
> Use a worker pool for processing the events (e.g. udev, mdevctl config changes)
> and the initialization instead of a separate initThread and a mdevctl-thread.
> This has the large advantage that we can leverage the job API and now this
> thread pool is responsible to do all the "costly-work" and emitting the libvirt
> nodedev events.
>
> Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
> ---

[…snip…]

>  
>  
> +static void nodeDeviceEventHandler(void *data, void *opaque)
> +{
> +    virNodeDeviceDriverState *driver_state = opaque;
> +    g_autoptr(nodeDeviceEvent) processEvent = data;
> +
> +    switch (processEvent->eventType) {
> +    case NODE_DEVICE_EVENT_INIT:
> +    {
> +        struct udev *udev = processEvent->data;
> +
> +        processNodeStateInitializeEnumerate(driver_state, udev);
> +    }
> +    break;
> +    case NODE_DEVICE_EVENT_UDEV_ADD:
> +    case NODE_DEVICE_EVENT_UDEV_CHANGE:
> +    {
> +        struct udev_device *device = processEvent->data;
> +
> +        processNodeDeviceAddAndChangeEvent(driver_state, device);
> +    }
> +    break;
> +    case NODE_DEVICE_EVENT_UDEV_REMOVE:
> +    {
> +        struct udev_device *device = processEvent->data;
> +        const char *path = udev_device_get_syspath(device);
> +
> +        processNodeDeviceRemoveEvent(driver_state, path);
> +    }
> +    break;
> +    case NODE_DEVICE_EVENT_UDEV_MOVE:
> +    {
> +        struct udev_device *device = processEvent->data;
> +        const char *devpath_old = udevGetDeviceProperty(device, "DEVPATH_OLD");
> +
> +        if (devpath_old) {
> +            g_autofree char *devpath_old_fixed = g_strdup_printf("/sys%s", devpath_old);
> +
> +            processNodeDeviceRemoveEvent(driver_state, devpath_old_fixed);
> +        }
> +
> +        processNodeDeviceAddAndChangeEvent(driver_state, device);
> +    }
> +    break;
> +    case NODE_DEVICE_EVENT_MDEVCTL_CONFIG_CHANGED:
> +    {
> +        if (nodeDeviceUpdateMediatedDevices(driver_state) < 0)
> +            VIR_WARN("mdevctl failed to update mediated devices");
> +    }
> +    break;
> +    case NODE_DEVICE_EVENT_LAST:

> +        g_assert_not_reached();

The assert statement should be replaced with:

virReportEnumRangeError(nodeDeviceEventType, processEvent->eventType);

> +        break;
> +    }
> +}

[…snip]

-- 
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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