VirtualBox

Ignore:
Timestamp:
Feb 8, 2011 1:20:04 AM (14 years ago)
Author:
vboxsync
Message:

Main, VMM, vboxshell: more PCI work (persistent settings, logging, more driver API), API consumer in vboxshell

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r35783 r35885  
    31033103    return
    31043104
     3105def parsePci(str):
     3106    pcire = re.compile(r'(?P<b>\d+):(?P<d>\d+)\.(?P<f>\d)')
     3107    m = pcire.search(str)
     3108    if m is None:
     3109        return -1
     3110    dict = m.groupdict()
     3111    return ((int(dict['b'])) << 8) | ((int(dict['d'])) << 3) | int(dict['f'])
    31053112
    31063113def lspciCmd(ctx, args):
     
    31123119        return 0
    31133120    cmdExistingVm(ctx, mach, 'guestlambda', [lambda ctx,mach,console,args:  lspci(ctx, console)])
     3121    return 0
     3122
     3123def attachpciCmd(ctx, args):
     3124    if (len(args) < 3):
     3125        print "usage: attachpci vm hostpci <guestpci>"
     3126        return 0
     3127    mach = argsToMach(ctx,args)
     3128    if mach == None:
     3129        return 0
     3130    hostaddr = parsePci(args[2])
     3131    if hostaddr == -1:
     3132        print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" %(args[2])
     3133        return 0
     3134
     3135    if (len(args) > 3):
     3136        guestaddr = parsePci(args[3])
     3137        if guestaddr == -1:
     3138            print "invalid guest PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" %(args[3])
     3139            return 0
     3140    else:
     3141        guestaddr = hostaddr
     3142    cmdClosedVm(ctx, mach, lambda ctx,mach,a: mach.attachHostPciDevice(hostaddr, guestaddr, True))
     3143    return 0
     3144
     3145def detachpciCmd(ctx, args):
     3146    if (len(args) < 3):
     3147        print "usage: detachpci vm hostpci"
     3148        return 0
     3149    mach = argsToMach(ctx,args)
     3150    if mach == None:
     3151        return 0
     3152    hostaddr = parsePci(args[2])
     3153    if hostaddr == -1:
     3154        print "invalid host PCI %s, accepted format 01:02.3 for bus 1, device 2, function 3" %(args[2])
     3155        return 0
     3156
     3157    cmdClosedVm(ctx, mach, 'guestlambda', lambda ctx,mach,a: mach.detachHostPciDevice(hostaddr))
    31143158    return 0
    31153159
     
    32003244            'recordDemo':['Record demo: recordDemo Win32 file.dmo 10', recordDemoCmd, 0],
    32013245            'playbackDemo':['Playback demo: playbackDemo Win32 file.dmo 10', playbackDemoCmd, 0],
    3202             'lspci': ['List PCI devices attached to the VM: lspci Win32', lspciCmd]
     3246            'lspci': ['List PCI devices attached to the VM: lspci Win32', lspciCmd, 0],
     3247            'attachpci': ['Attach host PCI device to the VM: attachpci Win32 01:00.0', attachpciCmd, 0],
     3248            'detachpci': ['Detach host PCI device from the VM: detachpci Win32 01:00.0', detachpciCmd, 0]
    32033249            }
    32043250
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