[libvirt] [PATCH v2 1/8] xml: Add element to allow short description of domains</span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=libvir-list@redhat.com&q=from:%22Peter+Krempa%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Peter Krempa</span></span></a></span> <span class="date"><a href="/search?l=libvir-list@redhat.com&q=date:20120118" rel="nofollow">Wed, 18 Jan 2012 06:33:32 -0800</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre>This patch adds a new element <title> to the domain XML. This attribute can hold a short title defined by the user to ease the identification of domains. The title is limited to 40 bytes and can't contain newlines.</pre><pre> *docs/formatdomain.html.in *docs/schemas/domaincommon.rng - add schema grammar for the new element and documentation *src/conf/domain_conf.c *src/conf/domain_conf.h - add field to hold the new attribute - add code to parse and create XML with the new attribute --- Changes to v1: - use a new element <title> in the XML instead of attribute to domain - Tweaked commit message - Tweaked docs - Added restrictions into the RNG grammar for the new element - Added tests! (hopefuly right) docs/formatdomain.html.in | 6 ++++ docs/schemas/domaincommon.rng | 13 +++++++++- src/conf/domain_conf.c | 19 ++++++++++++++ src/conf/domain_conf.h | 1 + .../qemu-simple-description-title.xml | 27 ++++++++++++++++++++ tests/qemuxml2argvdata/qemuxml2argv-minimal.xml | 5 +++ 6 files changed, 70 insertions(+), 1 deletions(-) create mode 100644 tests/domainschemadata/qemu-simple-description-title.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index de9b480..2945868 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -33,6 +33,7 @@ &lt;name&gt;fv0&lt;/name&gt; &lt;uuid&gt;4dea22b31d52d8f32516782e98ab3fa0&lt;/uuid&gt; &lt;description&gt;Some human readable description&lt;/description&gt; + &lt;title&gt;A short description - title - of the domain&lt;/title&gt; ...</pre> <dl> @@ -59,6 +60,11 @@ human readable description of the virtual machine. This data is not used by libvirt in any way, it can contain any information the user wants. <span class="since">Since 0.7.2</span></dd> + + <dt><code>title</code></dt> + <dd>The optional element <code>title</code> provides space for a + shorter description, capped at 40 bytes and with no newline, + <span class="since">since 0.9.10</span>.</dd> </dl> <h3><a name="elementsOS">Operating system booting</a></h3> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 2041dfb..bd40e42 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -6,7 +6,7 @@ <include href='networkcommon.rng'/> <!-- - description element, may be placed anywhere under the root + description and title element, may be placed anywhere under the root --> <define name="description"> <element name="description"> @@ -14,6 +14,14 @@ </element> </define> + <define name="title"> + <element name="title"> + <data type="string"> + <param name='pattern'>[^\n]{0,40}</param> + </data> + </element> + </define> + <!-- We handle only document defining a domain --> @@ -26,6 +34,9 @@ <ref name="description"/> </optional> <optional> + <ref name="title"/> + </optional> + <optional> <ref name="cpu"/> </optional> <optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f97014e..c04a4c0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1478,6 +1478,7 @@ void virDomainDefFree(virDomainDefPtr def) VIR_FREE(def->cpumask); VIR_FREE(def->emulator); VIR_FREE(def->description); + VIR_FREE(def->title); virBlkioDeviceWeightArrayClear(def->blkio.devices, def->blkio.ndevices); @@ -7090,6 +7091,22 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, VIR_FREE(tmp); } + /* Extract short description of domain (title) */ + def->title = virXPathString("string(./title[1])", ctxt); + if (def->title) { + if (strchr(def->title, '\n')) { + virDomainReportError(VIR_ERR_XML_ERROR, + "%s", _("Domain title can't contain newlines")); + goto error; + } + + if (strlen(def->title) > 40) { + virDomainReportError(VIR_ERR_XML_ERROR, + "%s", _("Domain title too long")); + goto error; + } + } + /* Extract documentation if present */ def->description = virXPathString("string(./description[1])", ctxt); @@ -11420,6 +11437,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferEscapeString(buf, " <description>%s</description>\n", def->description); + virBufferEscapeString(buf, " <title>%s</title>\n", def->title); + virBufferAsprintf(buf, " <memory>%lu</memory>\n", def->mem.max_balloon); virBufferAsprintf(buf, " <currentMemory>%lu</currentMemory>\n", def->mem.cur_balloon); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b121f9c..cbaa2df 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1420,6 +1420,7 @@ struct _virDomainDef { int id; unsigned char uuid[VIR_UUID_BUFLEN]; char *name; + char *title; char *description; struct { diff --git a/tests/domainschemadata/qemu-simple-description-title.xml b/tests/domainschemadata/qemu-simple-description-title.xml new file mode 100644 index 0000000..a8a9cac --- /dev/null +++ b/tests/domainschemadata/qemu-simple-description-title.xml @@ -0,0 +1,27 @@ +<domain type='qemu'> + <name>qemu-demo</name> + <uuid>603cc28c-9841-864e-0949-8cc7d3bae9f8</uuid> + <memory>65536</memory> + <currentMemory>65536</currentMemory> + <title>A short description of this domain</title> + <description> + A longer explanation that this domain is a test domain + for validating domain schemas. + </description> + <vcpu>1</vcpu> + <os> + <type arch='x86_64' machine='pc-0.14'>hvm</type> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <emulator>/usr/bin/qemu-kvm</emulator> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml index 2f13d46..6cb0b31 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml @@ -1,6 +1,11 @@ <domain type='qemu'> <name>QEMUGuest1</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <description> + A test of qemu&apos;s minimal configuration. + This test also tests the description and title elements. + </description> + <title>A description of the test machine.</title> <memory>219100</memory> <currentMemory>219100</currentMemory> <vcpu cpuset='1-4,8-20,525'>1</vcpu> -- 1.7.3.4 -- libvir-list mailing list libvir-list@redhat.com <a rel="nofollow" href="https://www.redhat.com/mailman/listinfo/libvir-list">https://www.redhat.com/mailman/listinfo/libvir-list</a> </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg50657.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="index.html#50658">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="maillist.html#50658">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg50659.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email"><span class="subject"><a href="msg50655.html">[libvirt] [PATCH v2 0/8] Add ability to store notes wit...</a></span> <span class="sender italic">Peter Krempa</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg50654.html">[libvirt] [PATCH v2 4/8] virsh: Add support for mo...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50656.html">[libvirt] [PATCH 7/8] lxc, qemu: Add support for v...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50657.html">[libvirt] [PATCH 5/8] lxc: implement description A...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email tSliceCur"><span class="subject">[libvirt] [PATCH v2 1/8] xml: Add element <titl...</span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50659.html">[libvirt] [PATCH v2 3/8] qemu: Implement note API ...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50660.html">[libvirt] [PATCH 6/8] api: Add API to get domain t...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50661.html">[libvirt] [PATCH 8/8] virsh: Add support for virDo...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50662.html">[libvirt] [PATCH 2/8] api: Add api to set domain t...</a></span> <span class="sender italic">Peter Krempa</span></li> <li class="icons-email"><span class="subject"><a href="msg50833.html">Re: [libvirt] [PATCH v2 0/8] Add ability to store ...</a></span> <span class="sender italic">Peter Krempa</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg50839.html">Re: [libvirt] [PATCH v2 0/8] Add ability to st...</a></span> <span class="sender italic">Eric Blake</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg50841.html">Re: [libvirt] [PATCH v2 0/8] Add ability t...</a></span> <span class="sender italic">Daniel P. Berrange</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg50845.html">Re: [libvirt] [PATCH v2 0/8] Add abili...</a></span> <span class="sender italic">Eric Blake</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg50846.html">Re: [libvirt] [PATCH v2 0/8] Add ...</a></span> <span class="sender italic">Daniel P. Berrange</span></li> </ul> </ul> </ul> </ul> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="[libvirt] [PATCH v2 1/8] xml: Add element <title> to allow short description of domains"> <input type="hidden" name="msgid" value="4e441b2ad561b48a16200472fe68c65564b8ce52.1326894593.git.pkrempa@redhat.com"> <input type="hidden" name="relpath" value="libvir-list@redhat.com/msg50658.html"> <input type="submit" value=" Peter Krempa "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="libvir-list@redhat.com"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search libvir-list"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/libvir-list@redhat.com/">libvir-list - all messages</a></li> <li class="icons-about"><a href="/libvir-list@redhat.com/info.html">libvir-list - about the list</a></li> <li class="icons-expand"><a href="/search?l=libvir-list@redhat.com&q=subject:%22%5C%5Blibvirt%5C%5D+%5C%5BPATCH+v2+1%5C%2F8%5C%5D+xml%5C%3A+Add+element+%3Ctitle%3E+to+allow+short%09description+of+domains%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg50657.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg50659.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">4e441b2ad561b48a16200472fe68c65564b8ce52.1326894593.git.pkrempa@redhat.com</li> </ul> </div> </body> </html>