Revision 86af067e util/vm/build.py

View differences:

util/vm/build.py
435 435
    log( '* Ubuntu installation completed in %.2f seconds' % elapsed )
436 436

  
437 437

  
438
def boot( cow, kernel, initrd, logfile, memory=1024 ):
438
def boot( cow, kernel, initrd, logfile, memory=1024, cpuCores=1 ):
439 439
    """Boot qemu/kvm with a COW disk and local/user data store
440 440
       cow: COW disk path
441 441
       kernel: kernel path
442 442
       logfile: log file for pexpect object
443 443
       memory: memory size in MB
444
       cpuCores: number of CPU cores to use
444 445
       returns: pexpect object to qemu process"""
445 446
    # pexpect might not be installed until after depend() is called
446 447
    global pexpect
......
469 470
            '-append "root=/dev/vda1 init=/sbin/init console=ttyS0" ' ]
470 471
    if Forward:
471 472
        cmd += sum( [ [ '-redir', f ] for f in Forward ], [] )
473
    if cpuCores > 1:
474
        cmd += [ '-smp cores=%s' % cpuCores ]
472 475
    cmd = ' '.join( cmd )
473 476
    log( '* BOOTING VM FROM', cow )
474 477
    log( cmd )
......
881 884
    return version
882 885

  
883 886

  
884
def bootAndRun( image, prompt=Prompt, memory=1024, outputFile=None,
887
def bootAndRun( image, prompt=Prompt, memory=1024, cpuCores=1, outputFile=None,
885 888
                runFunction=None, **runArgs ):
886 889
    """Boot and test VM
887 890
       tests: list of tests to run
888 891
       pre: command line to run in VM before tests
889 892
       post: command line to run in VM after tests
890 893
       prompt: shell prompt (default '$ ')
891
       memory: VM memory size in MB"""
894
       memory: VM memory size in MB
895
       cpuCores: number of CPU cores to use"""
892 896
    bootTestStart = time()
893 897
    basename = path.basename( image )
894 898
    image = abspath( image )
......
906 910
                                      suffix='.testlog', delete=False )
907 911
    log( '* Logging VM output to', logfile.name )
908 912
    vm = boot( cow=cow, kernel=kernel, initrd=initrd, logfile=logfile,
909
               memory=memory )
913
               memory=memory, cpuCores=cpuCores )
910 914
    login( vm )
911 915
    log( '* Waiting for prompt after login' )
912 916
    vm.expect( prompt )

Also available in: Unified diff