On Monday 03 November 2014 15:58:35 Michael Tokarev wrote: > 03.11.2014 15:22, Peter Wu wrote: > [] > > As an aside, would it be possible to override the samba binary at runtime, > > without compiling? Either an envvar (SMBD) or an option (-net > > user,smb=...,smbd=...). > > The whole thing needs to be rewritten to use a shell script to create > smb.conf and to call smbd. It's something I wanted to do for very long > time, the only question is where to put this script so a user can > easily customize it. In debian we have a rule that anything in /etc > is a conffile, and it gets upgraded (when upgrading the corresponding > package) only if it hasn't been modified by the user. Everything else > (in /usr/lib, /usr/share etc) gets upgraded unconditionally. So maybe > storing it in /etc/qemu/run-smbd.sh or somehting like that makes sense.
I do not think that everyone is (or wants to be) a Samba wizard. For that reason, I see little value in giving the user too much control over the creation of the samba config file. There exists helpers for setting up bridges, but that is because it may need more privileges, and starting samba is not such a case. > The rest is a shell code to create smb.conf in a temp dir -- the same > as current code does in qemu, plus all your additions, If by "my additions" you mean specifying a custom samba path, that is just a single program, why not allow to override it at runtime? > plus whatever else might be needed (that script can even query which > samba version is in use and enable one or another option). That single program could be a wrapper script that modifies the files as needed. I propose to keep a simple interface which do not need users to modify a shell script or learn Samba. Consider Virtual Box' and VMWare' shared folders functionality. It allows multiple folders to be specified with these properties: - share name, - folder to be shared, - read-only, - automount it in the guest (feature of VBox Guest additions), - disable after session (after reboot/poweroff, VMWare feature). Only the first three options are interesting enough for QEMU's interface. What about extending the current '-net user,smb' option as follows (lines are wrapped for readability): smb=[sharename:]folder, [smb=sharename2:folder2[:readonly]] (etc) If 'sharename' is omitted, 'qemu' is used. Duplicate share names must result in a fatal error. 'readonly' requires specification of the sharename to avoid an ambiguity. Further share options could be added in the future as needed using ':' as separator (the comma is already parsed by -net). Alternative option (defaults to rw:): smb=[rw:|ro:][sharename:]folder, smb=[rw:|ro:][sharename2:]folder2 (etc) It would also be nice if a QMP/HMP was also available to add shares on runtime. In the current implementation, that could be done by writing a new config file, renaming it to smb.conf when done. Samba appears to have support to do this without restarting samba, but I have no idea whether it can be used in the current implementation where communication happens through stdin/stdout. By the way, how well does '-net user,smb' work with multiple connections? The documentation for guestfwd suggests that the command gets executed for each connection. Won't that cause concurrency issues in the access to databases? -- Kind regards, Peter https://lekensteyn.nl