[Spice-devel] [PATCH 5/5] usb-device-manager: Configure UsbDk hiding rules on auto-redirection

Christophe Fergeau cfergeau at redhat.com
Mon Jun 1 00:22:59 PDT 2015


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.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150601/4ef6e55f/attachment-0001.sig>


More information about the Spice-devel mailing list