From 8e8985c69f621ec63a6029468cc29475bc785849 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 18 Mar 2019 17:53:14 +0700 Subject: [PATCH 1/2] Fix vcpus configuration for GNS3 VM on VMware. Ref #2738. --- gns3server/controller/gns3vm/vmware_gns3_vm.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gns3server/controller/gns3vm/vmware_gns3_vm.py b/gns3server/controller/gns3vm/vmware_gns3_vm.py index 2931de6d..a02fd26b 100644 --- a/gns3server/controller/gns3vm/vmware_gns3_vm.py +++ b/gns3server/controller/gns3vm/vmware_gns3_vm.py @@ -72,18 +72,19 @@ class VMwareGNS3VM(BaseGNS3VM): if ram % 4 != 0: raise GNS3VMError("Allocated memory {} for the GNS3 VM must be a multiple of 4".format(ram)) - available_vcpus = psutil.cpu_count() + available_vcpus = psutil.cpu_count(logical=True) if vcpus > available_vcpus: raise GNS3VMError("You have allocated too many vCPUs for the GNS3 VM! (max available is {} vCPUs)".format(available_vcpus)) try: pairs = VMware.parse_vmware_file(self._vmx_path) - pairs["numvcpus"] = str(vcpus) - cores_per_sockets = int(available_vcpus / psutil.cpu_count(logical=False)) - if cores_per_sockets >= 1: - pairs["cpuid.corespersocket"] = str(cores_per_sockets) - pairs["memsize"] = str(ram) - VMware.write_vmx_file(self._vmx_path, pairs) + if vcpus > 1: + pairs["numvcpus"] = str(vcpus) + cores_per_sockets = int(vcpus / psutil.cpu_count(logical=False)) + if cores_per_sockets > 1: + pairs["cpuid.corespersocket"] = str(cores_per_sockets) + pairs["memsize"] = str(ram) + VMware.write_vmx_file(self._vmx_path, pairs) log.info("GNS3 VM vCPU count set to {} and RAM amount set to {}".format(vcpus, ram)) except OSError as e: raise GNS3VMError('Could not read/write VMware VMX file "{}": {}'.format(self._vmx_path, e)) From e291ec1eb902d0ae42e48d375e166efe8af6daf2 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 18 Mar 2019 18:05:40 +0700 Subject: [PATCH 2/2] Fix IOU symlink issue on remote servers. --- gns3server/compute/iou/iou_vm.py | 7 +++++++ gns3server/compute/project.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index 53cfe25d..e4b5e8c0 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -662,6 +662,13 @@ class IOUVM(BaseNode): pass self._iou_process = None + try: + symlink = os.path.join(self.working_dir, os.path.basename(self.path)) + if os.path.islink(symlink): + os.unlink(symlink) + except OSError as e: + log.warning("Could not delete symbolic link: {}".format(e)) + self._started = False self.save_configs() diff --git a/gns3server/compute/project.py b/gns3server/compute/project.py index ee2b1c19..f94c0ca3 100644 --- a/gns3server/compute/project.py +++ b/gns3server/compute/project.py @@ -415,7 +415,7 @@ class Project: """ files = [] - for dirpath, dirnames, filenames in os.walk(self.path): + for dirpath, dirnames, filenames in os.walk(self.path, followlinks=False): for filename in filenames: if not filename.endswith(".ghost"): path = os.path.relpath(dirpath, self.path)