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
|
args['name'] = self.name
|
||||||
if hasattr(self, 'kernels_dir'):
|
if hasattr(self, 'kernels_dir'):
|
||||||
args['kerneldir'] = self.kernels_dir
|
args['kerneldir'] = self.kernels_dir
|
||||||
args['uuidnode'] = '<uuid>{!s}</uuid>'.format(self.uuid) \
|
args['uuid'] = str(self.uuid)
|
||||||
if hasattr(self, 'uuid') else ''
|
|
||||||
args['vmdir'] = self.dir_path
|
args['vmdir'] = self.dir_path
|
||||||
args['pcidevs'] = ''.join(lxml.etree.tostring(self.lvxml_pci_dev(dev))
|
args['pcidevs'] = ''.join(lxml.etree.tostring(self.lvxml_pci_dev(dev))
|
||||||
for dev in self.devices['pci'])
|
for dev in self.devices['pci'])
|
||||||
|
@ -317,13 +317,8 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
|
|
||||||
# XXX _update_libvirt_domain?
|
# XXX _update_libvirt_domain?
|
||||||
try:
|
try:
|
||||||
if hasattr(self, 'uuid'):
|
self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByUUID(
|
||||||
self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByUUID(
|
self.uuid.bytes)
|
||||||
self.uuid.bytes)
|
|
||||||
else:
|
|
||||||
self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByName(
|
|
||||||
self.name)
|
|
||||||
self.uuid = uuid.UUID(bytes=self._libvirt_domain.UUID())
|
|
||||||
except libvirt.libvirtError:
|
except libvirt.libvirtError:
|
||||||
if self.app.vmm.libvirt_conn.virConnGetLastError()[0] == \
|
if self.app.vmm.libvirt_conn.virConnGetLastError()[0] == \
|
||||||
libvirt.VIR_ERR_NO_DOMAIN:
|
libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
@ -544,6 +539,12 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
# event handlers
|
# 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')
|
@qubes.events.handler('property-set:label')
|
||||||
def on_property_set_label(self, event, name, new_label, old_label=None):
|
def on_property_set_label(self, event, name, new_label, old_label=None):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -1717,7 +1718,6 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
try:
|
try:
|
||||||
self._libvirt_domain = self.app.vmm.libvirt_conn.defineXML(
|
self._libvirt_domain = self.app.vmm.libvirt_conn.defineXML(
|
||||||
domain_config)
|
domain_config)
|
||||||
self.uuid = uuid.UUID(bytes=self._libvirt_domain.UUID())
|
|
||||||
except libvirt.libvirtError:
|
except libvirt.libvirtError:
|
||||||
if self.app.vmm.libvirt_conn.virConnGetLastError()[0] == \
|
if self.app.vmm.libvirt_conn.virConnGetLastError()[0] == \
|
||||||
libvirt.VIR_ERR_NO_DOMAIN:
|
libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<domain type='test'>
|
<domain type='test'>
|
||||||
<name>{name}</name>
|
<name>{name}</name>
|
||||||
{uuidnode}
|
<uuid>{uuid}</uuid>
|
||||||
<memory unit='MiB'>{maxmem}</memory>
|
<memory unit='MiB'>{maxmem}</memory>
|
||||||
<os>
|
<os>
|
||||||
<type>hvm</type>
|
<type>hvm</type>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<domain type='test'>
|
<domain type='test'>
|
||||||
<name>{name}</name>
|
<name>{name}</name>
|
||||||
{uuidnode}
|
<uuid>{uuid}</uuid>
|
||||||
<memory unit='MiB'>{maxmem}</memory>
|
<memory unit='MiB'>{maxmem}</memory>
|
||||||
<os>
|
<os>
|
||||||
<type>pv</type>
|
<type>pv</type>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<domain type='xen'>
|
<domain type='xen'>
|
||||||
<name>{name}</name>
|
<name>{name}</name>
|
||||||
{uuidnode}
|
<uuid>{uuid}</uuid>
|
||||||
<memory unit='MiB'>{maxmem}</memory>
|
<memory unit='MiB'>{maxmem}</memory>
|
||||||
<currentMemory unit='MiB'>{mem}</currentMemory>
|
<currentMemory unit='MiB'>{mem}</currentMemory>
|
||||||
<vcpu placement='static'>{vcpus}</vcpu>
|
<vcpu placement='static'>{vcpus}</vcpu>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<domain type='xen'>
|
<domain type='xen'>
|
||||||
<name>{name}</name>
|
<name>{name}</name>
|
||||||
{uuidnode}
|
<uuid>{uuid}</uuid>
|
||||||
<memory unit='MiB'>{maxmem}</memory>
|
<memory unit='MiB'>{maxmem}</memory>
|
||||||
<currentMemory unit='MiB'>{mem}</currentMemory>
|
<currentMemory unit='MiB'>{mem}</currentMemory>
|
||||||
<vcpu placement='static'>{vcpus}</vcpu>
|
<vcpu placement='static'>{vcpus}</vcpu>
|
||||||
|
Loading…
Reference in New Issue
Block a user