Libxl stores maxmem in xenstore (/local/domain/X/memory/static-max) and sets maxmem and target_mem to actual memory. So qmemman should use xenstore entry as memory_maximum (when exists) and also adjust maxmem when changing domain memory.