Matthew Booth
2010-Apr-12 14:43 UTC
[Libguestfs] [PATCH] Converter: Update xvc0 console to ttyS0
This change updates a guest which uses Xen's xvc0 to use ttyS0 instead. In a related change, it also makes a console a 'standard device' will always be configured. --- lib/Sys/VirtV2V/Converter.pm | 5 +++- lib/Sys/VirtV2V/Converter/Linux.pm | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletions(-) diff --git a/lib/Sys/VirtV2V/Converter.pm b/lib/Sys/VirtV2V/Converter.pm index 8d46502..45038ee 100644 --- a/lib/Sys/VirtV2V/Converter.pm +++ b/lib/Sys/VirtV2V/Converter.pm @@ -75,6 +75,7 @@ use constant KVM_XML_VIRTIO => " <video> <model type='cirrus' vram='9216' heads='1'/> </video> + <console type='pty'/> </devices> </domain> "; @@ -98,6 +99,7 @@ use constant KVM_XML_NOVIRTIO => " <video> <model type='cirrus' vram='9216' heads='1'/> </video> + <console type='pty'/> </devices> </domain> "; @@ -240,7 +242,8 @@ sub _configure_default_devices my ($input_devices) = $default_dom->findnodes('/domain/devices'); # Add new default devices from default XML - foreach my $input ($input_devices->findnodes('input | video | graphics')) { + foreach my $input ($input_devices->findnodes('input | video | '. + 'graphics | console')) { my $new = $input->cloneNode(1); $new->setOwnerDocument($devices->getOwnerDocument()); $devices->appendChild($new); diff --git a/lib/Sys/VirtV2V/Converter/Linux.pm b/lib/Sys/VirtV2V/Converter/Linux.pm index 96e37a4..df7c969 100644 --- a/lib/Sys/VirtV2V/Converter/Linux.pm +++ b/lib/Sys/VirtV2V/Converter/Linux.pm @@ -112,6 +112,7 @@ sub convert my $virtio = $guestos->supports_virtio($kernel); # Configure the rest of the system + _configure_console($g); _configure_display_driver($guestos, $virtio); $guestos->remap_block_devices($devices, $virtio); _configure_kernel_modules($guestos, $desc, $virtio); @@ -193,6 +194,51 @@ sub _configure_kernel_modules } } +# We configure a console on ttyS0. Make sure existing console references use it. +sub _configure_console +{ + my ($g) = @_; + + # Look for gettys which use xvc0 + foreach my $augpath ($g->aug_match("/files/etc/inittab/*/process")) { + my $proc = $g->aug_get($augpath); + + # If the process mentions xvc0, change it to ttyS0 + if ($proc =~ /\bxvc0\b/) { + $proc =~ s/\bxvc0\b/ttyS0/g; + $g->aug_set($augpath, $proc); + } + } + + # Replace any mention of xvc0 in /etc/securetty with ttyS0 + my $size = 0; + my @lines = (); + + foreach my $line ($g->read_lines('/etc/securetty')) { + if($line eq "xvc0") { + $line = "ttyS0"; + } + + $size += length($line) + 1; + push(@lines, $line); + } + + $g->write_file('/etc/securetty', join("\n", @lines)."\n", $size); + + # Update any kernel console lines + foreach my $augpath + ($g->aug_match("/files/boot/grub/menu.lst/title/kernel/console")) + { + my $console = $g->aug_get($augpath); + if ($console =~ /\bxvc0\b/) { + $console =~ s/\bxvc0\b/ttyS0/g; + $g->aug_set($augpath, $console); + } + } + + $g->aug_save(); +} + sub _configure_display_driver { my ($guestos, $virtio) = @_; -- 1.6.6.1
Matthew Booth
2010-Apr-12 14:45 UTC
[Libguestfs] [PATCH] Converter: Update xvc0 console to ttyS0
On 12/04/10 15:43, Matthew Booth wrote:> This change updates a guest which uses Xen's xvc0 to use ttyS0 instead. In a > related change, it also makes a console a 'standard device' will always be > configured.I should have said in the commit message that this fixes RHBZ#580501. I have already updated my local copy. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
Maybe Matching Threads
- [PATCH 1/2] Fix remapping of block devices
- [PATCH] Move all interaction with the config file into Sys::VirtV2V::Config
- [PATCH 1/2] Refactor guest and volume creation into Sys::VirtV2V::Target::LibVirt
- [PATCH] Default to IDE when VirtIO isn't available
- [PATCH] Use augeas to update securetty