[gnome-boxes/dont-clone-mac-address] libvirt-machine: Recreate network interface while cloning
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/dont-clone-mac-address] libvirt-machine: Recreate network interface while cloning
- Date: Wed, 17 Oct 2018 11:43:27 +0000 (UTC)
commit 73e91a4d5cfebfa20b031d801e1c6f582a9399cd
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Oct 17 13:32:31 2018 +0200
libvirt-machine: Recreate network interface while cloning
While cloning a libvirt machine, Boxes copies the literal VM XML
config and duplicates it into a newly created machine. This way
the machines are expected to be identical.
Users won't ever want to have two Boxes with the same mac address.
A common use-case for Boxes is for someone to create and configure
a single box and clone it into multiple instances.
Therefore after duplicating the machine's XML, we now re-add the
network interface, this way the cloned machine will have a different
MAC address than the original one.
Fixes #262
src/libvirt-machine.vala | 7 +++++++
1 file changed, 7 insertions(+)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 63a94797..cd8d87f9 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -696,6 +696,13 @@ public override async void clone () {
config.set_uuid (null);
var media = new LibvirtClonedMedia (storage_volume.get_path (), config);
+
+ // Recreate network interface so clones won't have the same mac address
+ var iface= VMConfigurator.create_network_interface (config,
+ is_libvirt_bridge_net_available (),
+ media.supports_virtio_net);
+ config.add_device (iface);
+
var vm_cloner = media.get_vm_creator ();
var clone_machine = yield vm_cloner.create_vm (null);
vm_cloner.launch_vm (clone_machine, this.config.access_last_time);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]