On 08/28/2017 02:47 PM, Fam Zheng wrote: [...]
+ def __init__(self, debug=False, vcpus=None): + self._guest = None + self._tmpdir = tempfile.mkdtemp(prefix="qemu-vm-") + atexit.register(shutil.rmtree, self._tmpdir) + + self._ssh_key_file = os.path.join(self._tmpdir, "id_rsa") + open(self._ssh_key_file, "w").write(SSH_KEY) + subprocess.check_call(["chmod", "600", self._ssh_key_file]) + + self._ssh_pub_key_file = os.path.join(self._tmpdir, "id_rsa.pub") + open(self._ssh_pub_key_file, "w").write(SSH_PUB_KEY) + + self.debug = debug + self._stderr = sys.stderr + self._devnull = open("/dev/null", "w") + if self.debug: + self._stdout = sys.stdout + else: + self._stdout = self._devnull + self._args = [ \ + "-nodefaults", "-m", "2G", + "-cpu", "host", + "-netdev", "user,id=vnet,hostfwd=:0.0.0.0:0-:22", + "-device", "virtio-net-pci,netdev=vnet", + "-vnc", ":0,to=20", + "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")] + if vcpus: + self._args += ["-smp", str(vcpus)]
What about enabling mttcg which isn't default? self._args += ["--accel", "tcg,thread=multi"]
+ if os.access("/dev/kvm", os.R_OK | os.W_OK): + self._args += ["-enable-kvm"] + else: + logging.info("KVM not available, not using -enable-kvm") + self._data_args = []
[...]