mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-27 09:18:09 +00:00
Merge pull request #1986 from GNS3/remove-qemu-legacy-networking
Remove Qemu legacy networking support
This commit is contained in:
commit
16ac9358df
@ -146,7 +146,6 @@ class QemuVM(BaseNode):
|
|||||||
self._initrd = ""
|
self._initrd = ""
|
||||||
self._kernel_image = ""
|
self._kernel_image = ""
|
||||||
self._kernel_command_line = ""
|
self._kernel_command_line = ""
|
||||||
self._legacy_networking = False
|
|
||||||
self._replicate_network_connection_state = True
|
self._replicate_network_connection_state = True
|
||||||
self._create_config_disk = False
|
self._create_config_disk = False
|
||||||
self._on_close = "power_off"
|
self._on_close = "power_off"
|
||||||
@ -679,30 +678,6 @@ class QemuVM(BaseNode):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def legacy_networking(self):
|
|
||||||
"""
|
|
||||||
Returns either QEMU legacy networking commands are used.
|
|
||||||
|
|
||||||
:returns: boolean
|
|
||||||
"""
|
|
||||||
|
|
||||||
return self._legacy_networking
|
|
||||||
|
|
||||||
@legacy_networking.setter
|
|
||||||
def legacy_networking(self, legacy_networking):
|
|
||||||
"""
|
|
||||||
Sets either QEMU legacy networking commands are used.
|
|
||||||
|
|
||||||
:param legacy_networking: boolean
|
|
||||||
"""
|
|
||||||
|
|
||||||
if legacy_networking:
|
|
||||||
log.info(f'QEMU VM "{self._name}" [{self._id}] has enabled legacy networking')
|
|
||||||
else:
|
|
||||||
log.info(f'QEMU VM "{self._name}" [{self._id}] has disabled legacy networking')
|
|
||||||
self._legacy_networking = legacy_networking
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def replicate_network_connection_state(self):
|
def replicate_network_connection_state(self):
|
||||||
"""
|
"""
|
||||||
@ -2208,16 +2183,6 @@ class QemuVM(BaseNode):
|
|||||||
["-net", "none"]
|
["-net", "none"]
|
||||||
) # we do not want any user networking back-end if no adapter is connected.
|
) # we do not want any user networking back-end if no adapter is connected.
|
||||||
|
|
||||||
patched_qemu = False
|
|
||||||
if self._legacy_networking:
|
|
||||||
qemu_version = await self.manager.get_qemu_version(self.qemu_path)
|
|
||||||
if qemu_version:
|
|
||||||
if parse_version(qemu_version) >= parse_version("2.9.0"):
|
|
||||||
raise QemuError("Qemu version 2.9.0 and later doesn't support legacy networking mode")
|
|
||||||
if parse_version(qemu_version) < parse_version("1.1.0"):
|
|
||||||
# this is a patched Qemu if version is below 1.1.0
|
|
||||||
patched_qemu = True
|
|
||||||
|
|
||||||
# Each 32 PCI device we need to add a PCI bridge with max 9 bridges
|
# Each 32 PCI device we need to add a PCI bridge with max 9 bridges
|
||||||
pci_devices = 4 + len(self._ethernet_adapters) # 4 PCI devices are use by default by qemu
|
pci_devices = 4 + len(self._ethernet_adapters) # 4 PCI devices are use by default by qemu
|
||||||
pci_bridges = math.floor(pci_devices / 32)
|
pci_bridges = math.floor(pci_devices / 32)
|
||||||
@ -2244,38 +2209,6 @@ class QemuVM(BaseNode):
|
|||||||
if custom_mac_address:
|
if custom_mac_address:
|
||||||
mac = int_to_macaddress(macaddress_to_int(custom_mac_address))
|
mac = int_to_macaddress(macaddress_to_int(custom_mac_address))
|
||||||
|
|
||||||
if self._legacy_networking:
|
|
||||||
# legacy QEMU networking syntax (-net)
|
|
||||||
if nio:
|
|
||||||
network_options.extend(["-net", f"nic,vlan={adapter_number},macaddr={mac},model={adapter_type}"])
|
|
||||||
if isinstance(nio, NIOUDP):
|
|
||||||
if patched_qemu:
|
|
||||||
# use patched Qemu syntax
|
|
||||||
network_options.extend(
|
|
||||||
[
|
|
||||||
"-net",
|
|
||||||
"udp,vlan={},name=gns3-{},sport={},dport={},daddr={}".format(
|
|
||||||
adapter_number, adapter_number, nio.lport, nio.rport, nio.rhost
|
|
||||||
),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# use UDP tunnel support added in Qemu 1.1.0
|
|
||||||
network_options.extend(
|
|
||||||
[
|
|
||||||
"-net",
|
|
||||||
"socket,vlan={},name=gns3-{},udp={}:{},localaddr={}:{}".format(
|
|
||||||
adapter_number, adapter_number, nio.rhost, nio.rport, "127.0.0.1", nio.lport
|
|
||||||
),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
elif isinstance(nio, NIOTAP):
|
|
||||||
network_options.extend(["-net", f"tap,name=gns3-{adapter_number},ifname={nio.tap_device}"])
|
|
||||||
else:
|
|
||||||
network_options.extend(["-net", f"nic,vlan={adapter_number},macaddr={mac},model={adapter_type}"])
|
|
||||||
|
|
||||||
else:
|
|
||||||
# newer QEMU networking syntax
|
|
||||||
device_string = f"{adapter_type},mac={mac}"
|
device_string = f"{adapter_type},mac={mac}"
|
||||||
bridge_id = math.floor(pci_device_id / 32)
|
bridge_id = math.floor(pci_device_id / 32)
|
||||||
if bridge_id > 0:
|
if bridge_id > 0:
|
||||||
|
@ -201,7 +201,6 @@ class QemuTemplate(Template):
|
|||||||
kernel_image = Column(String)
|
kernel_image = Column(String)
|
||||||
bios_image = Column(String)
|
bios_image = Column(String)
|
||||||
kernel_command_line = Column(String)
|
kernel_command_line = Column(String)
|
||||||
legacy_networking = Column(Boolean)
|
|
||||||
replicate_network_connection_state = Column(Boolean)
|
replicate_network_connection_state = Column(Boolean)
|
||||||
create_config_disk = Column(Boolean)
|
create_config_disk = Column(Boolean)
|
||||||
on_close = Column(String)
|
on_close = Column(String)
|
||||||
|
@ -195,7 +195,6 @@ class QemuBase(BaseModel):
|
|||||||
mac_address: Optional[str] = Field(
|
mac_address: Optional[str] = Field(
|
||||||
None, description="QEMU MAC address", regex="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
|
None, description="QEMU MAC address", regex="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
|
||||||
)
|
)
|
||||||
legacy_networking: Optional[bool] = Field(None, description="Use QEMU legagy networking commands (-net syntax)")
|
|
||||||
replicate_network_connection_state: Optional[bool] = Field(
|
replicate_network_connection_state: Optional[bool] = Field(
|
||||||
None, description="Replicate the network connection state for links in Qemu"
|
None, description="Replicate the network connection state for links in Qemu"
|
||||||
)
|
)
|
||||||
|
@ -74,7 +74,6 @@ class QemuTemplate(TemplateBase):
|
|||||||
kernel_image: Optional[str] = Field("", description="QEMU kernel image path")
|
kernel_image: Optional[str] = Field("", description="QEMU kernel image path")
|
||||||
bios_image: Optional[str] = Field("", description="QEMU bios image path")
|
bios_image: Optional[str] = Field("", description="QEMU bios image path")
|
||||||
kernel_command_line: Optional[str] = Field("", description="QEMU kernel command line")
|
kernel_command_line: Optional[str] = Field("", description="QEMU kernel command line")
|
||||||
legacy_networking: Optional[bool] = Field(False, description="Use QEMU legagy networking commands (-net syntax)")
|
|
||||||
replicate_network_connection_state: Optional[bool] = Field(
|
replicate_network_connection_state: Optional[bool] = Field(
|
||||||
True, description="Replicate the network connection state for links in Qemu"
|
True, description="Replicate the network connection state for links in Qemu"
|
||||||
)
|
)
|
||||||
|
@ -748,7 +748,6 @@ class TestQemuTemplate:
|
|||||||
"initrd": "",
|
"initrd": "",
|
||||||
"kernel_command_line": "",
|
"kernel_command_line": "",
|
||||||
"kernel_image": "",
|
"kernel_image": "",
|
||||||
"legacy_networking": False,
|
|
||||||
"linked_clone": True,
|
"linked_clone": True,
|
||||||
"mac_address": "",
|
"mac_address": "",
|
||||||
"name": "Qemu template",
|
"name": "Qemu template",
|
||||||
|
Loading…
Reference in New Issue
Block a user