Re: [PATCH] virsh: Fix a regression of detaching device

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

 



On 12/19/2011 11:38 AM, Eric Blake wrote:
> On 12/19/2011 04:01 AM, Osier Yang wrote:
>> Since for node <address>, the values for attrs "domain", "bus", "slot",
>> "function" are all converted to heximal when parsing the XML. However
>> commit ea7182c29 tries to examine if the device represented by the XML
>> from user exists in the domain XML earlier before the XML parsing, and
>> thus if the user use different base to represent the device address, e.g.
>>   <address type='pci' domain='0' bus='0' slot='7'/>
>>
>> vshCompleteXMLFromDomain won't find the device, and quit with error
>> "no such device" even if the device does exist.
>> ---
>>  tools/virsh.c |   41 +++++++++++++++++++++++++++++++++++------
>>  1 files changed, 35 insertions(+), 6 deletions(-)
> 
> Hmm.  I agree that we have a problem, but I think this patch is taking
> the wrong approach to fixing it.  By special casing which pieces of XML
> should be parsed as an integer and compared by integer value rather than
> by string equality, we effectively end up having to add more and more
> exceptions every time someone else points out another field that needs
> to be treated as an integer.
> 
> It would be a lot better to read the user's input, and normalize it into
> a single form, then compare the normalized forms; rather than this
> patch's attempt to normalize individual fields during the comparison.
> But I'm not sure how we would go about doing that, short of reusing our
> XML parsing code from domain_conf.c which does the normalization by
> flattening XML into a consistent in-memory representation, followed by
> the code that re-generates XML from that in-memory representation.

Maybe we need a new API, something like:

char *virConnectNormalizeXML(virConnectPtr conn, const char *xml,
unsigned int flags)

that takes incoming xml, passes it through the internal parser, and
spits back out the resulting xml (or diagnoses the xml as invalid by
returning NULL), all without modifying any existing domain, network,
storage pool, or other object managed by xml.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
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

[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]