#NEWLINE# def setmem( vm_ , memory , config = False ) : #NEWLINE# #INDENT# "\n    Changes the amount of memory allocated to VM. The VM must be shutdown\n    for this to work.\n\n    memory is to be specified in MB\n    If config is True then we ask libvirt to modify the config as well\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' virt.setmem <domain> <size>\n        salt '*' virt.setmem my_domain 768\n    " #NEWLINE# if ( vm_state ( vm_ ) != 'shutdown' ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# dom = _get_domain ( vm_ ) #NEWLINE# flags = libvirt . VIR_DOMAIN_MEM_MAXIMUM #NEWLINE# if config : #NEWLINE# #INDENT# flags = ( flags | libvirt . VIR_DOMAIN_AFFECT_CONFIG ) #NEWLINE# #UNINDENT# ret1 = dom . setMemoryFlags ( ( memory * 1024 ) , flags ) #NEWLINE# ret2 = dom . setMemoryFlags ( ( memory * 1024 ) , libvirt . VIR_DOMAIN_AFFECT_CURRENT ) #NEWLINE# return ( ret1 == ret2 == 0 )