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@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list