答复: Re: [PATCH] virsh: add transient interfaces check for iface-unbridge

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

 




 

>>> Michal Privoznik <mprivozn@xxxxxxxxxx> 2014-12-17 下午 20:34 >>>
>On 17.12.2014 11:34, Lin Ma wrote:
>> iface-unbridge(netcf interface backend) checks multiple interfaces
>> attaching based on static configuration.
>> If guests interfaces(says tun/tap devices) are attaching to the bridge,
>> iface-unbridge doesn't check them, It causes the bridge is removed
>> although it's in use by other guests.
>>
>> Please refer to:
>> https://bugzilla.suse.com/show_bug.cgi?id=813117
>
> The bug is not publicly viewable. We tend to not put the BZ URL in the
> commit message in that case.

sorry about that, the URL will be removed, Thanks.

>>
>> Signed-off-by: Lin Ma
>> ---
>> tools/virsh-interface.c | 24 +++++++++++++++++++++---
>> 1 file changed, 21 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
>> index 5f848b6..63ba5bb 100644
>> --- a/tools/virsh-interface.c
>> +++ b/tools/virsh-interface.c
>> @@ -1040,11 +1040,11 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
>> const char *br_name;
>> char *if_type = NULL, *if_name = NULL;
>> bool nostart = false;
>> - char *br_xml = NULL;
>> + char *br_xml = NULL, *br_xml_transient_if = NULL;
>> xmlChar *if_xml = NULL;
>> int if_xml_size;
>> - xmlDocPtr xml_doc = NULL;
>> - xmlXPathContextPtr ctxt = NULL;
>> + xmlDocPtr xml_doc = NULL, xml_doc_transient_if = NULL;
>> + xmlXPathContextPtr ctxt = NULL, ctxt_transient_if = NULL;
>> xmlNodePtr top_node, if_node, cur;
>>
>> /* Get a handle to the original device */
>> @@ -1103,6 +1103,21 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
>> goto cleanup;
>> }
>>
>> + /* verify whether there is any transient interface attached to bridge. */
>> + if (!(br_xml_transient_if = virInterfaceGetXMLDesc(br_handle, 0)))
>> + goto cleanup;
>> + if (!(xml_doc_transient_if = virXMLParseStringCtxt(br_xml_transient_if,
>> + _("(bridge interface definition)"),
>> + &ctxt_transient_if))) {
>> + vshError(ctl, _("Failed to parse configuration of %s"), br_name);
>> + goto cleanup;
>> + }
>> +
>> + if (virXPathNode("./bridge/interface[2]", ctxt_transient_if) != NULL) {
>> + vshError(ctl, "%s", _("The bridge is in use by transient interfaces"));
>> + goto cleanup;
>> + }
>> +
>
> This effectively copies the code just a few lines above (not to be seen
> in this context though). The only difference is, that your code gest
> LIVE bridge XML, while pre-exisitng code dumps INACTIVE XML. Can we turn
> already existing code into checking LIVE XML instead? It feels more
> appropriate too. Live bridge can have only one interface plugged in (due
> to hot-unplugging) regardless of what INACTIVE XML says.

Actually, at the beginning of writing this patch, I tended to turn already existing code
into checking LIVE XML instead, But if I do so, it can't deal with this extreme circumstance:
says no any physical interface attached to the bridge, But one guest tap backend is
attaching to this bridge. The bridge will be removed in this case instead of reporting "No
interface attached to bridge".

Now I thought about it, no body configures the bridge and guest interface like that,
that
extreme circumstance is meaningless and useless scenario, So I agreed with your idea.

any else suggestions?

Thanks,
Lin
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]