[virt-tools-list] [virt-manager] [PATCH 1/4] cli: Add --genid option to support VM generation ID

Lin Ma lma at suse.com
Tue Mar 26 09:42:32 UTC 2019


Libvirt supports VM generation ID since 4.4.0, This patchset adds it
for virt-manager.

The value either is specified through cli or is generated by libvirt.
ex:
virt-install --genid e90ff655-47a5-4484-9f9c-79a683c2a2e2 --memory ...
OR
virt-install --genid --memory ...

Microsoft details about VM generation ID:
http://go.microsoft.com/fwlink/?LinkId=260709

Signed-off-by: Lin Ma <lma at suse.com>
---
 .../compare/virt-install-many-devices.xml         |  1 +
 tests/clitest.py                                  |  2 ++
 virt-install                                      | 15 +++++++++++++++
 virtinst/guest.py                                 |  3 ++-
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index 61c7df07..3e6877be 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -6,6 +6,7 @@
       <libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
     </libosinfo:libosinfo>
   </metadata>
+  <genid>e90ff655-47a5-4484-9f9c-79a683c2a2e2</genid>
   <memory>65536</memory>
   <currentMemory>65536</currentMemory>
   <vcpu placement="static">4</vcpu>
diff --git a/tests/clitest.py b/tests/clitest.py
index 8194e796..1ec246b0 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -466,6 +466,8 @@ c.add_compare(""" \
 --vcpus 4,cores=1,placement=static \
 --cpu none \
 \
+--genid e90ff655-47a5-4484-9f9c-79a683c2a2e2 \
+\
 --disk /dev/default-pool/UPPER,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149,boot_order=2 \
 --disk %(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace,discard=unmap,detect_zeroes=yes \
 --disk device=cdrom,bus=sata,read_bytes_sec=1,read_iops_sec=2,total_bytes_sec=10,total_iops_sec=20,write_bytes_sec=5,write_iops_sec=6,driver.copy_on_read=on,geometry.cyls=16383,geometry.heads=16,geometry.secs=63,geometry.trans=lba \
diff --git a/virt-install b/virt-install
index 57835849..0ca117d3 100755
--- a/virt-install
+++ b/virt-install
@@ -550,6 +550,12 @@ def build_guest_instance(conn, options):
         guest.os.arch = options.arch
     if options.machine:
         guest.os.machine = options.machine
+    if options.genid is None:
+        # The value of genid will be generated by libvirt in case of
+        # specifying --genid suboption without value
+        guest.genid = True
+    elif options.genid:
+        guest.genid = options.genid
 
     # If explicit os-variant requested, set it early since it will
     # provide more defaults in the future
@@ -793,6 +799,15 @@ def parse_args():
     geng.add_argument("-u", "--uuid", help=argparse.SUPPRESS)
     geng.add_argument("--description", help=argparse.SUPPRESS)
 
+    genid_kwargs = {
+        "dest": "genid",
+        "default": False,
+        "nargs": '?',
+        "help": _("Enable VM generation ID for windows."),
+    }
+
+    geng.add_argument("--genid", **genid_kwargs)
+
     insg = parser.add_argument_group(_("Installation Method Options"))
     insg.add_argument("-c", dest="cdrom_short", help=argparse.SUPPRESS)
     insg.add_argument("--cdrom", help=_("CD-ROM installation media"))
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 0538ccfd..1ae60e5e 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -140,7 +140,7 @@ class Guest(XMLBuilder):
 
     XML_NAME = "domain"
     _XML_PROP_ORDER = [
-        "type", "name", "uuid", "title", "description", "_metadata",
+        "type", "name", "uuid", "title", "description", "_metadata", "genid",
         "hotplugmemorymax", "hotplugmemoryslots", "maxmemory", "_memory",
         "blkiotune", "memtune", "memoryBacking",
         "_vcpus", "curvcpus", "vcpu_placement",
@@ -206,6 +206,7 @@ class Guest(XMLBuilder):
     cpuset = XMLProperty("./vcpu/@cpuset")
 
     uuid = XMLProperty("./uuid")
+    genid = XMLProperty("./genid")
     id = XMLProperty("./@id", is_int=True)
     type = XMLProperty("./@type")
     bootloader = XMLProperty("./bootloader")
-- 
2.21.0




More information about the virt-tools-list mailing list