VirtualBox

Changeset 104178 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Apr 5, 2024 12:23:48 PM (10 months ago)
Author:
vboxsync
Message:

Guest Control:

  • Factored out most of the guest process stream handling of GuestToolboxStream (deprecated) into a new generic class GuestProcessOutputStream. That way we can make use of most of that code for other, non-toolbox related functionality.
  • Factoredd out most of the guest process wrapping functionality from GuestProcessToolbox into a new generic class GuestProcessWrapper. Ditto (see above).
  • Make more use of VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT to compile a lot less code if not defined. Toolbox handling is required for supporting older Guest Additions (< 7.1) though (so enabled by default).
Location:
trunk/src/VBox/Main/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r104003 r104178  
    968968};
    969969
     970/**
     971 * Generic class for handling a guest process output (i.e. stdout / stderr) stream.
     972 */
     973class GuestProcessOutputStream
     974{
     975public:
     976
     977    GuestProcessOutputStream();
     978
     979    virtual ~GuestProcessOutputStream();
     980
     981public:
     982
     983    int AddData(const BYTE *pbData, size_t cbData);
     984
     985    void Destroy();
     986
     987#ifdef DEBUG
     988    void Dump(const char *pszFile);
     989#endif
     990
     991    size_t GetOffset(void) const { return m_offBuf; }
     992
     993    size_t GetSize(void) const { return m_cbUsed; }
     994
     995    const BYTE *GetData(void) const { return m_pbBuffer; }
     996
     997protected:
     998
     999    /** Maximum allowed size the stream buffer can grow to.
     1000     *  Defaults to 32 MB. */
     1001    size_t m_cbMax;
     1002    /** Currently allocated size of internal stream buffer. */
     1003    size_t m_cbAllocated;
     1004    /** Currently used size at m_offBuffer. */
     1005    size_t m_cbUsed;
     1006    /** Current byte offset within the internal stream buffer. */
     1007    size_t m_offBuf;
     1008    /** Internal stream buffer. */
     1009    BYTE  *m_pbBuffer;
     1010};
    9701011
    9711012/**
     
    10101051 *
    10111052 * Only used for the busybox-like toolbox commands within VBoxService.
     1053 *
    10121054 * Deprecated, do not use anymore.
    10131055 */
     
    10821124 * Deprecated, do not use anymore.
    10831125 */
    1084 class GuestToolboxStream
     1126class GuestToolboxStream : public GuestProcessOutputStream
    10851127{
    10861128
     
    10931135public:
    10941136
    1095     int AddData(const BYTE *pbData, size_t cbData);
    1096 
    1097     void Destroy();
    1098 
    1099 #ifdef DEBUG
    1100     void Dump(const char *pszFile);
    1101 #endif
    1102 
    1103     size_t GetOffset(void) const { return m_offBuf; }
    1104 
    1105     size_t GetSize(void) const { return m_cbUsed; }
    1106 
    11071137    size_t GetBlocks(void) const { return m_cBlocks; }
    11081138
     
    11111141protected:
    11121142
    1113     /** Maximum allowed size the stream buffer can grow to.
    1114      *  Defaults to 32 MB. */
    1115     size_t m_cbMax;
    1116     /** Currently allocated size of internal stream buffer. */
    1117     size_t m_cbAllocated;
    1118     /** Currently used size at m_offBuffer. */
    1119     size_t m_cbUsed;
    1120     /** Current byte offset within the internal stream buffer. */
    1121     size_t m_offBuf;
    1122     /** Internal stream buffer. */
    1123     BYTE  *m_pbBuffer;
    11241143    /** How many completed stream blocks already were processed. */
    11251144    size_t m_cBlocks;
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r98614 r104178  
    217217
    218218/**
     219 * Wrapper class for running guest processes.
     220 */
     221class GuestProcessWrapper
     222{
     223public:
     224    DECLARE_TRANSLATE_METHODS(GuestProcessWrapper)
     225
     226    GuestProcessWrapper(void);
     227
     228    virtual ~GuestProcessWrapper(void);
     229
     230public:
     231
     232    int init(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo, bool fAsync, int *pvrcGuest);
     233
     234    void uninit(void);
     235
     236    /** Returns the stdout output from the guest process. */
     237    GuestProcessOutputStream &getStdOut(void) { return mStdOut; }
     238
     239    /** Returns the stderr output from the guest proces. */
     240    GuestProcessOutputStream &getStdErr(void) { return mStdErr; }
     241
     242    bool isRunning(void);
     243
     244    bool isTerminatedOk(void);
     245
     246    int getTerminationStatus(int32_t *piExitCode = NULL);
     247
     248    int terminate(uint32_t uTimeoutMS, int *pvrcGuest);
     249
     250protected:
     251
     252    /** Pointer to session this toolbox object is bound to. */
     253    ComObjPtr<GuestSession>     pSession;
     254    /** Pointer to process object this object is bound to. */
     255    ComObjPtr<GuestProcess>     pProcess;
     256    /** The process startup info. */
     257    GuestProcessStartupInfo     mStartupInfo;
     258    /** Stream object for handling stdout data. */
     259    GuestProcessOutputStream    mStdOut;
     260    /** Stream object for handling stderr data. */
     261    GuestProcessOutputStream    mStdErr;
     262};
     263
     264#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
     265/**
    219266 * Internal class for handling the BusyBox-like tools built into VBoxService
    220267 * on the guest side. It's also called the VBoxService Toolbox (tm).
     
    228275 * Note! When implementing new functionality / commands, do *not* use this approach anymore!
    229276 *       This class has to be kept to guarantee backwards-compatibility.
    230  */
    231 class GuestProcessToolbox
     277 *
     278 * Deprecated, do not use anymore.
     279 */
     280class GuestProcessToolbox : public GuestProcessWrapper
    232281{
    233282public:
    234     DECLARE_TRANSLATE_METHODS(GuestProcessTool)
     283    DECLARE_TRANSLATE_METHODS(GuestProcessToolbox)
    235284
    236285    GuestProcessToolbox(void);
     
    240289public:
    241290
    242     int init(GuestSession *pGuestSession, const GuestProcessStartupInfo &startupInfo, bool fAsync, int *pvrcGuest);
    243 
    244     void uninit(void);
     291    int wait(uint32_t fToolWaitFlags, int *pvrcGuest);
     292
     293    int waitEx(uint32_t fToolWaitFlags, GuestToolboxStreamBlock *strmBlockOut, int *pvrcGuest);
    245294
    246295    int getCurrentBlock(uint32_t uHandle, GuestToolboxStreamBlock &strmBlock);
     
    253302    /** Returns the stderr output from the guest process tool. */
    254303    GuestToolboxStream &getStdErr(void) { return mStdErr; }
    255 
    256     int wait(uint32_t fToolWaitFlags, int *pvrcGuest);
    257 
    258     int waitEx(uint32_t fToolWaitFlags, GuestToolboxStreamBlock *pStreamBlock, int *pvrcGuest);
    259 
    260     bool isRunning(void);
    261 
    262     bool isTerminatedOk(void);
    263 
    264     int getTerminationStatus(int32_t *piExitCode = NULL);
    265 
    266     int terminate(uint32_t uTimeoutMS, int *pvrcGuest);
    267304
    268305public:
     
    282319     * @{ */
    283320    static int exitCodeToRc(const GuestProcessStartupInfo &startupInfo, int32_t iExitCode);
    284 
    285321    static int exitCodeToRc(const char *pszTool, int32_t iExitCode);
    286322    /** @}  */
     
    293329protected:
    294330
    295     /** Pointer to session this toolbox object is bound to. */
    296     ComObjPtr<GuestSession>     pSession;
    297     /** Pointer to process object this toolbox object is bound to. */
    298     ComObjPtr<GuestProcess>     pProcess;
    299     /** The toolbox' startup info. */
    300     GuestProcessStartupInfo     mStartupInfo;
    301331    /** Stream object for handling the toolbox' stdout data. */
    302332    GuestToolboxStream          mStdOut;
     
    304334    GuestToolboxStream          mStdErr;
    305335};
     336#endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */
    306337
    307338#endif /* !MAIN_INCLUDED_GuestProcessImpl_h */
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r102654 r104178  
    363363    /** @}  */
    364364
     365#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
    365366    /** @name Public internal methods for supporting older Guest Additions via
    366      *        VBoxService' built-in toolbox (< 7.1).
     367     *        VBoxService' built-in toolbox (< 7.1). Deprecated, do not use anymore.
    367368     * @{  */
    368369    int                     i_directoryCreateViaToolbox(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pvrcGuest);
     
    372373    int                     i_fsObjQueryInfoViaToolbox(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pvrcGuest);
    373374    /** @}  */
     375#endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */
    374376
    375377public:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette