]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer.pm
bump version to 3.1-1
[qemu-server.git] / PVE / QemuServer.pm
index 24b7118d195a6f6444f59e8fa01f704ee93f9e53..3c9c54dc7125e38c535848019f29f1efeb9cdf25 100644 (file)
@@ -335,8 +335,8 @@ EODESC
     vga => {
        optional => 1,
        type => 'string',
-       description => "Select VGA type. If you want to use high resolution modes (>= 1280x1024x16) then you should use option 'std' or 'vmware'. Default is 'std' for win8/win7/w2k8, and 'cirrur' for other OS types. Option 'qxl' enables the SPICE display sever.",
-       enum => [qw(std cirrus vmware qxl)],
+       description => "Select VGA type. If you want to use high resolution modes (>= 1280x1024x16) then you should use option 'std' or 'vmware'. Default is 'std' for win8/win7/w2k8, and 'cirrur' for other OS types. Option 'qxl' enables the SPICE display sever. You can also run without any graphic card using a serial devive as terminal.",
+       enum => [qw(std cirrus vmware qxl serial0 serial1 serial2 serial3)],
     },
     watchdog => {
        optional => 1,
@@ -574,9 +574,9 @@ PVE::JSONSchema::register_standard_option("pve-qm-hostpci", $hostpcidesc);
 my $serialdesc = {
        optional => 1,
        type => 'string',
-       pattern => '/dev/ttyS\d+',
+       pattern => '(/dev/ttyS\d+|socket)',
        description =>  <<EODESCR,
-Map host serial devices (n is 0 to 3).
+Create a serial device inside the VM (n is 0 to 3), and pass through a host serial device, or create a unix socket on the host side (use 'qm terminal' to open a terminal connection).
 
 Note: This option allows direct access to host hardware. So it is no longer possible to migrate such machines - use with special care.
 
@@ -587,7 +587,7 @@ EODESCR
 my $paralleldesc= {
        optional => 1,
        type => 'string',
-       pattern => '/dev/parport\d+',
+        pattern => '/dev/parport\d+|/dev/usb/lp\d+',
        description =>  <<EODESCR,
 Map host parallel devices (n is 0 to 2).
 
@@ -2231,6 +2231,12 @@ sub foreach_volid {
     }
 }
 
+sub vga_conf_has_spice {
+    my ($vga) = @_;
+
+    return $vga && ($vga eq 'qxl');
+}
+
 sub config_to_command {
     my ($storecfg, $vmid, $conf, $defaults, $forcemachine) = @_;
 
@@ -2299,7 +2305,8 @@ sub config_to_command {
        $tablet = $conf->{tablet};
     } else {
        $tablet = $defaults->{tablet};
-       $tablet = 0 if $vga eq 'qxl'; # disable for spice because it is not needed
+       $tablet = 0 if vga_conf_has_spice($vga); # disable for spice because it is not needed
+       $tablet = 0 if $vga =~ m/^serial\d+$/; # disable if we use serial terminal (no vga card)
     }
 
     push @$devices, '-device', 'usb-tablet,id=tablet,bus=uhci.0,port=1' if $tablet;
@@ -2330,9 +2337,15 @@ sub config_to_command {
     # serial devices
     for (my $i = 0; $i < $MAX_SERIAL_PORTS; $i++)  {
        if (my $path = $conf->{"serial$i"}) {
-           die "no such serial device\n" if ! -c $path;
-           push @$devices, '-chardev', "tty,id=serial$i,path=$path";
-           push @$devices, '-device', "isa-serial,chardev=serial$i";
+           if ($path eq 'socket') {
+               my $socket = "/var/run/qemu-server/${vmid}.serial$i";
+               push @$devices, '-chardev', "socket,id=serial$i,path=$socket,server,nowait";
+               push @$devices, '-device', "isa-serial,chardev=serial$i";
+           } else {
+               die "no such serial device\n" if ! -c $path;
+               push @$devices, '-chardev', "tty,id=serial$i,path=$path";
+               push @$devices, '-device', "isa-serial,chardev=serial$i";
+           }
        }
     }
 
@@ -2373,7 +2386,7 @@ sub config_to_command {
 
     push @$cmd, '-no-reboot' if  defined($conf->{reboot}) && $conf->{reboot} == 0;
 
-    push @$cmd, '-vga', $vga if $vga; # for kvm 77 and later
+    push @$cmd, '-vga', $vga if $vga && $vga !~ m/^serial\d+$/; # for kvm 77 and later
 
     # time drift fix
     my $tdf = defined($conf->{tdf}) ? $conf->{tdf} : $defaults->{tdf};
@@ -2456,7 +2469,7 @@ sub config_to_command {
     }
 
     my $spice_port;
-    if ($vga eq 'qxl') {
+    if (vga_conf_has_spice($vga)) {
        my $pciaddr = print_pci_addr("spice", $bridges);
 
        $spice_port = PVE::Tools::next_unused_port(61000, 61099);
@@ -3047,11 +3060,17 @@ sub vm_start {
        my ($cmd, $vollist, $spice_port) = config_to_command($storecfg, $vmid, $conf, $defaults, $forcemachine);
 
        my $migrate_port = 0;
-
+       my $migrate_uri;
        if ($statefile) {
            if ($statefile eq 'tcp') {
+               my $localip = "localhost";
+               my $datacenterconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
+               if ($datacenterconf->{migration_unsecure}) {
+                       my $nodename = PVE::INotify::nodename();
+                       $localip = PVE::Cluster::remote_node_ip($nodename, 1);
+               }
                $migrate_port = PVE::Tools::next_migrate_port();
-               my $migrate_uri = "tcp:localhost:${migrate_port}";
+               $migrate_uri = "tcp:${localip}:${migrate_port}";
                push @$cmd, '-incoming', $migrate_uri;
                push @$cmd, '-S';
            } else {
@@ -3079,7 +3098,7 @@ sub vm_start {
        my $err = $@;
        die "start failed: $err" if $err;
 
-       print "migration listens on port $migrate_port\n" if $migrate_port;
+       print "migration listens on $migrate_uri\n" if $migrate_uri;
 
        if ($statefile && $statefile ne 'tcp')  {
            eval { vm_mon_cmd_nocheck($vmid, "cont"); };