* [PATCH] Allow off-line NIC removal
@ 2009-03-12 1:43 John Levon
2009-03-12 10:59 ` Daniel P. Berrange
0 siblings, 1 reply; 2+ messages in thread
From: John Levon @ 2009-03-12 1:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User John Levon <john.levon@sun.com>
# Date 1236822173 25200
# Node ID 36e28c9e7757b49ce79f693f1bdf80ab8f2c8a33
# Parent ce97fa7ee861ff3c68468715431ce2b117b5cbee
Allow off-line NIC removal
Match a MAC address so device_destroy can remove off-line NICs.
Signed-off-by: John Levon <john.levon@sun.com>
diff --git a/tools/python/xen/xend/server/netif.py b/tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py
+++ b/tools/python/xen/xend/server/netif.py
@@ -24,7 +24,7 @@ import random
import random
import re
-from xen.xend import XendOptions
+from xen.xend import XendOptions, sxp
from xen.xend.server.DevController import DevController
from xen.xend.XendError import VmError
from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
@@ -196,3 +196,23 @@ class NetifController(DevController):
result[x] = y
return result
+
+ # match a VIF ID from xenstore, or a MAC address stored in the domain config
+ def convertToDeviceNumber(self, devid):
+ try:
+ return int(devid)
+ except ValueError:
+ if type(devid) is not str:
+ raise VmError("devid %s is wrong type" % str(devid))
+ try:
+ dev = devid.split('/')[-1]
+ return (int(dev))
+ except ValueError:
+ devs = [d for d in self.vm.info.all_devices_sxpr()
+ if d[0] == 'vif']
+ for nr in range(len(devs)):
+ dev_type, dev_info = devs[nr]
+ if (sxp.child_value(dev_info, 'mac').lower() ==
+ devid.lower()):
+ return nr
+ raise VmError("unknown devid %s" % str(devid))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Allow off-line NIC removal
2009-03-12 1:43 [PATCH] Allow off-line NIC removal John Levon
@ 2009-03-12 10:59 ` Daniel P. Berrange
0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrange @ 2009-03-12 10:59 UTC (permalink / raw)
To: John Levon; +Cc: xen-devel
On Wed, Mar 11, 2009 at 06:43:07PM -0700, John Levon wrote:
> # HG changeset patch
> # User John Levon <john.levon@sun.com>
> # Date 1236822173 25200
> # Node ID 36e28c9e7757b49ce79f693f1bdf80ab8f2c8a33
> # Parent ce97fa7ee861ff3c68468715431ce2b117b5cbee
> Allow off-line NIC removal
>
> Match a MAC address so device_destroy can remove off-line NICs.
>
> Signed-off-by: John Levon <john.levon@sun.com>
This patch looks good to me - libvirt needs the ability remove NICs
from inactive guests & there's a patch for this blocking on this
functionality in XenD. Disks already have a similar conversion
that allows use of /dev/XXX device names, so this gives parity of
functionality for NICs.
Daniel
>
> diff --git a/tools/python/xen/xend/server/netif.py b/tools/python/xen/xend/server/netif.py
> --- a/tools/python/xen/xend/server/netif.py
> +++ b/tools/python/xen/xend/server/netif.py
> @@ -24,7 +24,7 @@ import random
> import random
> import re
>
> -from xen.xend import XendOptions
> +from xen.xend import XendOptions, sxp
> from xen.xend.server.DevController import DevController
> from xen.xend.XendError import VmError
> from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
> @@ -196,3 +196,23 @@ class NetifController(DevController):
> result[x] = y
>
> return result
> +
> + # match a VIF ID from xenstore, or a MAC address stored in the domain config
> + def convertToDeviceNumber(self, devid):
> + try:
> + return int(devid)
> + except ValueError:
> + if type(devid) is not str:
> + raise VmError("devid %s is wrong type" % str(devid))
> + try:
> + dev = devid.split('/')[-1]
> + return (int(dev))
> + except ValueError:
> + devs = [d for d in self.vm.info.all_devices_sxpr()
> + if d[0] == 'vif']
> + for nr in range(len(devs)):
> + dev_type, dev_info = devs[nr]
> + if (sxp.child_value(dev_info, 'mac').lower() ==
> + devid.lower()):
> + return nr
> + raise VmError("unknown devid %s" % str(devid))
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-12 10:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-12 1:43 [PATCH] Allow off-line NIC removal John Levon
2009-03-12 10:59 ` Daniel P. Berrange
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.