cli: --metadata: add genid= and genid_enable=

The latter is for triggering <genid/> bool XML, which tells libvirt
to auto-allocate a UUID. The cli isn't really XML conformant but
I can't think of anything better that is self advertising
This commit is contained in:
Cole Robinson 2019-05-14 14:26:19 -04:00
parent 7083294e2c
commit a6b5f11f13
5 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<genid/>
<description>foobar &amp; baz</description>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">

View File

@ -1,6 +1,7 @@
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<genid>e9392370-2917-565e-692b-d057f46512d6</genid>
<title>my-title</title>
<description>my-description</description>
<metadata>
@ -201,6 +202,7 @@
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<genid>e9392370-2917-565e-692b-d057f46512d6</genid>
<title>my-title</title>
<description>my-description</description>
<metadata>

View File

@ -418,6 +418,7 @@ c.add_compare("""
--clock offset=localtime
--resource /virtualmachines/production
--events on_crash=restart
--metadata genid_enable=yes
--disk none
--console none
@ -448,7 +449,7 @@ cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10,\
cache.mode=emulate,cache.level=3
--cputune vcpupin0.vcpu=0,vcpupin0.cpuset=0-3
--metadata title=my-title,description=my-description,uuid=00000000-1111-2222-3333-444444444444
--metadata title=my-title,description=my-description,uuid=00000000-1111-2222-3333-444444444444,genid=e9392370-2917-565e-692b-d057f46512d6
--boot cdrom,fd,hd,network,menu=off,loader=/foo/bar,emulator=/new/emu,bootloader=/new/bootld,rebootTimeout=3,initargs="foo=bar baz=woo"
--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10
--security type=static,label='system_u:object_r:svirt_image_t:s0:c100,c200',relabel=yes,baselabel=baselabel

View File

@ -1572,6 +1572,8 @@ class ParserMetadata(VirtCLIParser):
cls.add_arg("name", "name", can_comma=True)
cls.add_arg("title", "title", can_comma=True)
cls.add_arg("uuid", "uuid")
cls.add_arg("genid", "genid")
cls.add_arg("genid_enable", "genid_enable", is_onoff=True)
cls.add_arg("description", "description", can_comma=True)
cls.add_arg("os_name", None, lookup_cb=None,
cb=cls.set_os_name_cb)

View File

@ -144,7 +144,8 @@ class Guest(XMLBuilder):
XML_NAME = "domain"
_XML_PROP_ORDER = [
"type", "name", "uuid", "title", "description", "_metadata",
"type", "name", "uuid", "genid", "genid_enable",
"title", "description", "_metadata",
"maxMemory", "maxMemorySlots", "memory", "_currentMemory",
"blkiotune", "memtune", "memoryBacking",
"_vcpus", "vcpu_current", "vcpu_placement",
@ -210,6 +211,8 @@ class Guest(XMLBuilder):
vcpu_cpuset = XMLProperty("./vcpu/@cpuset")
uuid = XMLProperty("./uuid")
genid = XMLProperty("./genid")
genid_enable = XMLProperty("./genid", is_bool=True)
id = XMLProperty("./@id", is_int=True)
type = XMLProperty("./@type")
bootloader = XMLProperty("./bootloader")