Merge "libvirt: change get_console_output as prep work for bp/libvirt-virtlogd"
This commit is contained in:
commit
b95e6e98f1
@ -2661,6 +2661,18 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
|
|
||||||
return fpath
|
return fpath
|
||||||
|
|
||||||
|
def _get_console_output_file(self, instance, path):
|
||||||
|
libvirt_utils.chown(path, os.getuid())
|
||||||
|
|
||||||
|
with libvirt_utils.file_open(path, 'rb') as fp:
|
||||||
|
log_data, remaining = utils.last_bytes(fp,
|
||||||
|
MAX_CONSOLE_BYTES)
|
||||||
|
if remaining > 0:
|
||||||
|
LOG.info(_LI('Truncated console log returned, '
|
||||||
|
'%d bytes ignored'), remaining,
|
||||||
|
instance=instance)
|
||||||
|
return log_data
|
||||||
|
|
||||||
def get_console_output(self, context, instance):
|
def get_console_output(self, context, instance):
|
||||||
guest = self._host.get_guest(instance)
|
guest = self._host.get_guest(instance)
|
||||||
|
|
||||||
@ -2684,16 +2696,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
instance=instance)
|
instance=instance)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
libvirt_utils.chown(path, os.getuid())
|
return self._get_console_output_file(instance, path)
|
||||||
|
|
||||||
with libvirt_utils.file_open(path, 'rb') as fp:
|
|
||||||
log_data, remaining = utils.last_bytes(fp,
|
|
||||||
MAX_CONSOLE_BYTES)
|
|
||||||
if remaining > 0:
|
|
||||||
LOG.info(_LI('Truncated console log returned, '
|
|
||||||
'%d bytes ignored'), remaining,
|
|
||||||
instance=instance)
|
|
||||||
return log_data
|
|
||||||
|
|
||||||
# Try 'pty' types
|
# Try 'pty' types
|
||||||
pty_consoles = tree.findall("./devices/console[@type='pty']")
|
pty_consoles = tree.findall("./devices/console[@type='pty']")
|
||||||
@ -2717,15 +2720,15 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
libvirt_utils.chown(console_log, os.getuid())
|
libvirt_utils.chown(console_log, os.getuid())
|
||||||
|
|
||||||
data = self._flush_libvirt_console(pty)
|
data = self._flush_libvirt_console(pty)
|
||||||
|
# NOTE(markus_z): The virt_types kvm and qemu are the only ones
|
||||||
|
# which create a dedicated file device for the console logging.
|
||||||
|
# Other virt_types like xen, lxc, uml, parallels depend on the
|
||||||
|
# flush of that pty device into the "console.log" file to ensure
|
||||||
|
# that a series of "get_console_output" calls return the complete
|
||||||
|
# content even after rebooting a guest.
|
||||||
fpath = self._append_to_file(data, console_log)
|
fpath = self._append_to_file(data, console_log)
|
||||||
|
|
||||||
with libvirt_utils.file_open(fpath, 'rb') as fp:
|
return self._get_console_output_file(instance, fpath)
|
||||||
log_data, remaining = utils.last_bytes(fp, MAX_CONSOLE_BYTES)
|
|
||||||
if remaining > 0:
|
|
||||||
LOG.info(_LI('Truncated console log returned, '
|
|
||||||
'%d bytes ignored'),
|
|
||||||
remaining, instance=instance)
|
|
||||||
return log_data
|
|
||||||
|
|
||||||
def get_host_ip_addr(self):
|
def get_host_ip_addr(self):
|
||||||
ips = compute_utils.get_machine_ips()
|
ips = compute_utils.get_machine_ips()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user