docs: def createVM(rh):
      """
      Create a virtual machine in z/VM.
  
      Input:
         Request Handle with the following properties:
            function    - 'CMDVM'
            subfunction - 'CMD'
            userid      - userid of the virtual machine
  
      Output:
         Request Handle updated with the results.
         Return code - 0: ok, non-zero: error
      """
  
      rh.printSysLog("Enter makeVM.createVM")
  
      dirLines = []
      dirLines.append("USER " + rh.userid + " " + rh.parms['pw'] +
           " " + rh.parms['priMemSize'] + " " +
           rh.parms['maxMemSize'] + " " + rh.parms['privClasses'])
      if 'profName' in rh.parms:
          dirLines.append("INCLUDE " + rh.parms['profName'])
  
      if 'maxCPU' in rh.parms:
          dirLines.append("MACHINE ESA %i" % rh.parms['maxCPU'])
  
      dirLines.append("CPU 00 BASE")
      if 'cpuCnt' in rh.parms:
          for i in range(1, rh.parms['cpuCnt']):
              dirLines.append("CPU %0.2X" % i)
  
      if 'ipl' in rh.parms:
          ipl_string = "IPL %s " % rh.parms['ipl']
  
          if 'iplParam' in rh.parms:
              ipl_string += ("PARM %s " % rh.parms['iplParam'])
  
          if 'iplLoadparam' in rh.parms:
              ipl_string += ("LOADPARM %s " % rh.parms['iplLoadparam'])
  
          dirLines.append(ipl_string)
  
      if 'byUsers' in rh.parms:
          for user in rh.parms['byUsers']:
              dirLines.append("LOGONBY " + user)
  
      priMem = rh.parms['priMemSize'].upper()
      maxMem = rh.parms['maxMemSize'].upper()
      if 'setReservedMem' in rh.parms and (priMem != maxMem):
          reservedSize = getReservedMemSize(rh, priMem, maxMem)
          if rh.results['overallRC'] != 0:
              rh.printSysLog("Exit makeVM.createVM, rc: " +
                     str(rh.results['overallRC']))
              return rh.results['overallRC']
          if reservedSize != '0M':
              dirLines.append("COMMAND DEF STOR RESERVED %s" % reservedSize)
  
      # Construct the temporary file for the USER entry.
      fd, tempFile = mkstemp()
      to_write = '\n'.join(dirLines) + '\n'
      os.write(fd, to_write.encode())
      os.close(fd)
  
      parms = ["-T", rh.userid, "-f", tempFile]
      results = invokeSMCLI(rh, "Image_Create_DM", parms)
      if results['overallRC'] != 0:
          # SMAPI API failed.
          rh.printLn("ES", results['response'])
          rh.updateResults(results)    # Use results from invokeSMCLI
  
      os.remove(tempFile)
  
      rh.printSysLog("Exit makeVM.createVM, rc: " +
          str(rh.results['overallRC']))
      return rh.results['overallRC']