home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / usr / share / YaST2 / clients / inst_vm_hardware.ycp < prev    next >
Text File  |  2006-11-29  |  6KB  |  183 lines

  1. /**
  2.  * Module:    inst_vm_hardware.ycp
  3.  *
  4.  * Authors:    Ladislav Slezak <lslezak@suse.cz>
  5.  *        Michael G. Fritch <mgfritch@novell.com>
  6.  *
  7.  * Purpose:    Ask the user for various options for the virtual machine.
  8.  *
  9.  * $Id: inst_vm_options.ycp 28826 2006-03-10 14:35:49Z lslezak $
  10.  *
  11.  */
  12.  
  13. {
  14.     textdomain "vm";
  15.  
  16.     import "VM";
  17.     import "VM_Common";
  18.     import "Wizard";
  19.     import "Popup";
  20.     import "String";
  21.     import "Report";
  22.  
  23.     // screen title for virtual machine options
  24.     string title = _("Hardware");
  25.  
  26.     // build and show dialog
  27.  
  28.     Wizard::OpenAcceptDialog ();
  29.  
  30.     term contents = `MarginBox(15, 1,
  31.             `HBox(
  32.                   `VBox(
  33.                     `ComboBox(`id(`memory), `opt(`editable,`hstretch),
  34.                             // combobox label
  35.                             _("&Memory Size in MB"),
  36.                             ["32", "64", "128", "256", "512", "1024"]),
  37.                     (VM::GetVirtualizationType() == "full") ?
  38.                     `VBox(
  39.                         `VSpacing(0.5),
  40.                         `ComboBox(`id(`stdvga), `opt(`hstretch),
  41.                                 // combobox label
  42.                                 _("Virtual Graphics Card"),
  43.                                 [
  44.                                  // combobox item
  45.                                  `item(`id(0), _("Cirrus Logic")),
  46.                                  // combobox item
  47.                                  `item(`id(1), _("Standard VGA")),
  48.                                  ]),
  49.                         `VSpacing(0.5),
  50.                         `ComboBox(`id(`sdl), `opt(`hstretch),
  51.                                 // combobox label
  52.                                 _("Graphics Viewer"),
  53.                                 [
  54.                                  // combobox item
  55.                                  `item(`id(1), _("SDL")),
  56.                                  // combobox item
  57.                                  `item(`id(0), _("VNC")),
  58.                                  ]),
  59.                         `VSpacing(0.5),
  60.                         `ComboBox(`id(`localtime), `opt(`hstretch),
  61.                                 // combobox label
  62.                                 _("Virtual Hardware Clock"),
  63.                                 [
  64.                                  // combobox item
  65.                                  `item(`id(1), _("Local Time")),
  66.                                  // combobox item
  67.                                  `item(`id(0), _("UTC")),
  68.                                  ])
  69.                     )
  70.                     : // para virt
  71.                     `VBox(
  72.                         `VSpacing(0.5),
  73.                         `ComboBox(`id(`ncpus), `opt(`hstretch),
  74.                                 // combobox label
  75.                                 _("Number of Virtual &CPUs"),
  76.                                 ["1", "2", "3", "4"]),
  77.                         `VSpacing(0.5),
  78.                         `ComboBox(`id(`localtime), `opt(`hstretch),
  79.                                 // combobox label
  80.                                 _("Virtual Hardware Clock"),
  81.                                 [
  82.                                  // combobox item
  83.                                  `item(`id(1), _("Local Time")),
  84.                                  // combobox item
  85.                                  `item(`id(0), _("UTC")),
  86.                                  ])
  87.                     )
  88.                 )
  89.             )
  90.         );
  91.  
  92.  
  93.     // help text - hardware
  94.     string help_text = _("<p><b><big>Hardware</big></b></p>")
  95.     + _("<p><b>Memory size</b> specifies the amount of RAM, in megabytes, to allocate to the virtual machine when it starts.</p>");
  96.     if (VM::GetVirtualizationType() == "full") {
  97.     help_text = help_text
  98.     + _("<p>By default, Xen will emulate a <b>Cirrus Logic</b> graphics card for fully virtualized guests. If your operating system does not support that, select <b>Standard VGA</b>.</p>")
  99.     + _("<p>You may display the fully virtualized guest's screen using <b>SDL</b> or <b>VNC</b>. SDL is best when displaying locally; VNC is better when displaying remotely. Note that closing an SDL window terminates the VM, whereas VNC can reconnect to the VM at any time.</p>");
  100.     }
  101.     else {
  102.     help_text = help_text
  103.     + _("<p>The <b>number of virtual CPUs</b> may exceed the number of physical CPUs.</p>");
  104.     }
  105.     help_text = help_text
  106.     + _("<p>The <b>virtual hardware clock</b> can be set to local time or UTC.  Pick the setting that is compatible with your VM's operating system.</p>");
  107.  
  108.     Wizard::SetContents (title, contents, help_text, (boolean) WFM::Args(0),
  109.              (boolean) WFM::Args(1));
  110.  
  111.  
  112.     UI::ChangeWidget (`id(`memory), `ValidChars, "0123456789");
  113.     UI::ChangeWidget (`id(`memory), `Value, tostring (VM::GetMemorySize()));
  114.  
  115.     // set widget state
  116.     if (VM::GetVirtualizationType() == "full") {
  117.     UI::ChangeWidget (`id(`stdvga), `Value, VM::GetStdVga());
  118.     UI::ChangeWidget (`id(`sdl), `Value, VM::GetSdl());
  119.     }
  120.     else {
  121.     UI::ChangeWidget (`id(`ncpus), `ValidChars, "0123456789");
  122.     UI::ChangeWidget (`id(`ncpus), `Value, tostring (VM::GetNumberOfCpus()));
  123.     }
  124.     UI::ChangeWidget (`id(`localtime), `Value, VM::GetLocaltime());
  125.  
  126.     any ret = nil;
  127.     while (true)
  128.     {
  129.     ret = Wizard::UserInput ();
  130.  
  131.     if (ret == `abort || ret == `cancel) {
  132.         if (Popup::ReallyAbort(true))
  133.             break;
  134.     }
  135.     else if (ret == `back) {
  136.         break;
  137.     }
  138.     if (ret == `next) {
  139.         string mem_str = (string) UI::QueryWidget (`id(`memory), `Value);
  140.         integer mem = tointeger(mem_str);
  141.         integer freemem = (VM_Common::GetVirtualizationType() == "para") ? VM::GetMaxParaMemory() : VM::GetMaxHVMMemory();
  142.  
  143.         if (mem > freemem) {
  144.         // error message: requested memory size is greater that available free memory
  145.         string memory_size_error = sformat(_("The requested memory size is larger than the amount of space currently available.
  146. There is %1MB free memory available."), freemem);
  147.         Report::Error(memory_size_error);
  148.         continue;
  149.         }
  150.  
  151.         if (mem < 16) {
  152.         Report::Error(_("Memory Size in MB cannot be less than 16 MB."));
  153.         continue;
  154.         }
  155.  
  156.         VM::SetMemorySize(mem);
  157.  
  158.         if (VM::GetVirtualizationType() == "full") {
  159.         VM::SetStdVga((integer) UI::QueryWidget (`id(`stdvga), `Value));
  160.         VM::SetSdl((integer) UI::QueryWidget (`id(`sdl), `Value));
  161.         VM::SetNumberOfCpus(1); // hard-code the ncups to 1 when full virtualization.
  162.         }
  163.         else {
  164.         string ncpus_str = (string) UI::QueryWidget (`id(`ncpus), `Value);
  165.         integer ncpus = tointeger(ncpus_str);
  166.         VM::SetNumberOfCpus(ncpus);
  167.         }
  168.         VM::SetLocaltime((integer) UI::QueryWidget (`id(`localtime), `Value));
  169.  
  170.         break;
  171.     }
  172.     else {
  173.         y2error("unexpected retcode: %1", ret);
  174.         continue;
  175.     }
  176.     }
  177.  
  178.     Wizard::CloseDialog ();
  179.     return ret;
  180.  
  181. /* EOF */
  182. }
  183.