[Spice-devel] [PATCH 5/5] usb-device-manager: Configure UsbDk hiding rules on auto-redirection
Dmitry Fleytman
dmitry at daynix.com
Mon Jun 1 01:31:26 PDT 2015
> On Jun 1, 2015, at 10:22 AM, Christophe Fergeau <cfergeau at redhat.com> wrote:
>
> On Sun, May 31, 2015 at 12:30:56PM +0300, Dmitry Fleytman wrote:
>>>> +
>>>> +static
>>>> +void spice_usb_device_manager_set_rules(SpiceUsbDeviceManagerPrivate *priv)
>>>> +{
>>>> + struct usbredirfilter_rule *rules;
>>>> + int r, count;
>>>> +
>>>> + r = usbredirfilter_string_to_rules(priv->redirect_on_connect, ",", "|", &rules, &count);
>>>> + if (r) {
>>>> + SPICE_DEBUG("auto-conenct rules parsing failed with error %d", r);
>
> Only noticed now, but "auto-connect" typo here.
>
>>>> + return;
>>>> + }
>>>> +
>>>> + for (int i = 0; i < count; i++) {
>>>> + USB_DK_HIDE_RULE rule;
>>>> + rule.Hide = (uint64_t)rules[i].allow;
>>>> + rule.Class = (uint64_t)rules[i].device_class;
>>>> + rule.VID = (uint64_t)rules[i].vendor_id;
>>>> + rule.PID = (uint64_t)rules[i].product_id;
>>>> + rule.BCD = (uint64_t)rules[i].device_version_bcd;
>>>> + if(!priv->usbdk_api.AddRule(priv->usbdk_hider_handle, &rule)) {
>>>> + SPICE_DEBUG("UsbDk set hide rule API failed");
>>>> + }
>>>> + }
>>>> +
>>>> + free(rules);
>>>> +}
>>>> +
>>>
>>> This helper could go to usbdk_api_wrapper maybe:
>>> usbdk_api_wrapper_set_rules(wrapper, handle, priv->redirect_on_connect) ?
>>
>> I’d prefer to keep UsbDk wrapper code as independent as possible.
>
> Why ?
>
>> This parsing logic looks too specific.
>
> In the context of spice-gtk/usbredir (ie the git repository where the
> new files are added), this is not 'too specific', this is the right
> place to have that code.
Good point.
We will do as you suggest. Thanks.
>
> Christophe
More information about the Spice-devel
mailing list