Overview
Comment: | More or less written command line interface to create vms. Fixed monitor path in the start.template |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e43aa4d9b252d87582143416070ac1b0 |
User & Date: | vitus on 2015-12-11 15:27:48 |
Other Links: | manifest | tags |
Context
2015-12-11
| ||
20:21 | Moved create functionality into main vws script check-in: 8f4a02281b user: vitus tags: trunk | |
15:27 | More or less written command line interface to create vms. Fixed monitor path in the start.template check-in: e43aa4d9b2 user: vitus tags: trunk | |
2015-11-18
| ||
14:44 | Implemented list --state. Fixed first start of vm, when no monitor socket exists yet check-in: 33f6d5eeca user: vitus tags: trunk | |
Changes
mkvm became executable with contents [c9b2ef6117].
︙ | ︙ |
Modified start.template from [8a854bae9d] to [f5e7877513].
︙ | ︙ | |||
20 21 22 23 24 25 26 | {qemubinary} -name $NAME {accel} \ -m {memory} {drive} \ {cdrom}$CDROM \ {net} \ {usb} \ {sound} \ | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | {qemubinary} -name $NAME {accel} \ -m {memory} {drive} \ {cdrom}$CDROM \ {net} \ {usb} \ {sound} \ -chardev socket,server,nowait,path=monitor,id=monitor \ -mon chardev=monitor,mode=readline \ -vga qxl \ -spice port=$SPICE_PORT,$SPICE_AUTH \ -device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent \ -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \ -device ich9-usb-ehci1,id=usb \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on \ -chardev spicevmc,name=usbredir,id=usbredirchardev1 \ -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 \ -daemonize -pidfile pid |
Added vwscreate version [fd646c2a4e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #!/usr/bin/python import os,sys from argparse import ArgumentParser libdir="/usr/local/lib/vws" drivename="drive0.qcow2" args = ArgumentParser() args.add_argument("--no-usb",help="Disable USB controller",action='store_const', const = False, default=True, dest="usb") args.add_argument("--size",help="Size of primary disk images",dest="size",default="20G"); args.add_argument("--arch",help="Emulated architecture",dest="arch",default='x86_64'); args.add_argument("--no-sound",help="Disable sound card",action='store_const',const = False, default=True, dest="sound") args.add_argument("--net",help="Network - 'user' or bridge name",dest='net',default="user") args.add_argument("--mem",help="Size of memory",dest="mem",default="1024M") args.add_argument("--diskif",help="Disk interface",dest="diskif",default="virtio") args.add_argument('name',type=str,help='name of machine to create') args.add_argument('--shared',help='Create shared VM instead of private one',action='store_const',const= True,dest='shared',default=False) args.add_Argumnen('--image',help='Existing disk image to import',dest=image,default=None)) parsed_args = args.parse_args(sys.argv[1:]) options={'qemubinary':'qemu-system-x86_64', "accel":"-enable-kvm", "memory":"1024M", "drive":"-drive media=disk,index=0,if={interface},file={image}", "cdrom":"-drive media=cdrom,index=2,if=ide", "sound":"-soundhw hda", "usb":"-usb"} macaddr=":".join(map(lambda x: "%02x"%random.randrange(0,256),range(0,5))) if parsed_args.net != 'user': options["net"]="-net nic,macaddr=%s -net bridge,br=%s"%(macaddr,parsed_args.net), else: options["net"]="-net nic,macaddr=%s -net user"%(macaddr,)) optons["qemubinary"] = 'qemu-system-'+parset_args.arch if not parsed_args.arch in ('i386','x86_64'): print >>sys.stderr,"KVM acceleration disabled due to target architecture" options.accel = '' elif not os.access("/dev/kvm",os.W_OK): print >>sys.stderr,"KVM acceleration disabled due to unavailability on the host system" options.accel = '' if not parsed_args.usb: options["usb"]='' if not parsed_args.sound: options["sound"]='' options["memory"]=parsed_args.mem # Creating directory for VM driveopts={"interface":parsed_args.diskif,"image":drivename} if parsed_args.image: # Copying image file print >>sys.stderr,"Copying %s to %s"%(parsed_args.image,machinedir+"/"+drivename) chdir(machinedir) else: print >>sys.stderr,"Creating new image file" os.chdir(machinedir) os.system("qemu-img create -f qcow2 %s %s"%(drivename,parsed_args.size)) options["drive"]=options["drive"].format(driveopts) with open(libdir+"/start.template","r") as f: template=f.read() with open("start","w") as script: print script,template.format(options), os.chmod(start,0755) # If installation media is specified vws start for new vm |