Re: [et-mgmt-tools] [PATCH] [RESEND]Check the making domain's mac address(part 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hugh

Hugh Brock wrote:
Actually now that I have thought some more about this, I don't think we
want to apply it at all.

The current semantics of the --mac flag are as follows:

1. If --mac is specified, attempt to use that address. If it conflicts
with an in-use address, fail with an error

2. If --mac is not specified, choose an unused mac address at random.

You would like to add the case wherein if --mac is specified and
conflicts with an existing mac address, a user can override the
conflict. However, we want operations with virt-install to be scriptable
-- that is, we do not ever want the script to halt waiting for input
unless it is obviously being run interactively. This means that, since a
mac address is never entered at a prompt, we can't put up a warning if
it conflicts. And I don't think we want to change the semantics to
always prompt for a mac address if it is not specified, since most users
aren't going to care what the mac address is anyway.

One way we could address the underlying problem is to change the
mac-address conflict checking code in VirtualNetworkInterface.setup() so
that it prints a warning to the console or logs it, but continues with
the guest creation. I'm fine with this behavior, since it seems
reasonable to me that an installer might want to have multiple inactive
guests with the same mac address. Another alternative would be to fail
if there is an active guest with the same mac address, but only print a
warning (and continue) if there is an inactive guest with the same mac
address. I would take a patch for either scenario.

I agree with your suggestion.
I rewrite a patch that the mac-address conflict checking code in
VirtualNetworkInterface.setup() so that it prints a warning to
the stderr and logs.

Thanks,
Tatsuro Enokura
diff -r 36a9973c2e28 virtinst/Guest.py
--- a/virtinst/Guest.py	Tue Mar 27 08:13:38 2007 -0400
+++ b/virtinst/Guest.py	Wed Mar 28 14:17:05 2007 +0900
@@ -209,6 +209,12 @@ class VirtualNetworkInterface:
         for id in ids:
             vm = conn.lookupByID(id)
             vms.append(vm)
+        # get inactive Domains
+        inactive_vm = []
+        names = conn.listDefinedDomains()
+        for name in names:
+            vm = conn.lookupByName(name)
+            inactive_vm.append(vm)
 
         # get the Host's NIC MACaddress
         hostdevs = util.get_host_network_devices()
@@ -227,6 +233,10 @@ class VirtualNetworkInterface:
             for (dummy, dummy, dummy, dummy, host_macaddr) in hostdevs:
                 if self.macaddr.upper() == host_macaddr.upper():
                     raise RuntimeError, "The MAC address you entered conflicts with the physical NIC."
+            if self.countMACaddr(inactive_vm) > 0:
+                msg = "The MAC address you entered is already in use by another inactive guest!"
+                print >> sys.stderr, msg
+                logging.warning(msg)
 
         if not self.bridge and self.type == "bridge":
             self.bridge = util.default_bridge()

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux