Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2v: Implement MAC address to network/bridge mapping.
This allows specific NICs (identified by their source MAC address) to be mapped to networks or bridges on the target. You can use the --mac parameter to select this mapping, eg: $ virt-v2v ... \ --mac 52:54:00:d0:cf:0e:network:mgmt \ --mac 52:54:00:d0:cf:0f:network:clientdata The old --network and --bridge mappings can also be used but --mac takes precedence. Note this does not adjust MAC addresses inside the guest which is a hard problem to solve. For this to work you must still carry over the MAC addresses from the source to target hypervisor as that is how most guests identify and associate functions with specific network interfaces.
- Loading branch information
Showing
10 changed files
with
304 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<interface type='bridge'> | ||
<source bridge='VM Network'/> | ||
</interface> | ||
<interface type='network'> | ||
<!-- NIC mapped by MAC address to Network:nancy --> | ||
<source network='nancy'/> | ||
<mac address='52:54:00:01:02:03'/> | ||
</interface> | ||
<interface type='bridge'> | ||
<!-- NIC mapped by MAC address to Bridge:bob --> | ||
<source bridge='bob'/> | ||
<mac address='52:54:00:01:02:04'/> | ||
</interface> | ||
<interface type='network'> | ||
<!-- network mapped from "john" to default "default_network" --> | ||
<source network='default_network'/> | ||
<mac address='52:54:00:01:02:05'/> | ||
</interface> | ||
<interface type='network'> | ||
<!-- network mapped from "paul" to default "default_network" --> | ||
<source network='default_network'/> | ||
<mac address='52:54:00:01:02:06'/> | ||
</interface> | ||
<interface type='network'> | ||
<!-- network mapped from "george" to default "default_network" --> | ||
<source network='default_network'/> | ||
<mac address='52:54:00:01:02:07'/> | ||
</interface> | ||
<interface type='bridge'> | ||
<source bridge='ringo'/> | ||
<mac address='52:54:00:01:02:08'/> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash - | ||
# libguestfs virt-v2v test script | ||
# Copyright (C) 2014-2018 Red Hat Inc. | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
# Test --mac parameter. | ||
|
||
set -e | ||
|
||
$TEST_FUNCTIONS | ||
skip_if_skipped | ||
skip_if_backend uml | ||
skip_unless_phony_guest windows.img | ||
|
||
libvirt_uri="test://$abs_builddir/test-v2v-mac.xml" | ||
f=$top_builddir/test-data/phony-guests/windows.img | ||
|
||
export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools" | ||
|
||
d=test-v2v-mac.d | ||
rm -rf $d | ||
mkdir $d | ||
|
||
# Use --no-copy because we only care about metadata for this test. | ||
$VG virt-v2v --debug-gc \ | ||
-i libvirt -ic "$libvirt_uri" windows \ | ||
-o local -os $d --no-copy \ | ||
--mac 52:54:00:01:02:03:network:nancy \ | ||
--mac 52:54:00:01:02:04:bridge:bob \ | ||
--network default_network | ||
|
||
# Test the libvirt XML metadata was created. | ||
test -f $d/windows.xml | ||
|
||
# Extract just the network interfaces from the XML. | ||
# Delete the network model XML because that can change depending | ||
# on whether virtio-win is installed or not. | ||
sed -n '/interface/,/\/interface/p' $d/windows.xml | | ||
grep -v 'model type=' > $d/networks | ||
|
||
# Test that the output has mapped the networks and bridges correctly. | ||
diff -ur test-v2v-mac-expected.xml $d/networks | ||
|
||
rm -r $d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!-- | ||
libguestfs virt-v2v tool | ||
Copyright (C) 2009-2018 Red Hat Inc. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
--> | ||
<node> | ||
<domain type='test'> | ||
<name>windows</name> | ||
<memory>1048576</memory> | ||
<os> | ||
<type>hvm</type> | ||
<boot dev='hd'/> | ||
</os> | ||
<devices> | ||
<disk type='file' device='disk'> | ||
<driver name='qemu' type='raw'/> | ||
<source file='../test-data/phony-guests/windows.img'/> | ||
<target dev='vda' bus='virtio'/> | ||
</disk> | ||
|
||
<!-- standard ESX bridge --> | ||
<interface type='bridge'> | ||
<mac address='00:00:00:00:00:00'/> | ||
<source bridge='VM Network'/> | ||
<model type='e1000'/> | ||
</interface> | ||
|
||
<!-- various different NICs which can be remapped --> | ||
|
||
<interface type='bridge'> | ||
<mac address='52:54:00:01:02:03'/> | ||
<source bridge='bob'/> | ||
<model type='e1000'/> | ||
</interface> | ||
|
||
<interface type='network'> | ||
<mac address='52:54:00:01:02:04'/> | ||
<source network='default'/> | ||
<model type='virtio'/> | ||
</interface> | ||
|
||
<interface type='network'> | ||
<mac address='52:54:00:01:02:05'/> | ||
<source network='john'/> | ||
<model type='virtio'/> | ||
</interface> | ||
|
||
<interface type='network'> | ||
<source network='paul'/> | ||
<model type='virtio'/> | ||
<mac address='52:54:00:01:02:06'/> | ||
</interface> | ||
|
||
<interface type='network'> | ||
<model type='rtl8139'/> | ||
<source network='george'/> | ||
<mac address='52:54:00:01:02:07'/> | ||
</interface> | ||
|
||
<interface type='bridge'> | ||
<mac address='52:54:00:01:02:08'/> | ||
<model type='virtio'/> | ||
<source bridge='ringo'/> | ||
</interface> | ||
|
||
</devices> | ||
</domain> | ||
</node> |
Oops, something went wrong.