mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-31 21:33:49 +02:00
Use console port to allocate guest CID (console ID) for Qemu VMs. Fixes #2804
This commit is contained in:
parent
9cce4de190
commit
61c87e57a4
@ -53,12 +53,19 @@ class Qemu(BaseManager):
|
|||||||
:returns: QemuVM instance
|
:returns: QemuVM instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
async with self._guest_cid_lock:
|
node = await super().create_node(*args, **kwargs)
|
||||||
# wait for a node to be completely created before adding a new one
|
|
||||||
# this is important otherwise we allocate the same application ID
|
# allocate a guest console ID (CID)
|
||||||
# when creating multiple Qemu VMs at the same time
|
if node.console_type != "none" and node.console:
|
||||||
guest_cid = get_next_guest_cid(self.nodes)
|
# by default, the guest CID is equal to the console port
|
||||||
node = await super().create_node(*args, guest_cid=guest_cid, **kwargs)
|
node.guest_cid = node.console
|
||||||
|
else:
|
||||||
|
# otherwise pick a guest CID if no console port is configured
|
||||||
|
async with self._guest_cid_lock:
|
||||||
|
# wait for a node to be completely created before adding a new one
|
||||||
|
# this is important otherwise we allocate the same guest ID
|
||||||
|
# when creating multiple Qemu VMs at the same time
|
||||||
|
node.guest_cid = get_next_guest_cid(self.nodes)
|
||||||
return node
|
return node
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -67,7 +67,7 @@ class QemuVM(BaseNode):
|
|||||||
:param platform: Platform to emulate
|
:param platform: Platform to emulate
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, node_id, project, manager, guest_cid=None, linked_clone=True, qemu_path=None, console=None, console_type="telnet", platform=None):
|
def __init__(self, name, node_id, project, manager, linked_clone=True, qemu_path=None, console=None, console_type="telnet", platform=None):
|
||||||
|
|
||||||
super().__init__(name, node_id, project, manager, console=console, console_type=console_type, linked_clone=linked_clone, wrap_console=True)
|
super().__init__(name, node_id, project, manager, console=console, console_type=console_type, linked_clone=linked_clone, wrap_console=True)
|
||||||
server_config = manager.config.get_section_config("Server")
|
server_config = manager.config.get_section_config("Server")
|
||||||
@ -80,7 +80,7 @@ class QemuVM(BaseNode):
|
|||||||
self._qemu_img_stdout_file = ""
|
self._qemu_img_stdout_file = ""
|
||||||
self._execute_lock = asyncio.Lock()
|
self._execute_lock = asyncio.Lock()
|
||||||
self._local_udp_tunnels = {}
|
self._local_udp_tunnels = {}
|
||||||
self._guest_cid = guest_cid
|
self._guest_cid = None
|
||||||
|
|
||||||
# QEMU VM settings
|
# QEMU VM settings
|
||||||
if qemu_path:
|
if qemu_path:
|
||||||
@ -128,13 +128,23 @@ class QemuVM(BaseNode):
|
|||||||
@property
|
@property
|
||||||
def guest_cid(self):
|
def guest_cid(self):
|
||||||
"""
|
"""
|
||||||
Returns guest_cid (console ID) which unique identifier between 3 and 65535
|
Returns the CID (console ID) which is an unique identifier between 3 and 65535
|
||||||
|
|
||||||
:returns: integer between 3 and 65535
|
:returns: integer between 3 and 65535
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self._guest_cid
|
return self._guest_cid
|
||||||
|
|
||||||
|
@guest_cid.setter
|
||||||
|
def guest_cid(self, guest_cid):
|
||||||
|
"""
|
||||||
|
Set the CID (console ID) which is an unique identifier between 3 and 65535
|
||||||
|
|
||||||
|
:returns: integer between 3 and 65535
|
||||||
|
"""
|
||||||
|
|
||||||
|
self._guest_cid = guest_cid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def monitor(self):
|
def monitor(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user