mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Remove default FLASH when no hda disk for Qemu VMs. Fixes #535.
This commit is contained in:
parent
8cc46f66c6
commit
f0649b4ac3
@ -1011,31 +1011,23 @@ class QemuVM(BaseVM):
|
|||||||
if not qemu_img_path:
|
if not qemu_img_path:
|
||||||
raise QemuError("Could not find qemu-img in {}".format(qemu_path_dir))
|
raise QemuError("Could not find qemu-img in {}".format(qemu_path_dir))
|
||||||
|
|
||||||
try:
|
if self._hda_disk_image:
|
||||||
if self._hda_disk_image:
|
if not os.path.isfile(self._hda_disk_image) or not os.path.exists(self._hda_disk_image):
|
||||||
if not os.path.isfile(self._hda_disk_image) or not os.path.exists(self._hda_disk_image):
|
if os.path.islink(self._hda_disk_image):
|
||||||
if os.path.islink(self._hda_disk_image):
|
raise QemuError("hda disk image '{}' linked to '{}' is not accessible".format(self._hda_disk_image, os.path.realpath(self._hda_disk_image)))
|
||||||
raise QemuError("hda disk image '{}' linked to '{}' is not accessible".format(self._hda_disk_image, os.path.realpath(self._hda_disk_image)))
|
else:
|
||||||
else:
|
raise QemuError("hda disk image '{}' is not accessible".format(self._hda_disk_image))
|
||||||
raise QemuError("hda disk image '{}' is not accessible".format(self._hda_disk_image))
|
hda_disk = os.path.join(self.working_dir, "hda_disk.qcow2")
|
||||||
hda_disk = os.path.join(self.working_dir, "hda_disk.qcow2")
|
if not os.path.exists(hda_disk):
|
||||||
if not os.path.exists(hda_disk):
|
try:
|
||||||
process = yield from asyncio.create_subprocess_exec(qemu_img_path, "create", "-o",
|
process = yield from asyncio.create_subprocess_exec(qemu_img_path, "create", "-o",
|
||||||
"backing_file={}".format(self._hda_disk_image),
|
"backing_file={}".format(self._hda_disk_image),
|
||||||
"-f", "qcow2", hda_disk)
|
"-f", "qcow2", hda_disk)
|
||||||
retcode = yield from process.wait()
|
retcode = yield from process.wait()
|
||||||
log.info("{} returned with {}".format(qemu_img_path, retcode))
|
log.info("{} returned with {}".format(qemu_img_path, retcode))
|
||||||
else:
|
except (OSError, subprocess.SubprocessError) as e:
|
||||||
# create a "FLASH" with 256MB if no disk image has been specified
|
raise QemuError("Could not create hda disk image {}".format(e))
|
||||||
hda_disk = os.path.join(self.working_dir, "flash.qcow2")
|
options.extend(["-hda", hda_disk])
|
||||||
if not os.path.exists(hda_disk):
|
|
||||||
process = yield from asyncio.create_subprocess_exec(qemu_img_path, "create", "-f", "qcow2", hda_disk, "256M")
|
|
||||||
retcode = yield from process.wait()
|
|
||||||
log.info("{} returned with {}".format(qemu_img_path, retcode))
|
|
||||||
|
|
||||||
except (OSError, subprocess.SubprocessError) as e:
|
|
||||||
raise QemuError("Could not create hda disk image {}".format(e))
|
|
||||||
options.extend(["-hda", hda_disk])
|
|
||||||
|
|
||||||
if self._hdb_disk_image:
|
if self._hdb_disk_image:
|
||||||
if not os.path.isfile(self._hdb_disk_image) or not os.path.exists(self._hdb_disk_image):
|
if not os.path.isfile(self._hdb_disk_image) or not os.path.exists(self._hdb_disk_image):
|
||||||
|
Loading…
Reference in New Issue
Block a user