[libvirt] Need your help with virsh desc
Zhimou Peng
zhpeng at redhat.com
Wed Feb 29 08:08:30 UTC 2012
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 at redhat.com>
To: "Zhimou Peng" <zhpeng at redhat.com>
Cc: "Alex Jia" <ajia at redhat.com>, "Rita Wu" <rwu at 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 1�a;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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
More information about the libvir-list
mailing list