VirtualBox

Changeset 70795 in vbox


Ignore:
Timestamp:
Jan 29, 2018 6:00:14 PM (7 years ago)
Author:
vboxsync
Message:

ValidationKit/vboxwrappers.py: Add wrappers for enabling the serial port and changing the attachment during runtime

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py

    r70762 r70795  
    24052405
    24062406
     2407    def enableSerialPort(self, iSerialPort):
     2408        """
     2409        Enables the given serial port setting the initial port mode to disconnected.
     2410        """
     2411        try:
     2412            oPort = self.o.machine.getSerialPort(iSerialPort);
     2413        except:
     2414            fRc = reporter.errorXcpt('failed to get serial port #%u' % (iSerialPort,));
     2415        else:
     2416            try:
     2417                oPort.hostMode = vboxcon.PortMode_Disconnected;
     2418            except:
     2419                fRc = reporter.errorXcpt('failed to set the "hostMode" property on serial port #%u to PortMode_Disconnected'
     2420                                         % (iSerialPort,));
     2421            else:
     2422                try:
     2423                    oPort.enabled = True;
     2424                except:
     2425                    fRc = reporter.errorXcpt('failed to set the "enable" property on serial port #%u to True'
     2426                                             % (iSerialPort,));
     2427                else:
     2428                    reporter.log('set SerialPort[%s].enabled/hostMode/=True/Disconnected' % (iSerialPort,));
     2429                    fRc = True;
     2430        self.oTstDrv.processPendingEvents();
     2431        return fRc;
     2432
     2433
     2434    def changeSerialPortAttachment(self, iSerialPort, ePortMode, sPath, fServer):
     2435        """
     2436        Changes the attachment of the given serial port to the attachment config given.
     2437        """
     2438        try:
     2439            oPort = self.o.machine.getSerialPort(iSerialPort);
     2440        except:
     2441            fRc = reporter.errorXcpt('failed to get serial port #%u' % (iSerialPort,));
     2442        else:
     2443            try:
     2444                # Change port mode to disconnected first so changes get picked up by a potentially running VM.
     2445                oPort.hostMode = vboxcon.PortMode_Disconnected;
     2446            except:
     2447                fRc = reporter.errorXcpt('failed to set the "hostMode" property on serial port #%u to PortMode_Disconnected'
     2448                                         % (iSerialPort,));
     2449            else:
     2450                try:
     2451                    oPort.path     = sPath;
     2452                    oPort.server   = fServer;
     2453                    oPort.hostMode = ePortMode;
     2454                except:
     2455                    fRc = reporter.errorXcpt('failed to configure the serial port');
     2456                else:
     2457                    reporter.log('set SerialPort[%s].hostMode/path/server=%s/%s/%s'
     2458                                 % (iSerialPort, ePortMode, sPath, fServer));
     2459                    fRc = True;
     2460        self.oTstDrv.processPendingEvents();
     2461        return fRc;
     2462
    24072463    #
    24082464    # IConsole wrappers.
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