Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package virt-scenario for openSUSE:Factory checked in at 2023-03-21 17:43:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/virt-scenario (Old) and /work/SRC/openSUSE:Factory/.virt-scenario.new.31432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "virt-scenario" Tue Mar 21 17:43:19 2023 rev:5 rq:1073511 version:0.7.6 Changes: -------- --- /work/SRC/openSUSE:Factory/virt-scenario/virt-scenario.changes 2023-03-17 17:04:39.133803557 +0100 +++ /work/SRC/openSUSE:Factory/.virt-scenario.new.31432/virt-scenario.changes 2023-03-21 17:44:15.946615921 +0100 @@ -1,0 +2,16 @@ +Tue Mar 21 10:01:43 UTC 2023 - Antoine Ginies <[email protected]> + +- fix memory user issue + +------------------------------------------------------------------- +Mon Mar 20 17:31:07 UTC 2023 - Antoine Ginies <[email protected]> + +- version 0.7.6: + * add support for virtual network selection (vnet) + * add force_sev to extract a local PDH (not recommended: for testing purposes) + * improve connect to libvirtd socket (more info) + * fix memory_pin issue while user was setting memory + * fixes around bootdev + * various other bug fixes + +------------------------------------------------------------------- Old: ---- virt-scenario-0.7.4.tar.gz New: ---- virt-scenario-0.7.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ virt-scenario.spec ++++++ --- /var/tmp/diff_new_pack.Hdz44Q/_old 2023-03-21 17:44:16.454618350 +0100 +++ /var/tmp/diff_new_pack.Hdz44Q/_new 2023-03-21 17:44:16.466618407 +0100 @@ -19,7 +19,7 @@ %define pythons python3 Name: virt-scenario -Version: 0.7.4 +Version: 0.7.6 Release: 0 Summary: Create XML guest configuration and prepare the host for a scenario License: GPL-3.0-or-later ++++++ virt-scenario-0.7.4.tar.gz -> virt-scenario-0.7.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/ChangeLog new/virt-scenario-0.7.6/ChangeLog --- old/virt-scenario-0.7.4/ChangeLog 2023-03-16 17:38:01.000000000 +0100 +++ new/virt-scenario-0.7.6/ChangeLog 2023-03-21 11:00:51.000000000 +0100 @@ -1,3 +1,158 @@ +2023-03-21 aginies <[email protected]> + + fix memoryuser + + +2023-03-20 aginies <[email protected]> + + v0.7.6 + + +2023-03-20 Antoine Giniès <[email protected]> + + Merge pull request #8 from aginies/version0.7.5 + Merge pull request #7 from aginies/main + +2023-03-20 Antoine Giniès <[email protected]> + + Merge pull request #7 from aginies/main + final version of 0.7.5 + +2023-03-20 Antoine Giniès <[email protected]> + + Merge pull request #6 from aginies/devel + Merge pull request #5 from aginies/main + +2023-03-20 Antoine Giniès <[email protected]> + + Merge pull request #5 from aginies/main + merge main into devel + +2023-03-20 aginies <[email protected]> + + fix memory_pin issue while user was setting memory + + +2023-03-20 aginies <[email protected]> + + try to avoid error in case of pin key doesnt exist + + +2023-03-20 aginies <[email protected]> + + fix force_sev + + +2023-03-20 aginies <[email protected]> + + fix typo for boot_dev + + +2023-03-20 aginies <[email protected]> + + improve connect to libvirtd socket (more info) + + +2023-03-20 aginies <[email protected]> + + typo + + +2023-03-20 aginies <[email protected]> + + small fixes around bootdev + + +2023-03-20 aginies <[email protected]> + + select an CD/DVD switch bootdev to cdrom + + +2023-03-20 aginies <[email protected]> + + cleanup help_ + + +2023-03-20 aginies <[email protected]> + + fix print_error + + +2023-03-17 Antoine Giniès <[email protected]> + + typo fix + + +2023-03-17 aginies <[email protected]> + + various fix around SEV and force mode + + +2023-03-17 aginies <[email protected]> + + add force_sev in the promptline + + +2023-03-17 aginies <[email protected]> + + add a force_sev to generate locally the PDH file (not secure) + + +2023-03-17 aginies <[email protected]> + + fix print_warning + + +2023-03-17 aginies <[email protected]> + + add a list of network + + +2023-03-17 aginies <[email protected]> + + dont show session and dhCert data + + +2023-03-17 aginies <[email protected]> + + sync man page + + +2023-03-17 aginies <[email protected]> + + add virtual network selection support + + +2023-03-17 aginies <[email protected]> + + sync with README.md + + +2023-03-17 aginies <[email protected]> + + sync with code + + +2023-03-17 aginies <[email protected]> + + prepare 0.7.5 + + +2023-03-17 aginies <[email protected]> + + add a -l option + + +2023-03-17 aginies <[email protected]> + + use lines.append instead of a long list + + +2023-03-17 aginies <[email protected]> + + do not use memory pin for desktop and computation + + 2023-03-16 aginies <[email protected]> update man page diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/PKG-INFO new/virt-scenario-0.7.6/PKG-INFO --- old/virt-scenario-0.7.4/PKG-INFO 2023-03-16 17:38:01.000000000 +0100 +++ new/virt-scenario-0.7.6/PKG-INFO 2023-03-21 11:00:51.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: virt-scenario -Version: 0.7.4 +Version: 0.7.6 Summary: Virt-scenario Home-page: https://github.com/aginies/virt-scenario Author: Antoine Ginies @@ -31,6 +31,7 @@ User can set some parameter in the **/etc/virt-scenario/virtscenario.yaml**. This will override the scenario setting (but will display the recommended setting). + Example: ```yaml # WARNING: INCORRET PARAMATERS WILL LEAD TO BAD VM CONFIGURATION # Dont change the section name @@ -74,6 +75,8 @@ ```yaml localhost: url: qemu:///system + # Generate with 'sevctl export --full filename.pdh' on the given host + sev-cert: /path/to/host-cert-chain.pdh ``` # Usage @@ -94,7 +97,7 @@ > desktop ``` - Tool to select a firmware based on their features: + Tool to select a firmware based on feature: ``` python3 -m virt_select_firmware ``` @@ -139,6 +142,7 @@ * **name**: Define a name for the VM * **vcpu**: Choose how many VCPU * **memory**: Choose the Memory size (in GiB) + * **vnet**: Virtual Network for the VM * **machine**: Select the Machine type (from a list) * **bootdev**: Select the boot dev (from a list) * **diskpath**: Directory where to store disk image @@ -253,7 +257,7 @@ ``` class Features() -> XXX_perf() -> BasicConfiguration.XXX - -> ComplexConfiguration.XXX + -> ComplexConfiguration.XXX ``` [BasicConfiguration()](src/virtscenario/configuration.py#L20) @@ -291,7 +295,7 @@ ## Templates definition - All templates are in the python lib src/virt-scenario/template.py file. + All templates are in the python lib **virt-scenario/template.py** file. ## Python Files (virtscenario) @@ -321,7 +325,7 @@ * enable an AMD SEV system * generate SEV attestation and update VM XML * check if running in a container and display host config to apply - * configure HugePages + * configure HugePages and THP * enable/disable KSM * adjust swappiness * manage IO scheduler diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/README.md new/virt-scenario-0.7.6/README.md --- old/virt-scenario-0.7.4/README.md 2023-03-16 17:25:00.000000000 +0100 +++ new/virt-scenario-0.7.6/README.md 2023-03-17 14:50:41.000000000 +0100 @@ -23,6 +23,7 @@ User can set some parameter in the **/etc/virt-scenario/virtscenario.yaml**. This will override the scenario setting (but will display the recommended setting). +Example: ```yaml # WARNING: INCORRET PARAMATERS WILL LEAD TO BAD VM CONFIGURATION # Dont change the section name @@ -66,6 +67,8 @@ ```yaml localhost: url: qemu:///system +# Generate with 'sevctl export --full filename.pdh' on the given host + sev-cert: /path/to/host-cert-chain.pdh ``` # Usage @@ -86,7 +89,7 @@ > desktop ``` -Tool to select a firmware based on their features: +Tool to select a firmware based on feature: ``` python3 -m virt_select_firmware ``` @@ -131,6 +134,7 @@ * **name**: Define a name for the VM * **vcpu**: Choose how many VCPU * **memory**: Choose the Memory size (in GiB) +* **vnet**: Virtual Network for the VM * **machine**: Select the Machine type (from a list) * **bootdev**: Select the boot dev (from a list) * **diskpath**: Directory where to store disk image @@ -245,7 +249,7 @@ ``` class Features() -> XXX_perf() -> BasicConfiguration.XXX - -> ComplexConfiguration.XXX + -> ComplexConfiguration.XXX ``` [BasicConfiguration()](src/virtscenario/configuration.py#L20) @@ -283,7 +287,7 @@ ## Templates definition -All templates are in the python lib src/virt-scenario/template.py file. +All templates are in the python lib **virt-scenario/template.py** file. ## Python Files (virtscenario) @@ -313,7 +317,7 @@ * enable an AMD SEV system * generate SEV attestation and update VM XML * check if running in a container and display host config to apply -* configure HugePages +* configure HugePages and THP * enable/disable KSM * adjust swappiness * manage IO scheduler diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/man/virt-scenario.1 new/virt-scenario-0.7.6/man/virt-scenario.1 --- old/virt-scenario-0.7.4/man/virt-scenario.1 2023-03-16 17:37:40.000000000 +0100 +++ new/virt-scenario-0.7.6/man/virt-scenario.1 2023-03-17 14:54:02.000000000 +0100 @@ -44,6 +44,8 @@ \f[B]/etc/virt-scenario/virtscenario.yaml\f[R]. This will override the scenario setting (but will display the recommended setting). +.PP +Example: .IP .nf \f[C] @@ -93,6 +95,8 @@ \f[C] localhost: url: qemu:///system +# Generate with \[aq]sevctl export --full filename.pdh\[aq] on the given host + sev-cert: /path/to/host-cert-chain.pdh \f[R] .fi .SH Usage @@ -115,7 +119,7 @@ \f[R] .fi .PP -Tool to select a firmware based on their features: +Tool to select a firmware based on feature: .IP .nf \f[C] @@ -169,6 +173,8 @@ .IP \[bu] 2 \f[B]memory\f[R]: Choose the Memory size (in GiB) .IP \[bu] 2 +\f[B]vnet\f[R]: Virtual Network for the VM +.IP \[bu] 2 \f[B]machine\f[R]: Select the Machine type (from a list) .IP \[bu] 2 \f[B]bootdev\f[R]: Select the boot dev (from a list) @@ -629,7 +635,7 @@ \f[C] class Features() -> XXX_perf() -> BasicConfiguration.XXX - -> ComplexConfiguration.XXX + -> ComplexConfiguration.XXX \f[R] .fi .PP @@ -673,7 +679,8 @@ .fi .SS Templates definition .PP -All templates are in the python lib src/virt-scenario/template.py file. +All templates are in the python lib \f[B]virt-scenario/template.py\f[R] +file. .SS Python Files (virtscenario) .IP \[bu] 2 virtscenario.yaml: user setting (overwrite scenario settings) @@ -728,7 +735,7 @@ .IP \[bu] 2 check if running in a container and display host config to apply .IP \[bu] 2 -configure HugePages +configure HugePages and THP .IP \[bu] 2 enable/disable KSM .IP \[bu] 2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/setup.py new/virt-scenario-0.7.6/setup.py --- old/virt-scenario-0.7.4/setup.py 2023-03-16 16:55:25.000000000 +0100 +++ new/virt-scenario-0.7.6/setup.py 2023-03-20 18:29:10.000000000 +0100 @@ -182,7 +182,7 @@ setuptools.setup( name="virt-scenario", - version="0.7.4", + version="0.7.6", author="Antoine Ginies", author_email="[email protected]", description="Virt-scenario", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virt_scenario.egg-info/PKG-INFO new/virt-scenario-0.7.6/src/virt_scenario.egg-info/PKG-INFO --- old/virt-scenario-0.7.4/src/virt_scenario.egg-info/PKG-INFO 2023-03-16 17:38:01.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virt_scenario.egg-info/PKG-INFO 2023-03-21 11:00:51.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: virt-scenario -Version: 0.7.4 +Version: 0.7.6 Summary: Virt-scenario Home-page: https://github.com/aginies/virt-scenario Author: Antoine Ginies @@ -31,6 +31,7 @@ User can set some parameter in the **/etc/virt-scenario/virtscenario.yaml**. This will override the scenario setting (but will display the recommended setting). + Example: ```yaml # WARNING: INCORRET PARAMATERS WILL LEAD TO BAD VM CONFIGURATION # Dont change the section name @@ -74,6 +75,8 @@ ```yaml localhost: url: qemu:///system + # Generate with 'sevctl export --full filename.pdh' on the given host + sev-cert: /path/to/host-cert-chain.pdh ``` # Usage @@ -94,7 +97,7 @@ > desktop ``` - Tool to select a firmware based on their features: + Tool to select a firmware based on feature: ``` python3 -m virt_select_firmware ``` @@ -139,6 +142,7 @@ * **name**: Define a name for the VM * **vcpu**: Choose how many VCPU * **memory**: Choose the Memory size (in GiB) + * **vnet**: Virtual Network for the VM * **machine**: Select the Machine type (from a list) * **bootdev**: Select the boot dev (from a list) * **diskpath**: Directory where to store disk image @@ -253,7 +257,7 @@ ``` class Features() -> XXX_perf() -> BasicConfiguration.XXX - -> ComplexConfiguration.XXX + -> ComplexConfiguration.XXX ``` [BasicConfiguration()](src/virtscenario/configuration.py#L20) @@ -291,7 +295,7 @@ ## Templates definition - All templates are in the python lib src/virt-scenario/template.py file. + All templates are in the python lib **virt-scenario/template.py** file. ## Python Files (virtscenario) @@ -321,7 +325,7 @@ * enable an AMD SEV system * generate SEV attestation and update VM XML * check if running in a container and display host config to apply - * configure HugePages + * configure HugePages and THP * enable/disable KSM * adjust swappiness * manage IO scheduler diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/__init__.py new/virt-scenario-0.7.6/src/virtscenario/__init__.py --- old/virt-scenario-0.7.4/src/virtscenario/__init__.py 2023-03-16 17:25:48.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/__init__.py 2023-03-20 18:29:10.000000000 +0100 @@ -30,4 +30,4 @@ builtins.__dict__["_"] = str -__version__ = "0.7.4" +__version__ = "0.7.6" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/configstore.py new/virt-scenario-0.7.6/src/virtscenario/configstore.py --- old/virt-scenario-0.7.4/src/virtscenario/configstore.py 2023-03-16 16:20:43.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/configstore.py 2023-03-20 12:09:22.000000000 +0100 @@ -123,5 +123,5 @@ util.print_error("VM with name {} already exists in {} directory.\nPlease set a new name and try again.\nYou can also use the option: overwirte on".format(vm_data.name['VM_name'], cfg_store.get_path())) return None elif cfg_store.exists() and overwrite == "on": - util.print_ok("VM with name {} already exists in {} directory.\nForce mode enabled, i will overwirte files.".format(vm_data.name['VM_name'], cfg_store.get_path())) + util.print_ok("VM with name {} already exists in {} directory.\nForce mode enabled, I will overwirte files.".format(vm_data.name['VM_name'], cfg_store.get_path())) return cfg_store diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/configuration.py new/virt-scenario-0.7.6/src/virtscenario/configuration.py --- old/virt-scenario-0.7.4/src/virtscenario/configuration.py 2023-03-16 16:14:37.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/configuration.py 2023-03-20 16:31:33.000000000 +0100 @@ -268,7 +268,7 @@ """ self.network_data = { 'mac_address': mac, - 'network': network, + 'source_network': network, 'type': intertype, } return self.network_data diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/guest.py new/virt-scenario-0.7.6/src/virtscenario/guest.py --- old/virt-scenario-0.7.4/src/virtscenario/guest.py 2023-03-16 16:14:37.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/guest.py 2023-03-20 18:12:29.000000000 +0100 @@ -67,7 +67,7 @@ xml = Template(xml_template).substitute(xml_mem) - if memory_data['pin'] == True: + if memory_data.get('pin') == True: memory = int(memory_data['memory']) if memory_data['mem_unit'] == 'Gib': memory = memory * 1024 @@ -199,7 +199,7 @@ xml_template = template.INTERFACE_TEMPLATE xml_interface = { 'mac_address': interface_data['mac_address'], - 'network': interface_data['network'], + 'source_network': interface_data['source_network'], 'type': interface_data['type'], } xml = Template(xml_template).substitute(xml_interface) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/hypervisors.py new/virt-scenario-0.7.6/src/virtscenario/hypervisors.py --- old/virt-scenario-0.7.4/src/virtscenario/hypervisors.py 2023-03-16 16:22:17.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/hypervisors.py 2023-03-20 14:41:52.000000000 +0100 @@ -47,12 +47,26 @@ def connect(self): if self.conn is None: - self.conn = libvirt.open(self.url) - return self.is_connected() + try: + self.conn = libvirt.open(self.url) + ver = self.conn.getVersion() + util.print_ok('Connected to libvirtd socket; Version: '+str(ver)) + return self.is_connected() + except libvirt.libvirtError as verror: + print(repr(verror), file=sys.stderr) + return 666 def domain_capabilities(self): return self.conn.getDomainCapabilities() + def network_list(self): + """ + Return a list of all network available on the hypervisor + """ + networks = self.conn.listNetworks() + inactive_networks = self.conn.listDefinedNetworks() + return inactive_networks+networks + def dominfo(self, name): try: return self.conn.lookupByName(name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/main.py new/virt-scenario-0.7.6/src/virtscenario/main.py --- old/virt-scenario-0.7.4/src/virtscenario/main.py 2023-03-16 16:16:30.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/main.py 2023-03-21 10:46:42.000000000 +0100 @@ -97,6 +97,8 @@ else: executable = data.loader xmlutil.add_loader_nvram(filename, executable, qemulist.OVMF_VARS+"/"+data.callsign+".VARS") + if "vnet" in data.custom: + xmlutil.change_network_source(filename, data.vnet) ### if "XXXX" in data.custom: def final_step_guest(cfg_store, data): @@ -118,7 +120,8 @@ show the virsh define command """ util.print_summary_ok("How to use this on your system") - util.print_ok("virsh define "+filename+"\n") + util.print_ok("Use the virt-scenario-launch tool\n") + util.print_ok("You can also import this config with virsh: virsh define "+filename+"\n") def find_ext_file(ext): """ @@ -199,26 +202,25 @@ memory_pin = False # prompt Cmd prompt = 'virt-scenario > ' - introl = {} - introl[0] = "\n"+util.esc('green') +" virt-scenario "+util.esc('reset')+ "Interactive Terminal!\n\n" - introl[1] = " Setting the virt-scenario Configuration: "+util.esc('blue')+"conf"+util.esc('reset')+"\n" - introl[2] = " Guest/Host/Both mode could be selected using: "+util.esc('blue')+"mode"+util.esc('reset')+"\n" - introl[3] = " Force overwrite previous setting: "+util.esc('blue')+"overwrite"+util.esc('reset')+"\n" - introl[4] = "\n Prepare a Libvirt XML guest config and the host to run a customized guest:\n" - introl[5] = util.esc('blue')+" computation | desktop | securevm"+util.esc('reset')+"\n" - introl[6] = "\n Possible User Settings For VM are:\n" - introl[7] = util.esc('blue')+" name | vcpu | memory | machine | bootdev | diskpath | cdrom"+util.esc('reset')+"\n" - introl[8] = "\n Hypervisors parameters:\n" - introl[9] = util.esc('blue')+" hconf | hv_select | hvlist"+util.esc('reset')+"\n" - introl[10] = "\n"+" You can overwrite some recommended VM settings editing: "+conffile+"\n" - introl[11] = "\n Please read the manpage and the README.md file:\n" - introl[12] = " https://github.com/aginies/virt-scenario/blob/main/README.md\n" - introl[13] = util.esc('red')+"\n WARNING:"+util.esc('reset')+" This is under Devel...\n" - introl[14] = " Source code: https://github.com/aginies/virt-scenario\n" - introl[15] = " Report bug: https://github.com/aginies/virt-scenario/issues\n" - intro = '' - for line in range(16): - intro += introl[line] + lines = [] + lines.append("\n"+util.esc('green') +" virt-scenario "+util.esc('reset')+ "Interactive Terminal!\n\n") + lines.append(" Setting the virt-scenario Configuration: "+util.esc('blue')+"conf"+util.esc('reset')+"\n") + lines.append(" Guest/Host/Both mode could be selected using: "+util.esc('blue')+"mode"+util.esc('reset')+"\n") + lines.append(" Force overwrite previous setting: "+util.esc('blue')+"overwrite"+util.esc('reset')+"\n") + lines.append("\n Prepare a Libvirt XML guest config and the host to run a customized guest:\n") + lines.append(util.esc('blue')+" computation | desktop | securevm"+util.esc('reset')+"\n") + lines.append("\n Possible User Settings For VM are:\n") + lines.append(util.esc('blue')+" name | vcpu | memory | machine | bootdev | vnet | diskpath | cdrom"+util.esc('reset')+"\n") + lines.append("\n Hypervisors parameters:\n") + lines.append(util.esc('blue')+" hconf | hv_select | hvlist"+util.esc('reset')+"\n") + lines.append("\n"+" You can overwrite some recommended VM settings editing: "+conffile+"\n") + lines.append("\n Please read the manpage and the README.md file:\n") + lines.append(" https://github.com/aginies/virt-scenario/blob/main/README.md\n") + lines.append(util.esc('red')+"\n WARNING:"+util.esc('reset')+" This is under Devel...\n") + lines.append(" Source code: https://github.com/aginies/virt-scenario\n") + lines.append(" Report bug: https://github.com/aginies/virt-scenario/issues\n") + + intro = ''.join(lines) # There is some Immutable in dict for the moment... #IMMUT = immut.Immutable() @@ -236,14 +238,16 @@ mode = "both" all_modes = ['guest', 'host', 'both'] overwrite = "off" - overwrite_options = ['on', 'off'] + force_sev = "off" + on_off_options = ['on', 'off'] dataprompt = { 'name': None, 'vcpu': None, 'memory': None, 'machine': None, - 'bootdev': None, + 'boot_dev': None, + 'vnet': None, 'cdrom': None, 'mainconf': conffile, 'hvconf': hvfile, @@ -295,27 +299,35 @@ memoryuser = self.dataprompt.get('memory') if memoryuser != None: - self.memory = guest.create_memory({ + mem_dict = { 'mem_unit': 'Gib', 'max_memory': memoryuser, 'current_mem_unit': 'Gib', 'memory': memoryuser, - 'pin': virtum.memory_pin, - }) + } + if virtum.memory_pin: + mem_dict['pin'] = virtum.memory_pin + self.memory = guest.create_memory(mem_dict) else: self.memory = guest.create_memory(virtum.memory) + cdrom = self.dataprompt.get('dvd') + if cdrom != None: + self.cdrom = guest.create_cdrom({'source_file': cdrom}) + # if CD/DVD selected swith boot dev to cdrom by default + self.listosdef.update({'boot_dev': 'cdrom'}) + machineuser = self.dataprompt.get('machine') - bootdevuser = self.dataprompt.get('bootdev') + bootdevuser = self.dataprompt.get('boot_dev') if machineuser != None: self.listosdef.update({'machine': machineuser}) if bootdevuser != None: self.listosdef.update({'boot_dev': bootdevuser}) self.osdef = guest.create_osdef(self.listosdef) - cdrom = self.dataprompt.get('dvd') - if cdrom != None: - self.cdrom = guest.create_cdrom({'source_file': cdrom}) + vnet = self.dataprompt.get('vnet') + if vnet != None: + self.vnet = vnet overwrite = self.dataprompt.get('overwrite') if overwrite != None: @@ -329,8 +341,10 @@ ('Vcpu', 'vcpu'), ('Memory', 'memory'), ('Machine Type', 'machine'), - ('Boot Device', 'bootdev'), + ('Boot Device', 'boot_dev'), ('Disk Path', 'path'), + ('Force SEV PDH extraction', 'force_sev'), + ('Virtual Network', 'vnet'), ('Main Configuration', 'mainconf'), ('Hypervisor Configuration', 'hvconf'), ('Hypervisor Selected', 'hvselected'), @@ -346,7 +360,7 @@ if option_value is not None: line = util.esc('green') + option_name + ': ' + util.esc('reset') + option_value + '\n' if option_key == 'dvd': - self.dataprompt.update({'bootdev': 'cdrom'}) + self.listosdef.update({'boot_dev': 'cdrom'}) # append to the main line lines.append(line) @@ -383,6 +397,7 @@ self.clock = "" self.ondef = "" self.network = "" + self.vnet = "default" self.filename = "" self.tpm = "" self.iothreads = "" @@ -628,7 +643,7 @@ def do_shell(self, args): """ - Execute a system command + Execute a System Command """ out, errs = util.system_command(args) if errs: @@ -638,15 +653,9 @@ else: print(out) - def help_shell(self): - """ - help on execute command - """ - print("Execute a system command") - def do_info(self, args): """ - show system info + Show System Info """ import psutil util.print_data("Number of Physical cores", str(psutil.cpu_count(logical=False))) @@ -656,21 +665,9 @@ virtual_memory = psutil.virtual_memory() util.print_data("Total Memory present", str(util.bytes_to_gibibytes(virtual_memory.total))+"Gb") - def help_info(self): - """ - show help on info - """ - print("Show system info") - - def help_computation(self): - """ - show some help on computation scenario - """ - print("Will prepare a Guest XML config for computation") - def do_computation(self, args): """ - computation + Will prepare the System for a Computation VM """ if self.check_conffile() is not False: self.basic_config() @@ -689,8 +686,13 @@ self.callsign = computation.name['VM_name'] self.name = guest.create_name(computation.name) + # Configure VM without pinned memory + self.set_memory_pin(False) + computation.memory_pin = False + # Check user setting self.check_user_settings(computation) + cfg_store = configstore.create_config_store(self, computation, hypervisor, self.overwrite) if cfg_store is None: return @@ -706,7 +708,7 @@ self.iothreads = guest.create_iothreads(computation.iothreads) self.controller = guest.create_controller(self.listosdef) - self.custom = ["loader",] + self.custom = ["loader", "vnet"] fw_features = ['secure-boot'] firmware = fw.find_firmware(self.fw_info, arch=self.listosdef['arch'], features=fw_features, interface='uefi') if firmware: @@ -744,15 +746,9 @@ show_how_to_use(cfg_store.get_path()+"domain.xml") - def help_desktop(self): - """ - show some help on desktop scenario - """ - print("Will prepare a Guest XML config for Desktop VM") - def do_desktop(self, args): """ - desktop + Will prepare a Guest XML config for Desktop VM """ if self.check_conffile() is not False: self.basic_config() @@ -771,6 +767,10 @@ self.callsign = desktop.name['VM_name'] self.name = guest.create_name(desktop.name) + # Configure VM without pinned memory + self.set_memory_pin(False) + desktop.memory_pin = False + # Check user setting self.check_user_settings(desktop) @@ -793,6 +793,7 @@ fw_features = ['secure-boot'] firmware = fw.find_firmware(self.fw_info, arch=self.listosdef['arch'], features=fw_features, interface='uefi') + self.custom = ["vnet"] self.STORAGE_DATA['storage_name'] = self.callsign self.STORAGE_DATA_REC['path'] = self.diskpath['path'] self.STORAGE_DATA_REC['preallocation'] = "metadata" @@ -828,15 +829,9 @@ show_how_to_use(cfg_store.get_path()+"domain.xml") - def help_securevm(self): - """ - show some help on secure VM scenario - """ - print("Will prepare a Guest XML config and Host for Secure VM") - def do_securevm(self, args): """ - securevm + Will prepare a Guest XML config and Host for Secure VM """ if self.check_conffile() is not False: self.basic_config() @@ -868,6 +863,7 @@ # Configure VM with pinned memory self.set_memory_pin(True) + securevm.memory_pin = True # Check user setting self.check_user_settings(securevm) @@ -905,7 +901,7 @@ # transparent hugepages doesnt need any XML config self.hugepages = "" - self.custom = ["loader",] + self.custom = ["vnet"] # Find matching firmware if sev_info.es_supported(): fw_features = ['amd-sev-es'] @@ -914,7 +910,7 @@ firmware = fw.find_firmware(self.fw_info, arch=self.listosdef['arch'], features=fw_features, interface='uefi') if firmware: - self.custom = ["loader"] + self.custom = ["loader", "nvet"] self.loader = firmware # XML File path @@ -929,11 +925,17 @@ if sev_info.sev_supported is True: host.kvm_amd_sev(sev_info) - #session = None dh_params = None - if hypervisor.has_sev_cert(): - # A host certificate is configured, try to enable remote attestation - cert_file = hypervisor.sev_cert_file() + # force generation of a local PDH: NOT SECURE! + if self.force_sev is True or hypervisor.has_sev_cert(): + if self.force_sev is True: + cert_file = "localhost.pdh" + sev.sev_extract_pdh(cfg_store, cert_file) + sev.sev_validate_pdh(cfg_store, cert_file) + elif hypervisor.has_sev_cert(): + # A host certificate is configured, try to enable remote attestation + cert_file = hypervisor.sev_cert_file() + policy = sev_info.get_policy() if not sev.sev_prepare_attestation(cfg_store, policy, cert_file): util.print_error("Creation of attestation keys failed!") @@ -1033,11 +1035,11 @@ if args not in qemulist.LIST_BOOTDEV: print("Please select a correct boot devices") else: - bootdev = { - 'bootdev': args, + boot_dev = { + 'boot_dev': args, } - self.dataprompt.update({'bootdev': bootdev['bootdev']}) - self.update_prompt(bootdev['bootdev']) + self.dataprompt.update({'boot_dev': boot_dev['boot_dev']}) + self.update_prompt(boot_dev['boot_dev']) def complete_bootdev(self, text, line, begidx, endidx): """ @@ -1063,6 +1065,26 @@ else: util.print_error("CDROM/DVD ISO source file " +file +" Doesnt exist!") + def do_vnet(self, args): + """ + Select the virtual network + """ + hypervisor = hv.select_hypervisor() + if not hypervisor.is_connected(): + util.print_error("No connection to LibVirt") + return + + net_list = hypervisor.network_list() + if args not in net_list: + print("Please select a Virtual Network name from:") + print(net_list) + else: + config = { + 'vnet': args, + } + self.dataprompt.update({'vnet': config['vnet']}) + self.update_prompt(config['vnet']) + def do_memory(self, args): """ Set Memory size, should be in Gib @@ -1098,14 +1120,14 @@ def do_mode(self, args): """ - Select if: - - XML guest configuration should be done - - host configuration + Mode available are:: + - guest: only XML guest configuration + - host: only host configuration - both should be done (default) """ mode = args if mode not in self.all_modes: - print("Dont know this mode...") + print("Dont know this mode: help mode") else: self.mode = mode @@ -1119,12 +1141,31 @@ completions = [f for f in self.all_modes if f.startswith(text)] return completions + def do_force_sev(self, args): + """ + Force the extract of a localhost PDH file + This is NOT secure as this file should be stored in a secure place! + """ + force = args + if force not in self.on_off_options: + print("on / off") + else: + if force == "on": + util.print_warning("This is NOT secure as the PDH should be stored in a secure place!") + self.force_sev = True + config = { + 'force_sev': force, + } + self.dataprompt.update({'force_sev': config['force_sev']}) + self.update_prompt(config['force_sev']) + + def do_overwrite(self, args): """ Overwrite mode allow you to overwrite previous config (XML and config store) """ overwrite = args - if overwrite not in self.overwrite_options: + if overwrite not in self.on_off_options: print("on / off") else: overwrite = args diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/template.py new/virt-scenario-0.7.6/src/virtscenario/template.py --- old/virt-scenario-0.7.4/src/virtscenario/template.py 2023-03-16 16:14:37.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/template.py 2023-03-17 13:43:19.000000000 +0100 @@ -135,7 +135,7 @@ INTERFACE_TEMPLATE = """ <interface type='network'> <mac address='${mac_address}'/> - <source network='${network}'/> + <source network='${source_network}'/> <model type='${type}'/> <!--<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>--> </interface>""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/util.py new/virt-scenario-0.7.6/src/virtscenario/util.py --- old/virt-scenario-0.7.4/src/virtscenario/util.py 2023-03-16 12:24:50.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/util.py 2023-03-20 10:49:10.000000000 +0100 @@ -68,18 +68,15 @@ """ Print error in red """ - color = esc('red') - reset = esc('reset') - #print('{color}{text}{reset}'.format(color=color, text=text, reset=reset)) - prefix = esc('bg_yellow') + ' ERROR ' + reset + " " - formated_text = prefix+color+text+reset + prefix = esc('bg_yellow') + ' ERROR ' + esc('reset') + " " + formated_text = prefix+esc('red')+text+esc('reset')+"\n" print(formated_text) def print_warning(text): """ Print warning in red """ - prefix = esc('bg_yellow') + ' WARNING ' + reset + " " + prefix = esc('bg_yellow') + ' WARNING ' + esc('reset') + " " formated_text = "\n "+prefix+esc('red') +text.upper()+esc('reset')+"\n" print(formated_text) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario/xmlutil.py new/virt-scenario-0.7.6/src/virtscenario/xmlutil.py --- old/virt-scenario-0.7.4/src/virtscenario/xmlutil.py 2023-03-16 16:15:19.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario/xmlutil.py 2023-03-17 15:40:01.000000000 +0100 @@ -85,6 +85,29 @@ # Write the modified XML tree back to the file tree.write(file_path, encoding='UTF-8', xml_declaration=True) +def change_network_source(file_path: str, source_network: str) -> None: + """ + Change virtual network name in the Tree + """ + # Parse the XML file + tree = ET.parse(file_path) + root = tree.getroot() + # Find the interface + # Find the 'interface' element within the 'devices' element + interface_elem = root.find("./devices/interface") + + if interface_elem is not None: + # Find the 'source' element within the 'interface' element + source_elem = interface_elem.find("source") + if source_elem is not None and 'network' in source_elem.attrib: + # Set the value of the 'network' attribute to a new value + source_elem.set("network", source_network) + else: + print("Lost in SPACE?") + + # Write the modified XML tree back to the file + tree.write(file_path, encoding='UTF-8', xml_declaration=True) + def show_tag(root: ET.Element, child: str) -> None: """ Print the tag, attributes, and text of a child element of the root element. @@ -111,8 +134,10 @@ util.print_data(str(dev.tag), toprint) # parse all sub element for sube in dev: - show_attrib_text(sube) - #print(sube.tag) + if sube.tag == "session" or sube.tag == "dhCert": + util.print_data(str(sube.tag), "Confidential Data") + else: + show_attrib_text(sube) #for key, value in sube.items(): # util.print_data(key, value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/virt-scenario-0.7.4/src/virtscenario_launch/main.py new/virt-scenario-0.7.6/src/virtscenario_launch/main.py --- old/virt-scenario-0.7.4/src/virtscenario_launch/main.py 2023-03-16 16:28:10.000000000 +0100 +++ new/virt-scenario-0.7.6/src/virtscenario_launch/main.py 2023-03-17 10:38:10.000000000 +0100 @@ -30,7 +30,7 @@ def get_arg_parse(): parser = argparse.ArgumentParser(description='Perform SEV guest attestation and launch guest') - parser.add_argument('--list', help='List domain configurations', action='store_true') + parser.add_argument('--list', '-l', help='List domain configurations', action='store_true') parser.add_argument('--start', help='Start domain') parser.add_argument('--status', help='Check domain status') parser.add_argument('--off', help="Shutdown domain")
