Richard W.M. Jones dfd9fac743 v2v: Copy static IP address information over for Windows guests (RHBZ#1626503).
For Linux the guest itself remembers the IP address associated with
each MAC address.  Thus it doesn't matter if the interface type
changes (ie. to virtio-net), because as long as we preserve the MAC
address the guest will use the same IP address or the same DHCP
configuration.

However on Windows this association is not maintained by MAC address.
In fact the MAC address isn't saved anywhere in the guest registry.
(It seems instead this is likely done through PCI device type and
address which we don't record at the moment and is almost impossible
to preserve.)  When a guest which doesn't use DHCP is migrated, the
guest sees the brand new virtio-net devices and doesn't know what to
do with them, and meanwhile the right static IPs are still associated
with the old and now-defunct interfaces in the registry.

We cannot collect the required information from within the guest.
However we can collect it outside the tool by some other means
(eg. using VMware Tools APIs) and present this information to virt-v2v
which then writes it into the Windows guest at firstboot time.

This commit adds the --mac ..:ip:.. sub-option which creates a
Powershell script to set network adapters at firstboot.  An option
such as:

  --mac 00:0c:29:e6:3d:9d:ip:192.168.0.89,192.168.0.1,24,192.168.0.254

approximately turns into this script:

  # Wait for the netkvm (virtio-net) driver to become active.
  $adapters = @()
  While (-Not $adapters) {
      Start-Sleep -Seconds 5
      $adapters = Get-NetAdapter -Physical |
                     Where DriverFileName -eq "netkvm.sys"
  }
  $mac_address = '00-0c-29-e6-3d-9d'
  $ifindex = (Get-NetAdapter -Physical |
                 Where MacAddress -eq $mac_address).ifIndex
  if ($ifindex) {
      New-NetIPAddress -InterfaceIndex $ifindex
                       -IPAddress '192.168.0.89'
                       -DefaultGateway '192.168.0.1'
                       -PrefixLength 24
      Set-DnsClientServerAddress -InterfaceIndex $ifindex
                       -ServerAddresses ('192.168.0.254')
  }

Thanks: Brett Thurber for diagnosing the problem and suggesting paths
towards a fix.
2019-10-08 13:32:34 +01:00
2019-08-20 17:32:19 +01:00
2019-09-10 17:52:16 +02:00
2019-04-23 18:08:19 +02:00
2019-09-10 17:52:16 +02:00
2019-09-10 17:52:16 +02:00
2011-11-08 14:43:07 +00:00
2019-04-23 18:08:19 +02:00
2019-04-23 18:08:19 +02:00
2019-04-23 18:08:19 +02:00
2019-04-23 18:08:19 +02:00
2019-04-23 18:08:19 +02:00
2019-09-10 17:52:16 +02:00
2019-01-23 13:05:59 +00:00
2019-01-08 11:58:30 +00:00
2019-01-08 11:58:30 +00:00
2019-09-10 16:40:17 +01:00
2019-09-10 17:52:16 +02:00
2019-01-08 11:58:30 +00:00
2019-09-10 17:52:16 +02:00
2019-09-10 17:52:16 +02:00
2019-01-08 11:58:30 +00:00
2019-01-08 11:58:30 +00:00
2019-01-08 11:58:30 +00:00
2018-02-22 15:06:13 +00:00
2019-01-08 11:58:30 +00:00
2019-01-08 11:58:30 +00:00
2019-09-10 17:52:16 +02:00
2013-01-24 15:00:49 +00:00
2019-09-02 10:12:38 +01:00
2017-01-26 15:05:46 +00:00
2019-09-10 17:52:16 +02:00
2019-09-10 17:52:16 +02:00
2019-09-06 09:42:35 +01:00
2019-01-08 11:58:30 +00:00
2019-09-02 19:45:12 +01:00
2016-02-10 14:15:05 +01:00

Libguestfs is tools and a library for accessing and modifying guest
disk images.  For more information see the home page:

  http://libguestfs.org/

For discussion, development, patches, etc. please use the mailing
list:

  http://www.redhat.com/mailman/listinfo/libguestfs

To find out how to build libguestfs from source, read:

  docs/guestfs-building.pod
  http://libguestfs.org/guestfs-building.1.html
  man docs/guestfs-building.1

Copyright (C) 2009-2019 Red Hat Inc.

The library is distributed under the LGPLv2+.  The programs are
distributed under the GPLv2+.  Please see the files COPYING and
COPYING.LIB for full license information.  The examples are under a
very liberal license.
Languages
C 42.7%
OCaml 35.5%
Shell 7.1%
Makefile 4%
Perl 2.6%
Other 8%