XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Creating a CentOS VM From the CLI...

    Scheduled Pinned Locked Moved Compute
    14 Posts 2 Posters 1.6k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • epretoriousE Offline
      epretorious
      last edited by epretorious

      I'm attempting to create a CentOS-7 VM from the CLI using the instructions from the "Citrix XenServer 7.2 Virtual Machine User's Guide":

      # xe network-list | grep -B1 eth0
      uuid ( RO)                : 47a6223e-74d0-b75d-bec3-0ca6324b498c
                name-label ( RW): Pool-wide network associated with eth0
      
      # xe pool-param-list uuid=e3cdb4f9-6589-2ac2-f08a-9318a8a48a61 | grep default-SR
      default-SR ( RW): 21044441-dfba-9293-408b-41379e194718
      
      # xe vm-install template=Red\ Hat\ Enterprise\ Linux\ 7 new-name-label=CentOS7-1 sr-uuid=21044441-dfba-9293-408b-41379e194718 
      2f343ae1-0d57-ef21-6a54-6abe7b7264c6
      
      # xe vif-create vm-uuid=2f343ae1-0d57-ef21-6a54-6abe7b7264c6 network-uuid=47a6223e-74d0-b75d-bec3-0ca6324b498c mac=random device=0
      f21d558a-c9ba-bb65-d2bc-6c2310d4a0cf
      
      # xe vm-param-set uuid=2f343ae1-0d57-ef21-6a54-6abe7b7264c6 other-config:install-repository=nfs://192.168.0.95/srv/images/ISO/CentOS-7.7-x86_64-Minimal.iso
      
      # xe vm-start uuid=2f343ae1-0d57-ef21-6a54-6abe7b7264c6
      

      But when I start the VM: XAPI complains No text console available

      # xe console vm=CentOS7-1
      No text console available
      
      # xe vm-list | grep -A1 -B1 CentOS
      uuid ( RO)           : 2f343ae1-0d57-ef21-6a54-6abe7b7264c6
           name-label ( RW): CentOS7-1
          power-state ( RO): running
      

      What am I doing wrong?

      TIA,
      Eric Pretorious
      Reno, Nevada

      1 Reply Last reply Reply Quote 0
      • olivierlambertO Offline
        olivierlambert Vates 🪐 Co-Founder CEO
        last edited by

        That's because an HVM guest doesn't have a text console by default (only a VNC one). So this is expected.

        I'm not 100%, but you might try to tell CentOS kernel to send to the text console, I vaguely remember a discussion about this few years ago 🤔

        What do you want to achieve exactly? That might be easier to assist if I get the end goal 🙂

        epretoriousE 1 Reply Last reply Reply Quote 0
        • epretoriousE Offline
          epretorious @olivierlambert
          last edited by

          olivierlambert Is there a command for connecting VNC to the VM's console?

          1 Reply Last reply Reply Quote 0
          • olivierlambertO Offline
            olivierlambert Vates 🪐 Co-Founder CEO
            last edited by

            https://musteresel.github.io/posts/2018/02/vnc-ssh-tunnel-xen-vm.html

            But again, it's hard to help without knowing the bigger picture 🙂

            epretoriousE 1 Reply Last reply Reply Quote 0
            • epretoriousE Offline
              epretorious @olivierlambert
              last edited by

              olivierlambert I'm just wanting to create a CentOS VM using the CLI.

              1 Reply Last reply Reply Quote 0
              • olivierlambertO Offline
                olivierlambert Vates 🪐 Co-Founder CEO
                last edited by olivierlambert

                In an automated fashion? Manually? Provision a VM without any human? Want to repeat that a lot of time or just one shot?

                Depending on your final use cases, there's different answers 🙂

                epretoriousE 1 Reply Last reply Reply Quote 0
                • epretoriousE Offline
                  epretorious @olivierlambert
                  last edited by epretorious

                  olivierlambert Thanks for asking! My goal is to manually create a single CentOS VM so that I can get a better understanding all of the complicated details that XO hides from XCP-ng/XenServer administrators.

                  1 Reply Last reply Reply Quote 0
                  • olivierlambertO Offline
                    olivierlambert Vates 🪐 Co-Founder CEO
                    last edited by

                    It's not rocket science but it's not trivial either 🙂 Let me give you some details.

                    For VM creation, all clients are doing (broadly) the same thing behind: cloning a template, passing various configuration and starting the VM. XO is going deeper with Cloudinit support (and other stuff that xe and XenCenter can't achieve since they aren't persistent like XO).

                    But what matters is this: everything has to go to the XAPI in the end (xe IS a client for XAPI, so if you do things via xe, you are not doing what XO does, since XO is calling XAPI directly, not xe behind!).

                    So XAPI is the "core" of all those clients: see https://xapi-project.github.io/xen-api/ for an idea on XAPI functions.

                    xo-server is making a permanent connection to it, and since it's persistent and connected to multiple XAPI (pools) at the same time, can do very cool stuff in terms of orchestration, provisioning, backup and such.

                    epretoriousE 1 Reply Last reply Reply Quote 0
                    • epretoriousE Offline
                      epretorious @olivierlambert
                      last edited by epretorious

                      olivierlambert Thanks!

                      Using only the CLI: How can I connect VNC to the guest in order to complete the installation? e.g., xe console-list vm-name-label=<<<your_vm>>> lists an HTTP URL for connecting to the host...

                      # xe console-list vm-name-label=CentOS7-1 
                      uuid ( RO)             : fd376ea3-a644-2ed3-2d72-8ae7ca7a6b71
                                vm-uuid ( RO): 2f343ae1-0d57-ef21-6a54-6abe7b7264c6
                          vm-name-label ( RO): CentOS7-1
                               protocol ( RO): RFB
                               location ( RO): https://192.168.0.93/console?uuid=fd376ea3-a644-2ed3-2d72-8ae7ca7a6b71
                      

                      But it doesn't seem to do anything!

                      TIA,
                      Eric P.
                      Reno, Nevada

                      epretoriousE 1 Reply Last reply Reply Quote 0
                      • olivierlambertO Offline
                        olivierlambert Vates 🪐 Co-Founder CEO
                        last edited by

                        You can't access the VNC directly without authenticating. So you need to point your VNC client to it and enter XAPI creds (IIRC).

                        epretoriousE 1 Reply Last reply Reply Quote 0
                        • epretoriousE Offline
                          epretorious @epretorious
                          last edited by epretorious

                          I think that this wiki page from the Xen Project may provide the answer:

                          • Use SSH to tunnel localhost:5900 to TCP/5900 of the host system. And then
                          • Use a VNC client to access localhost:5900.

                          I've already confirmed that the host is listening on TCP/5900:

                          # netstat -tanp | grep \:59
                          tcp        0      0 127.0.0.1:5900          0.0.0.0:*               LISTEN      1276/vncterm
                          

                          So I configured the tunnel:

                          $ ssh -L 5900:localhost:5900 root@192.168.0.92
                          root@192.168.0.92's password: 
                          Last login: Tue Nov  1 01:10:30 2022
                          
                          # xe vm-list name-label=CentOS7-1 
                          uuid ( RO)           : 2f343ae1-0d57-ef21-6a54-6abe7b7264c6
                               name-label ( RW): CentOS7-1
                              power-state ( RO): running
                          
                          # xe vm-list name-label=CentOS7-1 params=dom-id
                          dom-id ( RO)    : 1
                          

                          And then I launched the client and connected to localhost:5900:

                          $ vncviewer 
                          
                          TigerVNC Viewer 64-bit v1.12.0
                          Built on: 2022-03-25 17:06
                          Copyright (C) 1999-2021 TigerVNC Team and many others (see README.rst)
                          See https://www.tigervnc.org for information on TigerVNC.
                          
                          Mon Oct 31 18:18:08 2022
                           DecodeManager: Detected 8 CPU core(s)
                           DecodeManager: Creating 4 decoder thread(s)
                           CConn:       Connected to host localhost port 5900
                           CConnection: Server supports RFB protocol version 3.3
                           CConnection: Using RFB protocol version 3.3
                           CConn:       Using pixel format depth 24 (32bpp) little-endian rgb888
                          

                          A connection is established:

                          # netstat -tanp | grep \:59
                          tcp        0      0 127.0.0.1:5900          0.0.0.0:*               LISTEN      1276/vncterm        
                          tcp        0      0 127.0.0.1:34046         127.0.0.1:5900          ESTABLISHED 18949/sshd: root@pt 
                          tcp        0      0 127.0.0.1:5900          127.0.0.1:34046         ESTABLISHED 1276/vncterm        
                          

                          But the display seems to be a text console on the host system!

                          Have I misunderstood some detail?

                          Eric P.
                          Reno, Nevada

                          epretoriousE 1 Reply Last reply Reply Quote 0
                          • epretoriousE Offline
                            epretorious @olivierlambert
                            last edited by epretorious

                            olivierlambert Yes - I authenticated as the root user. But after that there was nothing - Only a terminal session like a standard SSH session!

                            Ideas? Suggestions?

                            Eric P.
                            Reno, Nevada

                            1 Reply Last reply Reply Quote 0
                            • epretoriousE Offline
                              epretorious @epretorious
                              last edited by

                              FWIW: I did notice that there was more than one TCP port connected to the VNC server:

                              # netstat -tanp | grep vnc
                              tcp        0      0 127.0.0.1:5900          0.0.0.0:*               LISTEN      1276/vncterm        
                              tcp        0      0 127.0.0.1:9500          0.0.0.0:*               LISTEN      1276/vncterm
                              

                              So I also connected to the TCP/9500 port:

                              $ ssh -L 9500:localhost:9500 root@192.168.0.92
                              root@192.168.0.92's password: 
                              Last login: Tue Nov  1 01:14:11 2022
                              
                              # xe vm-list name-label=CentOS7-1 
                              uuid ( RO)           : 2f343ae1-0d57-ef21-6a54-6abe7b7264c6
                                   name-label ( RW): CentOS7-1
                                  power-state ( RO): running
                              
                              # xe vm-list name-label=CentOS7-1 params=dom-id
                              dom-id ( RO)    : 1
                              

                              But nothing ever happened! i.e., The VNC client failed to open a window on my local system.

                              What's the purpose of this other VNC daemon on TCP/9500?

                              TIA,
                              Eric P.
                              Reno, Nevada

                              epretoriousE 1 Reply Last reply Reply Quote 0
                              • epretoriousE Offline
                                epretorious @epretorious
                                last edited by epretorious

                                What's the purpose of this other VNC daemon on TCP/9500?

                                From the Xen Project wiki page on XCP:

                                The ports used for VNC console are 5901-5999, and the ports used for text console are 9501-9599.

                                AFAICT: TCP/5900 & TCP/9500 belong to Dom0...

                                # xenstore-ls /local/domain/0
                                control = ""
                                 feature-poweroff = "1"
                                 feature-reboot = "1"
                                 feature-suspend = "1"
                                domid = "0"
                                name = "Domain-0"
                                vncterm-pid = "1276"
                                console = ""
                                 vnc-port = "5900"
                                 tc-port = "9500"
                                vm = "/vm/7a4488c6-d4ac-4aaf-83f0-fb6d3f557f48"
                                

                                But I don't know how to connect to DomU #1's console because there is no entry in Xenstore for DomU #1:

                                # xenstore-ls /local/domain/1
                                xenstore-ls: xs_directory (/local/domain/1): No such file or directory
                                

                                Ideas? Suggestions?

                                Eric P.
                                Reno, Nevada

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post