qubes/vm/qubesvm: fix domain's UUID management
Now we generate UUID on domain's instantiation. This is needed, because we sometimes don't update XML (like in qvm-start). fixes QubesOS/qubes-issues#1236
This commit is contained in:
parent
c4da931a1d
commit
75c3f355db
@ -356,8 +356,7 @@ class BaseVM(qubes.PropertyHolder):
|
||||
args['name'] = self.name
|
||||
if hasattr(self, 'kernels_dir'):
|
||||
args['kerneldir'] = self.kernels_dir
|
||||
args['uuidnode'] = '<uuid>{!s}</uuid>'.format(self.uuid) \
|
||||
if hasattr(self, 'uuid') else ''
|
||||
args['uuid'] = str(self.uuid)
|
||||
args['vmdir'] = self.dir_path
|
||||
args['pcidevs'] = ''.join(lxml.etree.tostring(self.lvxml_pci_dev(dev))
|
||||
for dev in self.devices['pci'])
|
||||
|
@ -317,13 +317,8 @@ class QubesVM(qubes.vm.BaseVM):
|
||||
|
||||
# XXX _update_libvirt_domain?
|
||||
try:
|
||||
if hasattr(self, 'uuid'):
|
||||
self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByUUID(
|
||||
self.uuid.bytes)
|
||||
else:
|
||||
self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByName(
|
||||
self.name)
|
||||
self.uuid = uuid.UUID(bytes=self._libvirt_domain.UUID())
|
||||
self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByUUID(
|
||||
self.uuid.bytes)
|
||||
except libvirt.libvirtError:
|
||||
if self.app.vmm.libvirt_conn.virConnGetLastError()[0] == \
|
||||
libvirt.VIR_ERR_NO_DOMAIN:
|
||||
@ -544,6 +539,12 @@ class QubesVM(qubes.vm.BaseVM):
|
||||
# event handlers
|
||||
#
|
||||
|
||||
@qubes.events.handler('domain-init', 'domain-loaded')
|
||||
def on_domain_init_loaded(self, event):
|
||||
if not hasattr(self, 'uuid'):
|
||||
self.uuid = uuid.uuid4()
|
||||
|
||||
|
||||
@qubes.events.handler('property-set:label')
|
||||
def on_property_set_label(self, event, name, new_label, old_label=None):
|
||||
# pylint: disable=unused-argument
|
||||
@ -1717,7 +1718,6 @@ class QubesVM(qubes.vm.BaseVM):
|
||||
try:
|
||||
self._libvirt_domain = self.app.vmm.libvirt_conn.defineXML(
|
||||
domain_config)
|
||||
self.uuid = uuid.UUID(bytes=self._libvirt_domain.UUID())
|
||||
except libvirt.libvirtError:
|
||||
if self.app.vmm.libvirt_conn.virConnGetLastError()[0] == \
|
||||
libvirt.VIR_ERR_NO_DOMAIN:
|
||||
|
@ -1,6 +1,6 @@
|
||||
<domain type='test'>
|
||||
<name>{name}</name>
|
||||
{uuidnode}
|
||||
<uuid>{uuid}</uuid>
|
||||
<memory unit='MiB'>{maxmem}</memory>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<domain type='test'>
|
||||
<name>{name}</name>
|
||||
{uuidnode}
|
||||
<uuid>{uuid}</uuid>
|
||||
<memory unit='MiB'>{maxmem}</memory>
|
||||
<os>
|
||||
<type>pv</type>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<domain type='xen'>
|
||||
<name>{name}</name>
|
||||
{uuidnode}
|
||||
<uuid>{uuid}</uuid>
|
||||
<memory unit='MiB'>{maxmem}</memory>
|
||||
<currentMemory unit='MiB'>{mem}</currentMemory>
|
||||
<vcpu placement='static'>{vcpus}</vcpu>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<domain type='xen'>
|
||||
<name>{name}</name>
|
||||
{uuidnode}
|
||||
<uuid>{uuid}</uuid>
|
||||
<memory unit='MiB'>{maxmem}</memory>
|
||||
<currentMemory unit='MiB'>{mem}</currentMemory>
|
||||
<vcpu placement='static'>{vcpus}</vcpu>
|
||||
|
Loading…
Reference in New Issue
Block a user