[libvirt] [PATCH] virsh: Make <mac> required when device-detaching interface

Eric Blake eblake at redhat.com
Wed Feb 23 03:19:11 UTC 2011


On 02/22/2011 03:16 AM, Michal Privoznik wrote:
> Problem is, if user does not specify mac address in input XML,
> we generate a random one, which is why device-detach fails giving
> a confusing error message. Therefore <mac> needs to be required.
> ---
>  tools/virsh.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++-----------
>  1 files changed, 46 insertions(+), 11 deletions(-)

I'm not sure this is patching the right place.  This fixes virsh for the
detach-device <interface> case, but breaks detach-device <disk> and
friends (which don't have or need a <mac>).  Meanwhile, this is only
papering over things at the virsh, while still leaving the underlying
API vulnerable (if you use python, or perl, or java, or ... bindings).
Wouldn't the smarter fix be to change the underlying API, so that when
detach-device is called on an <interface> and the domain only has one
interface available, then that interface is detached without requiring a
<mac>; therefore, the problem of requiring a <mac> should only be when
there are more than one <interface> attached to the domain in the first
place?  That is, the detach device code that parses XML into the device
that needs to be detached needs to know whether the mac address was
auto-generated (good for attach, ignorable on detach with one interface,
error on detach with multiple interfaces), or explicitly specified (good
for attach, must match an existing an existing interface on detach).

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110222/f6923486/attachment-0001.sig>


More information about the libvir-list mailing list