mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-16 22:38:18 +00:00
API for creating a qemu disk image
This commit is contained in:
@ -189,7 +189,6 @@ class QemuVM(BaseVM):
|
||||
|
||||
:param hda_disk_image: QEMU hda disk image path
|
||||
"""
|
||||
|
||||
self._hda_disk_image = self.manager.get_abs_image_path(hda_disk_image)
|
||||
log.info('QEMU VM "{name}" [{id}] has set the QEMU hda disk image path to {disk_image}'.format(name=self._name,
|
||||
id=self._id,
|
||||
@ -1242,31 +1241,3 @@ class QemuVM(BaseVM):
|
||||
answer["kernel_image_md5sum"] = md5sum(self._kernel_image)
|
||||
|
||||
return answer
|
||||
|
||||
@asyncio.coroutine
|
||||
def _create_disk(self, name, options):
|
||||
"""
|
||||
Create a qemu disk with qemu-img
|
||||
|
||||
:param name: Image name without the extension
|
||||
:param options: Disk image creation options
|
||||
:returns: Image name with the extensions
|
||||
"""
|
||||
|
||||
img_format = options.pop("format")
|
||||
img_size = options.pop("size")
|
||||
img_name = "{}.{}".format(name, img_format)
|
||||
|
||||
qemu_img = self._get_qemu_img()
|
||||
command = [qemu_img, "create", "-f", img_format]
|
||||
for option in sorted(options.keys()):
|
||||
command.extend(["-o", "{}={}".format(option, options[option])])
|
||||
command.append(os.path.join(self.working_dir, img_name))
|
||||
command.append("{}M".format(img_size))
|
||||
try:
|
||||
process = yield from asyncio.create_subprocess_exec(*command)
|
||||
yield from process.wait()
|
||||
except (OSError, subprocess.SubprocessError) as e:
|
||||
raise QemuError("Could create disk image {}:{}".format(name, e))
|
||||
|
||||
return img_name
|
||||
|
Reference in New Issue
Block a user