From 7269285b0ff8bbf58da964bd681cea11fa0e6539 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 2 Oct 2017 00:47:16 +0800 Subject: [PATCH] Add more information when qemu-img fails. --- gns3server/compute/qemu/qemu_vm.py | 12 +++++++----- gns3server/web/web_server.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index d782cbe7..e6a94e49 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1386,15 +1386,17 @@ class QemuVM(BaseNode): if not os.path.exists(disk): # create the disk try: - process = yield from asyncio.create_subprocess_exec(qemu_img_path, "create", "-o", - "backing_file={}".format(disk_image), - "-f", "qcow2", disk) + command = [qemu_img_path, "create", "-o", "backing_file={}".format(disk_image), "-f", "qcow2", disk] + command_string = " ".join(shlex.quote(s) for s in command) + log.info("Executing qemu-img with: {}".format(command_string)) + process = yield from asyncio.create_subprocess_exec(*command) retcode = yield from process.wait() if retcode is not None and retcode != 0: - raise QemuError("Could not create {} disk image".format(disk_name)) + raise QemuError("Could not create {} disk image: qemu-img returned with {}".format(disk_name, + retcode)) log.info("{} returned with {}".format(qemu_img_path, retcode)) except (OSError, subprocess.SubprocessError) as e: - raise QemuError("Could not create {} disk image {}".format(disk_name, e)) + raise QemuError("Could not create {} disk image: {}".format(disk_name, e)) else: # The disk exists we check if the clone work try: diff --git a/gns3server/web/web_server.py b/gns3server/web/web_server.py index 9e17f0ba..d5b0be01 100644 --- a/gns3server/web/web_server.py +++ b/gns3server/web/web_server.py @@ -79,7 +79,7 @@ class WebServer: try: srv = self._loop.create_server(handler, self._host, self._port, ssl=ssl_context) self._server, startup_res = self._loop.run_until_complete(asyncio.gather(srv, self._app.startup(), loop=self._loop)) - except (OSError, asyncio.CancelledError) as e: + except (RuntimeError, OSError, asyncio.CancelledError) as e: log.critical("Could not start the server: {}".format(e)) return False return True