Re: [libvirt] Need your help with virsh desc

Hi Eric, I discussed this in my team. And i don't think refuse newlines is a good idea. Description can contains several lines is better. I agree with you of the second one, keep the format of user's input is better(virt-manager shows description too). And i need more information from upstream libvirt list, pls help. Thanks. zhpeng BR ----- Original Message ----- From: "Eric Blake" <eblake@redhat.com> To: "Zhimou Peng" <zhpeng@redhat.com> Cc: "Alex Jia" <ajia@redhat.com>, "Rita Wu" <rwu@redhat.com> Sent: Wednesday, February 29, 2012 12:28:48 AM Subject: Re: Need your help with virsh desc On 02/27/2012 10:49 PM, Zhimou Peng wrote:
Hi Eric,
I try to add some description to my guest, and i find xml format isn't like good.
For example: When i add/edit description with:
# virsh desc kvm1 asdfsadfssafsadfa Domain description updated successfully # virsh dumpxml kvm1 <domain type='kvm'> <name>kvm1</name> <uuid>d5cd1756-eb3b-fd9b-1f91-0cc801dfc622</uuid> <description>asdfsadfssafsadfa</description> ------> looks good
# virsh desc --edit --config kvm1 This is a test desc of kvm1
# virsh dumpxml kvm1 <domain type='kvm'> <name>kvm1</name> <uuid>d5cd1756-eb3b-fd9b-1f91-0cc801dfc622</uuid> <description>This is a test desc of kvm1 --------> I think the end of line *$* should be delete </description>
This is a case where your editor added a trailing newline, and libvirt passed that newline on through to the xml. We are already deleting the newline for <title> (which refuses newlines), but <description> allows newlines. I think we should open a BZ to have virsh strip the trailing newline always, and not just for <title>.
Expect result: <domain type='kvm'> <name>kvm1</name> <uuid>d5cd1756-eb3b-fd9b-1f91-0cc801dfc622</uuid> <description>This is a test desc of kvm1</description>
---------------------------------------------------------- Description can contain several lines:
# virsh desc --edit --config kvm2 This is a test desc of kvm2 We have 3 lines test test test
# virsh dumpxml kvm2 <domain type='kvm'> <name>kvm1</name> <uuid>d5cd1756-eb3b-fd9b-1f91-0cc801dfc622</uuid> <description>This is a test desc of kvm2 We have 3 lines test test test </description> ---------------------> I think libvirt should uniform XML format in guest configuration.
Expect result: <domain type='kvm'> <name>kvm1</name> <uuid>d5cd1756-eb3b-fd9b-1f91-0cc801dfc622</uuid> <description> This is a test desc of kvm2 We have 3 lines test test test </description>
Sorry. We _cannot_ alter the whitespace of the text in the element. While whitespace in between <> tags is flexible (and thus we format things to make it look nested), whitespace within the text surrounded by a <description></description> block is significant, because it was provided by the user, and must be given back to the user in the same format. Perhaps we could encode things using a; instead of a literal newline, as in: <description>Line 1a;Line 2</description> but I don't know if libxml2 can be made to do that reliably. This question would be better asked on the upstream libvirt list. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Feb 29, 2012 at 03:08:30AM -0500, Zhimou Peng wrote:
Hi Eric, I discussed this in my team. And i don't think refuse newlines is a good idea. Description can contains several lines is better. I agree with you of the second one, keep the format of user's input is better(virt-manager shows description too). And i need more information from upstream libvirt list, pls help.
I completely agree with Eric here, the description is user data and we cannot modify it. Now what you want is a short description i.e. a title and that was added in 0.9.10 http://libvirt.org/git/?p=libvirt.git;a=commit;h=b79ba8382e2205c416d7c4836ac... use that construct instead but don't ask us to modify description because it is in use already for complex use case and I will definitely not modify that data on input, it would be a terrible regression. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (2)
-
Daniel Veillard
-
Zhimou Peng