Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into upidapi/master
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyYakeley committed Jan 13, 2025
2 parents 5103240 + 9063243 commit 040c69a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tool/nixvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class Session:
def __init__(self,uri,verbose):
self.conn = libvirt.open(uri)
self.verbose = verbose
self.driver = self.conn.getType()

def vreport(self,msg):
if self.verbose:
print (msg, file=sys.stderr)
print ("NixVirt: " + self.driver + ": " + msg, file=sys.stderr)

class ObjectConnection:
def __init__(self,type,session):
Expand Down Expand Up @@ -114,10 +115,17 @@ def _descriptionXML(self,lvobj):
return lvobj.XMLDesc(flags=2)
def _undefine(self,lvobj):
# https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainUndefineFlagsValues
# VIR_DOMAIN_UNDEFINE_MANAGED_SAVE
# VIR_DOMAIN_UNDEFINE_KEEP_NVRAM
# VIR_DOMAIN_UNDEFINE_KEEP_TPM
lvobj.undefineFlags(flags=73)
match self.session.driver:
case "QEMU":
# VIR_DOMAIN_UNDEFINE_MANAGED_SAVE
# VIR_DOMAIN_UNDEFINE_KEEP_NVRAM
# VIR_DOMAIN_UNDEFINE_KEEP_TPM
flags=73
case "LXC":
flags=0 # LXC doesn't support undefine flags
case _:
flags=73 # best guess, same as QEMU
lvobj.undefineFlags(flags=flags)
def _fixDefinitionETree(self,objid,specDefETree):
interfaces = specDefETree.xpath("/domain/devices/interface")
index = 0
Expand Down

0 comments on commit 040c69a

Please sign in to comment.