[Spice-devel] [spice-gtk 9/9] usb-redir: enable redirection of emulated CD drive

Yuri Benditovich yuri.benditovich at daynix.com
Fri Jul 26 16:26:01 UTC 2019


On Fri, Jul 26, 2019 at 6:51 PM Frediano Ziglio <fziglio at redhat.com> wrote:
>
> > On Fri, Jul 26, 2019 at 4:17 PM Frediano Ziglio <fziglio at redhat.com> wrote:
> > >
> > > >
> > > > Register constructor for emulated CD device. Now creation
> > > > of CD devices at startup is possible.
> > > >
> > > > Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com>
> > > > ---
> > > >  src/meson.build   | 6 ++++++
> > > >  src/usb-backend.c | 1 +
> > > >  2 files changed, 7 insertions(+)
> > > >
> > > > diff --git a/src/meson.build b/src/meson.build
> > > > index 49fec52..944b083 100644
> > > > --- a/src/meson.build
> > > > +++ b/src/meson.build
> > > > @@ -124,6 +124,12 @@ spice_client_glib_sources = [
> > > >    'usb-backend.c',
> > > >    'usb-emulation.h',
> > > >    'usb-backend.h',
> > > > +  'usb-device-cd.c',
> > > > +  'cd-scsi.c',
> > > > +  'cd-scsi.h',
> > > > +  'cd-scsi-dev-params.h',
> > > > +  'cd-usb-bulk-msd.c',
> > > > +  'cd-usb-bulk-msd.h',
> > > >    'vmcstream.c',
> > > >    'vmcstream.h',
> > > >  ]
> > >
> > > I would split this part of the patch and add the files to the
> > > build as soon as they are added so to check that at least they
> > > compiler, even if they are not used.
> >
> > No problem
> >
> > >
> > > > diff --git a/src/usb-backend.c b/src/usb-backend.c
> > > > index 02369d2..760dc16 100644
> > > > --- a/src/usb-backend.c
> > > > +++ b/src/usb-backend.c
> > > > @@ -432,6 +432,7 @@ SpiceUsbBackend *spice_usb_backend_new(GError
> > > > **error)
> > > >  #endif
> > > >  #endif
> > > >          be->own_devices_mask = 3; /* exclude addresses 0 and 1 */
> > > > +        spice_usb_device_register_cd(be);
> > > >      }
> > > >      SPICE_DEBUG("%s <<", __FUNCTION__);
> > > >      return be;
> > >
> > > This is adding a circular dependency.
> > > usb-backend will depend on usb-device-cd which depends on usb-backend.
> >
> > I am not aware of deprecation of circular dependency between C files.
> > For example, last time I was requested by Victor to create such
> > dependency between usb-redir-channel and usb-backend.
> >
>
> Not specifically referring to link issue, I'm talking about Design Patterns,
> Dependency Inversion Principle and such stuff.
> If you like spaghetti code circular dependency is perfectly fine.

usb-device-manager and usb-redir-channel have such dependency - this is fine.
usb-backend and cd-emulation have such deoendency - this fails the design.
IMO, somebody need to concentrate a minimal knowledge about emulated
devices and the best candidate is the backend.
And IMO, all other do not need this knowledge.
And IMO, such limitation of knowledge is the way to prevent creation
of spaghetti code.


> Frediano


More information about the Spice-devel mailing list